本文整理汇总了PHP中MagicWord::getDoubleUnderscoreArray方法的典型用法代码示例。如果您正苦于以下问题:PHP MagicWord::getDoubleUnderscoreArray方法的具体用法?PHP MagicWord::getDoubleUnderscoreArray怎么用?PHP MagicWord::getDoubleUnderscoreArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MagicWord
的用法示例。
在下文中一共展示了MagicWord::getDoubleUnderscoreArray方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: doDoubleUnderscore
/**
* Strip double-underscore items like __NOGALLERY__ and __NOTOC__
* Fills $this->mDoubleUnderscores, returns the modified text
*
* @param $text string
*
* @return string
*/
function doDoubleUnderscore($text)
{
wfProfileIn(__METHOD__);
# The position of __TOC__ needs to be recorded
$mw = MagicWord::get('toc');
if ($mw->match($text)) {
$this->mShowToc = true;
$this->mForceTocPosition = true;
# Set a placeholder. At the end we'll fill it in with the TOC.
$text = $mw->replace('<!--MWTOC-->', $text, 1);
# Only keep the first one.
$text = $mw->replace('', $text);
}
# Now match and remove the rest of them
$mwa = MagicWord::getDoubleUnderscoreArray();
$this->mDoubleUnderscores = $mwa->matchAndRemove($text);
if (isset($this->mDoubleUnderscores['nogallery'])) {
$this->mOutput->mNoGallery = true;
}
if (isset($this->mDoubleUnderscores['notoc']) && !$this->mForceTocPosition) {
$this->mShowToc = false;
}
if (isset($this->mDoubleUnderscores['hiddencat']) && $this->mTitle->getNamespace() == NS_CATEGORY) {
$this->addTrackingCategory('hidden-category-category');
}
# (bug 8068) Allow control over whether robots index a page.
#
# @todo FIXME: Bug 14899: __INDEX__ always overrides __NOINDEX__ here! This
# is not desirable, the last one on the page should win.
if (isset($this->mDoubleUnderscores['noindex']) && $this->mTitle->canUseNoindex()) {
$this->mOutput->setIndexPolicy('noindex');
$this->addTrackingCategory('noindex-category');
}
if (isset($this->mDoubleUnderscores['index']) && $this->mTitle->canUseNoindex()) {
$this->mOutput->setIndexPolicy('index');
$this->addTrackingCategory('index-category');
}
# Cache all double underscores in the database
foreach ($this->mDoubleUnderscores as $key => $val) {
$this->mOutput->setProperty($key, '');
}
wfProfileOut(__METHOD__);
return $text;
}
示例3: doDoubleUnderscore
/**
* Strip double-underscore items like __NOGALLERY__ and __NOTOC__
* Fills $this->mDoubleUnderscores, returns the modified text
*/
function doDoubleUnderscore($text)
{
wfProfileIn(__METHOD__);
// The position of __TOC__ needs to be recorded
$mw = MagicWord::get('toc');
if ($mw->match($text)) {
$this->mShowToc = true;
$this->mForceTocPosition = true;
// Set a placeholder. At the end we'll fill it in with the TOC.
$text = $mw->replace('<!--MWTOC-->', $text, 1);
// Only keep the first one.
$text = $mw->replace('', $text);
}
// Now match and remove the rest of them
$mwa = MagicWord::getDoubleUnderscoreArray();
$this->mDoubleUnderscores = $mwa->matchAndRemove($text);
if (isset($this->mDoubleUnderscores['nogallery'])) {
$this->mOutput->mNoGallery = true;
}
if (isset($this->mDoubleUnderscores['notoc']) && !$this->mForceTocPosition) {
$this->mShowToc = false;
}
if (isset($this->mDoubleUnderscores['hiddencat']) && $this->mTitle->getNamespace() == NS_CATEGORY) {
$this->mOutput->setProperty('hiddencat', 'y');
$containerCategory = Title::makeTitleSafe(NS_CATEGORY, wfMsgForContent('hidden-category-category'));
if ($containerCategory) {
$this->mOutput->addCategory($containerCategory->getDBkey(), $this->getDefaultSort());
} else {
wfDebug(__METHOD__ . ": [[MediaWiki:hidden-category-category]] is not a valid title!\n");
}
}
# (bug 8068) Allow control over whether robots index a page.
#
# FIXME (bug 14899): __INDEX__ always overrides __NOINDEX__ here! This
# is not desirable, the last one on the page should win.
if (isset($this->mDoubleUnderscores['noindex'])) {
$this->mOutput->setIndexPolicy('noindex');
} elseif (isset($this->mDoubleUnderscores['index'])) {
$this->mOutput->setIndexPolicy('index');
}
wfProfileOut(__METHOD__);
return $text;
}
示例4: pageInfo
//.........这里部分代码省略.........
// restriction-upload
$pageInfo['header-restrictions'][] = array($this->msg("restriction-{$restrictionType}"), $message);
}
if (!$this->page->exists()) {
return $pageInfo;
}
// Edit history
$pageInfo['header-edits'] = array();
$firstRev = $this->page->getOldestRevision();
$lastRev = $this->page->getRevision();
$batch = new LinkBatch();
if ($firstRev) {
$firstRevUser = $firstRev->getUserText(Revision::FOR_THIS_USER);
if ($firstRevUser !== '') {
$batch->add(NS_USER, $firstRevUser);
$batch->add(NS_USER_TALK, $firstRevUser);
}
}
if ($lastRev) {
$lastRevUser = $lastRev->getUserText(Revision::FOR_THIS_USER);
if ($lastRevUser !== '') {
$batch->add(NS_USER, $lastRevUser);
$batch->add(NS_USER_TALK, $lastRevUser);
}
}
$batch->execute();
if ($firstRev) {
// Page creator
$pageInfo['header-edits'][] = array($this->msg('pageinfo-firstuser'), Linker::revUserTools($firstRev));
// Date of page creation
$pageInfo['header-edits'][] = array($this->msg('pageinfo-firsttime'), Linker::linkKnown($title, htmlspecialchars($lang->userTimeAndDate($firstRev->getTimestamp(), $user)), array(), array('oldid' => $firstRev->getId())));
}
if ($lastRev) {
// Latest editor
$pageInfo['header-edits'][] = array($this->msg('pageinfo-lastuser'), Linker::revUserTools($lastRev));
// Date of latest edit
$pageInfo['header-edits'][] = array($this->msg('pageinfo-lasttime'), Linker::linkKnown($title, htmlspecialchars($lang->userTimeAndDate($this->page->getTimestamp(), $user)), array(), array('oldid' => $this->page->getLatest())));
}
// Total number of edits
$pageInfo['header-edits'][] = array($this->msg('pageinfo-edits'), $lang->formatNum($pageCounts['edits']));
// Total number of distinct authors
if ($pageCounts['authors'] > 0) {
$pageInfo['header-edits'][] = array($this->msg('pageinfo-authors'), $lang->formatNum($pageCounts['authors']));
}
// Recent number of edits (within past 30 days)
$pageInfo['header-edits'][] = array($this->msg('pageinfo-recent-edits', $lang->formatDuration($config->get('RCMaxAge'))), $lang->formatNum($pageCounts['recent_edits']));
// Recent number of distinct authors
$pageInfo['header-edits'][] = array($this->msg('pageinfo-recent-authors'), $lang->formatNum($pageCounts['recent_authors']));
// Array of MagicWord objects
$magicWords = MagicWord::getDoubleUnderscoreArray();
// Array of magic word IDs
$wordIDs = $magicWords->names;
// Array of IDs => localized magic words
$localizedWords = $wgContLang->getMagicWords();
$listItems = array();
foreach ($pageProperties as $property => $value) {
if (in_array($property, $wordIDs)) {
$listItems[] = Html::element('li', array(), $localizedWords[$property][1]);
}
}
$localizedList = Html::rawElement('ul', array(), implode('', $listItems));
$hiddenCategories = $this->page->getHiddenCategories();
if (count($listItems) > 0 || count($hiddenCategories) > 0 || $pageCounts['transclusion']['from'] > 0 || $pageCounts['transclusion']['to'] > 0) {
$options = array('LIMIT' => $config->get('PageInfoTransclusionLimit'));
$transcludedTemplates = $title->getTemplateLinksFrom($options);
if ($config->get('MiserMode')) {
$transcludedTargets = array();
} else {
$transcludedTargets = $title->getTemplateLinksTo($options);
}
// Page properties
$pageInfo['header-properties'] = array();
// Magic words
if (count($listItems) > 0) {
$pageInfo['header-properties'][] = array($this->msg('pageinfo-magic-words')->numParams(count($listItems)), $localizedList);
}
// Hidden categories
if (count($hiddenCategories) > 0) {
$pageInfo['header-properties'][] = array($this->msg('pageinfo-hidden-categories')->numParams(count($hiddenCategories)), Linker::formatHiddenCategories($hiddenCategories));
}
// Transcluded templates
if ($pageCounts['transclusion']['from'] > 0) {
if ($pageCounts['transclusion']['from'] > count($transcludedTemplates)) {
$more = $this->msg('morenotlisted')->escaped();
} else {
$more = null;
}
$pageInfo['header-properties'][] = array($this->msg('pageinfo-templates')->numParams($pageCounts['transclusion']['from']), Linker::formatTemplates($transcludedTemplates, false, false, $more));
}
if (!$config->get('MiserMode') && $pageCounts['transclusion']['to'] > 0) {
if ($pageCounts['transclusion']['to'] > count($transcludedTargets)) {
$more = Linker::link($whatLinksHere, $this->msg('moredotdotdot')->escaped(), array(), array('hidelinks' => 1, 'hideredirs' => 1));
} else {
$more = null;
}
$pageInfo['header-properties'][] = array($this->msg('pageinfo-transclusions')->numParams($pageCounts['transclusion']['to']), Linker::formatTemplates($transcludedTargets, false, false, $more));
}
}
return $pageInfo;
}
示例5: onView
//.........这里部分代码省略.........
}
if ($userCanViewUnwatchedPages) {
// Number of page watchers
$table = $this->addRow($table, $this->msg('pageinfo-watchers')->escaped(), $lang->formatNum($pageInfo['watchers']));
}
// Redirects to this page
$whatLinksHere = SpecialPage::getTitleFor('Whatlinkshere', $title->getPrefixedText());
$table = $this->addRow($table, Linker::link($whatLinksHere, $this->msg('pageinfo-redirects-name')->escaped(), array(), array('hidelinks' => 1, 'hidetrans' => 1)), $this->msg('pageinfo-redirects-value')->numParams(count($title->getRedirectsHere()))->escaped());
// Subpages of this page, if subpages are enabled for the current NS
if (MWNamespace::hasSubpages($title->getNamespace())) {
$prefixIndex = SpecialPage::getTitleFor('Prefixindex', $title->getPrefixedText() . '/');
$table = $this->addRow($table, Linker::link($prefixIndex, $this->msg('pageinfo-subpages-name')->escaped()), $this->msg('pageinfo-subpages-value')->numParams($pageInfo['subpages']['total'], $pageInfo['subpages']['redirects'], $pageInfo['subpages']['nonredirects'])->escaped());
}
// Page protection
$content = $this->addTable($content, $table);
$content = $this->addHeader($content, $this->msg('pageinfo-header-restrictions')->text());
$table = '';
// Page protection
foreach ($wgRestrictionTypes as $restrictionType) {
$protectionLevel = implode(', ', $title->getRestrictions($restrictionType));
if ($protectionLevel == '') {
// Allow all users
$message = $this->msg('protect-default')->escaped();
} else {
// Administrators only
$message = $this->msg("protect-level-{$protectionLevel}");
if ($message->isDisabled()) {
// Require "$1" permission
$message = $this->msg("protect-fallback", $protectionLevel)->parse();
} else {
$message = $message->escaped();
}
}
$table = $this->addRow($table, $this->msg('pageinfo-restriction', $this->msg("restriction-{$restrictionType}")->plain())->parse(), $message);
}
// Edit history
$content = $this->addTable($content, $table);
$content = $this->addHeader($content, $this->msg('pageinfo-header-edits')->text());
$table = '';
$firstRev = $this->page->getOldestRevision();
// Page creator
$table = $this->addRow($table, $this->msg('pageinfo-firstuser')->escaped(), $firstRev->getUserText(Revision::FOR_THIS_USER, $user));
// Date of page creation
$table = $this->addRow($table, $this->msg('pageinfo-firsttime')->escaped(), Linker::linkKnown($title, $lang->userTimeAndDate($firstRev->getTimestamp(), $user), array(), array('oldid' => $firstRev->getId())));
// Latest editor
$table = $this->addRow($table, $this->msg('pageinfo-lastuser')->escaped(), $this->page->getUserText(Revision::FOR_THIS_USER, $user));
// Date of latest edit
$table = $this->addRow($table, $this->msg('pageinfo-lasttime')->escaped(), Linker::linkKnown($title, $lang->userTimeAndDate($this->page->getTimestamp(), $user), array(), array('oldid' => $this->page->getLatest())));
// Total number of edits
$table = $this->addRow($table, $this->msg('pageinfo-edits')->escaped(), $lang->formatNum($pageInfo['edits']));
// Total number of distinct authors
$table = $this->addRow($table, $this->msg('pageinfo-authors')->escaped(), $lang->formatNum($pageInfo['authors']));
// Recent number of edits (within past 30 days)
$table = $this->addRow($table, $this->msg('pageinfo-recent-edits', $lang->formatDuration($wgRCMaxAge))->escaped(), $lang->formatNum($pageInfo['recent_edits']));
// Recent number of distinct authors
$table = $this->addRow($table, $this->msg('pageinfo-recent-authors')->escaped(), $lang->formatNum($pageInfo['recent_authors']));
$content = $this->addTable($content, $table);
// Array of MagicWord objects
$magicWords = MagicWord::getDoubleUnderscoreArray();
// Array of magic word IDs
$wordIDs = $magicWords->names;
// Array of IDs => localized magic words
$localizedWords = $wgContLang->getMagicWords();
$listItems = array();
foreach ($pageProperties as $property => $value) {
if (in_array($property, $wordIDs)) {
$listItems[] = Html::element('li', array(), $localizedWords[$property][1]);
}
}
$localizedList = Html::rawElement('ul', array(), implode('', $listItems));
$hiddenCategories = $this->page->getHiddenCategories();
$transcludedTemplates = $title->getTemplateLinksFrom();
if (count($listItems) > 0 || count($hiddenCategories) > 0 || count($transcludedTemplates) > 0) {
// Page properties
$content = $this->addHeader($content, $this->msg('pageinfo-header-properties')->text());
$table = '';
// Magic words
if (count($listItems) > 0) {
$table = $this->addRow($table, $this->msg('pageinfo-magic-words')->numParams(count($listItems))->escaped(), $localizedList);
}
// Hide "This page is a member of # hidden categories explanation
$content .= Html::element('style', array(), '.mw-hiddenCategoriesExplanation { display: none; }');
// Hidden categories
if (count($hiddenCategories) > 0) {
$table = $this->addRow($table, $this->msg('pageinfo-hidden-categories')->numParams(count($hiddenCategories))->escaped(), Linker::formatHiddenCategories($hiddenCategories));
}
// Hide "Templates used on this page:" explanation
$content .= Html::element('style', array(), '.mw-templatesUsedExplanation { display: none; }');
// Transcluded templates
if (count($transcludedTemplates) > 0) {
$table = $this->addRow($table, $this->msg('pageinfo-templates')->numParams(count($transcludedTemplates))->escaped(), Linker::formatTemplates($transcludedTemplates));
}
$content = $this->addTable($content, $table);
}
// Footer
if (!$this->msg('pageinfo-footer')->isDisabled()) {
$content .= $this->msg('pageinfo-footer')->parse();
}
return $content;
}
示例6: pageInfo
//.........这里部分代码省略.........
$pageInfo['header-basic'][] = array(Linker::link($whatLinksHere, $this->msg('pageinfo-redirects-name')->escaped(), array(), array('hidelinks' => 1, 'hidetrans' => 1)), $this->msg('pageinfo-redirects-value')->numParams(count($title->getRedirectsHere())));
// Is it counted as a content page?
if ($this->page->isCountable()) {
$pageInfo['header-basic'][] = array($this->msg('pageinfo-contentpage'), $this->msg('pageinfo-contentpage-yes'));
}
// Subpages of this page, if subpages are enabled for the current NS
if (MWNamespace::hasSubpages($title->getNamespace())) {
$prefixIndex = SpecialPage::getTitleFor('Prefixindex', $title->getPrefixedText() . '/');
$pageInfo['header-basic'][] = array(Linker::link($prefixIndex, $this->msg('pageinfo-subpages-name')->escaped()), $this->msg('pageinfo-subpages-value')->numParams($pageCounts['subpages']['total'], $pageCounts['subpages']['redirects'], $pageCounts['subpages']['nonredirects']));
}
// Page protection
$pageInfo['header-restrictions'] = array();
// Is this page effected by the cascading protection of something which includes it?
if ($title->isCascadeProtected()) {
$cascadingFrom = '';
$sources = $title->getCascadeProtectionSources();
// Array deferencing is in PHP 5.4 :(
foreach ($sources[0] as $sourceTitle) {
$cascadingFrom .= Html::rawElement('li', array(), Linker::linkKnown($sourceTitle));
}
$cascadingFrom = Html::rawElement('ul', array(), $cascadingFrom);
$pageInfo['header-restrictions'][] = array($this->msg('pageinfo-protect-cascading-from'), $cascadingFrom);
}
// Is out protection set to cascade to other pages?
if ($title->areRestrictionsCascading()) {
$pageInfo['header-restrictions'][] = array($this->msg('pageinfo-protect-cascading'), $this->msg('pageinfo-protect-cascading-yes'));
}
// Page protection
foreach ($title->getRestrictionTypes() as $restrictionType) {
$protectionLevel = implode(', ', $title->getRestrictions($restrictionType));
if ($protectionLevel == '') {
// Allow all users
$message = $this->msg('protect-default')->escaped();
} else {
// Administrators only
$message = $this->msg("protect-level-{$protectionLevel}");
if ($message->isDisabled()) {
// Require "$1" permission
$message = $this->msg("protect-fallback", $protectionLevel)->parse();
} else {
$message = $message->escaped();
}
}
$pageInfo['header-restrictions'][] = array($this->msg("restriction-{$restrictionType}"), $message);
}
if (!$this->page->exists()) {
return $pageInfo;
}
// Edit history
$pageInfo['header-edits'] = array();
$firstRev = $this->page->getOldestRevision();
// Page creator
$pageInfo['header-edits'][] = array($this->msg('pageinfo-firstuser'), Linker::revUserTools($firstRev));
// Date of page creation
$pageInfo['header-edits'][] = array($this->msg('pageinfo-firsttime'), Linker::linkKnown($title, $lang->userTimeAndDate($firstRev->getTimestamp(), $user), array(), array('oldid' => $firstRev->getId())));
// Latest editor
$pageInfo['header-edits'][] = array($this->msg('pageinfo-lastuser'), Linker::revUserTools($this->page->getRevision()));
// Date of latest edit
$pageInfo['header-edits'][] = array($this->msg('pageinfo-lasttime'), Linker::linkKnown($title, $lang->userTimeAndDate($this->page->getTimestamp(), $user), array(), array('oldid' => $this->page->getLatest())));
// Total number of edits
$pageInfo['header-edits'][] = array($this->msg('pageinfo-edits'), $lang->formatNum($pageCounts['edits']));
// Total number of distinct authors
$pageInfo['header-edits'][] = array($this->msg('pageinfo-authors'), $lang->formatNum($pageCounts['authors']));
// Recent number of edits (within past 30 days)
$pageInfo['header-edits'][] = array($this->msg('pageinfo-recent-edits', $lang->formatDuration($wgRCMaxAge)), $lang->formatNum($pageCounts['recent_edits']));
// Recent number of distinct authors
$pageInfo['header-edits'][] = array($this->msg('pageinfo-recent-authors'), $lang->formatNum($pageCounts['recent_authors']));
// Array of MagicWord objects
$magicWords = MagicWord::getDoubleUnderscoreArray();
// Array of magic word IDs
$wordIDs = $magicWords->names;
// Array of IDs => localized magic words
$localizedWords = $wgContLang->getMagicWords();
$listItems = array();
foreach ($pageProperties as $property => $value) {
if (in_array($property, $wordIDs)) {
$listItems[] = Html::element('li', array(), $localizedWords[$property][1]);
}
}
$localizedList = Html::rawElement('ul', array(), implode('', $listItems));
$hiddenCategories = $this->page->getHiddenCategories();
$transcludedTemplates = $title->getTemplateLinksFrom();
if (count($listItems) > 0 || count($hiddenCategories) > 0 || count($transcludedTemplates) > 0) {
// Page properties
$pageInfo['header-properties'] = array();
// Magic words
if (count($listItems) > 0) {
$pageInfo['header-properties'][] = array($this->msg('pageinfo-magic-words')->numParams(count($listItems)), $localizedList);
}
// Hidden categories
if (count($hiddenCategories) > 0) {
$pageInfo['header-properties'][] = array($this->msg('pageinfo-hidden-categories')->numParams(count($hiddenCategories)), Linker::formatHiddenCategories($hiddenCategories));
}
// Transcluded templates
if (count($transcludedTemplates) > 0) {
$pageInfo['header-properties'][] = array($this->msg('pageinfo-templates')->numParams(count($transcludedTemplates)), Linker::formatTemplates($transcludedTemplates));
}
}
return $pageInfo;
}
示例7: doDoubleUnderscore
public function doDoubleUnderscore($text)
{
wfProfileIn(__METHOD__);
$mwa = MagicWord::getDoubleUnderscoreArray();
$regexes = $mwa->getRegex();
foreach ($regexes as $regex) {
if ($regex === '') {
continue;
}
$text = preg_replace_callback($regex, 'RTEParser::doDoubleUnderscoreReplace', $text);
}
wfProfileOut(__METHOD__);
return $text;
}