/** * Index action method * * @return void */ public function index() { $slug = substr($this->request->getRequestUri(), 5); if ($slug != '') { $tag = new Model\Tag(); $tag->getBySlug($slug, $this->application->modules()); if (isset($tag->id)) { if (count($tag->items) > $this->config->pagination) { $page = $this->request->getQuery('page'); $limit = $this->config->pagination; $pages = new Paginator(count($tag->items), $limit); $pages->useInput(true); $offset = null !== $page && (int) $page > 1 ? $page * $limit - $limit : 0; $tag->items = array_slice($tag->items, $offset, $limit, true); } else { $pages = null; } $this->prepareView('tags-public/tag.phtml'); $this->template = 'tag.phtml'; $this->view->title = 'Tag : ' . $tag->title; $this->view->tag_id = $tag->id; $this->view->tag_title = $tag->title; $this->view->tag_slug = $tag->slug; $this->view->pages = $pages; $this->view->merge($tag->toArray()); $this->send(); } else { $this->error(); } } else { $this->redirect(BASE_PATH == '' ? '/' : BASE_PATH); } }
/** * Remove action method * * @return void */ public function remove() { if ($this->request->isPost()) { $tag = new Model\Tag(); $tag->remove($this->request->getPost()); } $this->sess->setRequestValue('removed', true); $this->redirect(BASE_PATH . APP_URI . '/tags'); }