private function handlePluginList($tag, $parameters) { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $request = Request::getInstance(); $view = ViewManager::getInstance(); $searchcriteria = isset($parameters) && array_key_exists('searchcriteria', $parameters) ? $parameters['searchcriteria'] : array(); $keys = isset($parameters) && array_key_exists('keys', $parameters) ? $parameters['keys'] : array(); $searchcriteria['id'] = $keys; $settings = $this->plugin->getSettings(); $template->setVariable('settings', $settings); $systemSite = new SystemSite(); $tree = $systemSite->getTree(); $list = $this->getList($searchcriteria, $pagesize, $page); foreach ($list['data'] as &$item) { //TODO get url from caller plugin (newsletter) to track visits $url = new Url(); $url->setPath($request->getProtocol() . $request->getDomain() . $tree->getPath($item['tree_id'])); $url->setParameter('id', $item['id']); $url->setParameter(ViewManager::URL_KEY_DEFAULT, Calendar::VIEW_DETAIL); $item['href_detail'] = $url->getUrl(true); if ($item['thumbnail']) { $img = new Image($item['thumbnail'], $this->plugin->getContentPath(true)); $item['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } } $template->setVariable('calendar', $list); $this->template[$tag] = $template; }
/** * handle overview request */ private function handleOverview() { $view = ViewManager::getInstance(); $taglist = $this->plugin->getTagList(array('plugin_type' => Calendar::TYPE_HEADLINES)); if (!$taglist) { return; } $tree = $this->director->tree; $url = new Url(true); $url->setParameter($view->getUrlId(), Calendar::VIEW_DETAIL); // link to cal tree nodes $treeRef = new CalendarTreeRef(); foreach ($taglist as $tag) { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setPostfix($tag['tag']); $template->setCacheable(true); // check if template is in cache if (!$template->isCached()) { // get settings $settings = $this->getSettings(); $key = array('tree_id' => $tag['tree_id'], 'tag' => $tag['tag']); $detail = $this->getDetail($key); $treeRefList = $treeRef->getList($key); $treeItemList = array(); foreach ($treeRefList['data'] as $treeRefItem) { if (!$tree->exists($treeRefItem['ref_tree_id'])) { continue; } $treeItemList[] = $treeRefItem['ref_tree_id']; } if (!$treeItemList) { continue; } $searchcriteria = array('activated' => true, 'tree_id' => $treeItemList); $overview = $this->getCalendarOverview(); $list = $overview->getList($searchcriteria, $detail['rows']); // skip if empty if ($list['totalItems'] < 1) { continue; } foreach ($list['data'] as &$item) { $url->setPath($tree->getPath($item['tree_id'])); $url->setParameter('id', $item['id']); $item['href_detail'] = $url->getUrl(true); if ($item['thumbnail']) { $img = new Image($item['thumbnail'], $this->plugin->getContentPath(true)); $item['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } } $template->setVariable('cal', $list); $template->setVariable('name', $detail['name']); $template->setVariable('display', $settings['display_hdl']); } $this->template[$tag['tag']] = $template; } }
/** * 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(array('plugin_type' => Calendar::TYPE_ARCHIVE)); if (!$taglist) { return; } $taginfo = current($taglist); // process attachments $attachment = $this->plugin->getObject(Calendar::TYPE_ATTACHMENT); $attachment->handleHttpGetRequest(); // process images $image = $this->plugin->getObject(Calendar::TYPE_IMAGE); $image->handleHttpGetRequest(); // clear subtitle $view->setName(''); if (!$request->exists('id')) { throw new Exception('Calendar id is missing.'); } $id = intval($request->getValue('id')); $key = array('id' => $id, 'active' => true, 'finished' => true); $overview = $this->plugin->getObject(Calendar::TYPE_DEFAULT); if (!$overview->exists($key)) { return; } $detail = $overview->getDetail($key); // check if tree node of cal item is accessable $tree = $this->director->tree; if (!$tree->exists($detail['tree_id'])) { throw new HttpException('404'); } $objSettings = $this->plugin->getObject(Calendar::TYPE_SETTINGS); $settings = $objSettings->getSettings($detail['tree_id'], $detail['tag']); if ($detail['thumbnail']) { $img = new Image($detail['thumbnail'], $this->plugin->getContentPath(true)); $detail['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } $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(); // update view counter $overview->updateCount($key); // overwrite default naming $template->setVariable('pageTitle', $detail['name'], 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); $template->setVariable('cal', $detail, false); $template->setVariable('settings', $settings); $template->setVariable('calsettings', $settings, false); // get settings if ($settings['comment']) { // process comments $comment = $this->plugin->getObject(Calendar::TYPE_COMMENT); $comment->setSettings($settings); $comment->handleHttpGetRequest(); } $this->template[$taginfo['tag']] = $template; }