本文整理匯總了PHP中DataGrid::getTranslator方法的典型用法代碼示例。如果您正苦於以下問題:PHP DataGrid::getTranslator方法的具體用法?PHP DataGrid::getTranslator怎麽用?PHP DataGrid::getTranslator使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類DataGrid
的用法示例。
在下文中一共展示了DataGrid::getTranslator方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: renderPaginator
/**
* Renders data grid paginator.
* @return string
*/
public function renderPaginator()
{
$paginator = $this->dataGrid->paginator;
if ($paginator->pageCount <= 1) {
return '';
}
$container = $this->getWrapper('paginator container');
$translator = $this->dataGrid->getTranslator();
$a = Html::el('a');
$a->addClass(DataGridAction::$ajaxClass);
// to-first button
$first = $this->getWrapper('paginator button first');
$title = $this->dataGrid->translate('First');
$link = clone $a->href($this->dataGrid->link('page', 1));
if ($first instanceof Html) {
if ($paginator->isFirst()) {
$first->addClass('inactive');
} else {
$first = $link->add($first);
}
$first->title($title);
} else {
$first = $link->setText($title);
}
$container->add($first);
// previous button
$prev = $this->getWrapper('paginator button prev');
$title = $this->dataGrid->translate('Previous');
$link = clone $a->href($this->dataGrid->link('page', $paginator->page - 1));
if ($prev instanceof Html) {
if ($paginator->isFirst()) {
$prev->addClass('inactive');
} else {
$prev = $link->add($prev);
}
$prev->title($title);
} else {
$prev = $link->setText($title);
}
$container->add($prev);
// page input
$controls = $this->getWrapper('paginator controls container');
$form = $this->dataGrid->getForm(TRUE);
$format = $this->dataGrid->translate($this->paginatorFormat);
$html = str_replace(array('%label%', '%input%', '%count%'), array($form['page']->label, $form['page']->control, $paginator->pageCount), $format);
$controls->add(Html::el()->setHtml($html));
$container->add($controls);
// next button
$next = $this->getWrapper('paginator button next');
$title = $this->dataGrid->translate('Next');
$link = clone $a->href($this->dataGrid->link('page', $paginator->page + 1));
if ($next instanceof Html) {
if ($paginator->isLast()) {
$next->addClass('inactive');
} else {
$next = $link->add($next);
}
$next->title($title);
} else {
$next = $link->setText($title);
}
$container->add($next);
// to-last button
$last = $this->getWrapper('paginator button last');
$title = $this->dataGrid->translate('Last');
$link = clone $a->href($this->dataGrid->link('page', $paginator->pageCount));
if ($last instanceof Html) {
if ($paginator->isLast()) {
$last->addClass('inactive');
} else {
$last = $link->add($last);
}
$last->title($title);
} else {
$last = $link->setText($title);
}
$container->add($last);
// page change submit
$control = $form['pageSubmit']->control;
$control->title = $control->value;
$container->add($control);
unset($first, $prev, $next, $last, $button, $paginator, $link, $a, $form);
return $container->render();
}