Jump to content

Wikia code/includes/CategoryPage.php

From mediawiki.org
--- D:\Programming\SVN\mediawiki\branches\REL1_16\phase3\includes\CategoryPage.php	2011-07-18 22:31:27.982421900 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\CategoryPage.php	2011-08-17 15:28:46.344726600 +0100
@@ -96,7 +96,8 @@
 
 		$r = $this->getSubcategorySection() .
 			$this->getPagesSection() .
-			$this->getImageSection();
+			$this->getImageSection() .
+			$this->getOtherSection();
 
 		if ( $r == '' ) {
 			// If there is no category content to display, only
@@ -203,6 +204,11 @@
 	 */
 	function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) {
 		global $wgContLang;
+
+		/*Wikia changes start*/
+		wfRunHooks('CategoryPage::AddPage', array(&$this, &$title, &$titletext, &$sortkey));
+		/*Wikia changes end*/
+
 		$this->articles[] = $isRedirect
 			? '<span class="redirect-in-category">' .
 				$this->getSkin()->link(
@@ -238,11 +244,17 @@
 			$this->flip = false;
 		}
 
+		$userCon = '1 = 1';
+		/* Wikia change begin - @author: TomekO */
+		/* Category Galleries hook */
+		wfRunHooks('CategoryPage::beforeCategoryData',array(&$userCon));
+		/* Wikia change end */
+
 		$res = $dbr->select(
 			array( 'page', 'categorylinks', 'category' ),
 			array( 'page_title', 'page_namespace', 'page_len', 'page_is_redirect', 'cl_sortkey',
 				'cat_id', 'cat_title', 'cat_subcats', 'cat_pages', 'cat_files' ),
-			array( $pageCondition, 'cl_to' => $this->title->getDBkey() ),
+			array( $userCon, $pageCondition, 'cl_to' => $this->title->getDBkey() ),
 			__METHOD__,
 			array( 'ORDER BY' => $this->flip ? 'cl_sortkey DESC' : 'cl_sortkey',
 				'USE INDEX' => array( 'categorylinks' => 'cl_sortkey' ),
@@ -270,13 +282,26 @@
 			} elseif ( $this->showGallery && $title->getNamespace() == NS_FILE ) {
 				$this->addImage( $title, $x->cl_sortkey, $x->page_len, $x->page_is_redirect );
 			} else {
+				if( wfRunHooks( "CategoryViewer::addPage", array( &$this, &$title, &$x ) ) ) {
 				$this->addPage( $title, $x->cl_sortkey, $x->page_len, $x->page_is_redirect );
 			}
 		}
 	}
+	}
 
 	function getCategoryTop() {
-		$r = $this->getCategoryBottom();
+		$r = '';
+
+		/* Wikia change begin - @author: wladek */
+		/* Category Galleries hook */
+		wfRunHooks('CategoryPage::getCategoryTop',array($this,&$r));
+		/* Wikia change end */
+
+		if( $this->until != '' ) {
+			$r .= $this->pagingLinks( $this->title, $this->nextPage, $this->until, $this->limit );
+		} elseif( $this->nextPage != '' || $this->from != '' ) {
+			$r .= $this->pagingLinks( $this->title, $this->from, $this->nextPage, $this->limit );
+		}
 		return $r === ''
 			? $r
 			: "<br style=\"clear:both;\"/>\n" . $r;
@@ -338,6 +363,12 @@
 		}
 	}
 
+	function getOtherSection() {
+		$r = "";
+		wfRunHooks( "CategoryViewer::getOtherSection", array( &$this, &$r ) );
+		return $r;
+	}
+
 	function getCategoryBottom() {
 		if ( $this->until != '' ) {
 			return $this->pagingLinks( $this->title, $this->nextPage, $this->until, $this->limit );
@@ -491,7 +522,7 @@
 			);
 		}
 
-		return "($prevLink) ($nextLink)";
+		return "<div class=\"pagingLinks\"><span class=\"prevLink\">($prevLink)</span> <span class=\"nextLink\">($nextLink)</span></div>";
 	}
 
 	/**
@@ -547,4 +578,17 @@
 			$wgLang->formatNum( $totalcnt )
 		);
 	}
+
+	/**
+	 * getter for private $cat variable, used in Hooks
+	 *
+	 * @author Krzysztof Krzy┼╝aniak <eloy@wikia-inc.com>
+	 * @public
+	 *
+	 * @return Category $cat
+	 */
+	public function getCat() {
+		return $this->cat;
+	}
+
 }