/** * handle add */ public function addComment($values) { $request = Request::getInstance(); $view = ViewManager::getInstance(); $values['active'] = 1; try { $id = $this->insert($values); $calendar = $this->plugin->getObject(Calendar::TYPE_DEFAULT); $calendarDetail = $calendar->getDetail(array('id' => $values['cal_id'])); $url = new Url(); $url->setPath($this->director->tree->getPath($calendarDetail['tree_id'])); $url->setParameter('id', $calendarDetail['id']); $url->setParameter($view->getUrlId(), Calendar::VIEW_DETAIL); // notify insert $ip = $request->getValue('REMOTE_ADDR', Request::SERVER); $template = new TemplateEngine($this->getPath() . "templates/calendarcommentemail.tpl"); $template->setVariable($values); $template->setVariable('calendarName', $calendarDetail['name']); $template->setVariable('href_detail', $url->getUrl()); $template->setVariable('siteTitle', $this->director->tree->getTreeName()); $template->setVariable('domain', $request->getDomain()); $template->setVariable('protocol', $request->getProtocol()); $template->setVariable('ip', $ip); $template->setVariable('host', gethostbyaddr($ip)); $template->setVariable('client', $request->getValue('HTTP_USER_AGENT', Request::SERVER)); $this->director->systemUser->notify($calendarDetail['tree_id'], 'Comment added at ' . $request->getDomain(), $template->fetch()); } catch (Exception $e) { $template = new TemplateEngine(); $template->setVariable('commentError', $e->getMessage(), false); $template->setVariable('cmtValues', $values, false); } }
/** * 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; } }
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; }
/** * renders tree into menu template * @return object */ public function renderTree() { $template = new TemplateEngine($this->getPath() . "templates/menu.tpl"); $menu = $this->tree->getList(); //print_r($menu); // get selected main menu item //$firstNode = $this->tree->getFirstAncestorNode($this->tree->getCurrentId()); //$firstId = ($firstNode) ? $firstNode['id'] : 0; $request = Request::getInstance(); $view = ViewManager::getInstance(); if (($id = intval($request->getValue('tree_id', Request::GET))) < 1) { $id = $this->tree->getFirstNodeId(); } $parent = $this->tree->getParentId($id); $tree = $this->director->tree; $url = new Url(); $url->setPath($tree->getPath($tree->getCurrentId())); //$url->setPath($request->getPath()); $url->setParameter($view->getUrlId(), ViewManager::ADMIN_OVERVIEW); $template->setVariable('current_node', $this->getMenuId(), false); // add root node $siteGroup = $this->getSiteGroup(); $rootId = $this->tree->getRootId(); $parentRootId = $rootId - 1; $this->fileVars['parentRootId'] = $parentRootId; $template->setVariable('parentRootId', $parentRootId, false); $template->setVariable('rootId', $rootId, false); $rootnode = array('id' => $rootId, 'parent' => $parentRootId, 'name' => sprintf("%s (%s)", $this->tree->getTreeName(), $siteGroup->getLanguage($siteGroup->getCurrentId())), 'active' => 1, 'visible' => 1, 'activated' => 1); array_unshift($menu, $rootnode); foreach ($menu as &$item) { $url->setParameter('tree_id', $item['id']); $item['href_overview'] = $url->getUrl(true); $item['name'] = addslashes($item['name']); } $template->setVariable('sitemenu', $menu, false); return $template; }
/** * Add a service to the result list. In order to allow several items * of the same type (f.ex. rss feeds) every item is pushed on the * stack with a key for the service id and a key for the data. * * NOTE: This may change very soon * * @param string $service The service key (one of KnownServices::*) * @param array $data The data relating to the service. */ protected function addService($service, $data) { if (!isset($this->_services[$service])) { $this->_services[$service] = array(); } if (!preg_match('/^http[s]?:\\/\\//i', $data['url'])) { $u = new Url($this->_url); $u->setPath($data['url']); $data['url'] = $u->getUrl(); } $this->_services[$service][] = $data; }
/** * Request/URL factory. * @param PresenterComponent base * @param string destination in format "[[module:]presenter:]action" or "signal!" or "this" * @param array array of arguments * @param string forward|redirect|link * @return string URL * @throws InvalidLinkException * @internal */ protected final function createRequest($component, $destination, array $args, $mode) { // note: createRequest supposes that saveState(), run() & tryCall() behaviour is final // cached services for better performance static $presenterFactory, $router, $refUrl; if ($presenterFactory === NULL) { $presenterFactory = $this->getApplication()->getPresenterFactory(); $router = $this->getApplication()->getRouter(); $refUrl = new Url($this->getHttpRequest()->getUrl()); $refUrl->setPath($this->getHttpRequest()->getUrl()->getScriptPath()); } $this->lastCreatedRequest = $this->lastCreatedRequestFlag = NULL; // PARSE DESTINATION // 1) fragment $a = strpos($destination, '#'); if ($a === FALSE) { $fragment = ''; } else { $fragment = substr($destination, $a); $destination = substr($destination, 0, $a); } // 2) ?query syntax $a = strpos($destination, '?'); if ($a !== FALSE) { parse_str(substr($destination, $a + 1), $args); // requires disabled magic quotes $destination = substr($destination, 0, $a); } // 3) URL scheme $a = strpos($destination, '//'); if ($a === FALSE) { $scheme = FALSE; } else { $scheme = substr($destination, 0, $a); $destination = substr($destination, $a + 2); } // 4) signal or empty if (!$component instanceof Presenter || substr($destination, -1) === '!') { $signal = rtrim($destination, '!'); $a = strrpos($signal, ':'); if ($a !== FALSE) { $component = $component->getComponent(strtr(substr($signal, 0, $a), ':', '-')); $signal = (string) substr($signal, $a + 1); } if ($signal == NULL) { // intentionally == throw new InvalidLinkException("Signal must be non-empty string."); } $destination = 'this'; } if ($destination == NULL) { // intentionally == throw new InvalidLinkException("Destination must be non-empty string."); } // 5) presenter: action $current = FALSE; $a = strrpos($destination, ':'); if ($a === FALSE) { $action = $destination === 'this' ? $this->action : $destination; $presenter = $this->getName(); $presenterClass = get_class($this); } else { $action = (string) substr($destination, $a + 1); if ($destination[0] === ':') { // absolute if ($a < 2) { throw new InvalidLinkException("Missing presenter name in '{$destination}'."); } $presenter = substr($destination, 1, $a - 1); } else { // relative $presenter = $this->getName(); $b = strrpos($presenter, ':'); if ($b === FALSE) { // no module $presenter = substr($destination, 0, $a); } else { // with module $presenter = substr($presenter, 0, $b + 1) . substr($destination, 0, $a); } } try { $presenterClass = $presenterFactory->getPresenterClass($presenter); } catch (InvalidPresenterException $e) { throw new InvalidLinkException($e->getMessage(), NULL, $e); } } // PROCESS SIGNAL ARGUMENTS if (isset($signal)) { // $component must be IStatePersistent $reflection = new PresenterComponentReflection(get_class($component)); if ($signal === 'this') { // means "no signal" $signal = ''; if (array_key_exists(0, $args)) { throw new InvalidLinkException("Unable to pass parameters to 'this!' signal."); } } elseif (strpos($signal, self::NAME_SEPARATOR) === FALSE) { // TODO: AppForm exception // counterpart of signalReceived() & tryCall() $method = $component->formatSignalMethod($signal); if (!$reflection->hasCallableMethod($method)) { throw new InvalidLinkException("Unknown signal '{$signal}', missing handler {$reflection->name}::{$method}()"); } if ($args) { // convert indexed parameters to named self::argsToParams(get_class($component), $method, $args); } } // counterpart of IStatePersistent if ($args && array_intersect_key($args, $reflection->getPersistentParams())) { $component->saveState($args); } if ($args && $component !== $this) { $prefix = $component->getUniqueId() . self::NAME_SEPARATOR; foreach ($args as $key => $val) { unset($args[$key]); $args[$prefix . $key] = $val; } } } // PROCESS ARGUMENTS if (is_subclass_of($presenterClass, __CLASS__)) { if ($action === '') { $action = self::DEFAULT_ACTION; } $current = ($action === '*' || strcasecmp($action, $this->action) === 0) && $presenterClass === get_class($this); // TODO $reflection = new PresenterComponentReflection($presenterClass); if ($args || $destination === 'this') { // counterpart of run() & tryCall() $method = call_user_func(array($presenterClass, 'formatActionMethod'), $action); if (!$reflection->hasCallableMethod($method)) { $method = call_user_func(array($presenterClass, 'formatRenderMethod'), $action); if (!$reflection->hasCallableMethod($method)) { $method = NULL; } } // convert indexed parameters to named if ($method === NULL) { if (array_key_exists(0, $args)) { throw new InvalidLinkException("Unable to pass parameters to action '{$presenter}:{$action}', missing corresponding method."); } } elseif ($destination === 'this') { self::argsToParams($presenterClass, $method, $args, $this->params); } else { self::argsToParams($presenterClass, $method, $args); } } // counterpart of IStatePersistent if ($args && array_intersect_key($args, $reflection->getPersistentParams())) { $this->saveState($args, $reflection); } if ($mode === 'redirect') { $this->saveGlobalState(); } $globalState = $this->getGlobalState($destination === 'this' ? NULL : $presenterClass); if ($current && $args) { $tmp = $globalState + $this->params; foreach ($args as $key => $val) { if (http_build_query(array($val)) !== (isset($tmp[$key]) ? http_build_query(array($tmp[$key])) : '')) { $current = FALSE; break; } } } $args += $globalState; } // ADD ACTION & SIGNAL & FLASH $args[self::ACTION_KEY] = $action; if (!empty($signal)) { $args[self::SIGNAL_KEY] = $component->getParameterId($signal); $current = $current && $args[self::SIGNAL_KEY] === $this->getParameter(self::SIGNAL_KEY); } if (($mode === 'redirect' || $mode === 'forward') && $this->hasFlashSession()) { $args[self::FLASH_KEY] = $this->getParameter(self::FLASH_KEY); } $this->lastCreatedRequest = new PresenterRequest($presenter, PresenterRequest::FORWARD, $args, array(), array()); $this->lastCreatedRequestFlag = array('current' => $current); if ($mode === 'forward') { return; } // CONSTRUCT URL $url = $router->constructUrl($this->lastCreatedRequest, $refUrl); if ($url === NULL) { unset($args[self::ACTION_KEY]); $params = urldecode(http_build_query($args, NULL, ', ')); throw new InvalidLinkException("No route for {$presenter}:{$action}({$params})"); } // make URL relative if possible if ($mode === 'link' && $scheme === FALSE && !$this->absoluteUrls) { $hostUrl = $refUrl->getHostUrl(); if (strncmp($url, $hostUrl, strlen($hostUrl)) === 0) { $url = substr($url, strlen($hostUrl)); } } return $url . $fragment; }
public function formatLink(Url $url) { // save and reset query to save variable order $query = $url->getQuery(); $url->setQuery([]); // extract path to separate params and remove actions $parts = explode(self::REWRITE_PARAM_TO_ACTION_DELIMITER, $url->getPath()); foreach ($parts as $part) { // only extract "normal" parameters, avoid actions if (strpos($part, '-action') === false) { $paths = explode('/', strip_tags($part)); array_shift($paths); // create key => value pairs from the current request $x = 0; while ($x <= count($paths) - 1) { if (isset($paths[$x + 1])) { $url->setQueryParameter($paths[$x], $paths[$x + 1]); } // increment by 2, because the next offset is the key! $x = $x + 2; } } } // reset the path to not have duplicate path due to generic param generation $url->setPath(null); // merge query now to overwrite values already contained in the url $url->mergeQuery($query); $resultUrl = $this->getFormattedBaseUrl($url); $query = $url->getQuery(); if (count($query) > 0) { // get URL mappings and try to resolve mapped actions $mappings = $this->getActionUrMappingTokens(); foreach ($query as $name => $value) { // allow empty params that are action definitions to not // exclude actions with no params! if (!$this->isValueEmpty($value) || $this->isValueEmpty($value) && strpos($name, '-action') !== false || $this->isValueEmpty($value) && in_array($name, $mappings) !== false) { if (strpos($name, '-action') === false && in_array($name, $mappings) === false) { $resultUrl .= '/' . $name . '/' . $value; } else { // action blocks must be separated with group indicator // to be able to parse the parameters $resultUrl .= self::REWRITE_PARAM_TO_ACTION_DELIMITER . $name; // check whether value is empty and append action only if (!$this->isValueEmpty($value)) { $resultUrl .= '/' . $value; } } } } } // apply query to detect duplicate action definitions $actions = $this->getActionsUrlRepresentation($query, true); if (!empty($actions)) { $resultUrl .= self::REWRITE_PARAM_TO_ACTION_DELIMITER . $actions; } // encode blanks if desired if ($this->getEncodeBlanks() === true) { $resultUrl = strtr($resultUrl, [' ' => '%20']); } return $this->sanitizeUrl($this->appendAnchor($resultUrl, $url)); }
/** @return full url to core_dev root */ function getCoreDevUrl() { $t = new Url($this->getUrl()); $t->setPath($this->getRelativeCoreDevUrl()); return $t->get(); }
/** * handle overview request */ private function handleOverview() { $taglist = $this->getTagList(); if (!$taglist) { return; } $tree = $this->director->tree; foreach ($taglist as $item) { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setCacheable(true); $template->setPostfix($item['tag']); $key = array('tree_id' => $item['tree_id'], 'tag' => $item['tag']); // check if template is in cache if (!$template->isCached()) { $siteGroup = $this->getSiteGroup(); $id = $siteGroup->getCurrentId(); $detail = $this->exists($key) ? $this->getDetail($key) : $this->getFields(SqlParser::MOD_INSERT); $template->setVariable('detail', $detail); $url = new Url(); $url->setPath('/'); $grouplist = $siteGroup->getList(array('active' => true)); if ($grouplist['totalItems'] < 2) { continue; } foreach ($grouplist['data'] as &$list) { $url->setParameter(SystemSiteGroup::CURRENT_ID_KEY, $list['id']); $list['path'] = $url->getUrl(true); $list['selected'] = $list['id'] == $id; $list['img'] = $this->getImage($list['language']); } $template->setVariable('sitegroup', $grouplist, false); $template->setVariable('sitegroupId', $id); } $this->template[$item['tag']] = $template; } }
private function getDetailUrl($id, $tree_id, $tag, $htmlentities = true) { $view = ViewManager::getInstance(); $request = Request::getInstance(); $tree = $this->director->tree; $url_banner = new Url(); //$url_banner->useCurrent(false); $url_banner->setPath($tree->getPath($tree_id)); $url_banner->setParameter($view->getUrlId(), self::VIEW_BANNER); $url_banner->setParameter('id', $id); $url_banner->setParameter('tag', $tag); $url_banner->setParameter('tree_id', $tree_id); return $url_banner->getUrl($htmlentities); }
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(); } }
/** * Get the url relative to another url or two predefined formats. * * @param string|Url $relativeTo The url that the resulting string is going to be relative to */ public function getRelativeTo($relativeTo = self::RELATIVE_TO_NONE) { $buildUrl = ''; if ((int) $relativeTo === $relativeTo) { switch ($relativeTo) { case static::RELATIVE_TO_NONE: $parsed = parse_url($this->_url); return static::buildUrl($parsed); case static::RELATIVE_TO_SCHEME: $hostPart = $this->getHost(); if ($userPart = $this->getUser()) { if ($passPart = $this->getPassword()) { $userPart = $userPart . ':' . $passPart; } $hostPart = $userPart . '@' . $hostPart; } $buildUrl .= '//' . $hostPart; case static::RELATIVE_TO_HOST: $buildUrl .= $this->getPath(); if ($query = $this->getQuery()) { $buildUrl .= '?' . $query; } if ($fragment = $this->getFragment()) { $buildUrl .= '#' . $fragment; } return $buildUrl; } } if (!$relativeTo instanceof Url && is_string($relativeTo)) { $relativeTo = new Url($relativeTo); } else { if ($relativeTo instanceof Url) { $relativeTo = new Url($relativeTo->__toString()); } else { throw new Exception('Invalid argument, expected url!'); } } $relativeTo->clearParams(); $relativeTo->unsetFragment(); $pathRelative = $relativeTo->getPath(); if (!$pathRelative) { $pathRelative = '/'; } $relativeTo->setPath('/'); $relativeTo = $relativeTo->__toString(); $url = $this->getRelativeTo(static::RELATIVE_TO_NONE); if (strpos($url, $relativeTo) === 0) { $relWithPath = substr($url, strlen($relativeTo)); if (!$relWithPath || $relWithPath[0] != '/') { $relWithPath = '/' . $relWithPath; } $pathLen = strlen($pathRelative); while ($pathRelative[$pathLen - 1] == '/') { $pathLen--; } if ($pathLen == 0) { return $relWithPath; } $pathRelative = substr($pathRelative, 0, $pathLen); if ($pathRelative == $relWithPath) { return ''; } else { if (strpos($relWithPath, $pathRelative) === 0 && in_array($relWithPath[$pathLen], array('/', '?', '#'))) { /* Simple removal of the path relative to */ $relWithPath = substr($relWithPath, $pathLen); while ($relWithPath && $relWithPath[0] == '/') { $relWithPath = substr($relWithPath, 1); } return $relWithPath; } } return $relWithPath; } /* * Host-part did not match.. * Return full absolute url.. */ return $url; }
/** * Resolve an url with hashbang * * @param Url $url */ protected static function hashBang(Url $url) { if ($path = preg_replace('|^(/?!)|', '', $url->getFragment())) { $url->setPath($url->getPath() . $path); } }
/** * handle overview request */ private function handleOverview() { $view = ViewManager::getInstance(); $taglist = $this->plugin->getTagList(array('plugin_type' => News::TYPE_HEADLINES)); if (!$taglist) { return; } $tree = $this->director->tree; $url = new Url(true); $url->setParameter($view->getUrlId(), News::VIEW_DETAIL); // link to news tree nodes $treeRef = new NewsTreeRef(); foreach ($taglist as $tag) { $template = new TemplateEngine($this->getPath() . "templates/" . $this->templateFile); $template->setPostfix($tag['tag']); $template->setCacheable(true); // check if template is in cache if (!$template->isCached()) { // get settings //$settings = $this->getSettings(); $key = array('tree_id' => $tag['tree_id'], 'tag' => $tag['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('activated' => true, 'tree_id' => $treeItemList); $overview = $this->getNewsOverview(); $list = $overview->getList($searchcriteria, $detail['rows']); // skip if empty if ($list['totalItems'] < 1) { continue; } foreach ($list['data'] as &$item) { $url->setPath($tree->getPath($item['tree_id'])); $url->setParameter('id', $item['id']); $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('news', $list); $template->setVariable('settings', $detail); } $this->template[$tag['tag']] = $template; } }