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


PHP Title::isKnown方法代码示例

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


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

示例1: redirectDuplicate

 /**
  * If requested title doesn't exist, redirect to duplicate title (same name but different case) if exists.
  * NOTE: As of MediaWiki 1.18.0, $article is NULL 
  * @param Title $title
  * @param type $article
  * @param type $output
  * @param type $user
  * @param type $request
  * @param type $mediaWiki
  * @return boolean 
  */
 public static function redirectDuplicate(&$title, $article, &$output, &$user, $request, $mediaWiki)
 {
     if ($title->getNamespace() != NS_SPECIAL && !$title->isKnown() && ($duplicate = TitleKey::exactMatchTitle($title))) {
         wfDebugLog('preventduplicate', "{$title->getPrefixedDBkey()} asked, doesn't exist, suggest to use {$duplicate->getPrefixedDBkey()} instead");
         $title = $duplicate;
     }
     return true;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:19,代码来源:PreventDuplicate.hooks.php

示例2: getTargetURL

 private function getTargetURL(Title $title)
 {
     global $wgCreatePageEditExisting, $wgCreatePageUseVisualEditor;
     $isKnown = $title->isKnown();
     $query = array();
     if (!$isKnown || $wgCreatePageEditExisting) {
         # Preload is not yet supported by VisualEditor, but probably will be eventually.
         # See https://phabricator.wikimedia.org/T51622
         $query['preload'] = $this->getRequest()->getText('preload', '');
         if (!$isKnown) {
             $query['redlink'] = '1';
         }
         if ($wgCreatePageUseVisualEditor) {
             $query['veaction'] = 'edit';
         } else {
             $query['action'] = 'edit';
         }
     }
     return $title->getLocalUrl($query);
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:20,代码来源:SpecialCreatePageRedirect.php

示例3: hasViewableContent

 /**
  * Check if this page is something we're going to be showing
  * some sort of sensible content for. If we return false, page
  * views (plain action=view) will return an HTTP 404 response,
  * so spiders and robots can know they're following a bad link.
  *
  * @return bool
  */
 public function hasViewableContent()
 {
     return $this->mTitle->isKnown();
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:12,代码来源:WikiPage.php

示例4: tabAction

 /**
  * Builds an array with tab definition
  *
  * @param Title $title Page Where the tab links to
  * @param string|array $message Message key or an array of message keys (will fall back)
  * @param bool $selected Display the tab as selected
  * @param string $query Query string attached to tab URL
  * @param bool $checkEdit Check if $title exists and mark with .new if one doesn't
  *
  * @return array
  */
 function tabAction($title, $message, $selected, $query = '', $checkEdit = false)
 {
     $classes = array();
     if ($selected) {
         $classes[] = 'selected';
     }
     if ($checkEdit && !$title->isKnown()) {
         $classes[] = 'new';
         if ($query !== '') {
             $query = 'action=edit&redlink=1&' . $query;
         } else {
             $query = 'action=edit&redlink=1';
         }
     }
     // wfMessageFallback will nicely accept $message as an array of fallbacks
     // or just a single key
     $msg = wfMessageFallback($message)->setContext($this->getContext());
     if (is_array($message)) {
         // for hook compatibility just keep the last message name
         $message = end($message);
     }
     if ($msg->exists()) {
         $text = $msg->text();
     } else {
         global $wgContLang;
         $text = $wgContLang->getConverter()->convertNamespace(MWNamespace::getSubject($title->getNamespace()));
     }
     $result = array();
     if (!Hooks::run('SkinTemplateTabAction', array(&$this, $title, $message, $selected, $checkEdit, &$classes, &$query, &$text, &$result))) {
         return $result;
     }
     return array('class' => implode(' ', $classes), 'text' => $text, 'href' => $title->getLocalURL($query), 'primary' => true);
 }
开发者ID:eliagbayani,项目名称:LiteratureEditor,代码行数:44,代码来源:SkinTemplate.php

示例5: existenceCheck

 /**
  * Does the Title currently exists
  *
  * This method allows a subclass to override this check
  * (For example, wantedfiles, would want to check if the file exists
  * not just that a page in the file namespace exists).
  *
  * This will only control if the link is crossed out. Whether or not the link
  * is blue vs red is controlled by if the title exists.
  *
  * @note This will only be run if the page is cached (ie $wgMiserMode = true)
  *   unless forceExistenceCheck() is true.
  * @since 1.24
  * @return bool
  */
 protected function existenceCheck(Title $title)
 {
     return $title->isKnown();
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:19,代码来源:WantedQueryPage.php

示例6: onLinkBegin

 /**
  * Hook handler for LinkBegin
  * @param Linker $oLinker
  * @param Title $oTarget
  * @param string $sHtml
  * @param array $aCustomAttribs
  * @param array $aQuery
  * @param array $aOptions
  * @param string $sRet
  * @return boolean Always true to keep hook running
  */
 public function onLinkBegin($oLinker, $oTarget, &$sHtml, &$aCustomAttribs, &$aQuery, &$aOptions, &$sRet)
 {
     if (in_array('known', $aOptions)) {
         return true;
     }
     if (!in_array('broken', $aOptions)) {
         //It's not marked as "known" and not as "broken" so we have to check
         if ($oTarget->isKnown()) {
             return true;
         }
     }
     $aExNs = BsConfig::get('MW::PageTemplates::ExcludeNs');
     if (in_array($oTarget->getNamespace(), $aExNs)) {
         return true;
     }
     if (!isset($aQuery['preload'])) {
         $aQuery['action'] = 'view';
     }
     return true;
 }
开发者ID:hfroese,项目名称:mediawiki-extensions-BlueSpiceExtensions,代码行数:31,代码来源:PageTemplates.class.php

示例7: isTitleValidForBackground

 /**
  * 
  * @param Title $title
  */
 public static function isTitleValidForBackground($title)
 {
     return $title instanceof Title && $title->isKnown() && $title->isLocal() && $title->getNamespace() == NS_FILE && ($file = wfLocalFile($title)) != null && $file->exists() && self::isExtensionValidForBackground($file->getExtension());
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:8,代码来源:WpWikiplace.php

示例8: isOwner

 /**
  * If the page is in a Wikiplace namespace, search the owner and answer.
  * If the page is in a Wikiplace namespace but cannot be found, state only 
  * 
  * admins users are owner
  * @todo should not be a hook. Should be...
  * WpWikiPlaces->hasOwner($user)
  * and called by getUserPermissionError()
  * 
  * @param Title $title
  * @param User $user
  * @param boolean
  */
 public static function isOwner($title, $user, &$result)
 {
     $namespace = $title->getNamespace();
     $db_key = $title->getDBkey();
     if (WpPage::isPublic($namespace, $db_key) || !WpPage::isInWikiplaceNamespaces($namespace) || !$title->isKnown() || WpPage::isAdmin($namespace, $db_key)) {
         return true;
         // skip
     }
     $article_id = $title->getArticleID();
     $user_id = $user->getId();
     $result = WpPage::isOwner($article_id, $user);
     wfDebugLog('wikiplaces-debug', "{$user->getName()}({$user_id}) is" . ($result ? '' : ' not') . " owner of {$title->getPrefixedDBkey()}({$article_id})");
     return false;
     // stop hook processing, because we have the answer
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:28,代码来源:Wikiplaces.hooks.php

示例9: poUserCan

/**
 * Grant rights as needed later by $title->checkPagesRestriction(). Hook userCan is always called
 * in function $title->checkPermissionHooks(), before calling checkPagesRestriction(). So, it ensures
 * that correct rights are available when checkPagesRestriction() will be executed.
 * @global array $wgProtectOwnCacheUserCan
 * @param Title $title
 * @param User $user
 * @param string $action
 * @param boolean $result
 * @return boolean 
 */
function poUserCan($title, &$user, $action, &$result)
{
    if ($title->getNamespace() == NS_SPECIAL || !$title->isKnown()) {
        return true;
        // skip
    }
    // userCan is called before title->checkPageRestrictions
    $act = $action;
    //just in case, but shouldn't occur
    if ($action == '' || $action == 'view') {
        $act = 'read';
    }
    // update user right about the current title, especially the owner and member rights
    // (not pretty, but needed because this is the way MW core checks protection...)
    poGrantProtectionRights($title, $user);
    // fetch restriction and user groups from MediaWiki core
    $title_restrictions = $title->getRestrictions($act);
    // if no restrictions, return "the $user can do $action on $title"
    if ($title_restrictions === array()) {
        wfDebugLog('ProtectOwn', 'UserCan: action not restricted, resume other hooks' . ' title="' . $title->getPrefixedDBkey() . '"[' . $title->getArticleId() . ']' . ' isKnown()=' . ($title->isKnown() ? 'YES' : 'NO') . ' user="' . $user->getName() . '"[' . $user->getID() . ']' . ' action="' . $action . '"');
        return true;
        // continue userCan hooks processing (another hook can still disallow user)
    }
    //check if cached
    global $wgProtectOwnCacheUserCan;
    if (isset($wgProtectOwnCacheUserCan[$user->getID()][$title->getArticleId()][$act])) {
        $result = $wgProtectOwnCacheUserCan[$user->getID()][$title->getArticleId()][$act];
        /* 		wfDebugLog( 'ProtectOwn', 'UserCan: '.($result?'YES':'NO').', CACHE HIT '
              .' title="'.$title->getPrefixedDBkey().'"['.$title->getArticleId().']'
              .' isKnown()='.($title->isKnown()?'YES':'NO')
              .' user="'.$user->getName().'"['.$user->getID().']'
              .' action="'.$action.'"'
              );
             */
        return false;
        //stop processing
    }
    // there should only be one restriction level per page/action
    // (in MediaWiki core, if multiple levels, user has to be in every restricted level... not very logic, but it's like that)
    // if not... well, we handle this the same way as in MediaWiki core, but that's bad!
    if (count($title_restrictions) != 1) {
        wfDebugLog('ProtectOwn', 'UserCan: /!\\ few restricted level for only a page/action ' . '("' . $act . '" restricted to "' . implode(',', $title_restrictions) . '")');
        wfDebug('Restrictions.extension>>UserCan(): /!\\ few restricted level for only a page/action ' . '("' . $act . '" restricted to "' . implode(',', $title_restrictions) . '")');
    }
    // please kick this foreach or change Title.php>checkPageRestrictions() code... we should not test intersection !!!
    $result = true;
    foreach ($title_restrictions as $title_restriction) {
        // intersection test = if we know that user is not allowed for one, do not test other restrictions
        if (!$result) {
            break;
        }
        // exit foreach
        if ($title_restriction == 'owner') {
            // check if the current user is the owner
            $result = poIsOwner($title, $user);
        } elseif ($title_restriction == 'member') {
            // check if the current user is a member
            $result = poIsMember($title, $user) || poIsOwner($title, $user);
        } else {
            // allow if $user is member of the group
            $result = poIsUserInGroup($user, $title_restriction);
        }
    }
    // if the user has a bypass, she is allowed
    if ($user->isAllowed(PROTECTOWN_BYPASS)) {
        wfDebugLog('ProtectOwn', 'UserCan: YES, user has "' . PROTECTOWN_BYPASS . '" right');
        $result = true;
        // allowed
    }
    // store to cache
    $wgProtectOwnCacheUserCan[$user->getID()][$title->getArticleId()][$act] = $result;
    wfDebugLog('ProtectOwn', 'UserCan: ' . ($result ? 'YES' : 'NO') . ', CACHE MISS ' . ' title="' . $title->getPrefixedDBkey() . '"[' . $title->getArticleId() . ']' . ' isKnown()=' . ($title->isKnown() ? 'YES' : 'NO') . ' user="' . $user->getName() . '"[' . $user->getID() . ']' . ' action="' . $action . '"' . ' restrictions="' . implode(',', $title_restrictions) . '"');
    // stop processing
    return false;
}
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:86,代码来源:ProtectOwn.php


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