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


PHP Linker::makeSelfLinkObj方法代码示例

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


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

示例1: replaceInternalLinks2


//.........这里部分代码省略.........
             # Interwikis
             wfProfileIn(__METHOD__ . "-interwiki");
             if ($iw && $this->mOptions->getInterwikiMagic() && $nottalk && Language::fetchLanguageName($iw, null, 'mw')) {
                 // XXX: the above check prevents links to sites with identifiers that are not language codes
                 # Bug 24502: filter duplicates
                 if (!isset($this->mLangLinkLanguages[$iw])) {
                     $this->mLangLinkLanguages[$iw] = true;
                     $this->mOutput->addLanguageLink($nt->getFullText());
                 }
                 $s = rtrim($s . $prefix);
                 $s .= trim($trail, "\n") == '' ? '' : $prefix . $trail;
                 wfProfileOut(__METHOD__ . "-interwiki");
                 continue;
             }
             wfProfileOut(__METHOD__ . "-interwiki");
             if ($ns == NS_FILE) {
                 wfProfileIn(__METHOD__ . "-image");
                 if (!wfIsBadImage($nt->getDBkey(), $this->mTitle)) {
                     if ($wasblank) {
                         # if no parameters were passed, $text
                         # becomes something like "File:Foo.png",
                         # which we don't want to pass on to the
                         # image generator
                         $text = '';
                     } else {
                         # recursively parse links inside the image caption
                         # actually, this will parse them in any other parameters, too,
                         # but it might be hard to fix that, and it doesn't matter ATM
                         $text = $this->replaceExternalLinks($text);
                         $holders->merge($this->replaceInternalLinks2($text));
                     }
                     # cloak any absolute URLs inside the image markup, so replaceExternalLinks() won't touch them
                     $s .= $prefix . $this->armorLinks($this->makeImage($nt, $text, $holders)) . $trail;
                 } else {
                     $s .= $prefix . $trail;
                 }
                 wfProfileOut(__METHOD__ . "-image");
                 continue;
             }
             if ($ns == NS_CATEGORY) {
                 wfProfileIn(__METHOD__ . "-category");
                 $s = rtrim($s . "\n");
                 # bug 87
                 if ($wasblank) {
                     $sortkey = $this->getDefaultSort();
                 } else {
                     $sortkey = $text;
                 }
                 $sortkey = Sanitizer::decodeCharReferences($sortkey);
                 $sortkey = str_replace("\n", '', $sortkey);
                 $sortkey = $this->getConverterLanguage()->convertCategoryKey($sortkey);
                 $this->mOutput->addCategory($nt->getDBkey(), $sortkey);
                 /**
                  * Strip the whitespace Category links produce, see bug 87
                  */
                 $s .= trim($prefix . $trail, "\n") == '' ? '' : $prefix . $trail;
                 wfProfileOut(__METHOD__ . "-category");
                 continue;
             }
         }
         # Self-link checking. For some languages, variants of the title are checked in
         # LinkHolderArray::doVariants() to allow batching the existence checks necessary
         # for linking to a different variant.
         if ($ns != NS_SPECIAL && $nt->equals($this->mTitle) && !$nt->hasFragment()) {
             $s .= $prefix . Linker::makeSelfLinkObj($nt, $text, '', $trail);
             continue;
         }
         # NS_MEDIA is a pseudo-namespace for linking directly to a file
         # @todo FIXME: Should do batch file existence checks, see comment below
         if ($ns == NS_MEDIA) {
             wfProfileIn(__METHOD__ . "-media");
             # Give extensions a chance to select the file revision for us
             $options = array();
             $descQuery = false;
             wfRunHooks('BeforeParserFetchFileAndTitle', array($this, $nt, &$options, &$descQuery));
             # Fetch and register the file (file title may be different via hooks)
             list($file, $nt) = $this->fetchFileAndTitle($nt, $options);
             # Cloak with NOPARSE to avoid replacement in replaceExternalLinks
             $s .= $prefix . $this->armorLinks(Linker::makeMediaLinkFile($nt, $file, $text)) . $trail;
             wfProfileOut(__METHOD__ . "-media");
             continue;
         }
         wfProfileIn(__METHOD__ . "-always_known");
         # Some titles, such as valid special pages or files in foreign repos, should
         # be shown as bluelinks even though they're not included in the page table
         #
         # @todo FIXME: isAlwaysKnown() can be expensive for file links; we should really do
         # batch file existence checks for NS_FILE and NS_MEDIA
         if ($iw == '' && $nt->isAlwaysKnown()) {
             $this->mOutput->addLink($nt);
             $s .= $this->makeKnownLinkHolder($nt, $text, array(), $trail, $prefix);
         } else {
             # Links will be added to the output link list after checking
             $s .= $holders->makeHolder($nt, $text, array(), $trail, $prefix);
         }
         wfProfileOut(__METHOD__ . "-always_known");
     }
     wfProfileOut(__METHOD__);
     return $holders;
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:101,代码来源:Parser.php

