/** * handle overview request */ private function handleOverview() { $view = ViewManager::getInstance(); $taglist = $this->plugin->getTagList(array('plugin_type' => Gallery::TYPE_HEADLINES)); if (!$taglist) { return; } $tree = $this->director->tree; $url = new Url(true); //$url->setParameter($view->getUrlId(), Gallery::VIEW_DETAIL); // link to gallery tree nodes $treeRef = new GalleryTreeRef(); foreach ($taglist as $tag) { $key = array('tree_id' => $tag['tree_id'], 'tag' => $tag['tag']); $detail = $this->getDetail($key); $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setPostfix($tag['tag']); $cacheable = $detail['display_order'] != Gallery::ORDER_RANDOM; $template->setCacheable($cacheable); if (!$cacheable) { Cache::disableCache(); } $template->setVariable($detail); // include lightbox if needed if ($detail['display'] == self::DISP_LIGHTBOX) { $theme = $this->director->theme; $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/prototype.js"></script>'); $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/scriptaculous.js"></script>'); $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/lightbox.js"></script>'); $theme->addHeader('<link rel="stylesheet" href="' . DIF_VIRTUAL_WEB_ROOT . 'css/lightbox.css" type="text/css" media="screen" />'); } // check if template is in cache if (!$template->isCached()) { // get settings $settings = $this->getSettings(); $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->getGalleryOverview(); $list = $overview->getList($searchcriteria, $detail['rows'], 1, $detail['display_order']); // skip if empty if ($list['totalItems'] < 1) { continue; } foreach ($list['data'] as &$item) { $url->setPath($tree->getPath($item['tree_id'])); // go to detail if requested if ($detail['display'] == self::DISP_DETAIL) { $url->setParameter('id', $item['id']); } $item['href_detail'] = $url->getUrl(true); if ($item['image']) { $img = new Image($item['image'], $this->plugin->getContentPath(true)); $item['image'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } 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('gallery', $list); } $this->template[$tag['tag']] = $template; } }
/** * handle overview request */ private function handleOverview() { $request = Request::getInstance(); $view = ViewManager::getInstance(); $page = $this->getPage(); $this->pagerUrl->setParameter($view->getUrlId(), $view->getType()); // retrieve tags that are linked to this plugin $taglist = $this->plugin->getTagList(array('plugin_type' => Gallery::TYPE_DEFAULT)); if (!$taglist) { return; } $url = new Url(true); $url->setParameter($view->getUrlId(), Gallery::VIEW_DETAIL); $htdocsPathAbs = $this->plugin->getContentPath(true); $htdocsPath = $this->plugin->getContentPath(false); foreach ($taglist as $tag) { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setPostfix($tag['tag']); $template->setCacheable(true); // get settings $settings = $this->getSettings($tag['tree_id'], $tag['tag']); $this->handleDisplaySettings($settings['display']); $template->setVariable('settings', $settings); // check if template is in cache if (!$template->isCached()) { $pagesize = $settings['rows']; $searchcriteria = array('tree_id' => $tag['tree_id'], 'tag' => $tag['tag'], 'activated' => true); $imageSelect = array(); $list = $this->getList($searchcriteria, $pagesize, $page); foreach ($list['data'] as &$item) { $imageSelect[] = $item['id']; $url->setParameter('id', $item['id']); $item['href_detail'] = $url->getUrl(true); if ($item['image']) { $img = new Image($item['image'], $htdocsPathAbs); $item['image'] = array('src' => $htdocsPath . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } if ($item['thumbnail']) { $img = new Image($item['thumbnail'], $htdocsPathAbs); $item['thumbnail'] = array('src' => $htdocsPath . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } } if ($settings['display'] == Gallery::DISP_LIGHTBOX) { // retrieve all images for lightbox $all = $this->getList($searchcriteria); $pregallery = array(); $postgallery = array(); $pre = true; foreach ($all['data'] as $allImg) { if (in_array($allImg['id'], $imageSelect)) { // image is in selection, skip image and change array to post $pre = false; continue; } if ($allImg['image']) { $img = new Image($allImg['image'], $htdocsPathAbs); $allImg['image'] = array('src' => $htdocsPath . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } // add to right array $pre ? $pregallery[] = $allImg : ($postgallery[] = $allImg); } $template->setVariable('pregallery', $pregallery); $template->setVariable('postgallery', $postgallery); } $template->setVariable('gallery', $list); $template->setVariable('display', $settings['display'], false); } $this->template[$tag['tag']] = $template; } }