/** * handle tree edit */ private function handleTreeEditGet($retrieveFields = true) { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $request = Request::getInstance(); $view = ViewManager::getInstance(); $view->setType(ViewManager::TREE_EDIT); if (!$request->exists('id')) { throw new Exception('Galerij ontbreekt.'); } $id = intval($request->getValue('id')); $template->setVariable('id', $id, false); $key = array('id' => $id); if ($retrieveFields) { $fields = $this->getDetail($key); } else { $fields = $this->getFields(SqlParser::MOD_UPDATE); $detail = $this->getDetail($key); $fields['image'] = $detail['image']; } $this->setFields($fields); if ($fields['image']) { $img = new Image($fields['image'], $this->plugin->getContentPath(true)); $fields['image'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } $template->setVariable($fields); $this->handleTreeSettings($template); // get crop settings $settings = $this->getSettings($fields['tree_id'], $fields['tag']); //only crop if both width and height defaults are set if ($fields['image'] && $settings['image_width'] && $settings['image_height'] && $fields['image']['width'] > $settings['image_width'] && $fields['image']['height'] > $settings['image_height']) { $theme = $this->director->theme; $parseFile = new ParseFile(); $parseFile->setVariable($fields); $parseFile->setVariable('imgTag', 'imgsrc', false); $parseFile->setVariable($settings); $parseFile->setSource($this->plugin->getHtdocsPath(true) . "js/cropinit.js.in"); //$parseFile->setDestination($this->plugin->getCachePath(true)."cropinit_tpl_content.js"); //$parseFile->save(); $theme->addJavascript($parseFile->fetch()); $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/cropper.js"></script>'); $theme->addHeader('<script type="text/javascript" src="' . DIF_VIRTUAL_WEB_ROOT . 'js/mint.js"></script>'); //$theme->addHeader('<script type="text/javascript" src="'.$this->plugin->getCachePath().'cropinit_tpl_content.js"></script>'); } $this->template[$this->director->theme->getConfig()->main_tag] = $template; }
/** * 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; } }