From fc7369835258467bf97eb64f184b93691f9a9fd5 Mon Sep 17 00:00:00 2001 From: Yaco Date: Thu, 4 Jun 2020 11:01:00 -0300 Subject: first commit --- .../src/Components/NavbarHorizontal/Logo.php | 54 ++++++ .../src/Components/NavbarHorizontal/Menu.php | 51 +++++ .../src/Components/NavbarHorizontal/NavMenu.php | 51 +++++ .../src/Components/NavbarHorizontal/PageTools.php | 159 ++++++++++++++++ .../NavbarHorizontal/PageToolsAdaptable.php | 209 +++++++++++++++++++++ .../Components/NavbarHorizontal/PersonalTools.php | 117 ++++++++++++ .../src/Components/NavbarHorizontal/SearchBar.php | 55 ++++++ 7 files changed, 696 insertions(+) create mode 100644 www/wiki/skins/chameleon/src/Components/NavbarHorizontal/Logo.php create mode 100644 www/wiki/skins/chameleon/src/Components/NavbarHorizontal/Menu.php create mode 100644 www/wiki/skins/chameleon/src/Components/NavbarHorizontal/NavMenu.php create mode 100644 www/wiki/skins/chameleon/src/Components/NavbarHorizontal/PageTools.php create mode 100644 www/wiki/skins/chameleon/src/Components/NavbarHorizontal/PageToolsAdaptable.php create mode 100644 www/wiki/skins/chameleon/src/Components/NavbarHorizontal/PersonalTools.php create mode 100644 www/wiki/skins/chameleon/src/Components/NavbarHorizontal/SearchBar.php (limited to 'www/wiki/skins/chameleon/src/Components/NavbarHorizontal') diff --git a/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/Logo.php b/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/Logo.php new file mode 100644 index 00000000..d4e42823 --- /dev/null +++ b/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/Logo.php @@ -0,0 +1,54 @@ +. + * + * @file + * @ingroup Skins + */ + +namespace Skins\Chameleon\Components\NavbarHorizontal; + +use Skins\Chameleon\Components\Component; +use Skins\Chameleon\Components\Logo as GenLogo; + +/** + * The NavbarHorizontal\Logo class. + * + * Provides a Logo component to be included in a NavbarHorizontal component. + * + * @author Stephan Gambke + * @since 1.6 + * @ingroup Skins + */ +class Logo extends Component { + + /** + * @return String + */ + public function getHtml() { + + $logo = new GenLogo( $this->getSkinTemplate(), $this->getDomElement(), $this->getIndent() ); + $logo->addClasses( 'navbar-brand' ); + + return $logo->getHtml(); + } + +} \ No newline at end of file diff --git a/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/Menu.php b/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/Menu.php new file mode 100644 index 00000000..e47dca25 --- /dev/null +++ b/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/Menu.php @@ -0,0 +1,51 @@ +. + * + * @file + * @ingroup Skins + */ + +namespace Skins\Chameleon\Components\NavbarHorizontal; + +use Skins\Chameleon\Components\Component; +use Skins\Chameleon\Components\Menu as GenMenu; + +/** + * The NavbarHorizontal\Logo class. + * + * Provides a Menu component to be included in a NavbarHorizontal component. + * + * @author Stephan Gambke + * @since 1.6 + * @ingroup Skins + */ +class Menu extends Component { + + /** + * @return String + */ + public function getHtml() { + $menu = new GenMenu( $this->getSkinTemplate(), $this->getDomElement(), $this->getIndent() );; + return '\n"; + } + +} \ No newline at end of file diff --git a/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/NavMenu.php b/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/NavMenu.php new file mode 100644 index 00000000..1cc15c28 --- /dev/null +++ b/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/NavMenu.php @@ -0,0 +1,51 @@ +. + * + * @file + * @ingroup Skins + */ + +namespace Skins\Chameleon\Components\NavbarHorizontal; + +use Skins\Chameleon\Components\Component; +use Skins\Chameleon\Components\NavMenu as GenNavMenu; + +/** + * The NavbarHorizontal\NavMenu class. + * + * Provides a NavMenu component to be included in a NavbarHorizontal component. + * + * @author Stephan Gambke + * @since 1.6 + * @ingroup Skins + */ +class NavMenu extends Component { + + /** + * @return String + */ + public function getHtml() { + $navMenu = new GenNavMenu( $this->getSkinTemplate(), $this->getDomElement(), $this->getIndent() );; + return '\n"; + } + +} \ No newline at end of file diff --git a/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/PageTools.php b/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/PageTools.php new file mode 100644 index 00000000..58776077 --- /dev/null +++ b/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/PageTools.php @@ -0,0 +1,159 @@ +. + * + * @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; + } + + +} \ No newline at end of file diff --git a/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/PageToolsAdaptable.php b/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/PageToolsAdaptable.php new file mode 100644 index 00000000..e82e2ada --- /dev/null +++ b/www/wiki/skins/chameleon/src/Components/NavbarHorizontal/PageToolsAdaptable.php @@ -0,0 +1,209 @@ +. + * + * @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() . '