X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=classes%2Fplset.php;h=4b08d990e4e87536999f3b6e4e9bab59bdeb0d1b;hb=b39f2e65166eb3d1b6ce180c85b9b809dd689839;hp=648d81460a766fa15b0f965cae3ccb65ef34b874;hpb=d0327f6de73e81c4bcc656471ca4161e4f1e1e1b;p=platal.git diff --git a/classes/plset.php b/classes/plset.php index 648d814..4b08d99 100644 --- a/classes/plset.php +++ b/classes/plset.php @@ -1,6 +1,6 @@ fetchAllAssoc(); $count = XDB::query('SELECT FOUND_ROWS()'); $this->count = intval($count->fetchOneCell()); return $it; @@ -153,7 +154,7 @@ class PlSet return $view; } - public function apply($baseurl, PlatalPage &$page, $view = null, $data = null) + public function apply($baseurl, PlPage &$page, $view = null, $data = null) { $view =& $this->buildView($view, $data); if (is_null($view)) { @@ -163,7 +164,7 @@ class PlSet if (!isset($args['rechercher'])) { $args['rechercher'] = 'Chercher'; } - $page->changeTpl('core/plset.tpl'); + $page->coreTpl('plset.tpl'); $page->assign('plset_base', $baseurl); $page->assign('plset_mods', $this->mods); $page->assign('plset_mod', $this->mod); @@ -181,7 +182,7 @@ class PlSet interface PlView { public function __construct(PlSet &$set, $data, array $params); - public function apply(PlatalPage &$page); + public function apply(PlPage &$page); public function args(); } @@ -199,6 +200,8 @@ abstract class MultipageView implements PlView protected $sortkeys = array(); protected $defaultkey = null; + protected $bound_field = null; + public function __construct(PlSet &$set, $data, array $params) { $this->set =& $set; @@ -222,6 +225,11 @@ abstract class MultipageView implements PlView return null; } + public function bounds() + { + return null; + } + protected function addSortKey($name, array $keys, $desc, $default = false) { $this->sortkeys[$name] = array('keys' => $keys, 'desc' => $desc); @@ -253,22 +261,37 @@ abstract class MultipageView implements PlView abstract public function templateName(); - public function apply(PlatalPage &$page) + public function apply(PlPage &$page) { + $res = $this->set->get($this->fields(), + $this->joins(), + $this->where(), + $this->groupBy(), + $this->order(), + $this->entriesPerPage, + $this->offset); + $show_bounds = $this->bounds(); + $end = end($res); + if ($show_bounds) { + if ($show_bounds == 1) { + $first = $res[0][$this->bound_field]; + $last = $end[$this->bound_field]; + } elseif ($show_bounds == -1) { + $first = $end[$this->bound_field]; + $last = $res[0][$this->bound_field]; + } + $page->assign('first', $first); + $page->assign('last', $last); + } + + $page->assign('show_bounds', $show_bounds); $page->assign('order', Env::v('order', $this->defaultkey)); $page->assign('orders', $this->sortkeys); $page->assign_by_ref('plview', $this); - $page->assign_by_ref('set', - $this->set->get($this->fields(), - $this->joins(), - $this->where(), - $this->groupBy(), - $this->order(), - $this->entriesPerPage, - $this->offset)); + $page->assign_by_ref('set', $res); $count = $this->set->count(); $this->pages = intval(ceil($count / $this->entriesPerPage)); - return 'include/plview.multipage.tpl'; + return PlPage::getCoreTpl('plview.multipage.tpl'); } public function args()