Merge "Hygiene: divide VectorTemplate.renderNavigation()"

This commit is contained in:
jenkins-bot 2019-11-20 20:00:40 +00:00 committed by Gerrit Code Review
commit 501b94f1b4
1 changed files with 179 additions and 156 deletions

View File

@ -270,6 +270,50 @@ class VectorTemplate extends BaseTemplate {
foreach ( $elements as $name => $element ) {
switch ( $element ) {
case 'NAMESPACES':
$this->renderNamespacesComponent();
break;
case 'VARIANTS':
$this->renderVariantsComponent();
break;
case 'VIEWS':
$this->renderViewsComponent();
break;
case 'ACTIONS':
$this->renderActionsComponent();
break;
case 'PERSONAL':
$this->renderPersonalComponent();
break;
case 'SEARCH':
$this->renderSearchComponent();
break;
}
}
}
/**
* @inheritDoc
*/
public function makeListItem( $key, $item, $options = [] ) {
// For fancy styling of watch/unwatch star
if (
$this->config->get( 'VectorUseIconWatch' )
&& ( $key === 'watch' || $key === 'unwatch' )
) {
$item['class'] = rtrim( 'icon ' . $item['class'], ' ' );
$item['primary'] = true;
}
// Add CSS class 'collapsible' to links which are not marked as "primary"
if (
isset( $options['vector-collapsible'] ) && $options['vector-collapsible'] ) {
$item['class'] = rtrim( 'collapsible ' . $item['class'], ' ' );
}
return parent::makeListItem( $key, $item, $options );
}
private function renderNamespacesComponent() {
?>
<div id="p-namespaces" role="navigation" class="vectorTabs<?php
if ( count( $this->data['namespace_urls'] ) == 0 ) {
@ -286,8 +330,9 @@ class VectorTemplate extends BaseTemplate {
</ul>
</div>
<?php
break;
case 'VARIANTS':
}
private function renderVariantsComponent() {
?>
<div id="p-variants" role="navigation" class="vectorMenu<?php
if ( count( $this->data['variant_urls'] ) == 0 ) {
@ -317,8 +362,9 @@ class VectorTemplate extends BaseTemplate {
</ul>
</div>
<?php
break;
case 'VIEWS':
}
private function renderViewsComponent() {
?>
<div id="p-views" role="navigation" class="vectorTabs<?php
if ( count( $this->data['view_urls'] ) == 0 ) {
@ -337,8 +383,9 @@ class VectorTemplate extends BaseTemplate {
</ul>
</div>
<?php
break;
case 'ACTIONS':
}
private function renderActionsComponent() {
?>
<div id="p-cactions" role="navigation" class="vectorMenu<?php
if ( count( $this->data['action_urls'] ) == 0 ) {
@ -358,8 +405,9 @@ class VectorTemplate extends BaseTemplate {
</ul>
</div>
<?php
break;
case 'PERSONAL':
}
private function renderPersonalComponent() {
?>
<div id="p-personal" role="navigation"<?php
if ( count( $this->data['personal_urls'] ) == 0 ) {
@ -398,8 +446,9 @@ class VectorTemplate extends BaseTemplate {
</ul>
</div>
<?php
break;
case 'SEARCH':
}
private function renderSearchComponent() {
?>
<div id="p-search" role="search">
<h3<?php $this->html( 'userlangattributes' ) ?>>
@ -435,31 +484,5 @@ class VectorTemplate extends BaseTemplate {
</form>
</div>
<?php
break;
}
}
}
/**
* @inheritDoc
*/
public function makeListItem( $key, $item, $options = [] ) {
// For fancy styling of watch/unwatch star
if (
$this->config->get( 'VectorUseIconWatch' )
&& ( $key === 'watch' || $key === 'unwatch' )
) {
$item['class'] = rtrim( 'icon ' . $item['class'], ' ' );
$item['primary'] = true;
}
// Add CSS class 'collapsible' to links which are not marked as "primary"
if (
isset( $options['vector-collapsible'] ) && $options['vector-collapsible'] ) {
$item['class'] = rtrim( 'collapsible ' . $item['class'], ' ' );
}
return parent::makeListItem( $key, $item, $options );
}
}