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


PHP WikiPage::hasViewableContent方法代码示例

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


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

示例1: hasViewableContent

 /**
  * Don't return a 404 for categories in use.
  * In use defined as: either the actual page exists
  * or the category currently has members.
  */
 public function hasViewableContent()
 {
     if (parent::hasViewableContent()) {
         return true;
     } else {
         $cat = Category::newFromTitle($this->mTitle);
         // If any of these are not 0, then has members
         if ($cat->getPageCount() || $cat->getSubcatCount() || $cat->getFileCount()) {
             return true;
         }
     }
     return false;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:18,代码来源:WikiCategoryPage.php

示例2: showMissingArticle

 /**
  * Show the error text for a missing article. For articles in the MediaWiki
  * namespace, show the default message text. To be called from Article::view().
  */
 public function showMissingArticle()
 {
     global $wgSend404Code;
     $outputPage = $this->getContext()->getOutput();
     // Whether the page is a root user page of an existing user (but not a subpage)
     $validUserPage = false;
     # Show info in user (talk) namespace. Does the user exist? Is he blocked?
     if ($this->getTitle()->getNamespace() == NS_USER || $this->getTitle()->getNamespace() == NS_USER_TALK) {
         $parts = explode('/', $this->getTitle()->getText());
         $rootPart = $parts[0];
         $user = User::newFromName($rootPart, false);
         $ip = User::isIP($rootPart);
         if (!($user && $user->isLoggedIn()) && !$ip) {
             # User does not exist
             $outputPage->wrapWikiMsg("<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>", array('userpage-userdoesnotexist-view', wfEscapeWikiText($rootPart)));
         } elseif ($user->isBlocked()) {
             # Show log extract if the user is currently blocked
             LogEventsList::showLogExtract($outputPage, 'block', $user->getUserPage(), '', array('lim' => 1, 'showIfEmpty' => false, 'msgKey' => array('blocked-notice-logextract', $user->getName())));
             $validUserPage = !$this->getTitle()->isSubpage();
         } else {
             $validUserPage = !$this->getTitle()->isSubpage();
         }
     }
     wfRunHooks('ShowMissingArticle', array($this));
     # Show delete and move logs
     LogEventsList::showLogExtract($outputPage, array('delete', 'move'), $this->getTitle(), '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('moveddeleted-notice')));
     if (!$this->mPage->hasViewableContent() && $wgSend404Code && !$validUserPage) {
         // If there's no backing content, send a 404 Not Found
         // for better machine handling of broken links.
         $this->getContext()->getRequest()->response()->header("HTTP/1.1 404 Not Found");
     }
     $hookResult = wfRunHooks('BeforeDisplayNoArticleText', array($this));
     if (!$hookResult) {
         return;
     }
     # Show error message
     $oldid = $this->getOldID();
     if ($oldid) {
         $text = wfMessage('missing-revision', $oldid)->plain();
     } elseif ($this->getTitle()->getNamespace() === NS_MEDIAWIKI) {
         // Use the default message text
         $text = $this->getTitle()->getDefaultMessageText();
     } elseif ($this->getTitle()->quickUserCan('create', $this->getContext()->getUser()) && $this->getTitle()->quickUserCan('edit', $this->getContext()->getUser())) {
         $text = wfMessage('noarticletext')->plain();
     } else {
         $text = wfMessage('noarticletext-nopermission')->plain();
     }
     $text = "<div class='noarticletext'>\n{$text}\n</div>";
     $outputPage->addWikiText($text);
 }
开发者ID:mangowi,项目名称:mediawiki,代码行数:54,代码来源:Article.php

示例3: showMissingArticle

 /**
  * Show the error text for a missing article. For articles in the MediaWiki
  * namespace, show the default message text. To be called from Article::view().
  */
 public function showMissingArticle()
 {
     global $wgOut, $wgRequest, $wgUser;
     # Show info in user (talk) namespace. Does the user exist? Is he blocked?
     if ($this->getTitle()->getNamespace() == NS_USER || $this->getTitle()->getNamespace() == NS_USER_TALK) {
         $parts = explode('/', $this->getTitle()->getText());
         $rootPart = $parts[0];
         $user = User::newFromName($rootPart, false);
         $ip = User::isIP($rootPart);
         if (!$user->isLoggedIn() && !$ip) {
             # User does not exist
             $wgOut->wrapWikiMsg("<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>", array('userpage-userdoesnotexist-view', wfEscapeWikiText($rootPart)));
         } elseif ($user->isBlocked()) {
             # Show log extract if the user is currently blocked
             LogEventsList::showLogExtract($wgOut, 'block', $user->getUserPage()->getPrefixedText(), '', array('lim' => 1, 'showIfEmpty' => false, 'msgKey' => array('blocked-notice-logextract', $user->getName())));
         }
     }
     wfRunHooks('ShowMissingArticle', array($this));
     # Show delete and move logs
     LogEventsList::showLogExtract($wgOut, array('delete', 'move'), $this->getTitle()->getPrefixedText(), '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('moveddeleted-notice')));
     # Show error message
     $oldid = $this->getOldID();
     if ($oldid) {
         $text = wfMsgNoTrans('missing-article', $this->getTitle()->getPrefixedText(), wfMsgNoTrans('missingarticle-rev', $oldid));
     } elseif ($this->getTitle()->getNamespace() === NS_MEDIAWIKI) {
         // Use the default message text
         $text = $this->getTitle()->getDefaultMessageText();
     } else {
         $createErrors = $this->getTitle()->getUserPermissionsErrors('create', $wgUser);
         $editErrors = $this->getTitle()->getUserPermissionsErrors('edit', $wgUser);
         $errors = array_merge($createErrors, $editErrors);
         if (!count($errors)) {
             $text = wfMsgNoTrans('noarticletext');
         } else {
             $text = wfMsgNoTrans('noarticletext-nopermission');
         }
     }
     $text = "<div class='noarticletext'>\n{$text}\n</div>";
     if (!$this->mPage->hasViewableContent()) {
         // If there's no backing content, send a 404 Not Found
         // for better machine handling of broken links.
         $wgRequest->response()->header("HTTP/1.1 404 Not Found");
     }
     $wgOut->addWikiText($text);
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:49,代码来源:Article.php

示例4: testHasViewableContent

 /**
  * @dataProvider provideHasViewableContent
  * @covers WikiPage::hasViewableContent
  */
 public function testHasViewableContent($title, $viewable, $create = false)
 {
     $page = $this->newPage($title);
     $this->assertEquals($viewable, $page->hasViewableContent());
     if ($create) {
         $this->createPage($page, "some text", CONTENT_MODEL_WIKITEXT);
         $this->assertTrue($page->hasViewableContent());
         $page = new WikiPage($page->getTitle());
         $this->assertTrue($page->hasViewableContent());
     }
 }
开发者ID:Habatchii,项目名称:wikibase-for-mediawiki,代码行数:15,代码来源:WikiPageTest.php

示例5: showMissingArticle

 /**
  * Show the error text for a missing article. For articles in the MediaWiki
  * namespace, show the default message text. To be called from Article::view().
  */
 public function showMissingArticle()
 {
     global $wgSend404Code;
     $outputPage = $this->getContext()->getOutput();
     // Whether the page is a root user page of an existing user (but not a subpage)
     $validUserPage = false;
     # Show info in user (talk) namespace. Does the user exist? Is he blocked?
     if ($this->getTitle()->getNamespace() == NS_USER || $this->getTitle()->getNamespace() == NS_USER_TALK) {
         $parts = explode('/', $this->getTitle()->getText());
         $rootPart = $parts[0];
         $user = User::newFromName($rootPart, false);
         $ip = User::isIP($rootPart);
         if (!($user && $user->isLoggedIn()) && !$ip) {
             # User does not exist
             $outputPage->wrapWikiMsg("<div class=\"mw-userpage-userdoesnotexist error\">\n\$1\n</div>", array('userpage-userdoesnotexist-view', wfEscapeWikiText($rootPart)));
         } elseif ($user->isBlocked()) {
             # Show log extract if the user is currently blocked
             LogEventsList::showLogExtract($outputPage, 'block', $user->getUserPage(), '', array('lim' => 1, 'showIfEmpty' => false, 'msgKey' => array('blocked-notice-logextract', $user->getName())));
             $validUserPage = !$this->getTitle()->isSubpage();
         } else {
             $validUserPage = !$this->getTitle()->isSubpage();
         }
     }
     wfRunHooks('ShowMissingArticle', array($this));
     // Give extensions a chance to hide their (unrelated) log entries
     $logTypes = array('delete', 'move');
     $conds = array("log_action != 'revision'");
     wfRunHooks('Article::MissingArticleConditions', array(&$conds, $logTypes));
     # Show delete and move logs
     LogEventsList::showLogExtract($outputPage, $logTypes, $this->getTitle(), '', array('lim' => 10, 'conds' => $conds, 'showIfEmpty' => false, 'msgKey' => array('moveddeleted-notice')));
     if (!$this->mPage->hasViewableContent() && $wgSend404Code && !$validUserPage) {
         // If there's no backing content, send a 404 Not Found
         // for better machine handling of broken links.
         $this->getContext()->getRequest()->response()->header("HTTP/1.1 404 Not Found");
     }
     if ($validUserPage) {
         // Also apply the robot policy for nonexisting user pages (as those aren't served as 404)
         $policy = $this->getRobotPolicy('view');
         $outputPage->setIndexPolicy($policy['index']);
         $outputPage->setFollowPolicy($policy['follow']);
     }
     $hookResult = wfRunHooks('BeforeDisplayNoArticleText', array($this));
     if (!$hookResult) {
         return;
     }
     // WIKIHOW - Bebeth added this var to be used below for scustom messages
     $showHeader = false;
     # Show error message
     $oldid = $this->getOldID();
     if ($oldid) {
         $text = wfMessage('missing-revision', $oldid)->plain();
     } elseif ($this->getTitle()->getNamespace() === NS_MEDIAWIKI) {
         // Use the default message text
         $text = $this->getTitle()->getDefaultMessageText();
     } elseif ($this->getTitle()->quickUserCan('create', $this->getContext()->getUser()) && $this->getTitle()->quickUserCan('edit', $this->getContext()->getUser())) {
         // WIKIHOW - BEBETH changed inside this if condition for
         // custom messages and params needed for messages
         if ($this->mTitle->getNamespace() == NS_USER_TALK) {
             $text = wfMessage('noarticletext_user_talk', $this->getTitle()->getText(), $this->getTitle()->getFullURL() . "?action=edit")->plain();
             $showHeader = true;
         } else {
             if (MWNamespace::isTalk($this->mTitle->getNamespace())) {
                 $text = wfMessage('noarticletext_talk', $this->getTitle()->getText(), $this->getTitle()->getFullURL() . "?action=edit")->plain();
                 $showHeader = true;
             } else {
                 if ($this->mTitle->getNamespace() == NS_USER) {
                     $text = wfMessage('noarticletext_user', $this->getTitle()->getText(), $this->getTitle()->getFullURL() . "?action=edit")->plain();
                 } else {
                     if ($this->mTitle->getNamespace() == NS_USER_KUDOS) {
                         $text = wfMessage('noarticletext_user_kudos', $this->getTitle()->getText(), $this->getTitle()->getFullURL() . "?action=edit")->plain();
                     } else {
                         if ($this->mTitle->getNamespace() == NS_MAIN) {
                             $text = wfMessage('noarticletext', $this->getTitle()->getText(), $this->getTitle()->getFullURL() . "?action=edit", urlencode($this->getTitle()->getText()))->plain();
                             $showHeader = true;
                         } else {
                             $text = wfMessage('noarticletext_standard', $this->getTitle()->getText(), $this->getTitle()->getFullURL() . "?action=edit")->plain();
                         }
                     }
                 }
             }
         }
         // original lines that were commented out inside this block
         // $message = $this->getContext()->getUser()->isLoggedIn() ? 'noarticletext' : 'noarticletextanon';
         // $text = wfMessage( $message )->plain();
     } else {
         $text = wfMessage('noarticletext-nopermission')->plain();
     }
     $text = "<div class='noarticletext'>\n{$text}\n</div>";
     // WIKIHOW - BEBETH following 3 lines added for styling
     if ($showHeader) {
         $text = "<h2>" . wfMessage('noarticlefound')->text() . "</h2>{$text}";
     }
     $outputPage->addWikiText($text);
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:98,代码来源:Article.php


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