本文整理汇总了PHP中ParserOptions::setEditSection方法的典型用法代码示例。如果您正苦于以下问题:PHP ParserOptions::setEditSection方法的具体用法?PHP ParserOptions::setEditSection怎么用?PHP ParserOptions::setEditSection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ParserOptions
的用法示例。
在下文中一共展示了ParserOptions::setEditSection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: genParserOptions
function genParserOptions()
{
global $wgUser;
$this->mParserOptions = ParserOptions::newFromUser($wgUser);
$this->mParserOptions->setDateFormat('default');
$this->mParserOptions->setEditSection(false);
}
示例2: __construct
/**
* Constructor, always call this from child classes.
*/
public function __construct()
{
global $wgExtensionMessagesFiles, $wgUser, $wgHooks;
// Disable the i18n cache and LoadBalancer
Language::getLocalisationCache()->disableBackend();
LBFactory::disableBackend();
// Load the installer's i18n file.
$wgExtensionMessagesFiles['MediawikiInstaller'] = dirname(__FILE__) . '/Installer.i18n.php';
// Having a user with id = 0 safeguards us from DB access via User::loadOptions().
$wgUser = User::newFromId(0);
$this->settings = $this->internalDefaults;
foreach ($this->defaultVarNames as $var) {
$this->settings[$var] = $GLOBALS[$var];
}
foreach (self::getDBTypes() as $type) {
$installer = $this->getDBInstaller($type);
if (!$installer->isCompiled()) {
continue;
}
$defaults = $installer->getGlobalDefaults();
foreach ($installer->getGlobalNames() as $var) {
if (isset($defaults[$var])) {
$this->settings[$var] = $defaults[$var];
} else {
$this->settings[$var] = $GLOBALS[$var];
}
}
}
$this->parserTitle = Title::newFromText('Installer');
$this->parserOptions = new ParserOptions();
// language will be wrong :(
$this->parserOptions->setEditSection(false);
}
示例3: genParserOptions
function genParserOptions()
{
global $wgUser;
$this->mParserOptions = ParserOptions::newFromUser($wgUser);
$this->mParserOptions->setDateFormat(MW_DATE_DEFAULT);
$this->mParserOptions->setEditSection(false);
}
示例4: __construct
/**
* Constructor, always call this from child classes.
*/
public function __construct()
{
global $wgMessagesDirs, $wgUser;
// Disable the i18n cache and LoadBalancer
Language::getLocalisationCache()->disableBackend();
LBFactory::disableBackend();
// Load the installer's i18n.
$wgMessagesDirs['MediawikiInstaller'] = __DIR__ . '/i18n';
// Having a user with id = 0 safeguards us from DB access via User::loadOptions().
$wgUser = User::newFromId(0);
$this->settings = $this->internalDefaults;
foreach ($this->defaultVarNames as $var) {
$this->settings[$var] = $GLOBALS[$var];
}
$this->compiledDBs = array();
foreach (self::getDBTypes() as $type) {
$installer = $this->getDBInstaller($type);
if (!$installer->isCompiled()) {
continue;
}
$this->compiledDBs[] = $type;
}
$this->parserTitle = Title::newFromText('Installer');
$this->parserOptions = new ParserOptions();
// language will be wrong :(
$this->parserOptions->setEditSection(false);
}
示例5: __construct
/**
* Constructor, always call this from child classes.
*/
public function __construct()
{
global $wgMessagesDirs, $wgUser;
// Disable the i18n cache
Language::getLocalisationCache()->disableBackend();
// Disable LoadBalancer and wfGetDB etc.
LBFactory::disableBackend();
// Disable object cache (otherwise CACHE_ANYTHING will try CACHE_DB and
// SqlBagOStuff will then throw since we just disabled wfGetDB)
$GLOBALS['wgMemc'] = new EmptyBagOStuff();
ObjectCache::clear();
$emptyCache = array('class' => 'EmptyBagOStuff');
$GLOBALS['wgObjectCaches'] = array(CACHE_NONE => $emptyCache, CACHE_DB => $emptyCache, CACHE_ANYTHING => $emptyCache, CACHE_MEMCACHED => $emptyCache);
// Load the installer's i18n.
$wgMessagesDirs['MediawikiInstaller'] = __DIR__ . '/i18n';
// Having a user with id = 0 safeguards us from DB access via User::loadOptions().
$wgUser = User::newFromId(0);
$this->settings = $this->internalDefaults;
foreach ($this->defaultVarNames as $var) {
$this->settings[$var] = $GLOBALS[$var];
}
$this->doEnvironmentPreps();
$this->compiledDBs = array();
foreach (self::getDBTypes() as $type) {
$installer = $this->getDBInstaller($type);
if (!$installer->isCompiled()) {
continue;
}
$this->compiledDBs[] = $type;
}
$this->parserTitle = Title::newFromText('Installer');
$this->parserOptions = new ParserOptions();
// language will be wrong :(
$this->parserOptions->setEditSection(false);
}
示例6: wfSetParserOptions
function wfSetParserOptions()
{
global $wgParserOptions, $wgParser;
$wgParserOptions = new ParserOptions(null);
$wgParserOptions->setEditSection(false);
$wgParser->Options($wgParserOptions);
return $wgParserOptions;
}
示例7: msgWikiNoEdit
/**
* Like msgWiki() but it ensures edit section links are never shown.
*
* Needed for Mediawiki 1.19 & 1.20 due to bug 36975:
* https://bugzilla.wikimedia.org/show_bug.cgi?id=36975
*
* @param $message Name of wikitext message to return
*/
function msgWikiNoEdit($message)
{
global $wgOut;
global $wgParser;
$popts = new ParserOptions();
$popts->setEditSection(false);
$text = wfMessage($message)->text();
return $wgParser->parse($text, $wgOut->getTitle(), $popts)->getText();
}
示例8: rteparse
/**
* Parse provided wikitext to HTML using RTE parser
*/
public static function rteparse()
{
global $wgTitle, $wgRequest, $wgUser;
wfProfileIn(__METHOD__);
$wikitext = $wgRequest->getVal('wikitext', '');
$parserOptions = new ParserOptions();
// don't show [edit] link for sections
$parserOptions->setEditSection(false);
// disable headings numbering
$parserOptions->setNumberHeadings(false);
$parser = new RTEParser();
// call preSaveTransform so signatures, {{subst:foo}}, etc. will work
$wikitext = $parser->preSaveTransform($wikitext, $wgTitle, $wgUser, $parserOptions);
// parse wikitext using RTE parser
$html = $parser->parse($wikitext, $wgTitle, $parserOptions)->getText();
$res = array('html' => $html);
wfProfileOut(__METHOD__);
return $res;
}
示例9: embedWiki
public static function embedWiki($input, $argv)
{
// if(!ETParserFunctions::$inlineParser) {
// global $wgParserConf;
// ETParserFunctions::$inlineParser = wfCreateObject( $wgParserConf['class'], array( $wgParserConf ) );
// }
global $wgParser;
if ($wgParser->getTitle() instanceof Title && $wgParser->getOptions() instanceof ParserOptions) {
$result = $wgParser->recursiveTagParse($input);
} else {
global $wgTitle;
$popt = new ParserOptions();
$popt->setEditSection(false);
$pout = $wgParser->parse($input . '__NOTOC__', $wgTitle, $popt);
// / NOTE: as of MW 1.14SVN, there is apparently no better way to hide the TOC
SMWOutputs::requireFromParserOutput($pout);
$result = $pout->getText();
}
return $result;
}
示例10: __construct
/**
* Constructor, always call this from child classes.
*/
public function __construct()
{
global $wgMemc, $wgUser, $wgObjectCaches;
$defaultConfig = new GlobalVarConfig();
// all the stuff from DefaultSettings.php
$installerConfig = self::getInstallerConfig($defaultConfig);
// Reset all services and inject config overrides
MediaWiki\MediaWikiServices::resetGlobalInstance($installerConfig);
// Don't attempt to load user language options (T126177)
// This will be overridden in the web installer with the user-specified language
RequestContext::getMain()->setLanguage('en');
// Disable the i18n cache
// TODO: manage LocalisationCache singleton in MediaWikiServices
Language::getLocalisationCache()->disableBackend();
// Disable all global services, since we don't have any configuration yet!
MediaWiki\MediaWikiServices::disableStorageBackend();
// Disable object cache (otherwise CACHE_ANYTHING will try CACHE_DB and
// SqlBagOStuff will then throw since we just disabled wfGetDB)
$wgObjectCaches = MediaWikiServices::getInstance()->getMainConfig()->get('ObjectCaches');
$wgMemc = ObjectCache::getInstance(CACHE_NONE);
// Having a user with id = 0 safeguards us from DB access via User::loadOptions().
$wgUser = User::newFromId(0);
RequestContext::getMain()->setUser($wgUser);
$this->settings = $this->internalDefaults;
foreach ($this->defaultVarNames as $var) {
$this->settings[$var] = $GLOBALS[$var];
}
$this->doEnvironmentPreps();
$this->compiledDBs = [];
foreach (self::getDBTypes() as $type) {
$installer = $this->getDBInstaller($type);
if (!$installer->isCompiled()) {
continue;
}
$this->compiledDBs[] = $type;
}
$this->parserTitle = Title::newFromText('Installer');
$this->parserOptions = new ParserOptions($wgUser);
// language will be wrong :(
$this->parserOptions->setEditSection(false);
}
示例11: execute
public function execute()
{
global $egPushLoginUser, $egPushLoginPass, $egPushLoginUsers, $egPushLoginPasswords;
$params = $this->extractRequestParams();
if (!isset($params['text'])) {
$this->dieUsageMsg(array('missingparam', 'text'));
}
if (!isset($params['pagename'])) {
$this->dieUsageMsg(array('missingparam', 'pagename'));
}
$plaintext = $params['text'];
// Remove comments.
$plaintext = preg_replace('/\\<!--([^(--\\>)]*)--\\>/', '', $plaintext);
// Remove ref tags.
$plaintext = preg_replace('/<ref[^>]*\\>(.*?)<\\/ref>/si', '', $plaintext);
// Replace both internal and external wiki links with their plain text.
$plaintext = preg_replace('/\\[http(?:s)?:\\/\\/\\S*\\s([^\\]]*)]/', '$1', $plaintext);
$plaintext = preg_replace('/http(?:s)?:\\/\\/\\S*/', '$1', $plaintext);
$plaintext = preg_replace('/\\[\\[(?!(Category|Image|File|[^\\s]{2,5}:))[^\\|\\]]*\\|([^\\]]*)\\]\\]/', '$2', $plaintext);
$plaintext = preg_replace('/\\[\\[((?!(Category|Image|File|[^\\s]{2,5}:))[^\\]]*)\\]\\]/', '$1', $plaintext);
// Remove categories and files (images).
$plaintext = preg_replace('/\\[\\[(Category|File|Image|):[^\\]]+\\]\\]/', '', $plaintext);
// Remove inter language links.
$plaintext = preg_replace('/\\[\\[[^\\s]{2,5}:[^\\s][^\\]]+\\]\\]/', '', $plaintext);
for ($i = 3; $i > 0; $i--) {
$plaintext = preg_replace("/\\{\\{(?:[^\\}\\{]*)?\\}\\}/", '', $plaintext);
}
// Render the wikitext
$parser = new Parser();
$options = new ParserOptions();
$options->setEditSection(false);
$plaintext = $parser->parse(trim($plaintext), Title::newFromText($params['pagename']), $options)->getText();
// Remove excess whitespace
$plaintext = preg_replace('/\\s\\s+/', ' ', $plaintext);
$plaintext = str_replace("<p><br />\n</p>", '', $plaintext);
$this->getResult()->addValue(null, null, $plaintext);
}
示例12: text
/**
* Creates the RSS output for the single item.
*/
public function text()
{
global $wgServer, $wgParser, $smwgShowFactbox, $smwgRSSWithPages;
static $parser_options = null;
$smwgShowFactbox = SMW_FACTBOX_HIDDEN;
// just hide factbox; no need to restore this setting, I hope that nothing comes after FILE outputs
$text = "\t<item rdf:about=\"{$this->uri}\">\n";
$text .= "\t\t<title>" . smwfXMLContentEncode($this->label) . "</title>\n";
$text .= "\t\t<link>" . smwfXMLContentEncode($this->uri) . "</link>\n";
foreach ($this->date as $date) {
$text .= "\t\t<dc:date>{$date}</dc:date>\n";
}
foreach ($this->creator as $creator) {
$text .= "\t\t<dc:creator>" . smwfXMLContentEncode($creator) . "</dc:creator>\n";
}
if ($smwgRSSWithPages) {
$parser_options = new ParserOptions();
$parser_options->setEditSection(false);
// embedded sections should not have edit links
$parserOutput = $wgParser->parse('{{' . $this->articlename . '}}', $this->title, $parser_options);
$content = $parserOutput->getText();
// Make absolute URLs out of the local ones:
///TODO is there maybe a way in the parser options to make the URLs absolute?
$content = str_replace('<a href="/', '<a href="' . $wgServer . '/', $content);
$text .= "\t\t<description>" . smwfXMLContentEncode($content) . "</description>\n";
$text .= "\t\t<content:encoded rdf:datatype=\"http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral\"><![CDATA[{$content}]]></content:encoded>\n";
}
$text .= "\t</item>\n";
return $text;
}
示例13: __construct
public function __construct($name, $options, $lang)
{
global $wgContLang;
if (!self::$parserOptions) {
self::$parserOptions = new ParserOptions();
self::$parserOptions->setEditSection(false);
self::$parser = new Parser();
}
$this->name = $name;
$this->options = $options;
if ($options['inUserLanguage']) {
$this->language = $lang;
} else {
$this->language = $wgContLang;
}
}
示例14: parserOptions
/**
* Get/set the ParserOptions object to use for wikitext parsing
*
* @param ParserOptions|null $options Either the ParserOption to use or null to only get the
* current ParserOption object
* @return ParserOptions
*/
public function parserOptions($options = null)
{
if ($options !== null && !empty($options->isBogus)) {
// Someone is trying to set a bogus pre-$wgUser PO. Check if it has
// been changed somehow, and keep it if so.
$anonPO = ParserOptions::newFromAnon();
$anonPO->setEditSection(false);
if (!$options->matches($anonPO)) {
wfLogWarning(__METHOD__ . ': Setting a changed bogus ParserOptions: ' . wfGetAllCallers(5));
$options->isBogus = false;
}
}
if (!$this->mParserOptions) {
if (!$this->getContext()->getUser()->isSafeToLoad()) {
// $wgUser isn't unstubbable yet, so don't try to get a
// ParserOptions for it. And don't cache this ParserOptions
// either.
$po = ParserOptions::newFromAnon();
$po->setEditSection(false);
$po->isBogus = true;
if ($options !== null) {
$this->mParserOptions = empty($options->isBogus) ? $options : null;
}
return $po;
}
$this->mParserOptions = ParserOptions::newFromContext($this->getContext());
$this->mParserOptions->setEditSection(false);
}
if ($options !== null && !empty($options->isBogus)) {
// They're trying to restore the bogus pre-$wgUser PO. Do the right
// thing.
return wfSetVar($this->mParserOptions, null, true);
} else {
return wfSetVar($this->mParserOptions, $options);
}
}
示例15: smwf_nm_NotifyAccess
function smwf_nm_NotifyAccess( $method, $params ) {
$p_array = explode( ",", $params );
global $smwgQEnabled;
$result = "Query disabled.";
if ( $method == "updateMail" ) {
global $wgUser;
$wgUser->setOption( 'enotifyme', $params );
$wgUser->saveSettings();
return wfMsg( 'smw_nm_ajax_mailupdate' );
}
elseif ( $method == "addNotify" ) {
if ( $smwgQEnabled ) {
$result = SMWNotifyProcessor::addNotify( str_replace( '&', '&', str_replace( ',', ',', $p_array[0] ) ),
str_replace( '&', '&', str_replace( ',', ',', $p_array[3] ) ),
$p_array[1], $p_array[2], implode( ",", array_slice( $p_array, 4 ) ) );
}
return $result;
}
elseif ( $method == "getQueryResult" ) {
if ( $smwgQEnabled ) {
$params .= '
| format=table
| link=all';
// parse params and answer query
SMWQueryProcessor::processFunctionParams( SMWNotifyProcessor::getQueryRawParams( $params ), $querystring, $params, $printouts );
$result = SMWQueryProcessor::getResultFromQueryString( $querystring, $params, $printouts, SMW_OUTPUT_WIKI );
switch ( $params->format ) {
case 'timeline':
return $result;
break;
case 'eventline':
return $result;
break;
case 'googlepie':
return $result[0];
break;
case 'googlebar':
return $result[0];
break;
case 'exhibit':
return $result;
break;
default:
}
global $wgParser;
if ( ( $wgParser->getTitle() instanceof Title ) && ( $wgParser->getOptions() instanceof ParserOptions ) ) {
$result = $wgParser->recursiveTagParse( $result );
} else {
global $wgTitle;
$popt = new ParserOptions();
$popt->setEditSection( false );
$pout = $wgParser->parse( $result . '__NOTOC__', $wgTitle, $popt );
// / NOTE: as of MW 1.14SVN, there is apparently no better way to hide the TOC
SMWOutputs::requireFromParserOutput( $pout );
$result = $pout->getText();
}
// add target="_new" for all links
$pattern = "|<a|i";
$result = preg_replace( $pattern, '<a target="_new"', $result );
}
return $result;
}
elseif ( $method == "updateStates" ) {
if ( $smwgQEnabled ) {
$result = SMWNotifyProcessor::updateStates( $p_array );
}
return $result;
}
elseif ( $method == "updateReportAll" ) {
if ( $smwgQEnabled ) {
$result = SMWNotifyProcessor::updateReportAll( $p_array );
}
return $result;
}
elseif ( $method == "updateShowAll" ) {
if ( $smwgQEnabled ) {
$result = SMWNotifyProcessor::updateShowAll( $p_array );
}
return $result;
}
elseif ( $method == "updateDelegates" ) {
if ( $smwgQEnabled ) {
$result = SMWNotifyProcessor::updateDelegates( explode( "|", $params ) );
}
return $result;
}
elseif ( $method == "delNotify" ) {
if ( $smwgQEnabled ) {
$result = SMWNotifyProcessor::delNotify( $p_array );
}
return $result;
}
else {
return wfMsg( 'smw_nm_ajax_fail' );
}
//.........这里部分代码省略.........