当前位置: 首页>>代码示例>>PHP>>正文


PHP MagicWord类代码示例

本文整理汇总了PHP中MagicWord的典型用法代码示例。如果您正苦于以下问题:PHP MagicWord类的具体用法?PHP MagicWord怎么用?PHP MagicWord使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了MagicWord类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: MagicNoNumberedHeadingsParserBeforeInternalParse

function MagicNoNumberedHeadingsParserBeforeInternalParse($parser, $text, $stripState)
{
    if (MagicWord::get('MAG_NONUMBEREDHEADINGS')->matchAndRemove($text)) {
        $parser->mOptions->mNumberHeadings = FALSE;
    }
    return true;
}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:7,代码来源:MagicNoNumberedHeadings.php

示例2: onParserBeforeInternalParse

 /**
  *
  * Process the MagicWords
  *
  * @param Parser $parser
  * @param string $text
  * @param StripState $stripState
  * @return boolean
  */
 function onParserBeforeInternalParse(&$parser, &$text, &$stripState)
 {
     $config = \PageAttachment\Configuration\StaticConfiguration::getInstance();
     $pageAttachmentDefinedMagicWord = false;
     $allowAttachments = false;
     $magicWord1 = \MagicWord::get(self::MagicWord_NOATTACHMENTS);
     if ($magicWord1->matchAndRemove($text)) {
         $pageAttachmentDefinedMagicWord = true;
         $allowAttachments = false;
     }
     $magicWord2 = \MagicWord::get(self::MagicWord_ALLOWATTACHMENTS);
     if ($magicWord2->matchAndRemove($text)) {
         $pageAttachmentDefinedMagicWord = true;
         $allowAttachments = true;
     }
     if ($pageAttachmentDefinedMagicWord == true) {
         if ($allowAttachments == true) {
             if ($config->isAllowAttachmentsUsingMagicWord()) {
                 $parser->mOutput->addHeadItem('<script> pageAttachment__ALLOW_ATTACHMENTS__ = true; </script>');
             }
         } else {
             if ($config->isDisallowAttachmentsUsingMagicWord()) {
                 $parser->mOutput->addHeadItem('<script> pageAttachment__ALLOW_ATTACHMENTS__ = false; </script>');
             }
         }
     }
     return true;
 }
开发者ID:mediawiki-extensions,项目名称:mediawiki-page-attachment,代码行数:37,代码来源:MagicWordHandler.php

