Вот код функции пагинации.как перевести sprintf
в print_r
или echo
?Я хочу добавить class
в a href
и добавить onclick
вещь.Спасибо.
public function display() {
extract($this->_arrTemplateData);
if($total_pages <= $visible_pages) {
$page_start = 1;
$page_end = $total_pages;
} else if($page <= ceil($visible_pages/2)) {
$page_start = 1;
$page_end = $visible_pages;
} else if($page > ($total_pages - ceil($visible_pages/2))) {
$page_start = $total_pages - (ceil(($visible_pages/2)*2)-1);
$page_end = $total_pages;
} else {
$page_start = $page-(floor($visible_pages/2));
$page_end = $page+(floor($visible_pages/2));
}
$return = sprintf(
'<div class="summary"><p class="pages">%u %s</p><p class="total">%u %s</p></div>'
,$total_pages
,$total_pages == 1?'Page':'Pages'
,$found_rows
,$found_rows == 1?$label:$label
);
$return.= sprintf('<ul class="pagination">');
$return.= sprintf(
'<li class="first">%s%s%s</li>'
,$page == 1?'':sprintf('<a href="%s">',str_replace($page_flag,1,$base_path))
,'First'
,$page == 1?'':'</a>'
);
$return.= sprintf(
'<li class="previous">%s%s%s</li>'
,$page == 1?'':sprintf('<a href="%s">',str_replace($page_flag,($page-1),$base_path))
,'Previous'
,$page == 1?'':'</a>'
);
foreach(range($page_start,$page_end,1) as $i) {
$return.= sprintf(
'<li%s>%s%s%s</li>'
,$page == $i?' class="current"':''
,$page == $i?'':sprintf('<a href="%s">',str_replace($page_flag,$i,$base_path))
,$i
,$page == $i?'':'</a>'
);
}
$return.= sprintf(
'<li class="next">%s%s%s</li>'
,$page == $total_pages?'':sprintf('<a href="%s">',str_replace($page_flag,($page+1),$base_path))
,'Next'
,$page == $total_pages?'':'</a>'
);
$return.= sprintf(
'<li class="last">%s%s%s</li>'
,$page == $total_pages?'':sprintf('<a href="%s">',str_replace($page_flag,$total_pages,$base_path))
,'Last'
,$page == $total_pages?'':'</a>'
);
$return.= sprintf('</ul>');
return $return;
}