本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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" );
}
示例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';
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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 '';
}
}
示例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;
}
示例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();
}