Use different pagination images for different styles

This commit is contained in:
Dmitriy Simushev 2014-01-17 14:43:41 +00:00
parent e53314f403
commit a2451c0575
10 changed files with 26 additions and 13 deletions

View File

@ -47,6 +47,9 @@ class PageStyle extends Style implements StyleInterface {
// view. // view.
global $page, $version, $errors; global $page, $version, $errors;
// Add template root value to page variables
$page['stylepath'] = MIBEW_WEB_ROOT . '/' . $this->filesPath();
// Prepare to output html // Prepare to output html
start_html_output(); start_html_output();

View File

@ -141,7 +141,10 @@ class ChatTemplateEngine {
} elseif ($var == 'styleid') { } elseif ($var == 'styleid') {
return $this->styleName; return $this->styleName;
} elseif ($var == 'pagination') { } elseif ($var == 'pagination') {
return generate_pagination($this->templateData['pagination']); return generate_pagination(
MIBEW_WEB_ROOT . '/' . $this->stylePath,
$this->templateData['pagination']
);
} elseif ($var == 'errors' || $var == 'harderrors') { } elseif ($var == 'errors' || $var == 'harderrors') {
if ( if (
!empty($this->templateData['errors']) !empty($this->templateData['errors'])

View File

@ -29,9 +29,16 @@ function generate_pagination_link($page, $title)
return "<a href=\"" . htmlspecialchars($href) . "\" class=\"pagelink\">$title</a>"; return "<a href=\"" . htmlspecialchars($href) . "\" class=\"pagelink\">$title</a>";
} }
function generate_pagination_image($id, $alt) /**
{ * Builds HTML markup for pagination image
return "<img src=\"" . MIBEW_WEB_ROOT . "/images/$id.gif\" border=\"0\" alt=\"" . htmlspecialchars($alt) . "\"/>"; *
* @param string $style_path Root path of the style
* @param string $id Name of the image with neither path nor extension.
* @param string $alt Value of an 'alt' atribute of the image tag.
* @return string HTML markup
*/
function generate_pagination_image($style_path, $id, $alt) {
return "<img src=\"" . $style_path . "/images/$id.gif\" border=\"0\" alt=\"" . htmlspecialchars($alt) . "\"/>";
} }
function prepare_pagination($items_count, $default_items_per_page = 15) function prepare_pagination($items_count, $default_items_per_page = 15)
@ -127,7 +134,7 @@ function setup_empty_pagination()
$page['pagination'] = false; $page['pagination'] = false;
} }
function generate_pagination($pagination, $bottom = true) function generate_pagination($style_path, $pagination, $bottom = true)
{ {
global $pagination_spacing, $links_on_page; global $pagination_spacing, $links_on_page;
$result = getlocal2("tag.pagination.info", $result = getlocal2("tag.pagination.info",
@ -146,7 +153,7 @@ function generate_pagination($pagination, $bottom = true)
$maxPage = min($curr_page + $links_on_page, $pagination['total']); $maxPage = min($curr_page + $links_on_page, $pagination['total']);
if ($curr_page > 1) { if ($curr_page > 1) {
$result .= generate_pagination_link($curr_page - 1, generate_pagination_image("prevpage", getlocal("tag.pagination.previous"))) . $pagination_spacing; $result .= generate_pagination_link($curr_page - 1, generate_pagination_image($style_path, "prevpage", getlocal("tag.pagination.previous"))) . $pagination_spacing;
} }
for ($i = $minPage; $i <= $maxPage; $i++) { for ($i = $minPage; $i <= $maxPage; $i++) {
@ -160,7 +167,7 @@ function generate_pagination($pagination, $bottom = true)
} }
if ($curr_page < $pagination['total']) { if ($curr_page < $pagination['total']) {
$result .= $pagination_spacing . generate_pagination_link($curr_page + 1, generate_pagination_image("nextpage", getlocal("tag.pagination.next"))); $result .= $pagination_spacing . generate_pagination_link($curr_page + 1, generate_pagination_image($style_path, "nextpage", getlocal("tag.pagination.next")));
} }
$result .= "</div>"; $result .= "</div>";
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 915 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 914 B

View File

@ -102,7 +102,7 @@ if( $page['pagination.items'] ) {
<?php <?php
if( $page['pagination.items'] ) { if( $page['pagination.items'] ) {
echo "<br/>"; echo "<br/>";
echo generate_pagination($page['pagination']); echo generate_pagination($page['stylepath'], $page['pagination']);
} }
} }
?> ?>

View File

@ -109,7 +109,7 @@ if( $page['pagination.items'] ) {
<?php <?php
if( $page['pagination.items'] ) { if( $page['pagination.items'] ) {
echo "<br/>"; echo "<br/>";
echo generate_pagination($page['pagination']); echo generate_pagination($page['stylepath'], $page['pagination']);
} }
} }
?> ?>

View File

@ -119,7 +119,7 @@ if( $page['pagination.items'] ) {
<?php <?php
if( $page['pagination.items'] ) { if( $page['pagination.items'] ) {
echo "<br/>"; echo "<br/>";
echo generate_pagination($page['pagination']); echo generate_pagination($page['stylepath'], $page['pagination']);
} }
} }
?> ?>

View File

@ -67,7 +67,7 @@ function tpl_content() { global $page;
<?php <?php
if( $page['pagination'] ) { if( $page['pagination'] ) {
if( $page['pagination.items'] ) { if( $page['pagination.items'] ) {
echo generate_pagination($page['pagination'], false); echo generate_pagination($page['stylepath'], $page['pagination'], false);
} }
?> ?>
@ -113,7 +113,7 @@ if( $page['pagination.items'] ) {
<?php <?php
if( $page['pagination.items'] ) { if( $page['pagination.items'] ) {
echo "<br/>"; echo "<br/>";
echo generate_pagination($page['pagination']); echo generate_pagination($page['stylepath'], $page['pagination']);
} }
} }
?> ?>

View File

@ -72,7 +72,7 @@ if( $page['pagination.items'] ) {
<?php <?php
if( $page['pagination.items'] ) { if( $page['pagination.items'] ) {
echo "<br/>"; echo "<br/>";
echo generate_pagination($page['pagination']); echo generate_pagination($page['stylepath'], $page['pagination']);
} }
} }
?> ?>