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


PHP Title::getFragment方法代码示例

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


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

示例1: parseUserValue

 protected function parseUserValue($value)
 {
     global $wgContLang;
     // support inputs like " [[Test]] ";
     // note that this only works in pages if $smwgLinksInValues is set to true
     $value = ltrim(rtrim($value, ' ]'), ' [');
     // #1066, Manipulate the output only for when the value has no caption
     // assigned and only if a single :Foo is being present, ::Foo is not permitted
     if ($this->m_caption === false && isset($value[2]) && $value[0] === ':' && $value[1] !== ':') {
         $value = substr($value, 1);
     }
     if ($this->m_caption === false) {
         $this->m_caption = $value;
     }
     if ($value === '') {
         return $this->addErrorMsg(array('smw-datavalue-wikipage-empty'), Message::ESCAPED);
     }
     // #1701 If the DV is part of a Description and an approximate search
     // (e.g. ~foo* / ~Foo*) then use the value as-is and avoid being
     // transformed by the Title object
     // If the vaue contains a valid NS then use the Title to create a correct
     // instance to distinguish [[~Foo*]] from [[Help:~Foo*]]
     if ($this->getOptionBy(self::OPT_QUERY_COMP_CONTEXT)) {
         if (($title = Title::newFromText($value)) !== null && $title->getNamespace() !== NS_MAIN) {
             return $this->m_dataitem = SMWDIWikiPage::newFromTitle($title);
         } else {
             return $this->m_dataitem = new SMWDIWikiPage($value, NS_MAIN);
         }
     }
     if ($value[0] == '#') {
         if (is_null($this->m_contextPage)) {
             $this->addErrorMsg(array('smw-datavalue-wikipage-missing-fragment-context', $value));
             return;
         } else {
             $this->m_title = Title::makeTitle($this->m_contextPage->getNamespace(), $this->m_contextPage->getDBkey(), substr($value, 1), $this->m_contextPage->getInterwiki());
         }
     } else {
         $this->m_title = Title::newFromText($value, $this->m_fixNamespace);
     }
     /// TODO: Escape the text so users can see punctuation problems (bug 11666).
     if (is_null($this->m_title)) {
         $this->addErrorMsg(array('smw-datavalue-wikipage-invalid-title', $value));
     } elseif ($this->m_fixNamespace != NS_MAIN && $this->m_fixNamespace != $this->m_title->getNamespace()) {
         $this->addErrorMsg(array('smw_wrong_namespace', $wgContLang->getNsText($this->m_fixNamespace)));
     } else {
         $this->m_fragment = str_replace(' ', '_', $this->m_title->getFragment());
         $this->m_prefixedtext = '';
         $this->m_id = -1;
         // unset id
         $this->m_dataitem = SMWDIWikiPage::newFromTitle($this->m_title, $this->m_typeid);
     }
 }
开发者ID:jongfeli,项目名称:SemanticMediaWiki,代码行数:52,代码来源:SMW_DV_WikiPage.php

示例2: getInexpensiveTitleData

 /**
  * Extract inexpensive information from a Title object for return to Lua
  *
  * @param $title Title Title to return
  * @return array Lua data
  */
 private function getInexpensiveTitleData(Title $title)
 {
     $ns = $title->getNamespace();
     $ret = array('isLocal' => (bool) $title->isLocal(), 'interwiki' => $title->getInterwiki(), 'namespace' => $ns, 'nsText' => $title->getNsText(), 'text' => $title->getText(), 'fragment' => $title->getFragment(), 'thePartialUrl' => $title->getPartialURL());
     if ($ns === NS_SPECIAL) {
         // Core doesn't currently record special page links, but it may in the future.
         if ($this->getParser() && !$title->equals($this->getTitle())) {
             $this->getParser()->getOutput()->addLink($title);
         }
         $ret['exists'] = (bool) SpecialPageFactory::exists($title->getDBkey());
     }
     if ($ns !== NS_FILE && $ns !== NS_MEDIA) {
         $ret['file'] = false;
     }
     return $ret;
 }
