/** * Gets the search results. * * @return mixed Parsed content. */ public function getSearchResults() { global $_ARRAYLANG; $this->template->addBlockfile('ADMIN_CONTENT', 'search', 'Default.html'); if (!empty($this->term)) { $pages = $this->getSearchedPages(); $countPages = $this->countSearchedPages(); usort($pages, array($this, 'sortPages')); if ($countPages > 0) { $parameter = '&cmd=Search' . (empty($this->term) ? '' : '&term=' . contrexx_raw2encodedUrl($this->term)); $paging = \Paging::get($parameter, '', $countPages, 0, true, null, 'pos'); $this->template->setVariable(array('TXT_SEARCH_RESULTS_COMMENT' => sprintf($_ARRAYLANG['TXT_SEARCH_RESULTS_COMMENT'], $this->term, $countPages), 'TXT_SEARCH_TITLE' => $_ARRAYLANG['TXT_NAVIGATION_TITLE'], 'TXT_SEARCH_CONTENT_TITLE' => $_ARRAYLANG['TXT_PAGETITLE'], 'TXT_SEARCH_SLUG' => $_ARRAYLANG['TXT_CORE_CM_SLUG'], 'TXT_SEARCH_LANG' => $_ARRAYLANG['TXT_LANGUAGE'], 'SEARCH_PAGING' => $paging)); foreach ($pages as $page) { // used for alias pages, because they have no language if ($page->getLang() == "") { $languages = ""; foreach (\FWLanguage::getIdArray('frontend') as $langId) { $languages[] = \FWLanguage::getLanguageCodeById($langId); } } else { $languages = array(\FWLanguage::getLanguageCodeById($page->getLang())); } $aliasLanguages = implode(', ', $languages); $originalPage = $page; $link = 'index.php?cmd=ContentManager&page=' . $page->getId(); if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS) { $pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); if ($originalPage->isTargetInternal()) { // is internal target, get target page $originalPage = $pageRepo->getTargetPage($page); } else { // is an external target, set the link to the external targets url $originalPage = new \Cx\Core\ContentManager\Model\Entity\Page(); $originalPage->setTitle($page->getTarget()); $link = $page->getTarget(); } } $this->template->setVariable(array('SEARCH_RESULT_BACKEND_LINK' => $link, 'SEARCH_RESULT_TITLE' => $originalPage->getTitle(), 'SEARCH_RESULT_CONTENT_TITLE' => $originalPage->getContentTitle(), 'SEARCH_RESULT_SLUG' => substr($page->getPath(), 1), 'SEARCH_RESULT_LANG' => $aliasLanguages, 'SEARCH_RESULT_FRONTEND_LINK' => \Cx\Core\Routing\Url::fromPage($page))); $this->template->parse('search_result_row'); } } else { $this->template->setVariable(array('TXT_SEARCH_NO_RESULTS' => sprintf($_ARRAYLANG['TXT_SEARCH_NO_RESULTS'], $this->term))); } } else { $this->template->setVariable(array('TXT_SEARCH_NO_TERM' => $_ARRAYLANG['TXT_SEARCH_NO_TERM'])); } }
/** * Show the article groups for editing * @return boolean True on success, false otherwise * @author Reto Kohli <*****@*****.**> */ function view_article_groups() { global $_ARRAYLANG; if (isset($_GET['delete'])) { Discount::deleteArticleGroup($_GET['id']); } if (isset($_POST['store'])) { Discount::storeArticleGroup($_POST['groupName'], $_POST['id']); } // Force discounts to be reinitialised Discount::flush(); self::$objTemplate->addBlockfile('SHOP_PRODUCTS_FILE', 'shop_products_block', 'module_shop_discount_groups_article.html'); // Group overview $arrGroups = Discount::getArticleGroupArray(); self::$objTemplate->setCurrentBlock('shopGroup'); $i = 0; foreach ($arrGroups as $id => $arrGroup) { self::$objTemplate->setVariable(array('SHOP_GROUP_ID' => $id, 'SHOP_GROUP_NAME' => $arrGroup['name'], 'SHOP_ROW_STYLE' => 'row' . (++$i % 2 + 1))); self::$objTemplate->parseCurrentBlock(); } // Add/edit Group $id = 0; if (!empty($_GET['edit'])) { $id = intval($_GET['id']); self::$objTemplate->setGlobalVariable(array('SHOP_GROUP_EDIT_CLASS' => 'active', 'SHOP_GROUP_EDIT_DISPLAY' => 'block', 'SHOP_GROUP_LIST_CLASS' => '', 'SHOP_GROUP_LIST_DISPLAY' => 'none', 'TXT_ADD_OR_EDIT' => $_ARRAYLANG['TXT_EDIT'])); } else { self::$objTemplate->setGlobalVariable(array('SHOP_GROUP_EDIT_CLASS' => '', 'SHOP_GROUP_EDIT_DISPLAY' => 'none', 'SHOP_GROUP_LIST_CLASS' => 'active', 'SHOP_GROUP_LIST_DISPLAY' => 'block', 'TXT_ADD_OR_EDIT' => $_ARRAYLANG['TXT_ADD'])); } self::$objTemplate->setCurrentBlock('shopGroupName'); self::$objTemplate->setVariable(array('SHOP_GROUP_ID_EDIT' => $id, 'SHOP_ROW_STYLE' => 'row' . (++$i % 2 + 1))); if (isset($arrGroups[$id])) { self::$objTemplate->setVariable('SHOP_GROUP_NAME', $arrGroups[$id]['name']); } self::$objTemplate->parseCurrentBlock(); return true; }
/** * Calls hooks before content is processed * @todo Remove usage of globals * @global null $moduleStyleFile * @global type $plainCmd * @global type $plainSection * @global type $themesPages * @global type $page_template */ protected function preContentLoad() { global $moduleStyleFile, $plainCmd, $plainSection, $themesPages, $page_template; $this->ch->callPreContentLoadHooks(); if ($this->mode == self::MODE_FRONTEND) { // load content.html template (or customized version) $this->template->setTemplate($themesPages['index']); $this->template->addBlock('CONTENT_FILE', 'page_template', $page_template); // load application content template $this->loadContentTemplateOfPage(); // Set global content variables. $pageContent = $this->resolvedPage->getContent(); $this->parseGlobalPlaceholders($pageContent); $pageContent = str_replace('{TITLE}', $this->resolvedPage->getTitle(), $pageContent); //replace the {NODE_<ID>_<LANG>}- placeholders \LinkGenerator::parseTemplate($pageContent); $this->resolvedPage->setContent($pageContent); $moduleStyleFile = null; } else { if ($this->mode == self::MODE_BACKEND) { // Skip the nav/language bar for modules which don't make use of either. // TODO: Remove language selector for modules which require navigation but bring their own language management. if ($this->ch->isLegacyComponent($plainCmd)) { $this->template->addBlockfile('CONTENT_OUTPUT', 'content_master', 'LegacyContentMaster.html'); } $plainSection = $plainCmd; } } }