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


PHP OutputPage::isArticle方法代码示例

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


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

示例1: onOutputPageBeforeHTML

 public function onOutputPageBeforeHTML(OutputPage &$out, &$text)
 {
     wfProfileIn(__METHOD__);
     if ($out->isArticle() && F::app()->wg->request->getVal('diff') === null && F::app()->wg->title->getNamespace() == NS_MAIN) {
         $text .= F::app()->sendRequest('RelatedVideos', 'getCarusel')->toString();
     }
     wfProfileOut(__METHOD__);
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:9,代码来源:RelatedVideos.hooks.php

示例2: SharedHelpHook

/**
 * @param OutputPage $out
 * @param $text
 * @return bool
 */
function SharedHelpHook(&$out, &$text)
{
    global $wgTitle, $wgMemc, $wgSharedDB, $wgCityId, $wgHelpWikiId, $wgContLang, $wgLanguageCode, $wgArticlePath;
    /* Insurance that hook will be called only once #BugId:  */
    static $wasCalled = false;
    if ($wasCalled == true) {
        return true;
    }
    $wasCalled = true;
    if (empty($wgHelpWikiId) || $wgCityId == $wgHelpWikiId) {
        # Do not proceed if we don't have a help wiki or are on it
        return true;
    }
    if (!$out->isArticle()) {
        # Do not process for pages other then articles
        return true;
    }
    wfProfileIn(__METHOD__);
    # Do not process if explicitly told not to
    $mw = MagicWord::get('MAG_NOSHAREDHELP');
    if ($mw->match($text) || strpos($text, NOSHAREDHELP_MARKER) !== false) {
        wfProfileOut(__METHOD__);
        return true;
    }
    if ($wgTitle->getNamespace() == NS_HELP) {
        # Initialize shared and local variables
        # Canonical namespace is added here in case we ever want to share other namespaces (e.g. Advice)
        $sharedArticleKey = $wgSharedDB . ':sharedArticles:' . $wgHelpWikiId . ':' . MWNamespace::getCanonicalName($wgTitle->getNamespace()) . ':' . $wgTitle->getDBkey() . ':' . SHAREDHELP_CACHE_VERSION;
        $sharedArticle = $wgMemc->get($sharedArticleKey);
        $sharedServer = WikiFactory::getVarValueByName('wgServer', $wgHelpWikiId);
        $sharedScript = WikiFactory::getVarValueByName('wgScript', $wgHelpWikiId);
        $sharedArticlePath = WikiFactory::getVarValueByName('wgArticlePath', $wgHelpWikiId);
        // get defaults
        // in case anybody's curious: no, we can't use $wgScript cause that may be overridden locally :/
        // @TODO pull this from somewhere instead of hardcoding
        if (empty($sharedArticlePath)) {
            $sharedArticlePath = '/wiki/$1';
        }
        if (empty($sharedScript)) {
            $sharedScript = '/index.php';
        }
        $sharedArticlePathClean = str_replace('$1', '', $sharedArticlePath);
        $localArticlePathClean = str_replace('$1', '', $wgArticlePath);
        # Try to get content from memcache
        if (!empty($sharedArticle['timestamp'])) {
            if (wfTimestamp() - (int) $sharedArticle['timestamp'] < 600) {
                if (isset($sharedArticle['exists']) && $sharedArticle['exists'] == 0) {
                    wfProfileOut(__METHOD__);
                    return true;
                } else {
                    if (!empty($sharedArticle['cachekey'])) {
                        wfDebug("SharedHelp: trying parser cache {$sharedArticle['cachekey']}\n");
                        $key1 = str_replace('-1!', '-0!', $sharedArticle['cachekey']);
                        $key2 = str_replace('-0!', '-1!', $sharedArticle['cachekey']);
                        $parser = $wgMemc->get($key1);
                        if (!empty($parser) && is_object($parser)) {
                            $content = $parser->mText;
                        } else {
                            $parser = $wgMemc->get($key2);
                            if (!empty($parser) && is_object($parser)) {
                                $content = $parser->mText;
                            }
                        }
                    }
                }
            }
        }
        # If getting content from memcache failed (invalidate) then just download it via HTTP
        if (empty($content)) {
            $urlTemplate = $sharedServer . $sharedScript . "?title=Help:%s&action=render";
            $articleUrl = sprintf($urlTemplate, urlencode($wgTitle->getDBkey()));
            list($content, $c) = SharedHttp::get($articleUrl);
            # if we had redirect, then store it somewhere
            if (curl_getinfo($c, CURLINFO_HTTP_CODE) == 301) {
                if (preg_match("/^Location: ([^\n]+)/m", $content, $dest_url)) {
                    $destinationUrl = $dest_url[1];
                }
            }
            global $wgServer, $wgArticlePath, $wgRequest, $wgTitle;
            $helpNs = $wgContLang->getNsText(NS_HELP);
            $sk = RequestContext::getMain()->getSkin();
            if (!empty($_SESSION['SH_redirected'])) {
                $from_link = Title::newfromText($helpNs . ":" . $_SESSION['SH_redirected']);
                $redir = $sk->makeKnownLinkObj($from_link, '', 'redirect=no', '', '', 'rel="nofollow"');
                $s = wfMsg('redirectedfrom', $redir);
                $out->setSubtitle($s);
                $_SESSION['SH_redirected'] = '';
            }
            if (isset($destinationUrl)) {
                $destinationPageIndex = strpos($destinationUrl, "{$helpNs}:");
                # if $helpNs was not found, assume we're on help.wikia.com and try again
                if ($destinationPageIndex === false) {
                    $destinationPageIndex = strpos($destinationUrl, MWNamespace::getCanonicalName(NS_HELP) . ":");
                }
                $destinationPage = substr($destinationUrl, $destinationPageIndex);
//.........这里部分代码省略.........
开发者ID:schwarer2006,项目名称:wikia,代码行数:101,代码来源:SharedHelp.php

示例3: replaceSubtitle

 public static function replaceSubtitle(&$subpages, $skin = null, OutputPage $out)
 {
     if (!TranslatablePage::isTranslationPage($out->getTitle()) && !TranslatablePage::isSourcePage($out->getTitle())) {
         return true;
     }
     // Copied from Skin::subPageSubtitle()
     if ($out->isArticle() && MWNamespace::hasSubpages($out->getTitle()->getNamespace())) {
         $ptext = $out->getTitle()->getPrefixedText();
         if (preg_match('/\\//', $ptext)) {
             $links = explode('/', $ptext);
             array_pop($links);
             // Also pop of one extra for language code is needed
             if (TranslatablePage::isTranslationPage($out->getTitle())) {
                 array_pop($links);
             }
             $c = 0;
             $growinglink = '';
             $display = '';
             foreach ($links as $link) {
                 $growinglink .= $link;
                 $display .= $link;
                 $linkObj = Title::newFromText($growinglink);
                 if (is_object($linkObj) && $linkObj->exists()) {
                     $getlink = Linker::linkKnown(SpecialPage::getTitleFor('MyLanguage', $growinglink), htmlspecialchars($display));
                     $c++;
                     if ($c > 1) {
                         $subpages .= wfMessage('pipe-separator')->plain();
                     } else {
                         // This one is stupid imho, doesn't work with chihuahua
                         // $subpages .= '&lt; ';
                     }
                     $subpages .= $getlink;
                     $display = '';
                 } else {
                     $display .= '/';
                 }
                 $growinglink .= '/';
             }
         }
         return false;
     }
     return true;
 }
开发者ID:HuijiWiki,项目名称:mediawiki-extensions-Translate,代码行数:43,代码来源:PageTranslationHooks.php

示例4: onOutputPageBeforeHTML

 public static function onOutputPageBeforeHTML(OutputPage $out, &$text)
 {
     global $wgRequest;
     if ($out->isArticle() && $wgRequest->getVal('diff') === null && !F::app()->checkSkin('wikiamobile')) {
         $text .= F::app()->renderView('RelatedPages', 'Index');
     }
     return true;
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:8,代码来源:RelatedPages.class.php

示例5: onOutputPageBeforeHTML

 /**
  * Display Related Discussion (Forum posts) in bottom of article
  * @param OutputPage $out
  * @param string $text article HTML
  * @return bool: true because it is a hook
  */
 public static function onOutputPageBeforeHTML(OutputPage $out, &$text)
 {
     $app = F::app();
     $title = $out->getTitle();
     if ($out->isArticle() && $title->exists() && $title->getNamespace() == NS_MAIN && !Wikia::isMainPage() && $out->getRequest()->getVal('diff') === null && $out->getRequest()->getVal('action') !== 'render' && !$app->checkSkin('wikiamobile', $out->getSkin())) {
         // VOLDEV-46: Omit zero-state, only render if there are related forum threads
         $messages = RelatedForumDiscussionController::getData($title->getArticleId());
         unset($messages['lastupdate']);
         if (!empty($messages)) {
             $text .= $app->renderView('RelatedForumDiscussionController', 'index', array('messages' => $messages));
         }
     }
     return true;
 }
开发者ID:yusufchang,项目名称:app,代码行数:20,代码来源:ForumHooksHelper.class.php

示例6: onOutputPageBeforeHTML

 /**
  * @param OutputPage $out
  * @param            $text
  *
  * Add needed messages to page and add JS assets
  *
  * @return bool
  */
 public static function onOutputPageBeforeHTML(OutputPage $out, &$text)
 {
     $app = F::app();
     $wg = $app->wg;
     $request = $app->wg->Request;
     $title = $wg->Title;
     $am = AssetsManager::getInstance();
     $relatedPagesGroupName = 'relatedpages_js';
     if ($out->isArticle() && $request->getVal('action', 'view') == 'view') {
         JSMessages::enqueuePackage('RelatedPages', JSMessages::INLINE);
         if (!(Wikia::isMainPage() || !empty($title) && !in_array($title->getNamespace(), $wg->ContentNamespaces)) && !$app->checkSkin('wikiamobile') && $am->checkIfGroupForSkin($relatedPagesGroupName, $out->getSkin())) {
             if ($app->checkSkin('oasis')) {
                 OasisController::addSkinAssetGroup($relatedPagesGroupName);
             } else {
                 $scripts = $am->getURL($relatedPagesGroupName);
                 foreach ($scripts as $script) {
                     $wg->Out->addScript("<script src='{$script}'></script>");
                 }
             }
         }
     }
     return true;
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:31,代码来源:RelatedPages.class.php


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