/** * handle detail request */ private function handleDetail() { $request = Request::getInstance(); $view = ViewManager::getInstance(); // it makes no sense to have multiple tags for this plugin. // if someone did it, you get strange results and he probably can figure out why.. no multiple detail stuff in 1 page supported! // so take a shot and get the first tag to set the content $taglist = $this->plugin->getTagList(); if (!$taglist) { return; } $taginfo = current($taglist); // clear subtitle $view->setName(''); if (!$request->exists('id')) { continue; } $id = intval($request->getValue('id')); $key = array('id' => $id, 'active' => true); $overview = $this->getPollOverview(); if (!$overview->exists($key)) { throw new HttpException('404'); } $detail = $overview->getDetail($key); // check if tree node of poll item is accessable $tree = $this->director->tree; if (!$tree->exists($detail['tree_id'])) { throw new HttpException('404'); } $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setPostfix($detail['tag']); // disable cache because we want to count visits $template->setCacheable(false); Cache::disableCache(); // overwrite default naming $template->setVariable('pageTitle', $detail['name'], false); $template->setVariable('poll', $detail, false); $url = new Url(true); $url->clearParameter('id'); $url->setParameter($view->getUrlId(), ViewManager::OVERVIEW); $template->setVariable('href_back', $url->getUrl(true), false); $breadcrumb = array('name' => $detail['name'], 'path' => $url->getUrl(true)); $this->director->theme->addBreadcrumb($breadcrumb); $this->template[$taginfo['tag']] = $template; }
/** * handle overview request */ private function handleOverview() { $request = Request::getInstance(); $view = ViewManager::getInstance(); // retrieve tags that are linked to this plugin $taglist = $this->plugin->getTagList(); if (!$taglist) { return; } $url = new Url(true); $url->setParameter($view->getUrlId(), Poll::VIEW_DETAIL); Cache::disableCache(); foreach ($taglist as $tag) { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); //$template->setPostfix($tag['tag']); $template->setCacheable(false); // check if template is in cache if (!$template->isCached()) { // get settings $settings = array_merge($this->getPollSettings()->getSettings($tag['tag'], $tag['tree_id']), $this->plugin->getSettings()); $template->setVariable('settings', $settings); $searchcriteria = array('tree_id' => $tag['tree_id'], 'tag' => $tag['tag'], 'activated' => true); if (!$this->exists($searchcriteria)) { continue; } $poll = $this->getDetail($searchcriteria); $searchcriteria['poll_id'] = $poll['id']; $voted = $this->hasVoted($poll['id']); $template->setVariable('voted', $voted); $template->setVariable('poll', $poll); $itemlist = $this->getPollResult($poll['id'], $tag['tag'], $settings, $voted); $template->setVariable('tpl_poll_result', $itemlist); } $this->template[$tag['tag']] = $template; } }