示例2: makeSelfLinkObj

 public function makeSelfLinkObj($nt, $html = '', $query = '', $trail = '', $prefix = '')
 {
     return Linker::makeSelfLinkObj($nt, $html, $query, $trail, $prefix);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:4,代码来源:DummyLinker.php

示例3: replaceInternal

 /**
  * Replace internal links
  * @param string $text
  */
 protected function replaceInternal(&$text)
 {
     if (!$this->internals) {
         return;
     }
     global $wgContLang;
     $colours = [];
     $linkCache = LinkCache::singleton();
     $output = $this->parent->getOutput();
     $linkRenderer = $this->parent->getLinkRenderer();
     $threshold = $linkRenderer->getStubThreshold();
     $dbr = wfGetDB(DB_SLAVE);
     # Sort by namespace
     ksort($this->internals);
     $linkcolour_ids = [];
     # Generate query
     $lb = new LinkBatch();
     $lb->setCaller(__METHOD__);
     foreach ($this->internals as $ns => $entries) {
         foreach ($entries as $entry) {
             /** @var Title $title */
             $title = $entry['title'];
             $pdbk = $entry['pdbk'];
             # Skip invalid entries.
             # Result will be ugly, but prevents crash.
             if (is_null($title)) {
                 continue;
             }
             # Check if it's a static known link, e.g. interwiki
             if ($title->isAlwaysKnown()) {
                 $colours[$pdbk] = '';
             } elseif ($ns == NS_SPECIAL) {
                 $colours[$pdbk] = 'new';
             } else {
                 $id = $linkCache->getGoodLinkID($pdbk);
                 if ($id != 0) {
                     $colours[$pdbk] = Linker::getLinkColour($title, $threshold);
                     $output->addLink($title, $id);
                     $linkcolour_ids[$id] = $pdbk;
                 } elseif ($linkCache->isBadLink($pdbk)) {
                     $colours[$pdbk] = 'new';
                 } else {
                     # Not in the link cache, add it to the query
                     $lb->addObj($title);
                 }
             }
         }
     }
     if (!$lb->isEmpty()) {
         $fields = array_merge(LinkCache::getSelectFields(), ['page_namespace', 'page_title']);
         $res = $dbr->select('page', $fields, $lb->constructSet('page', $dbr), __METHOD__);
         # Fetch data and form into an associative array
         # non-existent = broken
         foreach ($res as $s) {
             $title = Title::makeTitle($s->page_namespace, $s->page_title);
             $pdbk = $title->getPrefixedDBkey();
             $linkCache->addGoodLinkObjFromRow($title, $s);
             $output->addLink($title, $s->page_id);
             $colours[$pdbk] = Linker::getLinkColour($title, $threshold);
             // add id to the extension todolist
             $linkcolour_ids[$s->page_id] = $pdbk;
         }
         unset($res);
     }
     if (count($linkcolour_ids)) {
         // pass an array of page_ids to an extension
         Hooks::run('GetLinkColours', [$linkcolour_ids, &$colours]);
     }
     # Do a second query for different language variants of links and categories
     if ($wgContLang->hasVariants()) {
         $this->doVariants($colours);
     }
     # Construct search and replace arrays
     $replacePairs = [];
     foreach ($this->internals as $ns => $entries) {
         foreach ($entries as $index => $entry) {
             $pdbk = $entry['pdbk'];
             $title = $entry['title'];
             $query = isset($entry['query']) ? $entry['query'] : [];
             $key = "{$ns}:{$index}";
             $searchkey = "<!--LINK {$key}-->";
             $displayText = $entry['text'];
             if (isset($entry['selflink'])) {
                 $replacePairs[$searchkey] = Linker::makeSelfLinkObj($title, $displayText, $query);
                 continue;
             }
             if ($displayText === '') {
                 $displayText = null;
             } else {
                 $displayText = new HtmlArmor($displayText);
             }
             if (!isset($colours[$pdbk])) {
                 $colours[$pdbk] = 'new';
             }
             $attribs = [];
             if ($colours[$pdbk] == 'new') {
//.........这里部分代码省略.........
开发者ID:claudinec,项目名称:galan-wiki,代码行数:101,代码来源:LinkHolderArray.php

示例4: replaceInternal

 /**
  * Replace internal links
  * @param string $text
  */
 protected function replaceInternal(&$text)
 {
     if (!$this->internals) {
         return;
     }
     global $wgContLang, $wgContentHandlerUseDB;
     $colours = array();
     $linkCache = LinkCache::singleton();
     $output = $this->parent->getOutput();
     $dbr = wfGetDB(DB_SLAVE);
     $threshold = $this->parent->getOptions()->getStubThreshold();
     # Sort by namespace
     ksort($this->internals);
     $linkcolour_ids = array();
     # Generate query
     $queries = array();
     foreach ($this->internals as $ns => $entries) {
         foreach ($entries as $entry) {
             /** @var Title $title */
             $title = $entry['title'];
             $pdbk = $entry['pdbk'];
             # Skip invalid entries.
             # Result will be ugly, but prevents crash.
             if (is_null($title)) {
                 continue;
             }
             # Check if it's a static known link, e.g. interwiki
             if ($title->isAlwaysKnown()) {
                 $colours[$pdbk] = '';
             } elseif ($ns == NS_SPECIAL) {
                 $colours[$pdbk] = 'new';
             } elseif (($id = $linkCache->getGoodLinkID($pdbk)) != 0) {
                 $colours[$pdbk] = Linker::getLinkColour($title, $threshold);
                 $output->addLink($title, $id);
                 $linkcolour_ids[$id] = $pdbk;
             } elseif ($linkCache->isBadLink($pdbk)) {
                 $colours[$pdbk] = 'new';
             } else {
                 # Not in the link cache, add it to the query
                 $queries[$ns][] = $title->getDBkey();
             }
         }
     }
     if ($queries) {
         $where = array();
         foreach ($queries as $ns => $pages) {
             $where[] = $dbr->makeList(array('page_namespace' => $ns, 'page_title' => array_unique($pages)), LIST_AND);
         }
         $fields = array('page_id', 'page_namespace', 'page_title', 'page_is_redirect', 'page_len', 'page_latest');
         if ($wgContentHandlerUseDB) {
             $fields[] = 'page_content_model';
         }
         $res = $dbr->select('page', $fields, $dbr->makeList($where, LIST_OR), __METHOD__);
         # Fetch data and form into an associative array
         # non-existent = broken
         foreach ($res as $s) {
             $title = Title::makeTitle($s->page_namespace, $s->page_title);
             $pdbk = $title->getPrefixedDBkey();
             $linkCache->addGoodLinkObjFromRow($title, $s);
             $output->addLink($title, $s->page_id);
             # @todo FIXME: Convoluted data flow
             # The redirect status and length is passed to getLinkColour via the LinkCache
             # Use formal parameters instead
             $colours[$pdbk] = Linker::getLinkColour($title, $threshold);
             // add id to the extension todolist
             $linkcolour_ids[$s->page_id] = $pdbk;
         }
         unset($res);
     }
     if (count($linkcolour_ids)) {
         // pass an array of page_ids to an extension
         Hooks::run('GetLinkColours', array($linkcolour_ids, &$colours));
     }
     # Do a second query for different language variants of links and categories
     if ($wgContLang->hasVariants()) {
         $this->doVariants($colours);
     }
     # Construct search and replace arrays
     $replacePairs = array();
     foreach ($this->internals as $ns => $entries) {
         foreach ($entries as $index => $entry) {
             $pdbk = $entry['pdbk'];
             $title = $entry['title'];
             $query = isset($entry['query']) ? $entry['query'] : array();
             $key = "{$ns}:{$index}";
             $searchkey = "<!--LINK {$key}-->";
             $displayText = $entry['text'];
             if (isset($entry['selflink'])) {
                 $replacePairs[$searchkey] = Linker::makeSelfLinkObj($title, $displayText, $query);
                 continue;
             }
             if ($displayText === '') {
                 $displayText = null;
             }
             if (!isset($colours[$pdbk])) {
                 $colours[$pdbk] = 'new';
//.........这里部分代码省略.........
开发者ID:ngertrudiz,项目名称:mediawiki,代码行数:101,代码来源:LinkHolderArray.php

示例5: replaceInternalLinks2


//.........这里部分代码省略.........
                     $dataIdx = RTEData::put('placeholder', array('type' => 'category', 'wikitextIdx' => $RTE_wikitextIdx));
                     $s .= $prefix . RTEMarker::generate(RTEMarker::PLACEHOLDER, $dataIdx) . $trail;
                 } else {
                     $s = rtrim($s . "\n");
                     # bug 87
                     if ($wasblank) {
                         $sortkey = $this->getDefaultSort();
                     } else {
                         $sortkey = $text;
                     }
                     $sortkey = Sanitizer::decodeCharReferences($sortkey);
                     $sortkey = str_replace("\n", '', $sortkey);
                     $sortkey = $this->getConverterLanguage()->convertCategoryKey($sortkey);
                     $this->mOutput->addCategory($nt->getDBkey(), $sortkey);
                     /**
                      * Strip the whitespace Category links produce, see bug 87
                      * @todo We might want to use trim($tmp, "\n") here.
                      */
                     $s .= trim($prefix . $trail, "\n") == '' ? '' : $prefix . $trail;
                 }
                 wfProfileOut(__METHOD__ . "-category");
                 continue;
             }
             /* Wikia change begin - @author: Owen Davis */
             /* Support for [[Poll:...]] */
             if (defined("NS_WIKIA_POLL") && $ns == NS_WIKIA_POLL) {
                 $poll = WikiaPoll::newFromTitle($nt);
                 if ($poll instanceof WikiaPoll) {
                     # RTE (Rich Text Editor) - begin
                     # @author: Owen Davis
                     if (!empty($wgRTEParserEnabled)) {
                         $s .= $prefix . WikiaPollHooks::generateRTE($poll, $nt, $RTE_wikitextIdx) . $trail;
                     } else {
                         $s .= $prefix . WikiaPollHooks::generate($poll, $nt) . $trail;
                     }
                     # RTE - end
                     continue;
                 }
             }
             /* Wikia change end */
         }
         # RTE (Rich Text Editor) - begin
         # @author: Inez Korczyński
         # No special handling for self-linking in RTE mode
         # Self-link checking
         if (empty($wgRTEParserEnabled) && $nt->getFragment() === '' && $ns != NS_SPECIAL) {
             if (in_array($nt->getPrefixedText(), $selflink, true)) {
                 $s .= $prefix . Linker::makeSelfLinkObj($nt, $text, '', $trail);
                 continue;
             }
         }
         # RTE - end
         # NS_MEDIA is a pseudo-namespace for linking directly to a file
         # @todo FIXME: Should do batch file existence checks, see comment below
         if ($ns == NS_MEDIA) {
             # RTE (Rich Text Editor) - begin
             # @author: macbre
             # BugId:1694 - handle [[Media:xxx]] as placeholders
             if (!empty($wgRTEParserEnabled)) {
                 $dataIdx = RTEData::put('placeholder', array('type' => 'media', 'wikitextIdx' => $RTE_wikitextIdx));
                 $s .= $prefix . RTEMarker::generate(RTEMarker::PLACEHOLDER, $dataIdx) . $trail;
                 continue;
             }
             # RTE - end
             wfProfileIn(__METHOD__ . "-media");
             # Give extensions a chance to select the file revision for us
             $options = array();
             $descQuery = false;
             wfRunHooks('BeforeParserFetchFileAndTitle', array($this, $nt, &$options, &$descQuery));
             # Fetch and register the file (file title may be different via hooks)
             list($file, $nt) = $this->fetchFileAndTitle($nt, $options);
             # Cloak with NOPARSE to avoid replacement in replaceExternalLinks
             $s .= $prefix . $this->armorLinks(Linker::makeMediaLinkFile($nt, $file, $text)) . $trail;
             wfProfileOut(__METHOD__ . "-media");
             continue;
         }
         wfProfileIn(__METHOD__ . "-always_known");
         # RTE (Rich Text Editor) - begin
         # @author: Inez Korczyński
         if (!empty($wgRTEParserEnabled)) {
             $text = RTEMarker::generate(RTEMarker::INTERNAL_DATA, RTEData::put('data', array('type' => 'internal', 'wikitextIdx' => $RTE_wikitextIdx, 'text' => $text, 'link' => $link, 'wasblank' => $wasblank, 'noforce' => $noforce))) . $text;
         }
         # RTE - end
         # Some titles, such as valid special pages or files in foreign repos, should
         # be shown as bluelinks even though they're not included in the page table
         #
         # @todo FIXME: isAlwaysKnown() can be expensive for file links; we should really do
         # batch file existence checks for NS_FILE and NS_MEDIA
         if ($iw == '' && $nt->isAlwaysKnown()) {
             $this->mOutput->addLink($nt);
             $s .= $this->makeKnownLinkHolder($nt, $text, array(), $trail, $prefix);
         } else {
             # Links will be added to the output link list after checking
             $s .= $holders->makeHolder($nt, $text, array(), $trail, $prefix);
         }
         wfProfileOut(__METHOD__ . "-always_known");
     }
     wfProfileOut(__METHOD__);
     return $holders;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:101,代码来源:Parser.php


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