示例3: onInternalParseBeforeLinks

 /**
  * Hook entry for removing the magic words from displayed text
  */
 public static function onInternalParseBeforeLinks(&$parser, &$text, &$strip_state)
 {
     global $wgRTEParserEnabled;
     if (empty($wgRTEParserEnabled)) {
         MagicWord::get('CATEXHIBITION_DISABLED')->matchAndRemove($text);
     }
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:11,代码来源:CategoryExhibitionHelper.class.php

示例4: PSINoTocNumParserBeforeInternalParse

function PSINoTocNumParserBeforeInternalParse($parser, $text, $stripState)
{
    if (MagicWord::get(MAG_NOTOCNUM)->matchAndRemove($text)) {
        global $wgOut;
        $wgOut->addScript('
                        <style type="text/css"><!-- .tocnumber {display:none;} --></style>
                ');
    }
    return true;
}
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:10,代码来源:PSINoTocNum.php

示例5: setUp

 protected function setUp()
 {
     parent::setUp();
     $contLang = Language::factory('en');
     $this->setMwGlobals(array('wgShowDBErrorBacktrace' => true, 'wgLanguageCode' => 'en', 'wgContLang' => $contLang, 'wgLang' => Language::factory('en'), 'wgMemc' => new EmptyBagOStuff(), 'wgAlwaysUseTidy' => false, 'wgCleanSignatures' => true));
     $this->options = ParserOptions::newFromUserAndLang(new User(), $contLang);
     $this->options->setTemplateCallback(array(__CLASS__, 'statelessFetchTemplate'));
     $this->parser = new Parser();
     MagicWord::clearCache();
 }
开发者ID:nischayn22,项目名称:mediawiki-core,代码行数:10,代码来源:ExtraParserTest.php

示例6: testMakeRedirectContent

 /**
  * @dataProvider provideMakeRedirectContent
  * @param Title|string $title Title object or string for Title::newFromText()
  * @param string $expected Serialized form of the content object built
  * @covers WikitextContentHandler::makeRedirectContent
  */
 public function testMakeRedirectContent($title, $expected)
 {
     global $wgContLang;
     $wgContLang->resetNamespaces();
     MagicWord::clearCache();
     if (is_string($title)) {
         $title = Title::newFromText($title);
     }
     $content = $this->handler->makeRedirectContent($title);
     $this->assertEquals($expected, $content->serialize());
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:17,代码来源:WikitextContentHandlerTest.php

示例7: execute

	public function execute() {
		$this->batchsize = $this->getOption( 'batchsize', 50 );
		$variableIDs = MagicWord::getVariableIDs();
		foreach ( $variableIDs as $id ) {
			$magic = MagicWord::get( $id );
			foreach ( $magic->getSynonyms() as $synonym ) {
				$this->processSynonym( $synonym );
			}
		}
		$this->output( "All done\n" );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:11,代码来源:cleanupBug31576.php

示例8: run

 function run()
 {
     if (!$this->redirTitle) {
         $this->setLastError('Invalid title');
         return false;
     }
     $targetRev = Revision::newFromTitle($this->title);
     if (!$targetRev) {
         wfDebug(__METHOD__ . ": target redirect already deleted, ignoring\n");
         return true;
     }
     $text = $targetRev->getText();
     $currentDest = Title::newFromRedirect($text);
     if (!$currentDest || !$currentDest->equals($this->redirTitle)) {
         wfDebug(__METHOD__ . ": Redirect has changed since the job was queued\n");
         return true;
     }
     # Check for a suppression tag (used e.g. in periodically archived discussions)
     $mw = MagicWord::get('staticredirect');
     if ($mw->match($text)) {
         wfDebug(__METHOD__ . ": skipping: suppressed with __STATICREDIRECT__\n");
         return true;
     }
     # Find the current final destination
     $newTitle = self::getFinalDestination($this->redirTitle);
     if (!$newTitle) {
         wfDebug(__METHOD__ . ": skipping: single redirect, circular redirect or invalid redirect destination\n");
         return true;
     }
     if ($newTitle->equals($this->redirTitle)) {
         # The redirect is already right, no need to change it
         # This can happen if the page was moved back (say after vandalism)
         wfDebug(__METHOD__ . ": skipping, already good\n");
     }
     # Preserve fragment (bug 14904)
     $newTitle = Title::makeTitle($newTitle->getNamespace(), $newTitle->getDBkey(), $currentDest->getFragment());
     # Fix the text
     # Remember that redirect pages can have categories, templates, etc.,
     # so the regex has to be fairly general
     $newText = preg_replace('/ \\[ \\[  [^\\]]*  \\] \\] /x', '[[' . $newTitle->getFullText() . ']]', $text, 1);
     if ($newText === $text) {
         $this->setLastError('Text unchanged???');
         return false;
     }
     # Save it
     global $wgUser;
     $oldUser = $wgUser;
     $wgUser = $this->getUser();
     $article = new Article($this->title);
     $reason = wfMsgForContent('double-redirect-fixed-' . $this->reason, $this->redirTitle->getPrefixedText(), $newTitle->getPrefixedText());
     $article->doEdit($newText, $reason, EDIT_UPDATE | EDIT_SUPPRESS_RC);
     $wgUser = $oldUser;
     return true;
 }
开发者ID:ui-libraries,项目名称:TIRW,代码行数:54,代码来源:DoubleRedirectJob.php

示例9: onInternalParseBeforeLinks

 /**
  * Entry for removing the magic words from displayed text
  */
 public static function onInternalParseBeforeLinks(&$parser, &$text, &$strip_state)
 {
     wfProfileIn(__METHOD__);
     if (empty(F::app()->wg->RTEParserEnabled)) {
         $oMagicWord = MagicWord::get('RELATEDVIDEOS_POSITION');
         $text = $oMagicWord->replace('<span data-placeholder="RelatedVideosModule"></span>', $text, 1);
         $text = $oMagicWord->replace('', $text);
     }
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:14,代码来源:RelatedVideos.hooks.php

示例10: init

	/**
	 * Static initializer.
	 */
	public static function init() {
		$iExQuoteMW                = MagicWord::get( 'wc_initial_exterior_quote' );
		$fExQuoteMW                = MagicWord::get( 'wc_final_exterior_quote' );
		$iInQuoteMW                = MagicWord::get( 'wc_initial_interior_quote' );
		$fInQuoteMW                = MagicWord::get( 'wc_final_interior_quote' );
		$iExQuotes                 = implode( $iExQuoteMW->getSynonyms() );
		$fExQuotes                 = implode( $fExQuoteMW->getSynonyms() );
		$iInQuotes                 = implode( $iInQuoteMW->getSynonyms() );
		$fInQuotes                 = implode( $fInQuoteMW->getSynonyms() );
		self::$patternExternal   = '/(^|[\p{Ps}\p{Zs}\p{Pd}\p{Pi}\'])[' . $iExQuotes . '](.*?)[' . $fExQuotes . ']($|[\p{Pe}\p{Zs}\.,;:?!\p{Pd}\p{Pf}\'])/usS';
		self::$patternInternal   = '/(^|[\p{Ps}\p{Zs}\p{Pd}\p{Pi}"])[' . $iInQuotes . '](.*?)[' . $fInQuotes . ']($|[\p{Pe}\p{Zs}\.,;:?!\p{Pd}\p{Pf}"])/usS';
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:15,代码来源:WCTitle.php

示例11: setUp

 protected function setUp()
 {
     parent::setUp();
     $contLang = Language::factory('en');
     $this->setMwGlobals(['wgShowDBErrorBacktrace' => true, 'wgCleanSignatures' => true]);
     $this->setUserLang('en');
     $this->setContentLang($contLang);
     // FIXME: This test should pass without setting global content language
     $this->options = ParserOptions::newFromUserAndLang(new User(), $contLang);
     $this->options->setTemplateCallback([__CLASS__, 'statelessFetchTemplate']);
     $this->parser = new Parser();
     MagicWord::clearCache();
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:13,代码来源:ExtraParserTest.php

示例12: stripMagicWords

 /**
  * Remove relevant SMW magic words from the given text and return
  * an array of the names of all discovered magic words. Moreover,
  * store this array in the current parser output, using the variable
  * mSMWMagicWords.
  */
 public static function stripMagicWords(&$text, Parser $parser)
 {
     $words = array();
     $mw = MagicWord::get('SMW_NOFACTBOX');
     if ($mw->matchAndRemove($text)) {
         $words[] = 'SMW_NOFACTBOX';
     }
     $mw = MagicWord::get('SMW_SHOWFACTBOX');
     if ($mw->matchAndRemove($text)) {
         $words[] = 'SMW_SHOWFACTBOX';
     }
     $output = $parser->getOutput();
     $output->mSMWMagicWords = $words;
     return $words;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:21,代码来源:SMW_ParseData.php

示例13: setUp

 function setUp()
 {
     global $wgMemc;
     global $wgContLang;
     global $wgShowDBErrorBacktrace;
     global $wgLanguageCode;
     global $wgAlwaysUseTidy;
     $wgShowDBErrorBacktrace = true;
     $wgLanguageCode = 'en';
     $wgContLang = new Language('en');
     $wgMemc = new EmptyBagOStuff();
     $wgAlwaysUseTidy = false;
     $this->options = new ParserOptions();
     $this->options->setTemplateCallback(array(__CLASS__, 'statelessFetchTemplate'));
     $this->parser = new Parser();
     MagicWord::clearCache();
 }
开发者ID:Jobava,项目名称:diacritice-meta-repo,代码行数:17,代码来源:ExtraParserTest.php

示例14: onArticleFromTitle

 /**
  * @param Title $title
  * @param WikiPage $article
  * @return bool
  */
 public function onArticleFromTitle(Title &$title, &$article)
 {
     if ($title->exists() && $title->getNamespace() != NS_FILE && $title->getNamespace() != NS_CATEGORY) {
         $key = $this->generateCacheKey($title->getArticleId());
         $this->switches = $this->app->wg->memc->get($key);
         if (empty($this->switches)) {
             $article = F::build('Article', array($title));
             $this->switches = array();
             foreach ($this->magicWords as $wordID) {
                 $magicWord = MagicWord::get($wordID);
                 $this->switches[$wordID] = 0 < $magicWord->match($article->getRawText());
             }
             $this->app->wg->memc->set($key, $this->switches, self::CACHE_DURATION);
         }
         $this->process();
     }
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:23,代码来源:LandingPagesParser.class.php

示例15: makeRedirectContent

 /**
  * Returns a WikitextContent object representing a redirect to the given destination page.
  *
  * @param Title $destination The page to redirect to.
  * @param string $text Text to include in the redirect, if possible.
  *
  * @return Content
  *
  * @see ContentHandler::makeRedirectContent
  */
 public function makeRedirectContent(Title $destination, $text = '')
 {
     $optionalColon = '';
     if ($destination->getNamespace() == NS_CATEGORY) {
         $optionalColon = ':';
     } else {
         $iw = $destination->getInterwiki();
         if ($iw && Language::fetchLanguageName($iw, null, 'mw')) {
             $optionalColon = ':';
         }
     }
     $mwRedir = MagicWord::get('redirect');
     $redirectText = $mwRedir->getSynonym(0) . ' [[' . $optionalColon . $destination->getFullText() . ']]';
     if ($text != '') {
         $redirectText .= "\n" . $text;
     }
     return new WikitextContent($redirectText);
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:28,代码来源:WikitextContentHandler.php


注:本文中的MagicWord类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。