/** * handle tree edit */ private function handleConfigGet($retrieveFields = true) { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $request = Request::getInstance(); $view = ViewManager::getInstance(); $view->setType(Form::VIEW_CONFIG); $key = $this->getKey(); $fields = array(); if ($retrieveFields) { if ($this->exists($key)) { $fields = $this->getDetail($key); } else { $fields = array_merge($this->getFields(SqlParser::MOD_INSERT), $this->plugin->getGlobalSettings()); } } else { $fields = $this->getFields(SqlParser::MOD_UPDATE); } // get all tree nodes which have plugin modules $site = new SystemSite(); $tree = $site->getTree(); $treelist = $tree->getList(); foreach ($treelist as &$item) { $item['name'] = $tree->toString($item['id'], '/', 'name'); } $template->setVariable('cbo_tree_id', Utils::getHtmlCombo($treelist, $fields['ref_tree_id'])); $template->setVariable('cbo_optin_tree_id', Utils::getHtmlCombo($treelist, $fields['optin_tree_id'])); // get action type $template->setVariable('cbo_action', Utils::getHtmlCombo($this->plugin->actionList, $fields['action'], '...')); $this->setFields($fields); $template->setVariable($fields); $template->setVariable($key); // add breadcrumb item $this->director->theme->handleAdminLinks($template); $this->template[$this->director->theme->getConfig()->main_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('tree_id')) { throw new Exception('Node ontbreekt.'); } if (!$request->exists('tag')) { throw new Exception('Tag ontbreekt.'); } $tree_id = intval($request->getValue('tree_id')); $tag = $request->getValue('tag'); $key = array('tree_id' => $tree_id, 'tag' => $tag); $fields = array(); if ($retrieveFields) { $fields = $this->exists($key) ? $this->getDetail($key) : $this->getFields(SqlParser::MOD_INSERT); } else { $fields = $this->getFields(SqlParser::MOD_UPDATE); } // get all tree nodes which have plugin modules $site = new SystemSite(); $tree = $site->getTree(); $treelist = $tree->getList($tree_id); foreach ($treelist as &$item) { $item['name'] = $tree->toString($item['id'], '/', 'name'); } $template->setVariable('cbo_tree_id', Utils::getHtmlCombo($treelist, $fields['ref_tree_id'])); $this->setFields($fields); $template->setVariable($this->getFields(SqlParser::MOD_UPDATE), NULL, false); $template->setVariable('tree_id', $tree_id, false); $template->setVariable('tag', $tag, false); $this->template[$this->director->theme->getConfig()->main_tag] = $template; }
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 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('Link is missing.'); } $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->getContentPath(true)); $fields['image'] = array('src' => $this->getContentPath(false) . $img->getFileName(false), 'width' => $img->getWidth(), 'height' => $img->getHeight()); } $template->setVariable($fields, NULL, false); $this->handleTreeSettings($template); $template->setVariable('fckBox', $this->getEditor($fields['text']), false); // get all tree nodes which have plugin modules $site = new SystemSite(); $tree = $site->getTree(); $treelist = $tree->getList(); foreach ($treelist as &$item) { $item['name'] = $tree->toString($item['id'], '/', 'name'); } $template->setVariable('cbo_tree_id', Utils::getHtmlCombo($treelist, $fields['ref_tree_id'], '...')); // get crop settings $settings = $this->plugin->getObject(Links::TYPE_SETTINGS)->getSettings($fields['tag'], $fields['tree_id']); //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, NULL, false); $parseFile->setVariable('imgTag', 'imgsrc', false); $parseFile->setVariable($settings, NULL, false); $parseFile->setSource($this->getHtdocsPath(true) . "js/cropinit.js.in"); //$parseFile->setDestination($this->getCachePath(true)."cropinit_tpl_content.js"); //$parseFile->save(); $theme->addJavascript($parseFile->fetch()); //$this->headers[] = '<script type="text/javascript" src="'.$this->getCachePath().'cropinit_tpl_content.js"></script>'; $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; }
/** * handle settings edit */ private function handleSettingsGet($retrieveFields = true) { viewManager::getInstance()->setType(self::VIEW_CONFIG); $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $request = Request::getInstance(); $view = ViewManager::getInstance(); if (!$request->exists('tree_id')) { throw new Exception('Node ontbreekt.'); } if (!$request->exists('tag')) { throw new Exception('Tag ontbreekt.'); } $tree_id = intval($request->getValue('tree_id')); $tag = $request->getValue('tag'); $key = array('tree_id' => $tree_id, 'tag' => $tag); $fields = array(); if ($retrieveFields) { $fields = $this->exists($key) ? $this->getDetail($key) : $this->getFields(SqlParser::MOD_INSERT); } else { $fields = $this->getFields(SqlParser::MOD_UPDATE); } $fields['tree_id'] = $tree_id; $fields['tag'] = $tag; $this->setFields($fields); $template->setVariable($fields); // get all tree nodes which have plugin modules $site = new SystemSite(); $tree = $site->getTree(); $treelist = $tree->getList(); foreach ($treelist as &$item) { $item['name'] = $tree->toString($item['id'], '/', 'name'); } $template->setVariable('cbo_tree_id', Utils::getHtmlCombo($treelist, $fields['ref_tree_id'])); $template->setVariable('cbo_optin_tree_id', Utils::getHtmlCombo($treelist, $fields['optin_tree_id'])); // get action type $template->setVariable('cbo_action', Utils::getHtmlCombo($this->actionList, $fields['action'], '...')); // add breadcrumb item $this->director->theme->handleAdminLinks($template); $this->template[$this->director->theme->getConfig()->main_tag] = $template; }
private function handlePreviewPost() { $request = Request::getInstance(); try { if (!$request->exists('nl_id')) { throw new Exception(__CLASS__ . "::" . __FUNCTION__ . " : nl_id parameter is missing"); } $key = array('id' => $request->getValue('nl_id')); $sendmail = $request->exists('send'); $email = $request->getValue('email'); if ($sendmail && !Utils::isEmail($email)) { throw new Exception("Invalid email address specified"); } if (!$this->exists($key)) { throw new HttpException('404'); } $detail = $this->getDetail($key); $user = array('gender_description' => NewsLetterUser::getGenderTypeDesc(NewsLetterUser::GENDER_MALE), 'name' => 'Test Recipient', 'email' => $email ? $email : $this->director->getConfig()->email_address); $systemSite = new SystemSite(); $tree = $systemSite->getTree(); $url_unsubscribe = new Url(); $url_unsubscribe->setPath($request->getProtocol() . $request->getDomain() . $tree->getPath($detail['tree_id'])); $url_unsubscribe->setParameter(ViewManager::URL_KEY_DEFAULT, NewsLetter::VIEW_USER_UNSUBSCRIBE); $url_unsubscribe->setParameter(NewsLetterUser::KEY_UNSUBSCRIBE, $user['email']); $parameters = array('user' => $user, 'href_unsubscribe' => $url_unsubscribe->getUrl(true)); $key = array('nl_id' => $key['id'], 'activated' => true); $theme = $this->getNewsLetterTheme($key, $detail); $this->handleThemePostProcessing($theme, $parameters); $content = $theme->fetchTheme(); if ($sendmail) { $objAttachment = $this->plugin->getObject(NewsLetter::TYPE_ATTACHMENT); $attachments = $objAttachment->getAttachmentList($key); $this->sendMail(array($email), $this->director->getConfig()->email_address, $detail['name'], $content, $attachments); // reset theme settings $this->director->theme->handlePreProcessing($this->director); $view = ViewManager::getInstance(); $view->setType(ViewManager::TREE_OVERVIEW); $this->handleHttpGetRequest(); } else { echo $content; exit; } } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handlePreviewGet(); } }