Skip to content

Commit

Permalink
Use navigation partial instead of inheritance
Browse files Browse the repository at this point in the history
The styling should be determined by the package view
  • Loading branch information
aimeos committed Dec 11, 2015
1 parent b1fda28 commit fd8c90f
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 148 deletions.
72 changes: 0 additions & 72 deletions client/jqadm/templates/base-default.php

This file was deleted.

105 changes: 42 additions & 63 deletions client/jqadm/templates/common/partials/navigation-default.php
@@ -1,66 +1,45 @@
<?php

/**
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
* @copyright Aimeos (aimeos.org), 2015
*/

$enc = $this->encoder();

$target = $this->config( 'client/jqadm/url/search/target' );
$controller = $this->config( 'client/jqadm/url/search/controller', 'jqadm' );
$action = $this->config( 'client/jqadm/url/search/action', 'search' );
$config = $this->config( 'client/jqadm/url/search/config', array() );

$params = $this->param();

$total = $this->get( 'total', 0 );
$offset = max( $this->param( 'page/offset', 0 ), 0 );
$limit = max( $this->param( 'page/limit', 100 ), 1 );

$first = ( $offset > 0 ? 0 : null );
$prev = ( $offset - $limit >= 0 ? $offset - $limit : null );
$next = ( $offset + $limit < $total ? $offset + $limit : null );
$last = ( ((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null );

$pageCurrent = floor( $offset / $limit ) + 1;
$pageTotal = ( $total != 0 ? ceil( $total / $limit ) : 1 );

?>
<nav class="search-navigation">
<ul class="pagination">
<li>
<a href="<?php $params['page']['offset'] = $first; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>" aria-label="<?php echo $enc->attr( $this->translate( 'client/jqadm', 'First' ) ); ?>">
<span class="glyphicon glyphicon-backward" aria-hidden="true"></span>
</a>
</li>
<li>
<a href="<?php $params['page']['offset'] = $prev; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>" aria-label="<?php echo $enc->attr( $this->translate( 'client/jqadm', 'Previous' ) ); ?>">
<span class="glyphicon glyphicon-triangle-left" aria-hidden="true"></span>
</a>
</li>
<li class="disabled"><?php echo $enc->html( sprintf( $this->translate( 'client/jqadm', 'Page %1$d of %2$d' ), $pageCurrent, $pageTotal ) ); ?></li>
<li>
<a href="<?php $params['page']['offset'] = $next; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>" aria-label="<?php echo $enc->attr( $this->translate( 'client/jqadm', 'Next' ) ); ?>">
<span class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span>
</a>
</li>
<li>
<a href="<?php $params['page']['offset'] = $last; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>" aria-label="<?php echo $enc->attr( $this->translate( 'client/jqadm', 'Last' ) ); ?>">
<span class="glyphicon glyphicon-forward" aria-hidden="true"></span>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="https://aimeos.org/update?type=<?php echo $this->get( 'type' ); ?>&version=<?php echo $this->get( 'version' ); ?>">
<img src="https://aimeos.org/check?type=<?php echo $this->get( 'type' ); ?>&version=<?php echo $this->get( 'version' ); ?>" title="Aimeos logo" />
</a>
</li>
</ul>
<ul class="size">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php echo $limit; ?> <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="<?php $params['page']['limit'] = 25; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>">25</a></li>
<li><a href="<?php $params['page']['limit'] = 50; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>">50</a></li>
<li><a href="<?php $params['page']['limit'] = 100; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>">100</a></li>
<li><a href="<?php $params['page']['limit'] = 200; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>">200</a></li>
<li><a href="<?php $params['page']['limit'] = 500; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>">500</a></li>
</div>

<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Default <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">Default</a></li>
<li><a href="#">Unit test</a></li>
<li><a href="#">Performance</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">English <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="#">English</a></li>
<li><a href="#">French</a></li>
<li><a href="#">German</a></li>
</ul>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Expert mode</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>

<?php echo $this->block()->get( 'jqadm_content' ); ?>
66 changes: 66 additions & 0 deletions client/jqadm/templates/common/partials/pagination-default.php
@@ -0,0 +1,66 @@
<?php

/**
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
* @copyright Aimeos (aimeos.org), 2015
*/

$enc = $this->encoder();

$target = $this->config( 'client/jqadm/url/search/target' );
$controller = $this->config( 'client/jqadm/url/search/controller', 'jqadm' );
$action = $this->config( 'client/jqadm/url/search/action', 'search' );
$config = $this->config( 'client/jqadm/url/search/config', array() );

$params = $this->param();

$total = $this->get( 'total', 0 );
$offset = max( $this->param( 'page/offset', 0 ), 0 );
$limit = max( $this->param( 'page/limit', 100 ), 1 );

$first = ( $offset > 0 ? 0 : null );
$prev = ( $offset - $limit >= 0 ? $offset - $limit : null );
$next = ( $offset + $limit < $total ? $offset + $limit : null );
$last = ( ((int) ($total / $limit)) * $limit > $offset ? ((int) ($total / $limit)) * $limit : null );

$pageCurrent = floor( $offset / $limit ) + 1;
$pageTotal = ( $total != 0 ? ceil( $total / $limit ) : 1 );

?>
<nav class="search-navigation">
<ul class="pagination">
<li>
<a href="<?php $params['page']['offset'] = $first; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>" aria-label="<?php echo $enc->attr( $this->translate( 'client/jqadm', 'First' ) ); ?>">
<span class="glyphicon glyphicon-backward" aria-hidden="true"></span>
</a>
</li>
<li>
<a href="<?php $params['page']['offset'] = $prev; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>" aria-label="<?php echo $enc->attr( $this->translate( 'client/jqadm', 'Previous' ) ); ?>">
<span class="glyphicon glyphicon-triangle-left" aria-hidden="true"></span>
</a>
</li>
<li class="disabled"><?php echo $enc->html( sprintf( $this->translate( 'client/jqadm', 'Page %1$d of %2$d' ), $pageCurrent, $pageTotal ) ); ?></li>
<li>
<a href="<?php $params['page']['offset'] = $next; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>" aria-label="<?php echo $enc->attr( $this->translate( 'client/jqadm', 'Next' ) ); ?>">
<span class="glyphicon glyphicon-triangle-right" aria-hidden="true"></span>
</a>
</li>
<li>
<a href="<?php $params['page']['offset'] = $last; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>" aria-label="<?php echo $enc->attr( $this->translate( 'client/jqadm', 'Last' ) ); ?>">
<span class="glyphicon glyphicon-forward" aria-hidden="true"></span>
</a>
</li>
</ul>
<ul class="size">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php echo $limit; ?> <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="<?php $params['page']['limit'] = 25; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>">25</a></li>
<li><a href="<?php $params['page']['limit'] = 50; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>">50</a></li>
<li><a href="<?php $params['page']['limit'] = 100; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>">100</a></li>
<li><a href="<?php $params['page']['limit'] = 200; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>">200</a></li>
<li><a href="<?php $params['page']['limit'] = 500; echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>">500</a></li>
</ul>
</li>
</ul>
</nav>
6 changes: 1 addition & 5 deletions client/jqadm/templates/product/item-default.php
Expand Up @@ -27,7 +27,7 @@
$listParam = array();

?>
<?php $this->block()->start( 'jqadm_content' ); ?>
<?php echo $this->partial( $this->config( 'client/jqadm/partial/navigation', 'common/partials/navigation-default.php' ), array() ); ?>

<form class="form-horizontal" method="POST" enctype="multipart/form-data" action="<?php echo $enc->attr( $this->url( $target, $cntl, $action, array(), array(), $config ) ); ?>">
<div class="panel-group" id="accordion" role="tablist" aria-multiselectable="true">
Expand Down Expand Up @@ -143,7 +143,3 @@
</a>
</div>
</form>

<?php $this->block()->stop(); ?>

<?php echo $this->render( 'base-default.php' ); ?>
14 changes: 6 additions & 8 deletions client/jqadm/templates/product/list-default.php
Expand Up @@ -39,14 +39,14 @@
'filterOperators' => $this->get( 'filterOperators', array() ),
);

$navParams = array( 'total' => $this->get( 'total', 0 ) );
$nav = $this->partial( $this->config( 'client/jqadm/partial/navigation', 'common/partials/navigation-default.php' ), $navParams );
$pageParams = array( 'total' => $this->get( 'total', 0 ) );
$pagination = $this->partial( $this->config( 'client/jqadm/partial/pagination', 'common/partials/pagination-default.php' ), $pageParams );

$default = $this->config( 'client/jqadm/product/fields', array( 'product.status', 'product.typeid', 'product.code', 'product.label' ) );
$fields = $this->param( 'fields', $default );

?>
<?php $this->block()->start( 'jqadm_content' ); ?>
<?php echo $this->partial( $this->config( 'client/jqadm/partial/navigation', 'common/partials/navigation-default.php' ), array() ); ?>

<form class="filter" method="POST" action="<?php echo $enc->attr( $this->url( $target, $controller, $action, $params, array(), $config ) ); ?>">
<?php echo $this->partial( $this->config( 'client/jqadm/partial/filter', 'common/partials/filter-default.php' ), $filterParams ); ?>
Expand All @@ -64,7 +64,8 @@
</div>
</form>

<?php echo $nav ?>
<?php echo $pagination; ?>

<table class="table table-hover">
<thead>
<tr>
Expand Down Expand Up @@ -201,8 +202,5 @@
<?php endforeach; ?>
</tbody>
</table>
<?php echo $nav; ?>

<?php $this->block()->stop(); ?>

<?php echo $this->render( 'base-default.php' ); ?>
<?php echo $pagination; ?>

0 comments on commit fd8c90f

Please sign in to comment.