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


PHP MagicWord::get方法代码示例

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


在下文中一共展示了MagicWord::get方法的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: 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

示例6: 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

示例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: 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

示例9: 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

示例10: 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

示例11: 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

示例12: onArticleFromTitle

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

示例13: switchHook

 function switchHook(&$parser)
 {
     $args = func_get_args();
     array_shift($args);
     $value = trim(array_shift($args));
     $found = false;
     $parts = null;
     $default = null;
     foreach ($args as $arg) {
         $parts = array_map('trim', explode('=', $arg, 2));
         if (count($parts) == 2) {
             if ($found || $parts[0] == $value) {
                 return $parts[1];
             } else {
                 $mwDefault =& MagicWord::get('default');
                 if ($mwDefault->matchStartAndRemove($parts[0])) {
                     $default = $parts[1];
                 }
                 # else wrong case, continue
             }
         } elseif (count($parts) == 1) {
             # Multiple input, single output
             # If the value matches, set a flag and continue
             if ($parts[0] == $value) {
                 $found = true;
             }
         }
         # else RAM corruption due to cosmic ray?
     }
     # Default case
     # Check if the last item had no = sign, thus specifying the default case
     if (count($parts) == 1) {
         return $parts[0];
     } elseif (!is_null($default)) {
         return $default;
     } else {
         return '';
     }
 }
开发者ID:clrh,项目名称:mediawiki,代码行数:39,代码来源:ParserFunctions.php

示例14: getDoubleUnderscoreRegex

	static function getDoubleUnderscoreRegex() {
		if ( WOMMagicWordParser::$mwa === null ) {
			WOMMagicWordParser::$mwa = MagicWord::getDoubleUnderscoreArray();
			foreach ( WOMMagicWordParser::$mwa->names as $name ) {
				$magic = MagicWord::get( $name );
				$case = intval( $magic->isCaseSensitive() );
				foreach ( $magic->getSynonyms() as $i => $syn ) {
					$group = '(' . preg_quote( $syn, '/' ) . ')';
					if ( WOMMagicWordParser::$underscores[$case] === '' ) {
						WOMMagicWordParser::$underscores[$case] = $group;
					} else {
						WOMMagicWordParser::$underscores[$case] .= '|' . $group;
					}
				}
			}
			if ( WOMMagicWordParser::$underscores[0] !== '' ) {
				WOMMagicWordParser::$underscores[0] = "/^(" . WOMMagicWordParser::$underscores[0] . ")/i";
			}
			if ( WOMMagicWordParser::$underscores[1] !== '' ) {
				WOMMagicWordParser::$underscores[1] = "/^(" . WOMMagicWordParser::$underscores[1] . ")/";
			}
		}
		return WOMMagicWordParser::$underscores;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:24,代码来源:WOMMagicWordParser.php

示例15: leaveTrace

 function leaveTrace($reason, $oldTitle, $newTitle)
 {
     $this->dieIfHistorical();
     // Create redirect text
     $mwRedir = MagicWord::get('redirect');
     $redirectText = $mwRedir->getSynonym(0) . ' [[' . $this->title()->getPrefixedText() . "]]\n";
     // Make the article edit.
     $traceTitle = Threads::newThreadTitle($this->subject(), new Article($oldTitle));
     $redirectArticle = new Article($traceTitle);
     $redirectArticle->doEdit($redirectText, $reason, EDIT_NEW | EDIT_SUPPRESS_RC);
     // Add the trace thread to the tracking table.
     $thread = Thread::create($redirectArticle, new Article($oldTitle), null, Threads::TYPE_MOVED, $this->subject());
     $thread->setSortkey($this->sortkey());
     $thread->save();
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:15,代码来源:Thread.php


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