/** * handle overview request */ private function handleOverview() { $request = Request::getInstance(); $view = ViewManager::getInstance(); $page = $this->getPage(); $this->pagerUrl->setParameter($view->getUrlId(), $view->getType()); $taglist = $this->plugin->getTagList(array('plugin_type' => NewsLetter::TYPE_ARCHIVE)); if (!$taglist) { return; } $tree = $this->director->tree; $url = new Url(true); $url->setParameter($view->getUrlId(), NewsLetter::VIEW_DETAIL); // link to news tree nodes $treeRef = new NewsLetterTreeRef(); foreach ($taglist as $item) { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setPostfix($item['tag']); $template->setCacheable(true); // check if template is in cache if (!$template->isCached()) { // get settings $settings = $this->getSettings(); $key = array('tree_id' => $item['tree_id'], 'tag' => $item['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('tree_id' => $treeItemList, 'active' => true); if ($detail['online']) { $searchcriteria['archiveonline'] = $detail['online']; } $searchcriteria['archiveoffline'] = $detail['offline'] ? $detail['offline'] : time(); $overview = $this->getNewsLetterOverview(); $list = $overview->getList($searchcriteria, $settings['rows'], $page); foreach ($list['data'] as &$newsLetteritem) { $url->setParameter('id', $newsLetteritem['id']); $newsLetteritem['href_detail'] = $url->getUrl(true); if ($newsLetteritem['thumbnail']) { $img = new Image($newsLetteritem['thumbnail'], $this->plugin->getContentPath(true)); $newsLetteritem['thumbnail'] = array('src' => $this->plugin->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } } $template->setVariable('newsLetter', $list); $template->setVariable('display', $settings['display'], false); } $this->template[$item['tag']] = $template; } }
/** * 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('Newsletter is missing.'); } $id = intval($request->getValue('id')); $template->setVariable('id', $id, false); $key = array('id' => $id); if ($retrieveFields) { $fields = $this->getDetail($key); $fields['online'] = $fields['online'] ? strftime('%Y-%m-%d', $fields['online']) : ''; $fields['offline'] = $fields['offline'] ? strftime('%Y-%m-%d', $fields['offline']) : ''; } 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); // get theme list $themeManager = new ThemeManager(); $searchcriteria = array('active' => true); $themelist = $themeManager->getList($searchcriteria); $template->setVariable('cbo_theme', Utils::getHtmlCombo($themelist['data'], $fields['theme_id'])); $this->handleTreeSettings($template); $datefields = array(); $datefields[] = array('dateField' => 'online', 'triggerElement' => 'online'); $datefields[] = array('dateField' => 'offline', 'triggerElement' => 'offline'); Utils::getDatePicker($this->director->theme, $datefields); // get crop settings $settings = $this->plugin->getSettings(); //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'); $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>'); } $this->template[$this->director->theme->getConfig()->main_tag] = $template; }