开发者ID:sammykumar,项目名称:TheVRForums,代码行数:22,代码来源:TitleLibrary.php

示例3: parseUserValue

 protected function parseUserValue($value)
 {
     global $wgContLang;
     // support inputs like " [[Test]] ";
     // note that this only works in pages if $smwgLinksInValues is set to true
     $value = ltrim(rtrim($value, ' ]'), ' [');
     // #1066, Manipulate the output only for when the value has no caption
     // assigned and only if a single :Foo is being present, ::Foo is not permitted
     if ($this->m_caption === false && isset($value[2]) && $value[0] === ':' && $value[1] !== ':') {
         $value = substr($value, 1);
     }
     if ($this->m_caption === false) {
         $this->m_caption = $value;
     }
     if ($value !== '') {
         if ($value[0] == '#') {
             if (is_null($this->m_contextPage)) {
                 $this->addError(wfMessage('smw_notitle', $value)->inContentLanguage()->text());
                 return;
             } else {
                 $this->m_title = Title::makeTitle($this->m_contextPage->getNamespace(), $this->m_contextPage->getDBkey(), substr($value, 1), $this->m_contextPage->getInterwiki());
             }
         } else {
             $this->m_title = Title::newFromText($value, $this->m_fixNamespace);
         }
         /// TODO: Escape the text so users can see punctuation problems (bug 11666).
         if (is_null($this->m_title)) {
             $this->addError(wfMessage('smw_notitle', $value)->inContentLanguage()->text());
         } elseif ($this->m_fixNamespace != NS_MAIN && $this->m_fixNamespace != $this->m_title->getNamespace()) {
             $this->addError(wfMessage('smw_wrong_namespace', $wgContLang->getNsText($this->m_fixNamespace))->inContentLanguage()->text());
         } else {
             $this->m_fragment = str_replace(' ', '_', $this->m_title->getFragment());
             $this->m_prefixedtext = '';
             $this->m_id = -1;
             // unset id
             $this->m_dataitem = SMWDIWikiPage::newFromTitle($this->m_title, $this->m_typeid);
         }
     } else {
         $this->addError(wfMessage('smw_notitle', $value)->inContentLanguage()->text());
     }
 }
开发者ID:WolfgangFahl,项目名称:SemanticMediaWiki,代码行数:41,代码来源:SMW_DV_WikiPage.php

