* Marked WikiCategoryPage::hasViewableContent() as "public"
[lhc/web/wiklou.git] / includes / WikiCategoryPage.php
1 <?php
2 /**
3 * Special handling for category pages
4 */
5 class WikiCategoryPage extends WikiPage {
6 /**
7 * Constructor from a page id
8 * @param $id Int article ID to load
9 */
10 public static function newFromID( $id ) {
11 $t = Title::newFromID( $id );
12 # @todo FIXME: Doesn't inherit right
13 return $t == null ? null : new self( $t );
14 # return $t == null ? null : new static( $t ); // PHP 5.3
15 }
16
17 /**
18 * Don't return a 404 for categories in use.
19 * In use defined as: either the actual page exists
20 * or the category currently has members.
21 */
22 public function hasViewableContent() {
23 if ( parent::hasViewableContent() ) {
24 return true;
25 } else {
26 $cat = Category::newFromTitle( $this->mTitle );
27 // If any of these are not 0, then has members
28 if ( $cat->getPageCount()
29 || $cat->getSubcatCount()
30 || $cat->getFileCount()
31 ) {
32 return true;
33 }
34 }
35 return false;
36 }
37 }