本文整理汇总了PHP中Jaws_Gadget::ParseText方法的典型用法代码示例。如果您正苦于以下问题:PHP Jaws_Gadget::ParseText方法的具体用法?PHP Jaws_Gadget::ParseText怎么用?PHP Jaws_Gadget::ParseText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jaws_Gadget
的用法示例。
在下文中一共展示了Jaws_Gadget::ParseText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Pagination
/**
* Builds page navigation for given records
*
* @access public
*/
function Pagination($page, $limit, $total, $action, $params = array())
{
$prevpage = $page - 1;
$nextpage = $page + 1;
$pagesCount = $total % $limit ? floor($total / $limit) + 1 : floor($total / $limit);
if ($pagesCount <= 1) {
return '';
}
$pagination = '';
$pageNext = _t('DIRECTORY_PAGE_NEXT');
$pageLast = _t('DIRECTORY_PAGE_LAST');
$pageFirst = _t('DIRECTORY_PAGE_FIRST');
$pagePrev = _t('DIRECTORY_PAGE_PREVIOUS');
$tpl = $this->gadget->template->load('Directory.html');
$tpl->SetBlock('pagination');
// First
if ($page > 1) {
unset($params['page']);
$url = $this->gadget->urlMap($action, $params);
$tpl->SetBlock('pagination/first');
$tpl->SetVariable('url', $url);
$tpl->SetVariable('first', $pageFirst);
$tpl->ParseBlock('pagination/first');
}
// Previous
if ($page > 1) {
if ($page != 2) {
$params['page'] = $page - 1;
}
$url = $this->gadget->urlMap($action, $params);
$tpl->SetBlock('pagination/prev');
$tpl->SetVariable('url', $url);
$tpl->SetVariable('previous', $pagePrev);
$tpl->ParseBlock('pagination/prev');
}
// Next
if ($page < $pagesCount) {
$params['page'] = $page + 1;
$url = $this->gadget->urlMap($action, $params);
$tpl->SetBlock('pagination/next');
$tpl->SetVariable('url', $url);
$tpl->SetVariable('next', $pageNext);
$tpl->ParseBlock('pagination/next');
}
// Last
if ($page < $pagesCount) {
$params['page'] = $pagesCount;
$url = $this->gadget->urlMap($action, $params);
$tpl->SetBlock('pagination/last');
$tpl->SetVariable('url', $url);
$tpl->SetVariable('last', $pageLast);
$tpl->ParseBlock('pagination/last');
}
// Page Numbers
$range = 5;
// TODO: can be a registry key
$start = $page - $range <= 1 ? 1 : $page - $range;
$end = $page + $range >= $pagesCount ? $pagesCount : $page + $range;
for ($i = $start; $i <= $end; $i++) {
$num = Jaws_Gadget::ParseText($i, 'Directory', false);
$tpl->SetBlock('pagination/page');
if ($i == $page || $page == 0 && $i == 1) {
$tpl->SetVariable('link', "<span>{$num}</span>");
$tpl->SetVariable('current', 'current');
} else {
if ($i == 1) {
unset($params['page']);
} else {
$params['page'] = $i;
}
$url = $this->gadget->urlMap($action, $params);
$link =& Piwi::CreateWidget('Link', $num, $url);
$tpl->SetVariable('link', $link->Get());
$tpl->SetVariable('current', '');
}
$tpl->ParseBlock('pagination/page');
}
$tpl->ParseBlock('pagination');
return $tpl->Get();
}