141 lines
4.6 KiB
PHP
141 lines
4.6 KiB
PHP
<?php
|
|
/*
|
|
* Smarty plugin
|
|
* -------------------------------------------------------------
|
|
* File: function.pagination.php
|
|
* Type: function
|
|
* Name: link
|
|
* Purpose: zwraca linki do pozostalych stron z danego zakresu
|
|
* Dependencies: function.url.php
|
|
* -------------------------------------------------------------
|
|
*/
|
|
|
|
include_once(PATH_SMARTY_PLUGINS . '/' . 'function.url.php');
|
|
|
|
function smarty_function_pagination($params, &$smarty) {
|
|
|
|
/**
|
|
* do funkcji nalezy podac parametry: currPage, pageCount i _value
|
|
* _value tak jak do smarty_function_url bez uwzgledniania strony
|
|
*/
|
|
|
|
//Utils::ArrayDisplay($params);
|
|
$class = 'pagination';
|
|
if(isset($params['class'])){
|
|
$class=$params['class'];
|
|
unset($params['class']);
|
|
}
|
|
|
|
$currPage = $params['currPage'];
|
|
$pageCount = $params['pageCount'];
|
|
|
|
$name = 'strona';
|
|
if(isset($params['name'])) {
|
|
$name = $params['name'];
|
|
unset($params['name']);
|
|
}
|
|
|
|
if( isset($params['ajax']) )
|
|
{
|
|
$ajax = $params['ajax'];
|
|
}
|
|
unset($params['ajax']);
|
|
unset($params['currPage']);
|
|
unset($params['pageCount']);
|
|
|
|
if($pageCount <= 1)return '';
|
|
|
|
if($currPage > $pageCount) {
|
|
$currPage = $pageCount;
|
|
}
|
|
|
|
$ret = '';
|
|
$url = smarty_function_url(array( $currPage-1 => $params['_current']), $smarty);
|
|
$ret = '<a href="' . $url . '" rel="nofollow"' . ($currPage > 1 ? '' : ' class="disabled" onclick="return false;"') . '>' . (isset($params['prev']) ? Dictionary::Translate($params['prev']) : '<<') . ($currPage > 1 ? '</a>' : '') . ' ';
|
|
for($i = 1; $i <= $pageCount; $i++) {
|
|
|
|
if ($i == $currPage) {
|
|
$selected = 'class="selected"';
|
|
} else {
|
|
$selected = '';
|
|
}
|
|
|
|
if($i == $currPage) {
|
|
$url = smarty_function_url(array( $i => $params['_current']), $smarty);
|
|
$ret .= '<a href="'.$url.'" '.$selected.' >'.$i.'</a> ';
|
|
} else {
|
|
$url = smarty_function_url(array( $i => $params['_current']), $smarty);
|
|
$ret .= '<a href="'.$url.' " >'.$i.'</a> '.($i < $pageCount?' ':'');
|
|
}
|
|
|
|
}
|
|
$url = smarty_function_url(array( $currPage+1 => $params['_current']), $smarty);
|
|
$ret .= '<a href="' . $url . '" rel="nofollow"' . ($currPage+1 <= $pageCount ? '' : ' class="disabled" onclick="return false;"') . ">" . (isset($params['next']) ? Dictionary::Translate($params['next']) : '>>') . '</a>';
|
|
|
|
// Utils::ArrayDisplay($currPage);
|
|
// Utils::ArrayDisplay($pageCount);
|
|
|
|
return $ret;
|
|
|
|
|
|
|
|
|
|
// $params['strona'] = 1;
|
|
// $ret = '<a href="'.smarty_function_url($params,$smarty).'"><<</a> ';
|
|
|
|
|
|
// $params[$name] = ($currPage < $pageCount?$currPage+1:$pageCount);
|
|
// Utils::ArrayDisplay($params);
|
|
// $href = (isset($ajax) ? 'onclick=Dosia.Request("' .smarty_function_url($params,$smarty).'") href="#"' :'href="'.smarty_function_url($params,$smarty).'"');
|
|
//
|
|
// $ret .= '<div class="floatRight"><a ' . $href . '>';
|
|
// $ret .= '<img src="'.URL_STATIC_CONTENT.'/image/buttonProfilZnajomiNastepna.gif" alt="" title="" border="0" /></a></div>';
|
|
//
|
|
//
|
|
//
|
|
// $ret .= '<div class="floatRight numbers">';
|
|
// if($pageCount < 6)for($i = 1; $i <= $pageCount; $i++){
|
|
// $params[$name] = $i;
|
|
// if($i != $currPage){
|
|
// Utils::ArrayDisplay($params);
|
|
// $href = (isset($ajax) ? 'onclick=Dosia.Request("' .smarty_function_url($params,$smarty).'") href="#"' :'href="'.smarty_function_url($params,$smarty).'"');
|
|
// Utils::ArrayDisplay($href);
|
|
// $ret .= '<a ' . $href . '>'.$i.'</a> '.($i<$pageCount?'| ':'');
|
|
// }else{
|
|
// $ret .= $i.($i < $pageCount?' | ':'');
|
|
// }
|
|
// }else{
|
|
// $arr = array();
|
|
// if($currPage > 2)$arr[] = $currPage - 2;
|
|
// if($currPage > 1)$arr[] = $currPage - 1;
|
|
//
|
|
// $arr[] = $currPage;
|
|
//
|
|
// if($currPage < $pageCount)$arr[] = $currPage + 1;
|
|
// if($currPage < $pageCount - 1)$arr[] = $currPage + 2;
|
|
//
|
|
// if($arr[0] > 1)$ret .= '... ';
|
|
// foreach($arr AS $k=>$strona){
|
|
//
|
|
// $params[$name] = $strona;
|
|
// if($strona != $currPage){
|
|
// $href = (isset($ajax) ? 'onclick=Dosia.Request("' .smarty_function_url($params,$smarty).'") href="#"' :'href="'.smarty_function_url($params,$smarty).'"');
|
|
//
|
|
// $ret .= '<a ' . $href . '>'.$strona.'</a> '.($k<count($arr) - 1?'| ':'');
|
|
// }else{
|
|
// $ret .= $strona.' '.($k<count($arr) - 1?'| ':'');
|
|
// }
|
|
// }
|
|
// if($arr[count($arr)-1] < $pageCount)$ret .= '... ';
|
|
//
|
|
// }
|
|
// $ret .= '</div>';
|
|
//
|
|
// $params[$name] = ($currPage > 1?$currPage-1:1);
|
|
// $href = (isset($ajax) ? 'onclick=Dosia.Request("' .smarty_function_url($params,$smarty).'") href="#"' :'href="'.smarty_function_url($params,$smarty).'"');
|
|
// $ret .= '<div class="floatRight"><a ' . $href . '><img src="'.URL_STATIC_CONTENT.'/image/buttonProfilZnajomiPoprzednia.gif" alt="" title="" border="0" /></a></div>';
|
|
//
|
|
//
|
|
// return '<div class="'.$class.'">'.$ret.'</div> <div class="clearBoth"></div>';
|
|
}
|
|
?>
|