/** * @param array $config */ static function initialize($config = array()) { foreach ($config as $key => $value) { self::${$key} = $value; } CMS::$page_navigator = new ReflectionMethod('CMS_PageNavigator', 'run'); }
/** * @param int $pagenum * * @return WebKit_Views_TemplateView */ public function page($pagenum) { $pagenum = (int) $pagenum; if ($pagenum < 1) { $page_num = 1; } $count = $this->count_all(); $numpages = $count / $this->perpage; if (floor($numpages) != $numpages) { $numpages = floor($numpages) + 1; } if ($numpages < 1 || $pagenum > $numpages) { $numpages = 1; } if ($pagenum < 1 || $pagenum > $numpages) { return $this->page_not_found(); } $rows = $this->select_all(($pagenum - 1) * $this->perpage, $this->perpage); return $this->render_list($this->template_list, array('pagenum' => $pagenum, 'numpages' => $numpages, 'count' => $count, 'rows' => $rows, 'page_navigator' => CMS::page_navigator($pagenum, $numpages, $this->page_url('%')))); }
protected function page_navigator($page_num, $num_pages, $tpl) { return CMS::page_navigator($page_num, $num_pages, $tpl); }
protected function action_list() { $fform = $this->create_filters_form(); $this->on_before_list(); $rows = $this->get_rows(); $form = false; if ($this->access_massupdate()) { $form = $this->massupdate_form($rows); if ($form) { if ($this->env->request->method_code == Net_HTTP::POST) { if ($form->process($this->env->request)) { foreach (explode(',', $form['ids']) as $id) { $id = trim($id); if ($id != '') { $item = $this->load($id); if ($this->access_edit($item)) { foreach ($this->massupdate_fields as $field => $data) { $name = "{$field}{$id}"; $type = CMS_Fields::type($data); $obj = new ArrayObject(); $type->assign_to_object($form, $obj, $name, $data); $item->{$field} = $obj[$name]; } $this->update($item); } } } Events::call('admin.change'); } return $this->redirect_to($this->action_url('list', $this->page)); } } } $page_navigator = false; if ($this->numpages > 1) { $page_navigator = CMS::page_navigator($this->page, $this->numpages, array($this, 'list_url')); } $filters_buttons = array(); foreach ($this->filters_buttons() as $caption => $url) { $url = trim($url); if ($caption[0] != '*') { if ($m = Core_Regexps::match_with_results('{^(\\w+)=(.+)$}', $url)) { $name = trim($m[1]); $value = trim($m[2]); if (isset($_GET[$name]) && $_GET[$name] == $value) { $caption = "*{$caption}"; } } if ($m = Core_Regexps::match_with_results('{\\{(.+)\\}}', $url)) { $cond = trim($m[1]); if ($cond != '' && $cond[0] == '!') { $cond = substr($cond, 1); if (!isset($_GET[$cond])) { $caption = "*{$caption}"; } } } } $url = preg_replace('{\\{.+\\}}', '', $url); if ($url == '' || $url[0] != '/' && !Core_Regexps::match('{^http:}', $url)) { $url = $this->action_url('list', 1, $url); } $filters_buttons[$caption] = $url; } $filters_form_fields = $this->prepare_filter_forms(); if ($this->add_in_list && $this->access_add()) { $this->create_form($this->action_url('add', $this->page), 'add'); $item = $this->new_object(); $this->item_to_form($item); } return $this->render_list(array('title' => $this->title_list(), 'form' => $this->add_in_list ? $this->form : null, 'form_fields' => $this->add_in_list ? $this->filtered_form_fields : null, 'submit_text' => $this->submit_add(), 'count' => $this->count, 'rows' => $rows, 'list_fields' => $this->list_fields(), 'list_style' => $this->list_style(), 'message_norows' => $this->message_norows(), 'can_add' => $this->access_add(), 'add_url' => $this->action_url('add', $this->page), 'add_button_caption' => $this->button_add(), 'massupdate_form' => $form, 'massupdate_fields' => $this->massupdate_fields, 'massupdate_submit_text' => $this->submit_massupdate(), 'page_navigator' => $page_navigator, 'filters_buttons' => $filters_buttons, 'filters_form' => $fform, 'filters_form_fields' => $filters_form_fields, 'sort' => $this->sort, 'sort_direction' => $this->sort_direction)); }