/** * handle Theme request */ private function handleMoveGet() { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $request = Request::getInstance(); $view = ViewManager::getInstance(); $view->setType(NewsLetter::VIEW_PLUGIN_MOVE); $objTag = $this->plugin->getObject(NewsLetter::TYPE_TAG); $key = $this->getKey(); $fields = $this->getDetail($key); // plugin is linked to tag if ($fields['type'] == self::TYPE_PLUGIN) { $objPlugin = $this->director->pluginManager->getPluginFromId(array('id' => $fields['plugin_id'])); $fields['plugin_name'] = $objPlugin->getDescription(); } else { $fields['plugin_name'] = self::$types[$fields['type']]; } $template->setVariable($fields); // get all tags $key = array('nl_id' => $key['nl_id']); $taglist = array(); $alltags = $objTag->getTagList($key); foreach ($alltags as $item) { if ($item['type'] == NewsLetterTag::TYPE_PARENT || $item['id'] == $fields['nl_tag']) { continue; } $taglist[] = $item; } $template->setVariable('cbo_tag', Utils::getHtmlCombo($taglist, $request->getValue('newtag'))); $this->handleSettings($template); $this->template[$this->director->theme->getConfig()->main_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' => NewsLetter::TYPE_ARCHIVE)); if (!$taglist) { return; } $taginfo = current($taglist); // process attachments $attachment = $this->plugin->getObject(NewsLetter::TYPE_ATTACHMENT); $attachment->handleHttpGetRequest(); // clear subtitle $view->setName(''); if (!$request->exists('id')) { continue; } $id = intval($request->getValue('id')); $key = array('id' => $id, 'active' => true); $overview = $this->getNewsLetterOverview(); if (!$overview->exists($key)) { throw new HttpException('404'); } $detail = $overview->getDetail($key); // check if tree node of newsLetter item is accessable $tree = $this->director->tree; if (!$tree->exists($detail['tree_id'])) { throw new HttpException('404'); } $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); $template->setVariable('newsLetter', $detail, 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); $this->template[$taginfo['tag']] = $template; }
/** * handle overview request */ private function handleOverviewPost() { $request = Request::getInstance(); $view = ViewManager::getInstance(); // retrieve tags that are linked to this plugin if (!$request->exists('tag')) { throw new Exception('Tag not defined'); } $tag = $request->getValue('tag'); $tree_id = $this->director->tree->getCurrentId(); // get objects $objSettings = $this->plugin->getObject(NewsLetter::TYPE_SETTINGS); $objUser = $this->plugin->getObject(NewsLetter::TYPE_USER); $objGroup = $this->plugin->getObject(NewsLetter::TYPE_GROUP); // get settings $globalSettings = $this->plugin->getSettings(); $settings = array_merge($globalSettings, $objSettings->getSettings($tree_id, $tag)); //$mailfrom = $settings['mailfrom']; try { $values = $request->getRequest(Request::POST); $values['tree_id'] = $tree_id; $values['tag'] = $tag; $ip = $request->getValue('REMOTE_ADDR', Request::SERVER); $values['active'] = true; $values['ip'] = $ip; $values['host'] = gethostbyaddr($ip); $values['client'] = $request->getValue('HTTP_USER_AGENT', Request::SERVER); $values['optin'] = $settings['action'] == NewsLetterSettings::ACTION_OPTIN ? md5(session_id() . time()) : ''; $group = is_array($request->getValue('group')) ? array_keys($request->getValue('group')) : array(); $id = $objUser->insert($values); foreach ($group as $item) { $objUser->addGroup($id, array('id' => $item)); } $settings['optin_key'] = $values['optin']; if ($settings['action']) { $info = array_merge($settings, $values); //add intro / activation text to email $tplContent = $this->composeText($info); $this->sendMail($values['email'], $this->director->getConfig()->email_address, $settings['subject'], $tplContent->fetch(), false); } $location = $settings['ref_tree_id'] ? $this->director->tree->getPath($settings['ref_tree_id']) : '/'; header("Location: {$location}"); exit; } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('newsLetterErrorMessage', $e->getMessage(), false); $this->handleOverviewGet(); } }
private function handleDeletePost() { $request = Request::getInstance(); $values = $request->getRequest(Request::POST); try { $key = $this->getKey(); $this->delete($key); viewManager::getInstance()->setType(NewsLetter::VIEW_PLUGIN_OVERVIEW); $plugin = $this->plugin->getObject(NewsLetter::TYPE_PLUGIN); $plugin->handleHttpGetRequest(); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('errorMessage', $e->getMessage(), false); $this->handleDeleteGet(); } }
private function getNewsLetterTheme($key, $newsLetter, $parameters = NULL) { $objTag = $this->plugin->getObject(NewsLetter::TYPE_TAG); $objPlugin = $this->plugin->getObject(NewsLetter::TYPE_PLUGIN); $objAttachment = $this->plugin->getObject(NewsLetter::TYPE_ATTACHMENT); $pluginManager = $this->director->pluginManager; // use fully qualified paths Director::setAppendDomain(true); $theme = $this->director->themeManager->getThemeFromId(array('id' => $newsLetter['theme_id'])); if (!$theme) { throw new Exception("Theme does not exists. Select theme in Config section first."); } $theme->handlePreProcessing($this->director); $template = $theme->getTemplate(); $template->setVariable($parameters, NULL, false); $pluginlist = $objPlugin->getList($key); foreach ($pluginlist['data'] as $item) { switch ($item['type']) { case NewsLetterPlugin::TYPE_CODE: case NewsLetterPlugin::TYPE_CODE_HEADER: case NewsLetterPlugin::TYPE_CODE_FOOTER: $code = new TemplateEngine($item['text'], false); // buffer dynamic template so variable can be replaced for each user $this->newsLetterTemplate[$item['nl_tag']] = $code; break; case NewsLetterPlugin::TYPE_TEXT: $template->setVariable($item['nl_tag'], $item['text'], false); break; case NewsLetterPlugin::TYPE_PLUGIN: if (!$item['plugin_keys']) { break; } $tmp = $pluginManager->getPluginFromId(array('id' => $item['plugin_id'])); $parameters = array('pluginType' => $item['plugin_type'], 'requestType' => PluginProvider::TYPE_LIST, 'tag' => $item['nl_tag'], 'parameters' => array('keys' => unserialize($item['plugin_keys']))); $this->director->callObjectsImplementing('PluginProvider', 'handlePluginRequest', $parameters); break; } } $this->director->callObjectsImplementing('PluginProvider', 'renderPluginRequest', array($theme)); // buffer replacement templates $this->newsLetterTemplate = array_merge($this->newsLetterTemplate, $objTag->getReplacementTemplates($key, $theme)); return $theme; }