. * * @file * @ingroup Skins */ namespace Skins\Chameleon\Components; use Action; use MWNamespace; use Skins\Chameleon\ChameleonTemplate; use Skins\Chameleon\IdRegistry; /** * The PageTools class. * * A unordered list containing content navigation links (Page, Discussion, * Edit, History, Move, ...) * * The tab list is a list of lists: ''; } return $ret; } /** * @return mixed */ public function &getPageToolsStructure() { if ( $this->mPageToolsStructure === null ) { $this->mPageToolsStructure = $this->getSkinTemplate()->get( 'content_navigation' , null ); } return $this->mPageToolsStructure; } /** * @return bool */ protected function hideSelectedNamespace() { return $this->getDomElement() !== null && filter_var( $this->getDomElement()->getAttribute( 'hideSelectedNameSpace' ), FILTER_VALIDATE_BOOLEAN ) && Action::getActionName( $this->getSkin() ) === 'view'; } /** * Generate strings used for xml 'id' names in tabs * * Stolen from MW's Title::getNamespaceKey() * * Difference: This function here reports the actual namespace while the * one in Title reports the subject namespace, i.e. no talk namespaces * * @return string */ public function getNamespaceKey() { global $wgContLang; // Gets the subject namespace if this title $namespace = $this->getSkinTemplate()->getSkin()->getTitle()->getNamespace(); // Checks if canonical namespace name exists for namespace if ( MWNamespace::exists( $this->getSkinTemplate()->getSkin()->getTitle()->getNamespace() ) ) { // Uses canonical namespace name $namespaceKey = MWNamespace::getCanonicalName( $namespace ); } else { // Uses text of namespace $namespaceKey = $this->getSkinTemplate()->getSkin()->getTitle()->getNsText(); } // Makes namespace key lowercase $namespaceKey = $wgContLang->lc( $namespaceKey ); // Uses main if ( $namespaceKey == '' ) { $namespaceKey = 'main'; } // Changes file to image for backwards compatibility if ( $namespaceKey == 'file' ) { $namespaceKey = 'image'; } return $namespaceKey; } /** * @param string $category * @param mixed[][] $tabsDescription * * @return string */ protected function buildTabGroup( $category, $tabsDescription ) { // TODO: visually group all links of one category (e.g. some space between categories) if ( empty( $tabsDescription ) ) { return ''; } $ret = $this->indent() . ''; if ( !$this->mFlat ) { $ret .= $this->buildTabGroupOpeningTags( $category ); } foreach ( $tabsDescription as $key => $tabDescription ) { $ret .= $this->buildTab( $tabDescription, $key ); } if ( !$this->mFlat ) { $ret .= $this->buildTabGroupClosingTags(); } return $ret; } /** * @param string $category * * @return string */ protected function buildTabGroupOpeningTags( $category ) { // output the name of the current category (e.g. 'namespaces', 'views', ...) $ret = $this->indent() . \Html::openElement( 'li', array( 'id' => IdRegistry::getRegistry()->getId( 'p-' . $category ) ) ) . $this->indent( 1 ) . '' . $this->indent( -1 ) . ''; } /** * Set the page tool menu to have submenus or not * * @param boolean $flat */ public function setFlat( $flat ) { $this->mFlat = $flat; } /** * Set the page tool menu to have submenus or not * * @param string|string[] $tools */ public function setRedundant( $tools ) { if ( is_string( $tools ) ) { $tools = array( $tools ); } $pageToolsStructure = &$this->getPageToolsStructure(); foreach ( $tools as $tool ) { foreach ( $pageToolsStructure as $group => $groupStructure ) { if ( array_key_exists( $tool, $groupStructure ) ) { $pageToolsStructure[ $group ][ $tool ][ 'redundant' ] = true; } } } } }