. * * @file * @ingroup Skins */ namespace Skins\Chameleon\Components\NavbarHorizontal; use Skins\Chameleon\Components\Component; use Skins\Chameleon\Components\PageTools as GenPageTools; /** * The NavbarHorizontal\PageTools class. * * Provides a PageTools component to be included in a NavbarHorizontal component. * * @author Stephan Gambke * @since 1.6 * @ingroup Skins */ class PageTools extends Component { /** * @return String */ public function getHtml() { $ret = ''; $pageTools = new GenPageTools( $this->getSkinTemplate(), $this->getDomElement(), $this->getIndent() + 1 ); $pageTools->setFlat( true ); $pageTools->removeClasses( 'text-center list-inline' ); $pageTools->addClasses( 'dropdown-menu' ); $editLinkHtml = $this->getEditLinkHtml( $pageTools ); $pageToolsHtml = $pageTools->getHtml(); if ( $editLinkHtml || $pageToolsHtml ) { $ret = $this->indent() . '' . $this->indent() . '' . "\n"; } return $ret; } /** * @param GenPageTools $pageTools * @return string */ protected function getEditLinkHtml( $pageTools ) { $pageToolsStructure = $pageTools->getPageToolsStructure(); if ( ! array_key_exists( 'views', $pageToolsStructure ) ) { return ''; } foreach ( $this->getReplaceableEditActionIds() as $id ) { if ( array_key_exists( $id, $pageToolsStructure[ 'views' ] ) ) { return $this->getLinkAndRemoveFromPageToolStructure( $pageTools, $id ); } } return ''; } /** * @param GenPageTools $pageTools * @param string $editActionId * * @return string */ protected function getLinkAndRemoveFromPageToolStructure( $pageTools, $editActionId ) { $pageToolsStructure = $pageTools->getPageToolsStructure(); $editActionStructure = $pageToolsStructure[ 'views' ][ $editActionId ]; $editActionStructure[ 'text' ] = ''; if ( array_key_exists( 'class', $editActionStructure ) ) { $editActionStructure[ 'class' ] .= ' navbar-tools-tools'; } else { $editActionStructure[ 'class' ] = 'navbar-tools-tools'; } $options = array ( 'text-wrapper' => array( 'tag' => 'span', 'attributes' => array('class' => 'glyphicon glyphicon-pencil',) ), ); $editLinkHtml = $this->getSkinTemplate()->makeListItem( $editActionId, $editActionStructure, $options ); $pageTools->setRedundant( $editActionId ); return $editLinkHtml; } /** * @return string[] */ protected function getReplaceableEditActionIds() { $editActionIds = array( 've-edit', 'edit' ); if ( array_key_exists( 'sfgRenameEditTabs', $GLOBALS ) && $GLOBALS[ 'sfgRenameEditTabs' ] === true || array_key_exists( 'wgPageFormsRenameEditTabs', $GLOBALS ) && $GLOBALS[ 'wgPageFormsRenameEditTabs' ] === true ) { $editActionIds = array_merge( array( 'formedit', 'form_edit' ), $editActionIds ); } return $editActionIds; } }