. * * @file * @ingroup Skins */ namespace Skins\Chameleon\Components\NavbarHorizontal; use Skins\Chameleon\Components\PageTools as GenPageTools; /** * The NavbarHorizontal\PageToolsAdaptable class. * * Provides an adaptable PageTools component to be included in a NavbarHorizontal component. * * @author Tobias Oetterer * @since 1.6 * @ingroup Skins */ class PageToolsAdaptable extends PageTools { const GLYPH_ICON_UNKNOWN_ACTION = 'asterisk'; /** * @var string[] */ private $mShowActions = null; /** * @var string[] */ private $mValidActionsToShow = null; /** * @var array */ private static $sGlyphIconForAction = array( 'delete' => 'trash', 'edit' => 'edit', 'formedit' => 'list-alt', 'history' => 'education', 'move' => 'share-alt', 'protect' => 'folder-close', 'purge' => 'repeat', 'undelete' => 'road', 'unprotect' => 'folder-open', 'unwatch' => 'star', 've-edit' => 'pencil', 'view' => 'eye-open', 'watch' => 'star-empty', ); /** * @param string $action * @param string $fallback * @return null|string */ public static function getGlyphIconForAction( $action, $fallback = null ) { if ( isset( self::$sGlyphIconForAction[$action] ) ) { return self::$sGlyphIconForAction[$action]; } return $fallback !== null ? $fallback : self::GLYPH_ICON_UNKNOWN_ACTION; } /** * @param string $icon * @param string $action */ public static function setGlyphIconForAction( $icon, $action ) { if ( is_string( $icon ) && $icon && is_string( $action ) && $action ) { self::$sGlyphIconForAction[$action] = $icon; } } /** * @param GenPageTools $pageTools * @return string * @throws \MWException */ protected function getEditLinkHtml( $pageTools ) { $pageToolsStructure = $pageTools->getPageToolsStructure(); if ( !array_key_exists( 'views', $pageToolsStructure ) ) { return ''; } $items = array(); $showActions = $this->getShowActions( $pageTools ); foreach ( $showActions as $actionId ) { if ( array_key_exists( $actionId, $pageToolsStructure['views'] ) ) { $items[] = $this->getLinkAndRemoveFromPageToolStructure( $pageTools, $actionId ); } } return implode( $this->indent() . '' . $this->indent() . '