Do not use style path for pagination generation

This commit is contained in:
Dmitriy Simushev 2014-09-05 10:15:28 +00:00
parent 84094ad38b
commit 7c1e123ad6
8 changed files with 12 additions and 16 deletions

View File

@ -29,10 +29,9 @@ use Handlebars\Template;
*
* Example of usage:
* <code>
* {{generatePagination stylePath paginationInfo bottom}}
* {{generatePagination paginationInfo bottom}}
* </code>
* where:
* - "stylePath" is expression for path to current style.
* - "paginationInfo" is 'info' key from the result of setup_pagination
* function.
* - "bottom": optional argument that indicate if pagination block shoud
@ -48,16 +47,14 @@ class GeneratePaginationHelper implements HelperInterface
public function execute(Template $template, Context $context, $args, $source)
{
$parsed_args = $template->parseArguments($args);
if (empty($parsed_args) || count($parsed_args) < 2) {
if (empty($parsed_args) || count($parsed_args) < 1) {
return '';
}
$stylePath = $context->get($parsed_args[0]);
$pagination_info = $context->get($parsed_args[1]);
$bottom = empty($parsed_args[2]) ? true : $context->get($parsed_args[2]);
$pagination_info = $context->get($parsed_args[0]);
$bottom = empty($parsed_args[1]) ? true : $context->get($parsed_args[1]);
$pagination = generate_pagination(
$stylePath,
$pagination_info,
($bottom === "false") ? false : true
);

View File

@ -142,14 +142,13 @@ function setup_pagination($items, $default_items_per_page = 15)
/**
* Builds HTML markup for pagination pager.
*
* @param string $style_path Root path of the style.
* @param array $pagination Pagination info. See description of the result of
* pagination_info function for details.
* @param bool $bottom Indicates if pager will be displayed at the bottom of a
* page.
* @return string HTML markup
*/
function generate_pagination($style_path, $pagination, $bottom = true)
function generate_pagination($pagination, $bottom = true)
{
$result = getlocal(
'Page {0} of {1}, {2}-{3} from {4}',

View File

@ -27,6 +27,6 @@
{{/if}}
</div>
<div class="clear">&nbsp;</div>
<div class="center">{{generatePagination stylePath pagination}}</div>
<div class="center">{{generatePagination pagination}}</div>
{{/override}}
{{/extends}}

View File

@ -75,7 +75,7 @@
{{#if pagination}}
<br />
{{generatePagination stylePath pagination}}
{{generatePagination pagination}}
{{/if}}
{{/override}}
{{/extends}}

View File

@ -87,7 +87,7 @@
{{#if pagination}}
<br />
{{generatePagination stylePath pagination}}
{{generatePagination pagination}}
{{/if}}
{{/override}}
{{/extends}}

View File

@ -98,7 +98,7 @@
{{#if pagination}}
<br/>
{{generatePagination stylePath pagination}}
{{generatePagination pagination}}
{{/if}}
{{/override}}
{{/extends}}

View File

@ -37,7 +37,7 @@
{{#if pagination}}
<br />
{{generatePagination stylePath pagination}}
{{generatePagination pagination}}
{{/if}}
{{/override}}
{{/extends}}

View File

@ -47,7 +47,7 @@
{{#if pagination}}
{{generatePagination stylePath pagination "false"}}
{{generatePagination pagination "false"}}
{{/if}}
<table class="translate">
@ -80,7 +80,7 @@
{{#if pagination}}
<br />
{{generatePagination stylePath pagination}}
{{generatePagination pagination}}
{{/if}}
{{/override}}
{{/extends}}