示例4: parseUserValue

 protected function parseUserValue($value)
 {
     global $wgContLang;
     // support inputs like " [[Test]] ";
     // note that this only works in pages if $smwgLinksInValues is set to true
     $value = ltrim(rtrim($value, ' ]'), ' [');
     if ($this->m_caption === false) {
         $this->m_caption = $value;
     }
     if ($value !== '') {
         if ($value[0] == '#') {
             if (is_null($this->m_contextPage)) {
                 $this->addError(wfMsgForContent('smw_notitle', $value));
                 return;
             } else {
                 $this->m_title = Title::makeTitle($this->m_contextPage->getNamespace(), $this->m_contextPage->getDBkey(), substr($value, 1), $this->m_contextPage->getInterwiki());
             }
         } else {
             $this->m_title = Title::newFromText($value, $this->m_fixNamespace);
         }
         /// TODO: Escape the text so users can see punctuation problems (bug 11666).
         if (is_null($this->m_title)) {
             $this->addError(wfMsgForContent('smw_notitle', $value));
         } elseif ($this->m_fixNamespace != NS_MAIN && $this->m_fixNamespace != $this->m_title->getNamespace()) {
             $this->addError(wfMsgForContent('smw_wrong_namespace', $wgContLang->getNsText($this->m_fixNamespace)));
         } else {
             $this->m_fragment = str_replace(' ', '_', $this->m_title->getFragment());
             $this->m_prefixedtext = '';
             $this->m_id = -1;
             // unset id
             $this->m_dataitem = SMWDIWikiPage::newFromTitle($this->m_title, $this->m_typeid);
         }
     } else {
         $this->addError(wfMsgForContent('smw_notitle', $value));
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:36,代码来源:SMW_DV_WikiPage.php

示例5: normaliseSpecialPage

 /**
  * @param $title Title
  * @return Title
  */
 static function normaliseSpecialPage(Title $title)
 {
     if ($title->getNamespace() == NS_SPECIAL) {
         list($name, $subpage) = SpecialPageFactory::resolveAlias($title->getDBkey());
         if (!$name) {
             return $title;
         }
         $ret = SpecialPage::getTitleFor($name, $subpage);
         $ret->mFragment = $title->getFragment();
         return $ret;
     } else {
         return $title;
     }
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:18,代码来源:Linker.php

示例6: insertRedirectEntry

 /**
  * Insert or update the redirect table entry for this page to indicate it redirects to $rt
  * @param Title $rt Redirect target
  * @param int|null $oldLatest Prior page_latest for check and set
  */
 public function insertRedirectEntry(Title $rt, $oldLatest = null)
 {
     $dbw = wfGetDB(DB_MASTER);
     $dbw->startAtomic(__METHOD__);
     if (!$oldLatest || $oldLatest == $this->lockAndGetLatest()) {
         $dbw->replace('redirect', ['rd_from'], ['rd_from' => $this->getId(), 'rd_namespace' => $rt->getNamespace(), 'rd_title' => $rt->getDBkey(), 'rd_fragment' => $rt->getFragment(), 'rd_interwiki' => $rt->getInterwiki()], __METHOD__);
     }
     $dbw->endAtomic(__METHOD__);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:14,代码来源:WikiPage.php

示例7: makeCommentLink

 /**
  * Generates a link to the given Title
  *
  * @note This is only public for technical reasons. It's not intended for use outside Linker.
  *
  * @param Title $title
  * @param string $text
  * @param string|null $wikiId Id of the wiki to link to (if not the local wiki),
  *  as used by WikiMap.
  * @param string|string[] $options See the $options parameter in Linker::link.
  *
  * @return string HTML link
  */
 public static function makeCommentLink(Title $title, $text, $wikiId = null, $options = array())
 {
     if ($wikiId !== null && !$title->isExternal()) {
         $link = Linker::makeExternalLink(WikiMap::getForeignURL($wikiId, $title->getPrefixedText(), $title->getFragment()), $text, false);
     } else {
         $link = Linker::link($title, $text, array(), array(), $options);
     }
     return $link;
 }
开发者ID:paladox,项目名称:2,代码行数:22,代码来源:Linker.php

示例8: insertRedirectEntry

 /**
  * Insert or update the redirect table entry for this page to indicate
  * it redirects to $rt .
  * @param Title $rt Redirect target
  */
 public function insertRedirectEntry($rt)
 {
     $dbw = wfGetDB(DB_MASTER);
     $dbw->replace('redirect', array('rd_from'), array('rd_from' => $this->getId(), 'rd_namespace' => $rt->getNamespace(), 'rd_title' => $rt->getDBkey(), 'rd_fragment' => $rt->getFragment(), 'rd_interwiki' => $rt->getInterwiki()), __METHOD__);
 }
开发者ID:Tanych,项目名称:mediawiki,代码行数:10,代码来源:WikiPage.php

示例9: newFromTitle

 /**
  * Create a data item from a MediaWiki Title.
  *
  * @param $title Title
  * @return SMWDIWikiPage
  */
 public static function newFromTitle(Title $title)
 {
     return new SMWDIWikiPage($title->getDBkey(), $title->getNamespace(), $title->getInterwiki(), str_replace(' ', '_', $title->getFragment()));
 }
开发者ID:yusufchang,项目名称:app,代码行数:10,代码来源:SMW_DI_WikiPage.php

示例10: normaliseSpecialPage

 /**
  * @param Title $title
  * @return Title
  */
 static function normaliseSpecialPage(Title $title)
 {
     if ($title->isSpecialPage()) {
         list($name, $subpage) = SpecialPageFactory::resolveAlias($title->getDBkey());
         if (!$name) {
             return $title;
         }
         $ret = SpecialPage::getTitleFor($name, $subpage, $title->getFragment());
         return $ret;
     } else {
         return $title;
     }
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:17,代码来源:Linker.php


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