protected function preRender($lang) { if ($this->template->placeholderExists('LEVELS_FULL') || $this->template->placeholderExists('levels_full')) { $this->rootNode = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node')->getRoot(); } $this->realPreRender($lang); }
/** * Use this to parse your backend page * * You will get the template located in /View/Template/{CMD}.html * You can access Cx class using $this->cx * To show messages, use \Message class * * @param \Cx\Core\Html\Sigma $template Template for current CMD * @param array $cmd CMD separated by slashes */ public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd) { $uploader = new Uploader(); $uploader->setFinishedCallback('\\Cx\\Core_Modules\\Uploader\\Model\\DefaultUploadCallback'); $uploader->setCallback('gallery.uploader'); $template->setVariable('UPLOADER_CODE', $uploader->getXHtml('Open Uploader 1')); $uploader2 = new Uploader(); $uploader2->setUploadLimit(1); $uploader2->setFinishedCallback('\\Cx\\Core_Modules\\Uploader\\Model\\DefaultUploadCallback'); $uploader2->setCallback('gallery.uploader2'); $uploader2->setType(Uploader::UPLOADER_TYPE_INLINE); $template->setVariable('UPLOADER_CODE2', $uploader2->getXHtml('Open Uploader 2')); $configurations = array(array(), array('startview' => 'sitestructure', 'views' => 'sitestructure'), array('views' => 'uploader'), array('views' => 'sitestructure'), array('views' => 'filebrowser'), array('startmediatype' => 'gallery'), array('mediatypes' => 'gallery, files'), array('multipleselect' => true), array('data-cx-Mb-Cb-Js-modalopened' => 'testfunction')); foreach ($configurations as $configuration) { $mediaBrowser = new MediaBrowser(); $mediaBrowser->setOptions($configuration); $mediaBrowser->setCallback('gallery.fancyCallback'); $template->setVariable('MEDIABROWSER_CODE', $mediaBrowser->getXHtml('MediaBrowser')); $template->setVariable('MEDIABROWSER_OPTIONS', var_export($configuration, true)); $template->setVariable('MEDIABROWSER_CODE_RAW', htmlspecialchars($mediaBrowser->getXHtml('MediaBrowser'))); $template->parse('mediabrowser_demo'); } $template->setVariable('MEDIABROWSER_FOLDER_WIDGET', new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($this->cx->getWebsiteImagesContentPath())); $template->setVariable('MEDIABROWSER_FOLDER_WIDGET_VIEW_MODE', new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($this->cx->getWebsiteImagesContentPath(), true)); }
/** * Render the option in the frontend. * * @param Sigma $template */ public function renderTheme($template) { $blockName = strtolower('TEMPLATE_EDITOR_' . $this->name); if ($template->blockExists($blockName) && $this->active) { $template->touchBlock($blockName); } }
/** * Parses a rudimentary system log backend page * @param \Cx\Core\Html\Sigma $template Backend template for this page * @param array $cmd Supplied CMD */ public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd) { $em = $this->cx->getDb()->getEntityManager(); $logRepo = $em->getRepository('Cx\\Core_Modules\\SysLog\\Model\\Entity\\Log'); // @todo: parse message if no entries (template block exists already) $parseObject = $this->getNamespace() . '\\Model\\Entity\\Log'; // set default sorting if (!isset($_GET['order'])) { $_GET['order'] = 'timestamp/DESC'; } // configure view $viewGenerator = new \Cx\Core\Html\Controller\ViewGenerator('Cx\\Core_Modules\\SysLog\\Model\\Entity\\Log', $this->getAllViewGeneratorOptions()); $template->setVariable('ENTITY_VIEW', $viewGenerator); }
public function showPrices() { global $_ARRAYLANG; $prices = $this->priceRepository->findAll(); if (empty($prices)) { $prices = new \Cx\Modules\Pim\Model\Entity\Price(); } $view = new \Cx\Core\Html\Controller\ViewGenerator($prices, array('header' => $_ARRAYLANG['TXT_MODULE_PIM_ACT_PRICE'], 'validate' => function ($formGenerator) { // this validation checks whether already a price for the currency and product exists $data = $formGenerator->getData()->toArray(); $currency = $data['currency']; $product = $data['product']; $priceRepository = \Env::get('cx')->getDb()->getEntityManager()->getRepository('Cx\\Modules\\Pim\\Model\\Entity\\Price'); $prices = $priceRepository->createQueryBuilder('p')->where('p.currency = ?1')->setParameter(1, $currency)->andWhere('p.product = ?2')->setParameter(2, $product); $prices = $prices->getQuery()->getResult(); if (!empty($data['editid']) && count($prices) > 1) { return false; } if (empty($data['editid']) && count($prices) > 0) { return false; } return true; }, 'functions' => array('add' => true, 'edit' => true, 'delete' => true, 'sorting' => true, 'paging' => true, 'filtering' => false))); $this->template->setVariable('PRICES_CONTENT', $view->render()); }
/** * Set up the full set of discount information placeholders * @param integer $groupCustomerId The customer group ID of the current customer * @param integer $groupArticleId The article group ID of the current article * @param integer $groupCountId The count discount group ID of the current article * @param integer $count The number of articles to be used for the count discount * @static * @author Reto Kohli <*****@*****.**> */ static function showDiscountInfo($groupCustomerId, $groupArticleId, $groupCountId, $count) { // Pick the unit for this product (count, meter, kilo, ...) $unit = Discount::getUnit($groupCountId); if (!empty($unit)) { self::$objTemplate->setVariable('SHOP_PRODUCT_UNIT', $unit); } if ($groupCustomerId > 0) { $rateCustomer = Discount::getDiscountRateCustomer($groupCustomerId, $groupArticleId); if ($rateCustomer > 0) { self::$objTemplate->setVariable(array('SHOP_DISCOUNT_RATE_CUSTOMER' => $rateCustomer)); } } if ($groupCountId > 0) { $rateCount = Discount::getDiscountRateCount($groupCountId, $count); $listCount = self::getDiscountCountString($groupCountId); if ($rateCount > 0) { // Show discount rate if applicable self::$objTemplate->setVariable('SHOP_DISCOUNT_RATE_COUNT', $rateCount); } if (!empty($listCount)) { // Show discount rate string if applicable self::$objTemplate->setVariable('SHOP_DISCOUNT_RATE_COUNT_LIST', $listCount); } } }
function showEcard() { global $objDatabase, $_ARRAYLANG; $this->_objTpl->setTemplate($this->pageContent); // Initialize variables $code = contrexx_addslashes($_GET['code']); // Get data from DB $query = "\n SELECT *\n FROM " . DBPREFIX . "module_ecard_ecards\n WHERE code='{$code}'"; $objResult = $objDatabase->Execute($query); // If entered code does match a record in db if (!$objResult->EOF) { $message = nl2br(htmlentities($objResult->fields['message'], ENT_QUOTES, CONTREXX_CHARSET)); $senderName = htmlentities($objResult->fields['senderName'], ENT_QUOTES, CONTREXX_CHARSET); $senderEmail = $objResult->fields['senderEmail']; $recipientName = htmlentities($objResult->fields['recipientName'], ENT_QUOTES, CONTREXX_CHARSET); $recipientEmail = $objResult->fields['recipientEmail']; $recipientsalutation = htmlentities($objResult->fields['salutation'], ENT_QUOTES, CONTREXX_CHARSET); // Get right file extension $globArray = glob(ASCMS_ECARD_SEND_ECARDS_PATH . '/' . $code . ".*"); $fileextension = substr($globArray[0], -4); $selectedMotive = $code . $fileextension; // Initialize DATA placeholder $this->_objTpl->setVariable(array('ECARD_DATA' => '<strong>' . $senderName . '</strong> (<a href="mailto:' . $senderEmail . '">' . $senderEmail . '</a>) ' . $_ARRAYLANG['TXT_ECARD_HAS_SENT_YOU_AN_ECARD'], 'ECARD_MOTIVE' => '<img src="' . ASCMS_ECARD_SEND_ECARDS_WEB_PATH . '/' . $selectedMotive . '" alt="' . $selectedMotive . '" title="' . $selectedMotive . '" />', 'ECARD_FROM' => $_ARRAYLANG['TXT_ECARD_FROM'] . ' ' . $senderName, 'ECARD_MESSAGE' => $message, 'ECARD_SENDER_NAME' => $senderName, 'ECARD_SENDER_EMAIL' => $senderEmail, 'ECARD_RECIPIENT_SALUTATION' => $recipientsalutation, 'ECARD_RECIPIENT_NAME' => $recipientName, 'ECARD_RECIPIENT_EMAIL' => $recipientEmail)); } else { // display error message $this->_objTpl->setVariable(array('ECARD_MESSAGE' => $_ARRAYLANG['TXT_ECARD_WRONG_CODE'], 'ECARD_FROM' => $_ARRAYLANG['TXT_ECARD_CAN_NOT_BE_DISPLAYED'])); } }
/** * placeholder * @global object $objDatabase * @global array $_ARRAYLANG */ function _placeholder() { global $_ARRAYLANG; $this->_pageTitle = $_ARRAYLANG['TXT_PLACEHOLDER']; $this->objTemplate->loadTemplateFile('placeholder.html'); $this->objTemplate->setVariable(array('TXT_DOWNLOADS_DOWNLOADS' => $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOADS'], 'TXT_DOWNLOADS_ICONS' => $_ARRAYLANG['TXT_DOWNLOADS_ICONS'], 'TXT_DOWNLOADS_CATEGORIES' => $_ARRAYLANG['TXT_DOWNLOADS_CATEGORIES'], 'TXT_PLACEHOLDER_FILE_ID' => $_ARRAYLANG['TXT_PLACEHOLDER_FILE_ID'], 'TXT_PLACEHOLDER_FILE_NAME' => $_ARRAYLANG['TXT_PLACEHOLDER_FILE_NAME'], 'TXT_PLACEHOLDER_FILE_DESC' => $_ARRAYLANG['TXT_PLACEHOLDER_FILE_DESC'], 'TXT_PLACEHOLDER_FILE_TYPE' => $_ARRAYLANG['TXT_PLACEHOLDER_FILE_TYPE'], 'TXT_PLACEHOLDER_FILE_SIZE' => $_ARRAYLANG['TXT_PLACEHOLDER_FILE_SIZE'], 'TXT_PLACEHOLDER_FILE_IMG' => $_ARRAYLANG['TXT_PLACEHOLDER_FILE_IMG'], 'TXT_PLACEHOLDER_FILE_AUTHOR' => $_ARRAYLANG['TXT_PLACEHOLDER_FILE_AUTHOR'], 'TXT_PLACEHOLDER_FILE_CREATED' => $_ARRAYLANG['TXT_PLACEHOLDER_FILE_CREATED'], 'TXT_PLACEHOLDER_FILE_LICENSE' => $_ARRAYLANG['TXT_PLACEHOLDER_FILE_LICENSE'], 'TXT_PLACEHOLDER_FILE_VERSION' => $_ARRAYLANG['TXT_PLACEHOLDER_FILE_VERSION'], 'TXT_PLACEHOLDER_CATEGORY_ID' => $_ARRAYLANG['TXT_PLACEHOLDER_CATEGORY_ID'], 'TXT_PLACEHOLDER_CATEGORY_NAME' => $_ARRAYLANG['TXT_PLACEHOLDER_CATEGORY_NAME'], 'TXT_PLACEHOLDER_CATEGORY_DESC' => $_ARRAYLANG['TXT_PLACEHOLDER_CATEGORY_DESC'], 'TXT_PLACEHOLDER_ICON_DISPLAY' => $_ARRAYLANG['TXT_PLACEHOLDER_ICON_DISPLAY'], 'TXT_PLACEHOLDER_ICON_FILTERS' => $_ARRAYLANG['TXT_PLACEHOLDER_ICON_FILTERS'], 'TXT_PLACEHOLDER_ICON_CATEGORY' => $_ARRAYLANG['TXT_PLACEHOLDER_ICON_CATEGORY'], 'TXT_PLACEHOLDER_ICON_FILE' => $_ARRAYLANG['TXT_PLACEHOLDER_ICON_FILE'], 'TXT_PLACEHOLDER_ICON_DOWNLOAD' => $_ARRAYLANG['TXT_PLACEHOLDER_ICON_DOWNLOAD'], 'TXT_PLACEHOLDER_ICON_INFO' => $_ARRAYLANG['TXT_PLACEHOLDER_ICON_INFO'])); }
/** * Parse a user's newsletter-list subscription interface * @param User User object of whoem the newsletter-list subscriptions shall be parsed */ protected function parseNewsletterLists($objUser) { global $_CONFIG, $objDatabase, $objInit; if (!$this->_objTpl->blockExists('access_newsletter')) { return; } if (\Cx\Core_Modules\License\License::getCached($_CONFIG, $objDatabase)->isInLegalComponents('Newsletter')) { $arrSubscribedNewsletterListIDs = $objUser->getSubscribedNewsletterListIDs(); $arrNewsletterLists = \Cx\Modules\Newsletter\Controller\NewsletterLib::getLists(); if (!count($arrNewsletterLists)) { $this->_objTpl->hideBlock('access_newsletter_list'); return; } $row = 0; foreach ($arrNewsletterLists as $listId => $arrList) { if ($objInit->mode != 'backend' && !$arrList['status'] && !in_array($listId, $arrSubscribedNewsletterListIDs)) { continue; } $this->_objTpl->setVariable(array($this->modulePrefix . 'NEWSLETTER_ID' => $listId, $this->modulePrefix . 'NEWSLETTER_NAME' => contrexx_raw2xhtml($arrList['name']), $this->modulePrefix . 'NEWSLETTER_SELECTED' => in_array($listId, $arrSubscribedNewsletterListIDs) ? 'checked="checked"' : '', $this->modulePrefix . 'NEWSLETTER_ROW_CLASS' => $row++ % 2 + 1)); $this->_objTpl->parse('access_newsletter_list'); } $this->_objTpl->touchBlock('access_newsletter'); if ($this->_objTpl->blockExists('access_newsletter_tab')) { $this->_objTpl->touchBlock('access_newsletter_tab'); } } else { $this->_objTpl->hideBlock('access_newsletter'); if ($this->_objTpl->blockExists('access_newsletter_tab')) { $this->_objTpl->hideBlock('access_newsletter_tab'); } } }
/** * Show the customer and article group discounts for editing. * * Handles storing of the discounts as well. * @return boolean True on success, false otherwise * @author Reto Kohli <*****@*****.**> */ function view_customer_discounts() { if (!empty($_POST['store'])) { $this->store_discount_customer(); } self::$objTemplate->loadTemplateFile("module_shop_discount_customer.html"); // Discounts overview $arrCustomerGroups = Discount::getCustomerGroupArray(); $arrArticleGroups = Discount::getArticleGroupArray(); $arrRate = null; $arrRate = Discount::getDiscountRateCustomerArray(); $i = 0; // Set up the customer groups header self::$objTemplate->setVariable(array('SHOP_CUSTOMER_GROUP_COUNT' => count($arrCustomerGroups), 'SHOP_DISCOUNT_ROW_STYLE' => 'row' . (++$i % 2 + 1))); foreach ($arrCustomerGroups as $id => $arrCustomerGroup) { self::$objTemplate->setVariable(array('SHOP_CUSTOMER_GROUP_ID' => $id, 'SHOP_CUSTOMER_GROUP_NAME' => $arrCustomerGroup['name'])); self::$objTemplate->parse('customer_group_header_column'); self::$objTemplate->touchBlock('article_group_header_column'); self::$objTemplate->parse('article_group_header_column'); } foreach ($arrArticleGroups as $groupArticleId => $arrArticleGroup) { //DBG::log("Article group ID $groupArticleId"); foreach ($arrCustomerGroups as $groupCustomerId => $arrCustomerGroup) { $rate = isset($arrRate[$groupCustomerId][$groupArticleId]) ? $arrRate[$groupCustomerId][$groupArticleId] : 0; self::$objTemplate->setVariable(array('SHOP_CUSTOMER_GROUP_ID' => $groupCustomerId, 'SHOP_DISCOUNT_RATE' => sprintf('%2.2f', $rate))); self::$objTemplate->parse('discount_column'); } self::$objTemplate->setVariable(array('SHOP_ARTICLE_GROUP_ID' => $groupArticleId, 'SHOP_ARTICLE_GROUP_NAME' => $arrArticleGroup['name'], 'SHOP_DISCOUNT_ROW_STYLE' => 'row' . (++$i % 2 + 1))); self::$objTemplate->parse('article_group_row'); } self::$objTemplate->setGlobalVariable('SHOP_DISCOUNT_ROW_STYLE', 'row' . (++$i % 2 + 1)); // self::$objTemplate->touchBlock('article_group_header_row'); // self::$objTemplate->parse('article_group_header_row'); return true; }
/** * Show the shadowbox */ function shadowbox() { global $objDatabase, $_ARRAYLANG, $objInit; $id = intval($_GET['id']); $lang = intval($_GET['lang']); $entries = $this->createEntryArray(); $entry = $entries[$id]; $settings = $this->createSettingsArray(); $title = $entry['translation'][$lang]['subject']; $content = $entry['translation'][$lang]['content']; $picture = !empty($entry['translation'][$lang]['image']) ? $entry['translation'][$lang]['image'] : "none"; $this->_objTpl = new \Cx\Core\Html\Sigma(ASCMS_THEMES_PATH); \Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl); $this->_objTpl->setCurrentBlock("shadowbox"); $objResult = $objDatabase->SelectLimit("\n SELECT foldername\n FROM " . DBPREFIX . "skins\n WHERE id='{$objInit->currentThemesId}'", 1); if ($objResult !== false) { $themesPath = $objResult->fields['foldername']; } $template = preg_replace('/\\[\\[([A-Z_]+)\\]\\]/', '{$1}', $settings['data_template_shadowbox']); $this->_objTpl->setTemplate($template); if ($entry['translation'][$lang]['attachment']) { $this->_objTpl->setVariable(array("HREF" => $entry['translation'][$lang]['attachment'], "TXT_DOWNLOAD" => empty($entry['translation'][$lang]['attachment_desc']) ? $_ARRAYLANG['TXT_DATA_DOWNLOAD_ATTACHMENT'] : $entry['translation'][$lang]['attachment_desc'])); $this->_objTpl->parse("attachment"); } $this->_objTpl->setVariable(array("TITLE" => $title, "CONTENT" => $content, "PICTURE" => $picture, "THEMES_PATH" => $themesPath)); if ($picture != "none") { $this->_objTpl->parse("image"); } else { $this->_objTpl->hideBlock("image"); } $this->_objTpl->parse("shadowbox"); $this->_objTpl->show(); die; }
function showCatEdit() { global $objDatabase, $_ARRAYLANG; // check if (!isset($_GET['set'])) { if (!isset($_GET['id']) or $_GET['id'] == '') { $this->goToReplace('&act=category'); die; } } //set if (isset($_GET['set']) and $_GET['set'] == 1) { if ($_POST['form_id'] != '' and $_POST['form_name'] != '' and $_POST['form_status'] != '' and $_POST['form_lang'] != '') { $id = intval($_POST['form_id']); $name = CONTREXX_ESCAPE_GPC ? strip_tags($_POST['form_name']) : addslashes(strip_tags($_POST['form_name'])); $status = intval($_POST['form_status']); $time = time(); $lang = intval($_POST['form_lang']); $this->showCatEditSet($id, $name, $status, $time, $lang); $_SESSION['strOkMessage'] = $_ARRAYLANG['TXT_FEED_MESSAGE_SUCCESSFUL_EDIT_CAT']; $this->goToReplace('&act=category'); die; } else { $_SESSION['strErrMessage'] = $_ARRAYLANG['TXT_FEED_MESSAGE_ERROR_FILL_IN_ALL']; $this->goToReplace('&act=catedit&id=' . $_POST['form_id']); die; } } $query = "SELECT id,\n name,\n status,\n lang\n FROM " . DBPREFIX . "module_feed_category\n WHERE id = '" . intval($_GET['id']) . "'"; $objResult = $objDatabase->Execute($query); $id = $objResult->fields['id']; $name = $objResult->fields['name']; $status = $objResult->fields['status']; $lang = $objResult->fields['lang']; if ($status == 0) { $status0 = ' selected'; $status1 = ''; } else { $status0 = ''; $status1 = ' selected'; } $this->_objTpl->setVariable(array('FEED_ID' => $id, 'FEED_NAME' => $name, 'FEED_STATUS0' => $status0, 'FEED_STATUS1' => $status1)); //lang $query = "SELECT id,\n name\n FROM " . DBPREFIX . "languages\n WHERE id<>0\n ORDER BY id"; $objResult = $objDatabase->Execute($query); while (!$objResult->EOF) { $selected = ''; if ($lang == $objResult->fields['id']) { $selected = ' selected'; } $this->_objTpl->setVariable(array('FEED_LANG_ID' => $objResult->fields['id'], 'FEED_LANG_SELECTED' => $selected, 'FEED_LANG_NAME' => $objResult->fields['name'])); $this->_objTpl->parse('feed_lang'); $objResult->MoveNext(); } //parse $_ARRAYLANG $this->_objTpl->setVariable(array('TXT_FEED_EDIT_CAT' => $_ARRAYLANG['TXT_FEED_EDIT_CAT'], 'TXT_FEED_NAME' => $_ARRAYLANG['TXT_FEED_NAME'], 'TXT_FEED_LANGUAGE' => $_ARRAYLANG['TXT_FEED_LANGUAGE'], 'TXT_FEED_STATUS' => $_ARRAYLANG['TXT_FEED_STATUS'], 'TXT_FEED_INACTIVE' => $_ARRAYLANG['TXT_FEED_INACTIVE'], 'TXT_FEED_ACTIVE' => $_ARRAYLANG['TXT_FEED_ACTIVE'], 'TXT_FEED_RESET' => $_ARRAYLANG['TXT_FEED_RESET'], 'TXT_FEED_SAVE' => $_ARRAYLANG['TXT_FEED_SAVE'], 'TXT_FEED_FORMCHECK_NAME' => $_ARRAYLANG['TXT_FEED_FORMCHECK_NAME'], 'TXT_FEED_FORMCHECK_LANGUAGE' => $_ARRAYLANG['TXT_FEED_FORMCHECK_LANGUAGE'], 'TXT_FEED_FORMCHECK_STATUS' => $_ARRAYLANG['TXT_FEED_FORMCHECK_STATUS'])); }
/** * Parses a rudimentary system log backend page * @param \Cx\Core\Html\Sigma $template Backend template for this page * @param array $cmd Supplied CMD */ public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd) { $em = $this->cx->getDb()->getEntityManager(); $logRepo = $em->getRepository('Cx\\Core_Modules\\SysLog\\Model\\Entity\\Log'); // @todo: parse message if no entries (template block exists already) $parseObject = $this->getNamespace() . '\\Model\\Entity\\Log'; // set default sorting if (!isset($_GET['order'])) { $_GET['order'] = 'timestamp/DESC'; } // configure view $viewGenerator = new \Cx\Core\Html\Controller\ViewGenerator($parseObject, array('functions' => array('delete' => 'true', 'paging' => true, 'sorting' => true, 'edit' => true), 'fields' => array('id' => array('showOverview' => false), 'timestamp' => array('readonly' => true), 'severity' => array('readonly' => true, 'table' => array('parse' => function ($data, $rows) { return '<span class="' . contrexx_raw2xhtml(strtolower($data)) . '_background">' . contrexx_raw2xhtml($data) . '</span>'; })), 'message' => array('readonly' => true, 'table' => array('parse' => function ($data, $rows) { $url = clone \Cx\Core\Routing\Url::fromRequest(); $url->setMode('backend'); $url->setParam('editid', $rows['id']); return '<a href="' . $url . '">' . contrexx_raw2xhtml($data) . '</a>'; })), 'data' => array('readonly' => true, 'showOverview' => false, 'type' => 'text'), 'logger' => array('readonly' => true)))); $template->setVariable('ENTITY_VIEW', $viewGenerator); }
/** * 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'])); } }
/** * Add or edit the jobs Locations * @global object $objDatabase * @global array $_ARRAYLANG * @param string $pageContent */ function manageLocations() { global $objDatabase, $_ARRAYLANG; $this->pageTitle = $_ARRAYLANG['TXT_LOCATION_MANAGER']; $this->_objTpl->loadTemplateFile('module_jobs_location.html', true, true); $this->_objTpl->setVariable(array('TXT_ADD_NEW_LOCATION' => $_ARRAYLANG['TXT_ADD_NEW_LOCATION'], 'TXT_NAME' => $_ARRAYLANG['TXT_NAME'], 'TXT_ADD' => $_ARRAYLANG['TXT_ADD'], 'TXT_SELECT_ALL' => $_ARRAYLANG['TXT_SELECT_ALL'], 'TXT_REMOVE_SELECTION' => $_ARRAYLANG['TXT_REMOVE_SELECTION'], 'TXT_LOCATION_LIST' => $_ARRAYLANG['TXT_LOCATION_LIST'], 'TXT_ID' => $_ARRAYLANG['TXT_ID'], 'TXT_ACTION' => $_ARRAYLANG['TXT_ACTION'], 'TXT_ACCEPT_CHANGES' => $_ARRAYLANG['TXT_ACCEPT_CHANGES'], 'TXT_CONFIRM_DELETE_DATA' => $_ARRAYLANG['TXT_CONFIRM_DELETE_DATA'], 'TXT_ACTION_IS_IRREVERSIBLE' => $_ARRAYLANG['TXT_ACTION_IS_IRREVERSIBLE'], 'TXT_ATTENTION_SYSTEM_FUNCTIONALITY_AT_RISK' => $_ARRAYLANG['TXT_ATTENTION_SYSTEM_FUNCTIONALITY_AT_RISK'], 'TXT_JOBS_SORTING' => $_ARRAYLANG['TXT_JOBS_SORTING'], 'TXT_JOBS_SORTTYPE' => $_ARRAYLANG['TXT_JOBS_SORTTYPE'])); $this->_objTpl->setGlobalVariable(array('TXT_DELETE' => $_ARRAYLANG['TXT_DELETE'])); // Add a new category if (isset($_POST['addLoc']) and $_POST['addLoc'] == true) { $locName = get_magic_quotes_gpc() ? strip_tags($_POST['newLocName']) : addslashes(strip_tags($_POST['newLocName'])); if ($objDatabase->Execute("INSERT INTO " . DBPREFIX . "module_jobs_location (name)\n VALUES ('{$locName}')")) { $this->strOkMessage = $_ARRAYLANG['TXT_DATA_RECORD_ADDED_SUCCESSFUL']; } else { $this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR']; } } // Modify a new category if (isset($_POST['modLoc']) and $_POST['modLoc'] == true) { foreach ($_POST['locName'] as $id => $name) { $name = get_magic_quotes_gpc() ? strip_tags($name) : addslashes(strip_tags($name)); $id = intval($id); // Unused // $sorting = !empty($_REQUEST['sortStyle'][$id]) ? contrexx_addslashes($_REQUEST['sortStyle'][$id]) : 'alpha'; if ($objDatabase->Execute("UPDATE " . DBPREFIX . "module_jobs_location\n SET name='{$name}'\n WHERE id={$id}")) { $this->strOkMessage = $_ARRAYLANG['TXT_DATA_RECORD_UPDATED_SUCCESSFUL']; } else { $this->strErrMessage = $_ARRAYLANG['TXT_DATABASE_QUERY_ERROR']; } } } $query = "SELECT `id`,\n `name`\n FROM `" . DBPREFIX . "module_jobs_location`\n ORDER BY `id` asc"; $objResult = $objDatabase->Execute($query); $this->_objTpl->setCurrentBlock('row'); $i = 0; while ($objResult !== false && !$objResult->EOF) { $class = $i % 2 == 0 ? "row1" : "row2"; // Unused // $sorting = $objResult->fields['sort_style']; $this->_objTpl->setVariable(array('JOBS_ROWCLASS' => $class, 'JOBS_LOC_ID' => $objResult->fields['id'], 'JOBS_LOC_NAME' => stripslashes($objResult->fields['name']))); $this->_objTpl->parseCurrentBlock('row'); $i++; $objResult->MoveNext(); } }
/** * Use this to parse your backend page * * You will get the template located in /View/Template/{CMD}.html * You can access Cx class using $this->cx * To show messages, use \Message class * * @param \Cx\Core\Html\Sigma $template Template for current CMD * @param array $cmd CMD separated by slashes */ public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd) { $uploader = new Uploader(); $uploader->setFinishedCallback('\\Cx\\Core_Modules\\Uploader\\Model\\DefaultUploadCallback'); $uploader->setCallback('gallery.uploader'); $template->setVariable('UPLOADER_CODE', $uploader->getXHtml('Open Uploader 1')); $uploader2 = new Uploader(); $uploader2->setFinishedCallback('\\Cx\\Core_Modules\\Uploader\\Model\\DefaultUploadCallback'); $uploader2->setCallback('gallery.uploader2'); $uploader2->setType(Uploader::UPLOADER_TYPE_INLINE); $template->setVariable('UPLOADER_CODE2', $uploader2->getXHtml('Open Uploader 2')); $mediaBrowser = new MediaBrowser(); $mediaBrowser->setCallback('gallery.fancyCallback'); $template->setVariable('MEDIABROWSER_CODE1', $mediaBrowser->getXHtml('MediaBrowser')); $template->setVariable('MEDIABROWSER_CODE1_RAW', htmlspecialchars($mediaBrowser->getXHtml('MediaBrowser'))); $template->setVariable('MEDIABROWSER_FOLDER_WIDGET', new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($this->cx->getWebsiteImagesContentPath())); $template->setVariable('MEDIABROWSER_FOLDER_WIDGET_VIEW_MODE', new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($this->cx->getWebsiteImagesContentPath(), true)); }
function chooseReservationProduct() { global $objDatabase, $_ARRAYLANG; $this->objTemplate->loadTemplateFile('module_gov_choose_product.html'); $this->_pageTitle = $_ARRAYLANG['TXT_EGOV_PRODUCT_FOR_RESERVATION']; $this->objTemplate->setVariable(array('TXT_PRODUCT' => $_ARRAYLANG['TXT_PRODUCT'], 'TXT_EGOV_CHOOSE_PRODUCT_FOR_RESERVATION' => $_ARRAYLANG['TXT_EGOV_CHOOSE_PRODUCT_FOR_RESERVATION'])); $query = "\n SELECT *\n FROM " . DBPREFIX . "module_egov_products\n ORDER BY product_orderby, product_name\n "; $objResult = $objDatabase->Execute($query); $i = 0; while (!$objResult->EOF) { $StatusImg = '<img src="../core/Core/View/Media/icons/status_green.gif" width="10" height="10" border="0" alt="" />'; if ($objResult->fields["product_status"] != 1) { $StatusImg = '<img src="../core/Core/View/Media/icons/status_red.gif" width="10" height="10" border="0" alt="" />'; } $this->objTemplate->setVariable(array('ROWCLASS' => ++$i % 2 ? 'row2' : 'row1', 'PRODUCT_ID' => $objResult->fields['product_id'], 'PRODUCT_NAME' => $objResult->fields['product_name'], 'PRODUCT_STATUS' => $StatusImg)); $this->objTemplate->parse('products_list'); $objResult->MoveNext(); } if ($i == 0) { $this->objTemplate->hideBlock('products_list'); } }
/** * Use this to parse your backend page * * You will get the template located in /View/Template/{CMD}.html * You can access Cx class using $this->cx * To show messages, use \Message class * @param \Cx\Core\Html\Sigma $template Template for current CMD * @param array $cmd CMD separated by slashes */ public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd) { global $_ARRAYLANG, $objInit; $objTpl = new \Cx\Core\Html\Sigma($this->getDirectory(true) . '/View/Template/Backend'); //merge language $langData = $objInit->loadLanguageData('Pdf'); $_ARRAYLANG = array_merge($_ARRAYLANG, $langData); $objTpl->setGlobalVariable($_ARRAYLANG); $objTpl->loadTemplatefile('Default.html'); // Not an entity, parse overview or settings switch (current($cmd)) { default: // Parse entity view generation pages $entityClassName = $this->getNamespace() . '\\Model\\Entity\\PdfTemplate'; $this->parseEntityClassPage($objTpl, $entityClassName, 'PdfTemplate'); if ($objTpl->blockExists('overview')) { $objTpl->touchBlock('overview'); } break; } \JS::registerCSS(substr($this->getDirectory(false, true) . '/View/Style/Backend.css', 1)); $template->setVariable(array('CONTENT_TITLE' => $_ARRAYLANG['TXT_CORE_MODULE_PDF'], 'ADMIN_CONTENT' => $objTpl->get())); }
/** * Do something before main template gets parsed * * @param \Cx\Core\Html\Sigma $template The main template */ public function preFinalize(\Cx\Core\Html\Sigma $template) { if ($this->cx->getMode() != \Cx\Core\Core\Controller\Cx::MODE_FRONTEND) { return; } // make all language data of Access component globally available $template->setVariable(\Env::get('init')->getComponentSpecificLanguageData($this->getName())); }
/** * parse the settings dropdown * * @param object $objTemplate template object * @param array $settingValues array of setting values * @param string $selected selected dropdown value * @param string $blockName block name for template parsing * * @return null */ public function parseSettingsDropDown(\Cx\Core\Html\Sigma $objTemplate, $settingValues, $selected, $blockName) { global $_ARRAYLANG; if (empty($settingValues)) { return; } foreach (array_keys($settingValues) as $key) { $selectedOption = $selected == $key ? 'selected="selected"' : ''; $objTemplate->setVariable(array('DOWNLOADS_SETTINGS_DROPDOWN_OPTION_VALUE' => $key, 'DOWNLOADS_SETTINGS_DROPDOWN_OPTION_NAME' => $_ARRAYLANG['TXT_DOWNLOADS_SETTINGS_' . strtoupper($key) . '_LABEL'], 'DOWNLOADS_SETTINGS_DROPDOWN_SELECTED_OPTION' => $selectedOption)); $objTemplate->parse('downloads_settings_sorting_dropdown_' . $blockName); } }
/** * Parsing the related News * * @global object $objDatabase * @global type $_ARRAYLANG * * @param Object $objTpl Template Object * @param Interger $newsId News Id * @param Interger $langId Language id * @param type $blockName Block Name * @param type $limit Limit * * @return null */ public function parseRelatedNews(\Cx\Core\Html\Sigma $objTpl, $newsId = null, $langId = null, $blockName = 'related_news', $limit = 0) { global $_ARRAYLANG, $objDatabase; if (empty($newsId) || !$objTpl->blockExists($blockName)) { return; } //Getting the related news ids $relatedNewsIds = $this->getRelatedNews($newsId); $defaultLangId = \FWLanguage::getDefaultLangId(); //Getting the related news details for the given languages $relatedNewsDetails = $this->getRelatedNewsDetails($relatedNewsIds, array($langId, $defaultLangId)); if (!empty($relatedNewsDetails)) { $defaultImage = \Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseCoreModulePath() . '/News/View/Media/default_news_image.png'; $currentCount = 1; foreach ($relatedNewsIds as $relatedNewsId) { //If the limit is reached then the loop is stopped if (!empty($limit) && $currentCount > $limit) { break; } /* * Checking the related news is available in the current * acitve front-end language if not available then the default * language details are getting used * Comment/Uncomment the following line if this condition * is required */ //$currentRelatedDetails = isset($relatedNewsDetails[$relatedNewsId][$langId]) // ? $relatedNewsDetails[$relatedNewsId][$langId] // : $relatedNewsDetails[$relatedNewsId][$defaultLangId]; /* * Checking the related news is available in the current * acitve front-end language if not available then the related * News not listed Comment/Uncomment the following * line if this condition is required */ $currentRelatedDetails = isset($relatedNewsDetails[$relatedNewsId][$langId]) ? $relatedNewsDetails[$relatedNewsId][$langId] : false; if (!$currentRelatedDetails) { continue; } ++$currentCount; $categories = $this->getCategoriesByNewsId($relatedNewsId); $newsUrl = empty($currentRelatedDetails['redirect']) ? empty($currentRelatedDetails['newscontent']) ? '' : \Cx\Core\Routing\Url::fromModuleAndCmd('news', $this->findCmdById('details', array_keys($categories)), FRONTEND_LANG_ID, array('newsid' => $relatedNewsId)) : $currentRelatedDetails['redirect']; $newstitle = $currentRelatedDetails['title']; $htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml('[' . $_ARRAYLANG['TXT_NEWS_MORE'] . '...]')); $htmlLinkTitle = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle)); // in case that the message is a stub, // we shall just display the news title instead of a html-a-tag // with no href target if (empty($htmlLinkTitle)) { $htmlLinkTitle = contrexx_raw2xhtml($newstitle); } $imagePath = !empty($currentRelatedDetails['teaser_image_path']) ? $currentRelatedDetails['teaser_image_path'] : $defaultImage; $imageThumbPath = !empty($currentRelatedDetails['teaser_image_thumbnail_path']) ? $currentRelatedDetails['teaser_image_thumbnail_path'] : $defaultImage; $this->parseImageBlock($objTpl, $imagePath, $newstitle, $newsUrl, 'related_news_image'); $this->parseImageBlock($objTpl, $imageThumbPath, $newstitle, $newsUrl, 'related_news_image_thumb'); $author = \FWUser::getParsedUserTitle($currentRelatedDetails['author_id'], $currentRelatedDetails['author']); $publisher = \FWUser::getParsedUserTitle($currentRelatedDetails['publisher_id'], $currentRelatedDetails['publisher']); $objSubResult = $objDatabase->Execute(' SELECT count(`id`) AS `countComments` FROM `' . DBPREFIX . 'module_news_comments` WHERE `newsid` = ' . $relatedNewsId); $objTpl->setVariable(array('NEWS_RELATED_NEWS_ID' => contrexx_raw2xhtml($relatedNewsId), 'NEWS_RELATED_NEWS_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_RELATED_NEWS_LINK' => $htmlLink, 'NEWS_RELATED_NEWS_TITLE' => contrexx_raw2xhtml($currentRelatedDetails['title']), 'NEWS_RELATED_NEWS_TITLE_SHORT' => strlen($currentRelatedDetails['title']) > 35 ? substr(strip_tags($currentRelatedDetails['title']), 0, 35) . '...' : strip_tags($currentRelatedDetails['title']), 'NEWS_RELATED_NEWS_TITLE_LINK' => $htmlLinkTitle, 'NEWS_RELATED_NEWS_TEXT' => $currentRelatedDetails['text'], 'NEWS_RELATED_NEWS_TEXT_SHORT' => strlen($currentRelatedDetails['text']) > 250 ? substr(strip_tags($currentRelatedDetails['text']), 0, 247) . '...' : strip_tags($currentRelatedDetails['text']), 'NEWS_RELATED_NEWS_TEASER_TEXT' => nl2br($currentRelatedDetails['teaser_text']), 'NEWS_RELATED_NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_RELATED_NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher), 'NEWS_RELATED_NEWS_CATEGORY_NAMES' => implode(', ', contrexx_raw2xhtml($categories)), 'NEWS_RELATED_NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_COUNT_COMMENTS' => $currentRelatedDetails['commentactive'] && $this->arrSettings['news_comments_activated'] ? contrexx_raw2xhtml($objSubResult->fields['countComments'] . ' ' . $_ARRAYLANG['TXT_NEWS_COMMENTS']) : '')); if (!$objSubResult->fields['countComments'] || !$this->arrSettings['news_comments_activated']) { if ($objTpl->blockExists('related_news_comments_count')) { $objTpl->hideBlock('related_news_comments_count'); } } if ($this->arrSettings['news_use_teaser_text'] != '1' && $objTpl->blockExists('news_use_teaser_text')) { $objTpl->hideBlock('news_use_teaser_text'); } $objTpl->parse($blockName); } if ($objTpl->blockExists('related_news_block')) { $objTpl->setVariable('TXT_NEWS_RELATED_NEWS', $_ARRAYLANG['TXT_NEWS_RELATED_NEWS']); $objTpl->touchBlock('related_news_block'); } } }
/** * Set the registration fields placeholders to the template * * @param \Cx\Core\Html\Sigma $objTpl Template instance * @param integer $regId Registration id */ function showRegistrationInputfields(\Cx\Core\Html\Sigma $objTpl, $regId = null) { global $_LANGID, $_ARRAYLANG; $i = 0; $objForm = new \Cx\Modules\Calendar\Controller\CalendarForm($this->formId); $objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration($this->formId, $regId); // parse the registration type for the add/edit subscription $regType = isset($_POST['registrationType']) ? (int) $_POST['registrationType'] : (!empty($regId) ? $objRegistration->type : 1); $regTypeField = '<select style="width: 208px;" class="calendarSelect" name="registrationType"> <option value="1" ' . ($regType == 1 ? "selected='selected'" : '') . ' />' . $_ARRAYLANG['TXT_CALENDAR_REG_REGISTRATION'] . '</option> <option value="0" ' . ($regType == 0 ? "selected='selected'" : '') . ' />' . $_ARRAYLANG['TXT_CALENDAR_REG_SIGNOFF'] . '</option> <option value="2" ' . ($regType == 2 ? "selected='selected'" : '') . ' />' . $_ARRAYLANG['TXT_CALENDAR_REG_WAITLIST'] . '</option> </select>'; $objTpl->setVariable(array($this->moduleLangVar . '_ROW' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_REGISTRATION_INPUTFIELD_NAME' => $_ARRAYLANG['TXT_CALENDAR_TYPE'], $this->moduleLangVar . '_REGISTRATION_INPUTFIELD_VALUE' => $regTypeField)); $objTpl->parse('calendar_registration_inputfield'); $i++; if ($this->event && $this->event->seriesStatus && $this->event->independentSeries) { $endDate = new \DateTime(); $endDate->modify('+10 years'); $eventManager = new CalendarEventManager(null, $endDate); $objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent($this->event->id); if ($eventManager->_addToEventList($objEvent)) { $eventManager->eventList[] = $objEvent; } $eventManager->_setNextSeriesElement($objEvent); $regEventDateField = '<select style="width: 208px;" class="calendarSelect" name="registrationEventDate">'; foreach ($eventManager->eventList as $event) { $selectedDate = $objRegistration->eventDate == $event->startDate->getTimestamp() ? 'selected="selected"' : ''; $regEventDateField .= '<option value="' . $event->startDate->getTimestamp() . '" ' . $selectedDate . ' />' . $this->format2userDate($event->startDate) . '</option>'; } $regEventDateField .= '</select>'; $objTpl->setVariable(array($this->moduleLangVar . '_ROW' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_REGISTRATION_INPUTFIELD_NAME' => $_ARRAYLANG['TXT_CALENDAR_DATE_OF_THE_EVENT'], $this->moduleLangVar . '_REGISTRATION_INPUTFIELD_VALUE' => $regEventDateField)); $objTpl->parse('calendar_registration_inputfield'); $i++; } foreach ($objForm->inputfields as $arrInputfield) { $inputfield = ''; $options = explode(',', $arrInputfield['default_value'][$_LANGID]); $optionSelect = true; if (isset($_POST['registrationField'][$arrInputfield['id']])) { $value = $_POST['registrationField'][$arrInputfield['id']]; } else { $value = $regId != null ? $objRegistration->fields[$arrInputfield['id']]['value'] : ''; } switch ($arrInputfield['type']) { case 'inputtext': case 'mail': case 'firstname': case 'lastname': $inputfield = '<input style="width: 200px;" type="text" class="calendarInputText" name="registrationField[' . $arrInputfield['id'] . ']" value="' . $value . '" />'; break; case 'textarea': $inputfield = '<textarea style="width: 196px;" class="calendarTextarea" name="registrationField[' . $arrInputfield['id'] . ']">' . $value . '</textarea>'; break; case 'seating': $optionSelect = false; case 'select': case 'salutation': $inputfield = '<select style="width: 208px;" class="calendarSelect" name="registrationField[' . $arrInputfield['id'] . ']">'; $selected = empty($_POST) ? 'selected="selected"' : ''; $inputfield .= $optionSelect ? '<option value="" ' . $selected . '>' . $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHOOSE'] . '</option>' : ''; foreach ($options as $key => $name) { $selected = $key + 1 == $value ? 'selected="selected"' : ''; $inputfield .= '<option value="' . intval($key + 1) . '" ' . $selected . '>' . $name . '</option>'; } $inputfield .= '</select>'; break; case 'radio': $arrValue = explode('[[', $value); $value = $arrValue[0]; $input = str_replace(']]', '', $arrValue[1]); foreach ($options as $key => $name) { $checked = $key + 1 == $value || in_array($key + 1, $_POST['registrationField'][$arrInputfield['id']]) ? 'checked="checked"' : ''; $textfield = '<input type="text" class="calendarInputCheckboxAdditional" name="registrationFieldAdditional[' . $arrInputfield['id'] . '][' . $key . ']" value="' . ($checked ? $input : '') . '" />'; $name = str_replace('[[INPUT]]', $textfield, $name); $inputfield .= '<input type="radio" class="calendarInputCheckbox" name="registrationField[' . $arrInputfield['id'] . ']" value="' . intval($key + 1) . '" ' . $checked . '/> ' . $name . '<br />'; } break; case 'checkbox': $results = explode(',', $value); foreach ($results as $result) { list($value, $input) = explode('[[', $result); $value = !empty($value) ? $value : 0; $input = str_replace(']]', '', $input); $newResult[$value] = $input; } foreach ($options as $key => $name) { $checked = array_key_exists($key + 1, $newResult) || in_array($key + 1, $_POST['registrationField'][$arrInputfield['id']]) ? 'checked="checked"' : ''; $textfield = '<input type="text" class="calendarInputCheckboxAdditional" name="registrationFieldAdditional[' . $arrInputfield['id'] . '][' . $key . ']" value="' . ($checked ? $newResult[$key + 1] : '') . '" />'; $name = str_replace('[[INPUT]]', $textfield, $name); $inputfield .= '<input ' . $checked . ' type="checkbox" class="calendarInputCheckbox" name="registrationField[' . $arrInputfield['id'] . '][]" value="' . intval($key + 1) . '" /> ' . $name . '<br />'; } break; case 'agb': $checked = $value ? "checked='checked'" : ''; $inputfield = '<input ' . $checked . ' class="calendarInputCheckbox" type="checkbox" name="registrationField[' . $arrInputfield['id'] . '][]" value="1" /> ' . $_ARRAYLANG['TXT_CALENDAR_AGB'] . '<br />'; break; } if ($arrInputfield['type'] != 'fieldset') { $objTpl->setVariable(array($this->moduleLangVar . '_ROW' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_REGISTRATION_INPUTFIELD_NAME' => $arrInputfield['name'][$_LANGID], $this->moduleLangVar . '_REGISTRATION_INPUTFIELD_REQUIRED' => $arrInputfield['required'] == 1 ? '<font class="calendarRequired"> *</font>' : '', $this->moduleLangVar . '_REGISTRATION_INPUTFIELD_VALUE' => $inputfield)); $objTpl->parse('calendar_registration_inputfield'); $i++; } } }
private function parseSearchForm($objCategory) { global $_ARRAYLANG; $this->objTemplate->setVariable(array('DOWNLOADS_SEARCH_KEYWORD' => htmlentities($this->searchKeyword, ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_SEARCH_URL' => CONTREXX_SCRIPT_PATH, 'DOWNLOADS_SEARCH_CATEGORY' => $objCategory->getId(), 'TXT_DOWNLOADS_SEARCH' => $_ARRAYLANG['TXT_DOWNLOADS_SEARCH'])); }
/** * @param Sigma $template */ public function preFinalize(Sigma $template) { if (count($this->mediaBrowserInstances) == 0) { return; } else { global $_ARRAYLANG; /** * @var $init \InitCMS */ $init = \Env::get('init'); $init->loadLanguageData('MediaBrowser'); foreach ($_ARRAYLANG as $key => $value) { if (preg_match("/TXT_FILEBROWSER_[A-Za-z0-9]+/", $key)) { \ContrexxJavascript::getInstance()->setVariable($key, $value, 'mediabrowser'); } } $thumbnailsTemplate = new Sigma(); $thumbnailsTemplate->loadTemplateFile($this->cx->getCoreModuleFolderName() . '/MediaBrowser/View/Template/Thumbnails.html'); $thumbnailsTemplate->setVariable('TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE', sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE'])); foreach (UploaderConfiguration::getInstance()->getThumbnails() as $thumbnail) { $thumbnailsTemplate->setVariable(array('THUMBNAIL_NAME' => sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_' . strtoupper($thumbnail['name']) . '_SIZE'], $thumbnail['size']), 'THUMBNAIL_ID' => $thumbnail['id'], 'THUMBNAIL_SIZE' => $thumbnail['size'])); $thumbnailsTemplate->parse('thumbnails'); } \ContrexxJavascript::getInstance()->setVariable('thumbnails_template', $thumbnailsTemplate->get(), 'mediabrowser'); \JS::activate('mediabrowser'); \JS::registerJS('core_modules/MediaBrowser/View/Script/mediabrowser.js'); } }
/** * Edit coupons * @param \Cx\Core\Html\Sigma $objTemplate The Template */ static function edit($objTemplate) { global $_ARRAYLANG; //DBG::activate(DBG_ADODB|DBG_LOG_FIREPHP|DBG_PHP); $result = true; if (isset($_GET['delete'])) { list($code, $customer_id) = explode('-', $_GET['delete']); $result &= self::delete(contrexx_input2raw($code), intval($customer_id)); } $edit = isset($_REQUEST['edit']) ? contrexx_input2raw($_REQUEST['edit']) : null; //DBG::log("Edit: ".($edit ? $edit : 'NULL')); $code = isset($_POST['code']) ? contrexx_input2raw($_POST['code']) : null; $payment_id = empty($_POST['payment_id']) ? 0 : intval($_POST['payment_id']); $start_time = empty($_POST['start_date']) ? 0 : strtotime(contrexx_input2raw($_POST['start_date'])); $end_time = empty($_POST['end_date_unlimited']) ? empty($_POST['end_date']) ? 0 : strtotime(contrexx_input2raw($_POST['end_date'])) : 0; $coupon_type = empty($_POST['coupon_type']) ? null : contrexx_input2raw($_POST['coupon_type']); $discount_rate = intval(empty($_POST['discount_rate']) ? 0 : floatval($_POST['discount_rate'])); $discount_amount = Currency::formatPrice(empty($_POST['discount_amount']) ? 0 : floatval($_POST['discount_amount'])); if ($coupon_type == 'rate') { $discount_amount = 0; } if ($coupon_type == 'amount') { $discount_rate = 0; } $minimum_amount = Currency::formatPrice(empty($_POST['minimum_amount']) ? 0 : floatval($_POST['minimum_amount'])); $uses = empty($_POST['unlimited']) ? empty($_POST['uses']) ? 1 : intval($_POST['uses']) : self::USES_UNLIMITED; $customer_id = empty($_POST['customer_id']) ? 0 : intval($_POST['customer_id']); $product_id = empty($_POST['product_id']) ? 0 : intval($_POST['product_id']); $global = !empty($_POST['global_or_customer']); //DBG::log("code $code, start_time $start_time, end_time $end_time, minimum amount $minimum_amount, discount_rate $discount_rate, discount_amount $discount_amount, uses $uses, customer_id $customer_id"); if (isset($code)) { $result &= self::storeCode($code, $payment_id, $minimum_amount, $discount_rate, $discount_amount, $start_time, $end_time, $uses, $global, $customer_id, $product_id, $edit); if ($result) { $code = $edit = null; } else { if (empty($edit)) { $edit = "{$code}-{$customer_id}"; } } } // Reset the end time if it's in the past if ($end_time < time()) { $end_time = 0; } $uri = \Html::getRelativeUri(); \Html::stripUriParam($uri, 'view'); \Html::stripUriParam($uri, 'edit'); \Html::stripUriParam($uri, 'order_coupon'); $arrSortingFields = array('code' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CODE'], 'start_time' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_START_TIME'], 'end_time' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_END_TIME'], 'minimum_amount' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'discount_rate' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_RATE'], 'discount_amount' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'uses' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_USES'], 'global' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_SCOPE'], 'customer_id' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CUSTOMER'], 'product_id' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PRODUCT'], 'payment_id' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PAYMENT']); $objSorting = new \Sorting($uri, $arrSortingFields, true, 'order_coupon'); $objTemplate->setGlobalVariable($_ARRAYLANG + array('TXT_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_CURRENCY' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'TXT_SHOP_DISCOUNT_COUPON_AMOUNT_CURRENCY' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'TXT_SHOP_DISCOUNT_COUPON_ADD_OR_EDIT' => $_ARRAYLANG[$edit ? 'TXT_SHOP_DISCOUNT_COUPON_EDIT' : 'TXT_SHOP_DISCOUNT_COUPON_ADD'], 'SHOP_DISCOUNT_COUPON_VIEW_ACTIVE' => $edit ? '' : 'active', 'SHOP_DISCOUNT_COUPON_EDIT_ACTIVE' => $edit ? 'active' : '', 'SHOP_DISCOUNT_COUPON_VIEW_DISPLAY' => $edit ? 'none' : 'block', 'SHOP_DISCOUNT_COUPON_EDIT_DISPLAY' => $edit ? 'block' : 'none', 'HEADER_SHOP_DISCOUNT_COUPON_CODE' => $objSorting->getHeaderForField('code'), 'HEADER_SHOP_DISCOUNT_COUPON_START_TIME' => $objSorting->getHeaderForField('start_time'), 'HEADER_SHOP_DISCOUNT_COUPON_END_TIME' => $objSorting->getHeaderForField('end_time'), 'HEADER_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_CURRENCY' => $objSorting->getHeaderForField('minimum_amount'), 'HEADER_SHOP_DISCOUNT_COUPON_RATE' => $objSorting->getHeaderForField('discount_rate'), 'HEADER_SHOP_DISCOUNT_COUPON_AMOUNT_CURRENCY' => $objSorting->getHeaderForField('discount_amount'), 'HEADER_SHOP_DISCOUNT_COUPON_USES' => $objSorting->getHeaderForField('uses'), 'HEADER_SHOP_DISCOUNT_COUPON_SCOPE' => $objSorting->getHeaderForField('global'), 'HEADER_SHOP_DISCOUNT_COUPON_CUSTOMER' => $objSorting->getHeaderForField('customer_id'), 'HEADER_SHOP_DISCOUNT_COUPON_PRODUCT' => $objSorting->getHeaderForField('product_id'), 'HEADER_SHOP_DISCOUNT_COUPON_PAYMENT' => $objSorting->getHeaderForField('payment_id'))); $count = 0; $limit = \Cx\Core\Setting\Controller\Setting::getValue('numof_coupon_per_page_backend', 'Shop'); if (empty($limit)) { self::errorHandler(); } $arrCoupons = self::getArray(\Paging::getPosition(), $limit, $count, $objSorting->getOrder()); $arrProductName = Products::getNameArray(true, $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PRODUCT_FORMAT']); $arrPaymentName = Payment::getNameArray(); $i = 0; $row = 0; $objCouponEdit = new Coupon(); $objCouponEdit->code($code); $objCouponEdit->payment_id($payment_id); $objCouponEdit->minimum_amount($minimum_amount); $objCouponEdit->discount_rate($discount_rate); $objCouponEdit->discount_amount($discount_amount); $objCouponEdit->start_time($start_time); $objCouponEdit->end_time($end_time); $objCouponEdit->uses($uses); $objCouponEdit->is_global($global); $objCouponEdit->customer_id($customer_id); $objCouponEdit->product_id($product_id); global $_CONFIG; foreach ($arrCoupons as $index => $objCoupon) { $coupon_uri_id = 'coupon_uri_' . $index; $objTemplate->setVariable(array('SHOP_ROWCLASS' => 'row' . (++$row % 2 + 1), 'SHOP_DISCOUNT_COUPON_CODE' => $objCoupon->code, 'SHOP_DISCOUNT_COUPON_URI_ICON' => '<div class="icon_url"' . '> </div>', 'SHOP_DISCOUNT_COUPON_URI_INPUT' => '<div class="layer_url" id="' . $coupon_uri_id . '">' . \Html::getInputText('dummy', 'http://' . $_CONFIG['domainUrl'] . \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath() . '/' . CONTREXX_DIRECTORY_INDEX . '?section=Shop' . MODULE_INDEX . '&coupon_code=' . $objCoupon->code, false, 'readonly="readonly"' . ' style="width: 200px;"' . ' onfocus="this.select();"' . ' onblur="cx.jQuery(\'#' . $coupon_uri_id . '\').hide();"') . '</div>', 'SHOP_DISCOUNT_COUPON_START_TIME' => $objCoupon->start_time ? date(ASCMS_DATE_FORMAT_DATE, $objCoupon->start_time) : $_ARRAYLANG['TXT_SHOP_DATE_NONE'], 'SHOP_DISCOUNT_COUPON_END_TIME' => $objCoupon->end_time ? date(ASCMS_DATE_FORMAT_DATE, $objCoupon->end_time) : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_END_TIME_UNLIMITED'], 'SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT' => $objCoupon->minimum_amount > 0 ? $objCoupon->minimum_amount : $_ARRAYLANG['TXT_SHOP_AMOUNT_NONE'], 'SHOP_DISCOUNT_COUPON_RATE' => $objCoupon->discount_rate > 0 ? $objCoupon->discount_rate : $_ARRAYLANG['TXT_SHOP_RATE_NONE'], 'SHOP_DISCOUNT_COUPON_AMOUNT' => $objCoupon->discount_amount > 0 ? $objCoupon->discount_amount : $_ARRAYLANG['TXT_SHOP_AMOUNT_NONE'], 'SHOP_DISCOUNT_COUPON_USES' => sprintf($_ARRAYLANG['TXT_SHOP_COUPON_USES_FORMAT'], $objCoupon->used, $objCoupon->uses < 1000000000.0 ? $objCoupon->uses : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_USES_UNLIMITED']), 'SHOP_DISCOUNT_COUPON_SCOPE' => $objCoupon->global ? $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_GLOBALLY'] : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PER_CUSTOMER'], 'SHOP_DISCOUNT_COUPON_PER_CUSTOMER' => !$objCoupon->global ? \Html::getRadio('foo_' . ++$i, '', false, true, '', \Html::ATTRIBUTE_DISABLED) : ' ', 'SHOP_DISCOUNT_COUPON_CUSTOMER' => $objCoupon->customer_id ? Customers::getNameById($objCoupon->customer_id, '%4$s (%3$u)') : $_ARRAYLANG['TXT_SHOP_CUSTOMER_ANY'], 'SHOP_DISCOUNT_COUPON_PRODUCT' => $objCoupon->product_id ? isset($arrProductName[$objCoupon->product_id]) ? $arrProductName[$objCoupon->product_id] : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PRODUCT_INVALID'] : $_ARRAYLANG['TXT_SHOP_PRODUCT_ANY'], 'SHOP_DISCOUNT_COUPON_PAYMENT' => $objCoupon->payment_id ? sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PAYMENT_FORMAT'], $objCoupon->payment_id, $arrPaymentName[$objCoupon->payment_id]) : $_ARRAYLANG['TXT_SHOP_PAYMENT_ANY'], 'SHOP_DISCOUNT_COUPON_FUNCTIONS' => \Html::getBackendFunctions(array('edit' => ADMIN_SCRIPT_PATH . '?cmd=Shop&act=settings&tpl=coupon&edit=' . urlencode($index), 'delete' => "javascript:delete_coupon('" . urlencode($index) . "');")))); $objTemplate->parse('shopDiscountCouponView'); if ($index === $edit) { $objCouponEdit = $objCoupon; } } $objTemplate->replaceBlock('shopDiscountCouponView', '', true); $paging = \Paging::get($uri, $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CODES'], $count, $limit); //DBG::log("Paging: $paging"); $objTemplate->setVariable('SHOP_PAGING', $paging); $attribute_code = 'style="width: 230px; text-align: left;" maxlength="20"'; $attribute_time = 'style="width: 230px; text-align: left;" maxlength="10"'; $attribute_discount_rate = 'style="width: 230px; text-align: right;" maxlength="3"'; $attribute_discount_amount = 'style="width: 230px; text-align: right;" maxlength="9"'; $attribute_minimum_amount = 'style="width: 230px; text-align: right;" maxlength="9"'; $attribute_uses = 'style="width: 230px; text-align: right;" maxlength="6"'; // Superseded by the widget, see below // $attribute_customer = 'style="width: 230px;"'; $attribute_product = 'style="width: 230px;"'; $attribute_payment = 'style="width: 230px;"'; $type = $objCouponEdit->discount_rate > 0 ? 'rate' : 'amount'; $customer_name = ''; //reset the add view if (!$edit) { $objCouponEdit = new Coupon(); } if ($objCouponEdit->customer_id) { $customer_name = Customers::getNameById($objCouponEdit->customer_id, '%4$s (%3$u)'); //DBG::log("Customer ID ".$objCouponEdit->customer_id.": name $customer_name"); } $objTemplate->setVariable(array('SHOP_ROWCLASS' => 'row' . (++$row % 2 + 1), 'SHOP_DISCOUNT_COUPON_INDEX' => $objCouponEdit->getIndex(), 'SHOP_DISCOUNT_COUPON_CODE' => \Html::getInputText('code', $objCouponEdit->code, '', $attribute_code), 'SHOP_DISCOUNT_COUPON_CODE_CREATE' => \Html::getInputButton('code_create', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CODE_NEW'], 'button', false, 'onclick="cx.jQuery(\'#code\').val(\'' . Coupon::getNewCode() . '\');' . 'cx.jQuery(this).css(\'display\', \'none\');"'), 'SHOP_DISCOUNT_COUPON_START_TIME' => \Html::getDatepicker('start_date', array('defaultDate' => date(ASCMS_DATE_FORMAT_DATE, $objCouponEdit->start_time ? $objCouponEdit->start_time : time())), $attribute_time), 'SHOP_DISCOUNT_COUPON_END_TIME' => \Html::getDatepicker('end_date', array('defaultDate' => $objCouponEdit->end_time ? date(ASCMS_DATE_FORMAT_DATE, $objCouponEdit->end_time) : ''), $attribute_time), 'SHOP_DISCOUNT_COUPON_END_TIME_UNLIMITED' => \Html::getCheckbox('end_time_unlimited', 1, '', $objCouponEdit->end_time ? '' : \Html::ATTRIBUTE_CHECKED) . \Html::getLabel('end_time_unlimited', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_END_TIME_UNLIMITED']), 'SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT' => \Html::getInputText('minimum_amount', $objCouponEdit->minimum_amount, false, $attribute_minimum_amount), 'SHOP_DISCOUNT_COUPON_TYPE' => \Html::getRadioGroup('coupon_type', array('rate' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_TYPE_RATE'], 'amount' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_TYPE_AMOUNT']), $type), 'SHOP_DISCOUNT_COUPON_TYPE_SELECTED' => $type, 'SHOP_DISCOUNT_COUPON_RATE' => \Html::getInputText('discount_rate', $objCouponEdit->discount_rate, false, $attribute_discount_rate), 'SHOP_DISCOUNT_COUPON_AMOUNT' => \Html::getInputText('discount_amount', number_format($objCouponEdit->discount_amount, 2, '.', ''), false, $attribute_discount_amount), 'SHOP_DISCOUNT_COUPON_USES' => \Html::getInputText('uses', $objCouponEdit->uses < 1000000000.0 ? $objCouponEdit->uses : '', 'uses', $attribute_uses), 'SHOP_DISCOUNT_COUPON_USES_UNLIMITED' => \Html::getCheckbox('unlimited', 1, 'unlimited', $objCouponEdit->uses > 1000000000.0) . \Html::getLabel('unlimited', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_USES_UNLIMITED']), 'SHOP_DISCOUNT_COUPON_GLOBALLY' => \Html::getRadio('global_or_customer', '1', 'global', $objCouponEdit->global) . \Html::getLabel('global', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_GLOBALLY']), 'SHOP_DISCOUNT_COUPON_PER_CUSTOMER' => \Html::getRadio('global_or_customer', '0', 'customer', !$objCouponEdit->global) . \Html::getLabel('customer', $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PER_CUSTOMER']), 'SHOP_DISCOUNT_COUPON_CUSTOMER_ID' => $objCouponEdit->customer_id, 'SHOP_DISCOUNT_COUPON_CUSTOMER_NAME' => $customer_name, 'SHOP_DISCOUNT_COUPON_PRODUCT' => \Html::getSelect('product_id', array(0 => $_ARRAYLANG['TXT_SHOP_PRODUCT_ANY']) + $arrProductName, $objCouponEdit->product_id, false, '', $attribute_product), 'SHOP_DISCOUNT_COUPON_PAYMENT' => \Html::getSelect('payment_id', array(0 => $_ARRAYLANG['TXT_SHOP_PAYMENT_ANY']) + $arrPaymentName, $objCouponEdit->payment_id, false, '', $attribute_payment), 'SHOP_DISCOUNT_COUPON_CUSTOMER_WIDGET_DISPLAY' => $objCouponEdit->global ? \Html::CSS_DISPLAY_NONE : \Html::CSS_DISPLAY_INLINE)); $objTemplate->parse('shopDiscountCouponEdit'); // Depends on, and thus implies loading jQuery as well! \FWUser::getUserLiveSearch(array('minLength' => 3, 'canCancel' => true, 'canClear' => true)); return $result; }
function showNews() { global $objDatabase, $_ARRAYLANG, $_LANGID; $this->_objTpl->setTemplate($this->pageContent, true, true); //feed path $this->feedpath = \Env::get('cx')->getWebsiteFeedPath() . '/'; //active (with $_LANGID) categories $query = "SELECT id,\n name\n FROM " . DBPREFIX . "module_feed_category\n WHERE status = '1'\n AND lang = '" . $_LANGID . "'\n ORDER BY pos"; if ($objResult = $objDatabase->Execute($query)) { while (!$objResult->EOF) { $cat_id[$objResult->fields['id']] = $objResult->fields['id']; $cat_name[$objResult->fields['id']] = $objResult->fields['name']; $objResult->MoveNext(); } } //active news $query = "SELECT id,\n subid,\n name\n FROM " . DBPREFIX . "module_feed_news\n WHERE status = '1'\n ORDER BY pos"; $objResult = $objDatabase->Execute($query); while (!$objResult->EOF) { $news_subid[$objResult->fields['subid']][$objResult->fields['id']] = $objResult->fields['subid']; $news_id[$objResult->fields['subid']][$objResult->fields['id']] = $objResult->fields['id']; $news_name[$objResult->fields['subid']][$objResult->fields['id']] = $objResult->fields['name']; $objResult->MoveNext(); } //no empty categories if (is_array($cat_id)) { foreach ($cat_id as $x) { if (!isset($news_id[$x])) { unset($cat_id[$x]); unset($cat_name[$x]); } } } if (count($cat_id) == 0) { unset($cat_id); } //output structure if (!is_array($cat_id)) { if (!isset($_GET['cat']) and !isset($_GET['news'])) { $this->_objTpl->setVariable('FEED_NO_NEWSFEED', $_ARRAYLANG['TXT_FEED_NO_NEWSFEED']); } else { \Cx\Core\Csrf\Controller\Csrf::header("Location: " . CONTREXX_DIRECTORY_INDEX . "?section=Feed"); } } else { if ($this->_objTpl->blockExists('feed_cat')) { foreach ($cat_id as $x) { //out cat $this->_objTpl->setVariable('FEED_CAT_NAME', $cat_name[$x]); //out news foreach ($news_id[$x] as $y) { $this->_objTpl->setVariable(array('FEED_NEWS_LINK' => CONTREXX_DIRECTORY_INDEX . '?section=Feed&cat=' . $news_subid[$x][$y] . '&news=' . $news_id[$x][$y], 'FEED_NEWS_NAME' => strip_tags($news_name[$x][$y]))); $this->_objTpl->parse('feed_news'); } $this->_objTpl->parse('feed_cat'); } } // first access if (!isset($_GET['cat']) and !isset($_GET['news'])) { reset($cat_id); $_GET['cat'] = current($cat_id); reset($news_id[$_GET['cat']]); $_GET['news'] = current($news_id[$_GET['cat']]); /* foreach($cat_id as $x) { $_GET['cat'] = $cat_id[$x]; foreach($news_id[$x] as $y) { $_GET['news'] = $news_id[$x][$y]; break; } break; }*/ } $getCat = intval($_GET['cat']); $getNews = intval($_GET['news']); //refresh control $query = "SELECT time,\n cache\n FROM " . DBPREFIX . "module_feed_news\n WHERE id = '" . $getNews . "'\n AND subid = '" . $getCat . "'\n AND status = '1'"; $objResult = $objDatabase->Execute($query); if ($objResult->RecordCount() == 0) { \Cx\Core\Csrf\Controller\Csrf::header("Location: " . CONTREXX_DIRECTORY_INDEX . "?section=Feed"); die; } $old_time = $objResult->fields['time'] + $objResult->fields['cache']; $time = time(); if ($time >= $old_time) { $this->showNewsRefresh($getNews, $time, $this->feedpath); } $query = "SELECT name,\n filename,\n time,\n articles,\n image\n FROM " . DBPREFIX . "module_feed_news\n WHERE id = '" . $getNews . "'\n AND subid = '" . $getCat . "'\n AND status = '1'"; $objResult = $objDatabase->Execute($query); //output selected news $news_name = $objResult->fields['name']; $this->_objTpl->setVariable(array('FEED_CAT' => $cat_name[$getCat], 'FEED_PAGE' => $news_name)); $filename = $this->feedpath . $objResult->fields['filename']; //rss class $rss = new \XML_RSS($filename); $rss->parse(); //channel info $out_title = strip_tags($rss->channel['title']); $out_time = date(ASCMS_DATE_FORMAT, $objResult->fields['time']); //image foreach ($rss->getImages() as $img) { if ($img['url'] != '' && $objResult->fields['image'] == 1) { $out_image = '<img src="' . strip_tags($img['url']) . '" alt="" /><br />'; } } $this->_objTpl->setVariable(array('FEED_IMAGE' => $out_image, 'FEED_TITLE' => $out_title, 'FEED_TIME' => $out_time, 'TXT_FEED_LAST_UPTDATE' => $_ARRAYLANG['TXT_FEED_LAST_UPDATE'])); //items $x = 0; foreach ($rss->getItems() as $value) { if ($x < $objResult->fields['articles']) { $this->_objTpl->setVariable(array('FEED_ROWCLASS' => $x % 2 ? 'row2' : 'row1', 'FEED_DATE' => date('d.m.Y', strtotime($value['pubdate'])), 'FEED_LINK' => $value['link'], 'FEED_NAME' => $value['title'])); $this->_objTpl->parse('feed_output_news'); $x++; } } $this->_objTpl->parse('feed_show_news'); } }
/** * Adds an external settings view to the current template * * The content must contain the full view, including the surrounding form * tags and submit button. * Note that these are always appended on the right end of the tab list. * @param \Cx\Core\Html\Sigma $objTemplateLocal Template object * @param string $tab_name The tab name to add * @param string $content The external content * @return boolean True on success */ static function show_external(&$objTemplateLocal, $tab_name, $content) { if (empty($objTemplateLocal) || !$objTemplateLocal->blockExists('core_setting_row')) { $objTemplateLocal = new \Cx\Core\Html\Sigma(\Env::get('cx')->getCodeBaseDocumentRootPath() . '/core/Setting/View/Template/Generic'); if (!$objTemplateLocal->loadTemplateFile('Form.html')) { die("Failed to load template Form.html"); } } $active_tab = isset($_REQUEST['active_tab']) ? $_REQUEST['active_tab'] : 1; // The tabindex must be set in the form name in any case $objTemplateLocal->setGlobalVariable(array('CORE_SETTING_TAB_INDEX' => self::$tab_index, 'CORE_SETTING_EXTERNAL' => $content)); // Set up the tab, if any if (!empty($tab_name)) { $objTemplateLocal->setGlobalVariable(array('CORE_SETTING_TAB_NAME' => $tab_name, 'CORE_SETTING_TAB_INDEX' => self::$tab_index, 'CORE_SETTING_TAB_CLASS' => self::$tab_index == $active_tab ? 'active' : '', 'CORE_SETTING_TAB_DISPLAY' => self::$tab_index++ == $active_tab ? 'block' : 'none', 'CORE_SETTING_CURRENT_TAB' => 'tab-' . $active_tab)); $objTemplateLocal->touchBlock('core_setting_tab_row'); $objTemplateLocal->parse('core_setting_tab_row'); $objTemplateLocal->touchBlock('core_setting_tab_div_external'); $objTemplateLocal->parse('core_setting_tab_div_external'); } return true; }
/** * Render the option in the frontend. * * @param Sigma $template */ public function renderTheme($template) { $template->setVariable('TEMPLATE_EDITOR_' . strtoupper($this->name), $this->activeChoice); }
/** * Parse the current navigation item * * @global array $_ARRAYLANG * * @param \Cx\Core\Html\Sigma $navigation * @param string $blockName * @param string $currentCmd * @param string $mainCmd * @param boolean $isActiveNav * @param boolean $isSubNav */ protected function parseCurrentNavItem(\Cx\Core\Html\Sigma $navigation, $blockName, $currentCmd, $mainCmd, $isActiveNav, $isSubNav) { global $_ARRAYLANG; if (empty($blockName)) { return; } $isActiveNav ? $navigation->touchBlock($blockName . '_active') : $navigation->hideBlock($blockName . '_active'); if (empty($isSubNav)) { $act = empty($currentCmd) ? '' : '&act=' . $currentCmd; $txt = empty($currentCmd) ? 'DEFAULT' : $currentCmd; } else { $act = '&act=' . $mainCmd . '/' . $currentCmd; $txt = (empty($mainCmd) ? 'DEFAULT' : $mainCmd) . '_'; $txt .= empty($currentCmd) ? 'DEFAULT' : strtoupper($currentCmd); } $actTxtKey = 'TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName() . '_ACT_' . $txt); $actTitle = isset($_ARRAYLANG[$actTxtKey]) ? $_ARRAYLANG[$actTxtKey] : $actTxtKey; $navigation->setVariable(array('HREF' => 'index.php?cmd=' . $this->getName() . $act, 'TITLE' => $actTitle)); $navigation->parse($blockName . '_entry'); }
/** * Shows the collected messages, if any * * Frontend use only. * Returns a status according to the message classes: * - null, if no message is present * - false, if any message of class CLASS_ERROR is encountered * - true, if no messages of class CLASS_ERROR are found * @param \Cx\Core\Html\Sigma $objTemplateLocal * The optional Template * @return boolean The status */ private static function show_frontend($objTemplateLocal = null) { if (empty($_SESSION['messages'])) { return null; } global $objTemplate; if (empty($objTemplateLocal)) { $objTemplateLocal =& $objTemplate; } foreach (self::$message_classes as $class) { if (empty($_SESSION['messages'][$class])) { continue; } $objTemplateLocal->setVariable(array('MESSAGE_CLASS' => $class, 'MESSAGE_TEXT' => join('<br />', $_SESSION['messages'][$class]->toArray()))); if ($objTemplateLocal->blockExists('messages')) { $objTemplateLocal->parse('messages'); } else { // If no block can be parsed, leave after the first // non-empty message class. // Note: This is why classes are parsed in descending // order of severity! break; } } // Fail when there are error messages if (isset($_SESSION['messages'][self::CLASS_ERROR])) { return false; } return true; }