Example #1
0
 /**
  * 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');
         }
     }
 }
Example #2
0
 /**
  * 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);
     }
 }
Example #3
0
 private function parseDownload($objDownload, $categoryId)
 {
     global $_LANGID, $_ARRAYLANG;
     if (!$this->objTemplate->blockExists('downloads_file_detail')) {
         return;
     }
     $this->parseDownloadAttributes($objDownload, $categoryId);
     $this->objTemplate->parse('downloads_file_detail');
     $objDownload->incrementViewCount();
 }
Example #4
0
 /**
  * Show the list of categories
  */
 function showCategoryOverview()
 {
     $arrCategories = $this->createCategoryArray();
     $catTree = $this->buildCatTree($arrCategories);
     $catList = $this->parseCategoryView($catTree, $arrCategories);
     $this->_objTpl->setVariable("CATEGORIES", $catList);
     if ($this->_objTpl->blockExists("showDataCategories")) {
         $this->_objTpl->parse("showDataCategories");
     }
 }
Example #5
0
 /**
  * Set up the template block with the shipment terms and conditions
  *
  * Please *DO NOT* remove this method, despite the site terms and
  * conditions have been removed from the Shop!
  * This has been requested by some shopkeepers and may be used at will.
  * @global    array   $_ARRAYLANG     Language array
  * @author    Reto Kohli <*****@*****.**>
  */
 static function showShipmentTerms()
 {
     if (self::$objTemplate->blockExists('shopShipper')) {
         // TODO: Should be set by the calling view, if any
         global $_ARRAYLANG;
         self::$objTemplate->setGlobalVariable($_ARRAYLANG + array('SHOP_CURRENCY_SYMBOL' => Currency::getActiveCurrencySymbol(), 'SHOP_CURRENCY_CODE' => Currency::getActiveCurrencyCode()));
         $arrShipment = Shipment::getShipmentConditions();
         foreach ($arrShipment as $strShipperName => $arrContent) {
             $strCountries = join(', ', $arrContent['countries']);
             $arrConditions = $arrContent['conditions'];
             self::$objTemplate->setCurrentBlock('shopShipment');
             foreach ($arrConditions as $arrData) {
                 self::$objTemplate->setVariable(array('SHOP_MAX_WEIGHT' => $arrData['max_weight'], 'SHOP_COST_FREE' => $arrData['free_from'], 'SHOP_COST' => $arrData['fee']));
                 self::$objTemplate->parse('shopShipment');
             }
             self::$objTemplate->setVariable(array('SHOP_SHIPPER' => $strShipperName, 'SHOP_COUNTRIES' => $strCountries));
             self::$objTemplate->parse('shopShipper');
         }
     }
 }
 /**
  * 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');
         }
     }
 }
Example #7
0
 /**
  * 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;
 }
Example #8
0
 /**
  * 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;
 }
Example #9
0
 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&amp;cat=' . $news_subid[$x][$y] . '&amp;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');
     }
 }
Example #10
0
 /**
  * Set up the detail view of the selected order
  * @access  public
  * @param   \Cx\Core\Html\Sigma $objTemplate    The Template, by reference
  * @param   boolean             $edit           Edit if true, view otherwise
  * @global  ADONewConnection    $objDatabase    Database connection object
  * @global  array               $_ARRAYLANG     Language array
  * @return  boolean                             True on success,
  *                                              false otherwise
  * @static
  * @author  Reto Kohli <*****@*****.**> (parts)
  * @version 3.1.0
  */
 static function view_detail(&$objTemplate = null, $edit = false)
 {
     global $objDatabase, $_ARRAYLANG, $objInit;
     $backend = $objInit->mode == 'backend';
     if ($objTemplate->blockExists('order_list')) {
         $objTemplate->hideBlock('order_list');
     }
     $have_option = false;
     // The order total -- in the currency chosen by the customer
     $order_sum = 0;
     // recalculated VAT total
     $total_vat_amount = 0;
     $order_id = intval($_REQUEST['order_id']);
     if (!$order_id) {
         return \Message::error($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_INVALID_ORDER_ID']);
     }
     if (!$objTemplate) {
         $template_name = $edit ? 'module_shop_order_edit.html' : 'module_shop_order_details.html';
         $objTemplate = new \Cx\Core\Html\Sigma(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseModulePath() . '/Shop/View/Template/Backend');
         //DBG::log("Orders::view_list(): new Template: ".$objTemplate->get());
         $objTemplate->loadTemplateFile($template_name);
         //DBG::log("Orders::view_list(): loaded Template: ".$objTemplate->get());
     }
     $objOrder = Order::getById($order_id);
     if (!$objOrder) {
         //DBG::log("Shop::shopShowOrderdetails(): Failed to find Order ID $order_id");
         return \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_ORDER_NOT_FOUND'], $order_id));
     }
     // lsv data
     $query = "\n            SELECT `holder`, `bank`, `blz`\n              FROM " . DBPREFIX . "module_shop" . MODULE_INDEX . "_lsv\n             WHERE order_id={$order_id}";
     $objResult = $objDatabase->Execute($query);
     if (!$objResult) {
         return self::errorHandler();
     }
     if ($objResult->RecordCount() == 1) {
         $objTemplate->setVariable(array('SHOP_ACCOUNT_HOLDER' => contrexx_raw2xhtml($objResult->fields['holder']), 'SHOP_ACCOUNT_BANK' => contrexx_raw2xhtml($objResult->fields['bank']), 'SHOP_ACCOUNT_BLZ' => contrexx_raw2xhtml($objResult->fields['blz'])));
     }
     $customer_id = $objOrder->customer_id();
     if (!$customer_id) {
         //DBG::log("Shop::shopShowOrderdetails(): Invalid Customer ID $customer_id");
         \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_INVALID_CUSTOMER_ID'], $customer_id));
     }
     $objCustomer = Customer::getById($customer_id);
     if (!$objCustomer) {
         //DBG::log("Shop::shopShowOrderdetails(): Failed to find Customer ID $customer_id");
         \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_CUSTOMER_NOT_FOUND'], $customer_id));
         $objCustomer = new Customer();
         // No editing allowed!
         $have_option = true;
     }
     Vat::is_reseller($objCustomer->is_reseller());
     Vat::is_home_country(\Cx\Core\Setting\Controller\Setting::getValue('country_id', 'Shop') == $objOrder->country_id());
     $objTemplate->setGlobalVariable($_ARRAYLANG + array('SHOP_CURRENCY' => Currency::getCurrencySymbolById($objOrder->currency_id())));
     //DBG::log("Order sum: ".Currency::formatPrice($objOrder->sum()));
     $objTemplate->setVariable(array('SHOP_CUSTOMER_ID' => $customer_id, 'SHOP_ORDERID' => $order_id, 'SHOP_DATE' => date(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME, strtotime($objOrder->date_time())), 'SHOP_ORDER_STATUS' => $edit ? Orders::getStatusMenu($objOrder->status(), false, null, 'swapSendToStatus(this.value)') : $_ARRAYLANG['TXT_SHOP_ORDER_STATUS_' . $objOrder->status()], 'SHOP_SEND_MAIL_STYLE' => $objOrder->status() == Order::STATUS_CONFIRMED ? 'display: inline;' : 'display: none;', 'SHOP_SEND_MAIL_STATUS' => $edit ? $objOrder->status() != Order::STATUS_CONFIRMED ? \Html::ATTRIBUTE_CHECKED : '' : '', 'SHOP_ORDER_SUM' => Currency::formatPrice($objOrder->sum()), 'SHOP_DEFAULT_CURRENCY' => Currency::getDefaultCurrencySymbol(), 'SHOP_GENDER' => $edit ? Customer::getGenderMenu($objOrder->billing_gender(), 'billing_gender') : $_ARRAYLANG['TXT_SHOP_' . strtoupper($objOrder->billing_gender())], 'SHOP_COMPANY' => $objOrder->billing_company(), 'SHOP_FIRSTNAME' => $objOrder->billing_firstname(), 'SHOP_LASTNAME' => $objOrder->billing_lastname(), 'SHOP_ADDRESS' => $objOrder->billing_address(), 'SHOP_ZIP' => $objOrder->billing_zip(), 'SHOP_CITY' => $objOrder->billing_city(), 'SHOP_COUNTRY' => $edit ? \Cx\Core\Country\Controller\Country::getMenu('billing_country_id', $objOrder->billing_country_id()) : \Cx\Core\Country\Controller\Country::getNameById($objOrder->billing_country_id()), 'SHOP_PHONE' => $objOrder->billing_phone(), 'SHOP_FAX' => $objOrder->billing_fax(), 'SHOP_EMAIL' => $objOrder->billing_email(), 'SHOP_SHIP_GENDER' => $edit ? Customer::getGenderMenu($objOrder->gender(), 'shipPrefix') : $_ARRAYLANG['TXT_SHOP_' . strtoupper($objOrder->gender())], 'SHOP_SHIP_COMPANY' => $objOrder->company(), 'SHOP_SHIP_FIRSTNAME' => $objOrder->firstname(), 'SHOP_SHIP_LASTNAME' => $objOrder->lastname(), 'SHOP_SHIP_ADDRESS' => $objOrder->address(), 'SHOP_SHIP_ZIP' => $objOrder->zip(), 'SHOP_SHIP_CITY' => $objOrder->city(), 'SHOP_SHIP_COUNTRY' => $edit ? \Cx\Core\Country\Controller\Country::getMenu('shipCountry', $objOrder->country_id()) : \Cx\Core\Country\Controller\Country::getNameById($objOrder->country_id()), 'SHOP_SHIP_PHONE' => $objOrder->phone(), 'SHOP_PAYMENTTYPE' => Payment::getProperty($objOrder->payment_id(), 'name'), 'SHOP_CUSTOMER_NOTE' => $objOrder->note(), 'SHOP_COMPANY_NOTE' => $objCustomer->companynote(), 'SHOP_SHIPPING_TYPE' => $objOrder->shipment_id() ? Shipment::getShipperName($objOrder->shipment_id()) : '&nbsp;'));
     if ($backend) {
         $objTemplate->setVariable(array('SHOP_CUSTOMER_IP' => $objOrder->ip() ? '<a href="index.php?cmd=NetTools&amp;tpl=whois&amp;address=' . $objOrder->ip() . '" title="' . $_ARRAYLANG['TXT_SHOW_DETAILS'] . '">' . $objOrder->ip() . '</a>' : '&nbsp;', 'SHOP_CUSTOMER_HOST' => $objOrder->host() ? '<a href="index.php?cmd=NetTools&amp;tpl=whois&amp;address=' . $objOrder->host() . '" title="' . $_ARRAYLANG['TXT_SHOW_DETAILS'] . '">' . $objOrder->host() . '</a>' : '&nbsp;', 'SHOP_CUSTOMER_LANG' => \FWLanguage::getLanguageParameter($objOrder->lang_id(), 'name'), 'SHOP_CUSTOMER_BROWSER' => $objOrder->browser() ? $objOrder->browser() : '&nbsp;', 'SHOP_LAST_MODIFIED' => $objOrder->modified_on() && $objOrder->modified_on() != '0000-00-00 00:00:00' ? $objOrder->modified_on() . '&nbsp;' . $_ARRAYLANG['TXT_EDITED_BY'] . '&nbsp;' . $objOrder->modified_by() : $_ARRAYLANG['TXT_ORDER_WASNT_YET_EDITED']));
     } else {
         // Frontend: Order history ONLY.  Repeat the Order, go to cart
         $objTemplate->setVariable(array('SHOP_ACTION_URI_ENCODED' => \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'cart')));
     }
     $ppName = '';
     $psp_id = Payment::getPaymentProcessorId($objOrder->payment_id());
     if ($psp_id) {
         $ppName = PaymentProcessing::getPaymentProcessorName($psp_id);
     }
     $objTemplate->setVariable(array('SHOP_SHIPPING_PRICE' => $objOrder->shipment_amount(), 'SHOP_PAYMENT_PRICE' => $objOrder->payment_amount(), 'SHOP_PAYMENT_HANDLER' => $ppName, 'SHOP_LAST_MODIFIED_DATE' => $objOrder->modified_on()));
     if ($edit) {
         // edit order
         $strJsArrShipment = Shipment::getJSArrays();
         $objTemplate->setVariable(array('SHOP_SEND_TEMPLATE_TO_CUSTOMER' => sprintf($_ARRAYLANG['TXT_SEND_TEMPLATE_TO_CUSTOMER'], $_ARRAYLANG['TXT_ORDER_COMPLETE']), 'SHOP_SHIPPING_TYP_MENU' => Shipment::getShipperMenu($objOrder->country_id(), $objOrder->shipment_id(), "calcPrice(0);"), 'SHOP_JS_ARR_SHIPMENT' => $strJsArrShipment, 'SHOP_PRODUCT_IDS_MENU_NEW' => Products::getMenuoptions(null, null, $_ARRAYLANG['TXT_SHOP_PRODUCT_MENU_FORMAT']), 'SHOP_JS_ARR_PRODUCT' => Products::getJavascriptArray($objCustomer->group_id(), $objCustomer->is_reseller())));
     }
     $options = $objOrder->getOptionArray();
     if (!empty($options[$order_id])) {
         $have_option = true;
     }
     // Order items
     $total_weight = $i = 0;
     $total_net_price = $objOrder->view_items($objTemplate, $edit, $total_weight, $i);
     // Show VAT with the individual products:
     // If VAT is enabled, and we're both in the same country
     // ($total_vat_amount has been set above if both conditions are met)
     // show the VAT rate.
     // If there is no VAT, the amount is 0 (zero).
     //if ($total_vat_amount) {
     // distinguish between included VAT, and additional VAT added to sum
     $tax_part_percentaged = Vat::isIncluded() ? $_ARRAYLANG['TXT_TAX_PREFIX_INCL'] : $_ARRAYLANG['TXT_TAX_PREFIX_EXCL'];
     $objTemplate->setVariable(array('SHOP_TAX_PRICE' => Currency::formatPrice($total_vat_amount), 'SHOP_PART_TAX_PROCENTUAL' => $tax_part_percentaged));
     //} else {
     // No VAT otherwise
     // remove it from the details overview if empty
     //$objTemplate->hideBlock('taxprice');
     //$tax_part_percentaged = $_ARRAYLANG['TXT_NO_TAX'];
     //}
     // Parse Coupon if applicable to this product
     // Coupon
     $objCoupon = Coupon::getByOrderId($order_id);
     if ($objCoupon) {
         $discount = $objCoupon->discount_amount() != 0 ? $objCoupon->discount_amount() : $total_net_price / 100 * $objCoupon->discount_rate();
         $objTemplate->setVariable(array('SHOP_COUPON_NAME' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CODE'], 'SHOP_COUPON_CODE' => $objCoupon->code(), 'SHOP_COUPON_AMOUNT' => Currency::formatPrice(-$discount)));
         $total_net_price -= $discount;
         //DBG::log("Order::view_detail(): Coupon: ".var_export($objCoupon, true));
     }
     $objTemplate->setVariable(array('SHOP_ROWCLASS_NEW' => 'row' . (++$i % 2 + 1), 'SHOP_TOTAL_WEIGHT' => Weight::getWeightString($total_weight), 'SHOP_NET_PRICE' => Currency::formatPrice($total_net_price)));
     $objTemplate->setVariable(array('TXT_PRODUCT_ID' => $_ARRAYLANG['TXT_ID'], 'TXT_TAX_RATE' => Vat::isIncluded() ? $_ARRAYLANG['TXT_TAX_PREFIX_INCL'] : $_ARRAYLANG['TXT_TAX_PREFIX_EXCL'], 'TXT_SHOP_ACCOUNT_VALIDITY' => $_ARRAYLANG['TXT_SHOP_VALIDITY']));
     // Disable the "edit" button when there are Attributes
     if ($backend && !$edit) {
         if ($have_option) {
             if ($objTemplate->blockExists('order_no_edit')) {
                 $objTemplate->touchBlock('order_no_edit');
             }
         } else {
             if ($objTemplate->blockExists('order_edit')) {
                 $objTemplate->touchBlock('order_edit');
             }
         }
     }
     return true;
 }
 /**
  * Parse the registration related palceholders
  * $hostUri and $hostTarget should be set before calling this method
  *
  * @param \Cx\Core\Html\Sigma                           $objTpl         Template instance
  * @param \Cx\Modules\Calendar\Controller\CalendarEvent $event          Event instance
  * @param string                                        $hostUri        Host uri of the event(internal/external)
  * @param string                                        $hostTarget     Host uri target type (_blank/null)
  *
  * @return null
  */
 public function parseRegistrationPlaceholders(\Cx\Core\Html\Sigma $objTpl, CalendarEvent $event, $hostUri = '', $hostTarget = '')
 {
     global $_ARRAYLANG;
     $numRegistrations = contrexx_input2int($event->getRegistrationCount());
     $numDeregistration = contrexx_input2int($event->getCancellationCount());
     $objEscortManager = new \Cx\Modules\Calendar\Controller\CalendarRegistrationManager($event, true, false);
     $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_COUNT_REG' => $numRegistrations, $this->moduleLangVar . '_EVENT_COUNT_SIGNOFF' => $numDeregistration, $this->moduleLangVar . '_EVENT_COUNT_SUBSCRIBER' => $objEscortManager->getEscortData(), $this->moduleLangVar . '_REGISTRATIONS_SUBSCRIBER' => $event->numSubscriber));
     // Only link to registration form if event registration is set up and event lies in the future
     if (!$event->registration || time() > $event->startDate->getTimestamp()) {
         $objTpl->hideBlock('calendarEventRegistration');
         return;
     }
     // Only show registration form if event accepts registrations.
     // Event accepts registrations, if
     //     - no attendee limit is set
     //     - or if there are still free places available
     $registrationOpen = true;
     $regLinkTarget = '_self';
     if ($event->registration == CalendarEvent::EVENT_REGISTRATION_EXTERNAL && !$event->registrationExternalFullyBooked || $event->registration == CalendarEvent::EVENT_REGISTRATION_INTERNAL && (empty($event->numSubscriber) || !\FWValidator::isEmpty($event->getFreePlaces()))) {
         if ($event->registration == CalendarEvent::EVENT_REGISTRATION_EXTERNAL) {
             $regLinkSrc = \FWValidator::getUrl($event->registrationExternalLink);
             $regLinkTarget = '_blank';
         } elseif ($hostUri) {
             $regLinkSrc = $hostUri . '/' . CONTREXX_DIRECTORY_INDEX . '?section=' . $this->moduleName . '&amp;cmd=register&amp;id=' . $event->id . '&amp;date=' . $event->startDate->getTimestamp();
         } else {
             $params = array('id' => $event->id, 'date' => $event->startDate->getTimestamp());
             $regLinkSrc = \Cx\Core\Routing\Url::fromModuleAndCmd($this->moduleName, 'register', FRONTEND_LANG_ID, $params)->toString();
         }
         $regLink = '<a href="' . $regLinkSrc . '" ' . $hostTarget . '>' . $_ARRAYLANG['TXT_CALENDAR_REGISTRATION'] . '</a>';
     } else {
         $regLink = '<i>' . $_ARRAYLANG['TXT_CALENDAR_EVENT_FULLY_BLOCKED'] . '</i>';
         $regLinkSrc = '';
         $registrationOpen = false;
     }
     $objTpl->setVariable(array($this->moduleLangVar . '_EVENT_REGISTRATION_LINK' => $regLink, $this->moduleLangVar . '_EVENT_REGISTRATION_LINK_SRC' => $regLinkSrc, $this->moduleLangVar . '_EVENT_REGISTRATION_LINK_TARGET' => $regLinkTarget));
     if ($objTpl->blockExists('calendarEventRegistrationOpen')) {
         if ($registrationOpen) {
             $objTpl->touchBlock('calendarEventRegistrationOpen');
         } else {
             $objTpl->hideBlock('calendarEventRegistrationOpen');
         }
     }
     if ($objTpl->blockExists('calendarEventRegistrationClosed')) {
         if (!$registrationOpen) {
             $objTpl->touchBlock('calendarEventRegistrationClosed');
         } else {
             $objTpl->hideBlock('calendarEventRegistrationClosed');
         }
     }
     $objTpl->parse('calendarEventRegistration');
 }
Example #12
0
 /**
  * The Cart view
  *
  * Mind that the Cart needs to be {@see update()}d before calling this
  * method.
  * @global  array $_ARRAYLANG   Language array
  * @param   \Cx\Core\Html\Sigma $objTemplate  The optional Template
  */
 static function view($objTemplate = null)
 {
     global $_ARRAYLANG;
     if (!$objTemplate) {
         // TODO: Handle missing or empty Template, load one
         die("Cart::view(): ERROR: No template");
         //            return false;
     }
     $objTemplate->setGlobalVariable($_ARRAYLANG);
     $i = 0;
     if (count(self::$products)) {
         foreach (self::$products as $arrProduct) {
             $groupCountId = $arrProduct['group_id'];
             $groupArticleId = $arrProduct['article_id'];
             $groupCustomerId = 0;
             if (Shop::customer()) {
                 $groupCustomerId = Shop::customer()->group_id();
             }
             Shop::showDiscountInfo($groupCustomerId, $groupArticleId, $groupCountId, $arrProduct['quantity']);
             // product image
             $arrProductImg = Products::get_image_array_from_base64($arrProduct['product_images']);
             $shopImagesWebPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesWebPath() . '/Shop/';
             $thumbnailPath = $shopImagesWebPath . ShopLibrary::noPictureName;
             foreach ($arrProductImg as $productImg) {
                 if (!empty($productImg['img']) && $productImg['img'] != ShopLibrary::noPictureName) {
                     $thumbnailPath = $shopImagesWebPath . \ImageManager::getThumbnailFilename($productImg['img']);
                     break;
                 }
             }
             /* UNUSED (and possibly obsolete, too)
                             if (isset($arrProduct['discount_string'])) {
             //DBG::log("Shop::view_cart(): Product ID ".$arrProduct['id'].": ".$arrProduct['discount_string']);
                                 $objTemplate->setVariable(
                                     'SHOP_DISCOUNT_COUPON_STRING',
                                         $arrProduct['coupon_string']
                                 );
                             }*/
             // The fields that don't apply have been set to ''
             // (empty string) already -- see update().
             $objTemplate->setVariable(array('SHOP_PRODUCT_ROW' => 'row' . (++$i % 2 + 1), 'SHOP_PRODUCT_ID' => $arrProduct['id'], 'SHOP_PRODUCT_CODE' => $arrProduct['product_id'], 'SHOP_PRODUCT_THUMBNAIL' => $thumbnailPath, 'SHOP_PRODUCT_CART_ID' => $arrProduct['cart_id'], 'SHOP_PRODUCT_TITLE' => str_replace('"', '&quot;', contrexx_raw2xhtml($arrProduct['title'])), 'SHOP_PRODUCT_PRICE' => $arrProduct['price'], 'SHOP_PRODUCT_PRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_PRODUCT_QUANTITY' => $arrProduct['quantity'], 'SHOP_PRODUCT_ITEMPRICE' => $arrProduct['itemprice'], 'SHOP_PRODUCT_ITEMPRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_REMOVE_PRODUCT' => $_ARRAYLANG['TXT_SHOP_REMOVE_ITEM']));
             //DBG::log("Attributes String: {$arrProduct['options_long']}");
             if ($arrProduct['options_long']) {
                 $objTemplate->setVariable('SHOP_PRODUCT_OPTIONS', $arrProduct['options_long']);
             }
             if (\Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop')) {
                 $objTemplate->setVariable(array('SHOP_PRODUCT_WEIGHT' => Weight::getWeightString($arrProduct['weight']), 'TXT_WEIGHT' => $_ARRAYLANG['TXT_TOTAL_WEIGHT']));
             }
             if (Vat::isEnabled()) {
                 $objTemplate->setVariable(array('SHOP_PRODUCT_TAX_RATE' => $arrProduct['vat_rate'] ? Vat::format($arrProduct['vat_rate']) : '', 'SHOP_PRODUCT_TAX_AMOUNT' => $arrProduct['vat_amount'] . '&nbsp;' . Currency::getActiveCurrencySymbol()));
             }
             if (intval($arrProduct['minimum_order_quantity']) > 0) {
                 $objTemplate->setVariable(array('SHOP_PRODUCT_MINIMUM_ORDER_QUANTITY' => $arrProduct['minimum_order_quantity']));
             } else {
                 if ($objTemplate->blockExists('orderQuantity')) {
                     $objTemplate->hideBlock('orderQuantity');
                 }
                 if ($objTemplate->blockExists('minimumOrderQuantity')) {
                     $objTemplate->hideBlock('minimumOrderQuantity');
                 }
             }
             $objTemplate->parse('shopCartRow');
         }
     } else {
         $objTemplate->hideBlock('shopCart');
         if ($objTemplate->blockExists('shopCartEmpty')) {
             $objTemplate->touchBlock('shopCartEmpty');
             $objTemplate->parse('shopCartEmpty');
         }
         if ($_SESSION['shop']['previous_product_ids']) {
             $ids = $_SESSION['shop']['previous_product_ids']->toArray();
             Shop::view_product_overview($ids);
         }
     }
     $objTemplate->setGlobalVariable(array('TXT_PRODUCT_ID' => $_ARRAYLANG['TXT_ID'], 'SHOP_PRODUCT_TOTALITEM' => self::get_item_count(), 'SHOP_PRODUCT_TOTALPRICE' => Currency::formatPrice(self::get_price()), 'SHOP_PRODUCT_TOTALPRICE_PLUS_VAT' => Currency::formatPrice(self::get_price() + (Vat::isEnabled() && !Vat::isIncluded() ? self::get_vat_amount() : 0)), 'SHOP_PRODUCT_TOTALPRICE_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_TOTAL_WEIGHT' => Weight::getWeightString(self::get_weight()), 'SHOP_PRICE_UNIT' => Currency::getActiveCurrencySymbol()));
     // Show the Coupon code field only if there is at least one defined
     if (Coupon::count_available()) {
         //DBG::log("Coupons available");
         $objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_CODE' => isset($_SESSION['shop']['coupon_code']) ? $_SESSION['shop']['coupon_code'] : ''));
         if ($objTemplate->blockExists('shopCoupon')) {
             $objTemplate->parse('shopCoupon');
         }
         if (self::get_discount_amount()) {
             $total_discount_amount = self::get_discount_amount();
             //DBG::log("Shop::view_cart(): Total: Amount $total_discount_amount");
             $objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_TOTAL' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_TOTAL'], 'SHOP_DISCOUNT_COUPON_TOTAL_AMOUNT' => Currency::formatPrice(-$total_discount_amount)));
         }
     }
     if (Vat::isEnabled()) {
         $objTemplate->setVariable(array('TXT_TAX_PREFIX' => Vat::isIncluded() ? $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_INCL'] : $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_EXCL'], 'SHOP_TOTAL_TAX_AMOUNT' => self::get_vat_amount() . '&nbsp;' . Currency::getActiveCurrencySymbol()));
         if (Vat::isIncluded()) {
             $objTemplate->setVariable(array('SHOP_GRAND_TOTAL_EXCL_TAX' => Currency::formatPrice(self::get_price() - self::get_vat_amount()) . '&nbsp;' . Currency::getActiveCurrencySymbol()));
         }
     }
     if (self::needs_shipment()) {
         $objTemplate->setVariable(array('TXT_SHIP_COUNTRY' => $_ARRAYLANG['TXT_SHIP_COUNTRY'], 'SHOP_COUNTRIES_MENU' => \Cx\Core\Country\Controller\Country::getMenu('countryId2', $_SESSION['shop']['countryId2'], true, "document.forms['shopForm'].submit()"), 'SHOP_COUNTRIES_MENUOPTIONS' => \Cx\Core\Country\Controller\Country::getMenuoptions($_SESSION['shop']['countryId2'])));
     }
     if (\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_min', 'Shop') > 0 && \Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_min', 'Shop') > self::get_price()) {
         $objTemplate->setVariable('MESSAGE_TEXT', sprintf($_ARRAYLANG['TXT_SHOP_ORDERITEMS_AMOUNT_MIN'], Currency::formatPrice(\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_min', 'Shop')), Currency::getActiveCurrencySymbol()));
     } elseif (\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_max', 'Shop') > 0 && \Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_max', 'Shop') < self::get_price()) {
         $objTemplate->setVariable('MESSAGE_TEXT', sprintf($_ARRAYLANG['TXT_SHOP_ORDERITEMS_AMOUNT_MAX'], Currency::formatPrice(\Cx\Core\Setting\Controller\Setting::getValue('orderitems_amount_max', 'Shop')), Currency::getActiveCurrencySymbol()));
     } else {
         $objTemplate->setVariable('TXT_NEXT', $_ARRAYLANG['TXT_NEXT']);
     }
 }
 /**
  * Render the option in the frontend.
  *
  * @param Sigma $template
  */
 public function renderTheme($template)
 {
     $blockName = strtolower('TEMPLATE_EDITOR_' . $this->name);
     if ($template->blockExists($blockName)) {
         foreach ($this->urls as $id => $url) {
             $template->setVariable(strtoupper('TEMPLATE_EDITOR_' . $this->name), contrexx_raw2xhtml($url));
             $template->parse($blockName);
         }
     }
 }
Example #14
0
 /**
  * Parses the main template in order to finish request
  * @todo Remove usage of globals
  * @global type $themesPages
  * @global null $moduleStyleFile
  * @global array $_CONFIG
  * @global type $subMenuTitle
  * @global type $_CORELANG
  * @global type $plainCmd
  * @global type $cmd
  */
 protected function finalize()
 {
     global $themesPages, $moduleStyleFile, $_CONFIG, $subMenuTitle, $_CORELANG, $plainCmd, $cmd;
     if ($this->mode == self::MODE_FRONTEND) {
         // parse system
         $parsingTime = $this->stopTimer();
         $this->template->setVariable('PARSING_TIME', $parsingTime);
         $this->parseGlobalPlaceholders($themesPages['sidebar']);
         $this->template->setVariable(array('SIDEBAR_FILE' => $themesPages['sidebar'], 'JAVASCRIPT_FILE' => $themesPages['javascript'], 'BUILDIN_STYLE_FILE' => $themesPages['buildin_style'], 'DATE_YEAR' => date('Y'), 'DATE_MONTH' => date('m'), 'DATE_DAY' => date('d'), 'DATE_TIME' => date('H:i'), 'BUILDIN_STYLE_FILE' => $themesPages['buildin_style'], 'JAVASCRIPT_LIGHTBOX' => '<script type="text/javascript" src="lib/lightbox/javascript/mootools.js"></script>
                 <script type="text/javascript" src="lib/lightbox/javascript/slimbox.js"></script>', 'JAVASCRIPT_MOBILE_DETECTOR' => '<script type="text/javascript" src="lib/mobiledetector.js"></script>'));
         if (!empty($moduleStyleFile)) {
             $this->template->setVariable('STYLE_FILE', "<link rel=\"stylesheet\" href=\"{$moduleStyleFile}\" type=\"text/css\" media=\"screen, projection\" />");
         }
         if (!$this->resolvedPage->getUseSkinForAllChannels() && isset($_GET['pdfview']) && intval($_GET['pdfview']) == 1) {
             $pageTitle = $this->resolvedPage->getTitle();
             $extenstion = empty($pageTitle) ? null : '.pdf';
             $objPDF = new \Cx\Core_Modules\Pdf\Model\Entity\PdfDocument();
             $objPDF->SetTitle($pageTitle . $extenstion);
             $objPDF->setContent($this->template->get());
             $objPDF->Create();
             exit;
         }
         // fetch the parsed webpage
         $this->template->setVariable('JAVASCRIPT', 'javascript_inserting_here');
         $endcode = $this->template->get();
         /**
          * Get all javascripts in the code, replace them with nothing, and register the js file
          * to the javascript lib. This is because we don't want something twice, and there could be
          * a theme that requires a javascript, which then could be used by a module too and therefore would
          * be loaded twice.
          */
         /* Finds all uncommented script tags, strips them out of the HTML and
          * stores them internally so we can put them in the placeholder later
          * (see JS::getCode() below)
          */
         \JS::findJavascripts($endcode);
         /*
          * Proposal:  Use this
          *     $endcode = preg_replace_callback('/<script\s.*?src=(["\'])(.*?)(\1).*?\/?>(?:<\/script>)?/i', array('JS', 'registerFromRegex'), $endcode);
          * and change JS::registerFromRegex to use index 2
          */
         // i know this is ugly, but is there another way
         $endcode = str_replace('javascript_inserting_here', \JS::getCode(), $endcode);
         // do a final replacement of all those node-urls ({NODE_<ID>_<LANG>}- placeholders) that haven't been captured earlier
         $endcode = preg_replace('/\\[\\[([A-Z0-9_-]+)\\]\\]/', '{\\1}', $endcode);
         \LinkGenerator::parseTemplate($endcode);
         // remove the meta tag X-UA-Compatible if the user agent ist neighter internet explorer nor chromeframe
         if (!preg_match('/(msie|chromeframe)/i', $_SERVER['HTTP_USER_AGENT'])) {
             $endcode = preg_replace('/<meta.*?X-UA-Compatible.*?>/i', '', $endcode);
         }
         // replace links from before contrexx 3
         $ls = new \LinkSanitizer($this, $this->getCodeBaseOffsetPath() . \Env::get('virtualLanguageDirectory') . '/', $endcode);
         $this->endcode = $ls->replace();
     } else {
         // backend meta navigation
         if ($this->template->blockExists('backend_metanavigation')) {
             // parse language navigation
             if ($this->template->blockExists('backend_language_navigation') && $this->template->blockExists('backend_language_navigation_item')) {
                 $backendLanguage = \FWLanguage::getActiveBackendLanguages();
                 if (count($backendLanguage) > 1) {
                     $this->template->setVariable('TXT_LANGUAGE', $_CORELANG['TXT_LANGUAGE']);
                     foreach ($backendLanguage as $language) {
                         $languageUrl = \Env::get('init')->getUriBy('setLang', $language['id']);
                         $this->template->setVariable(array('LANGUAGE_URL' => contrexx_raw2xhtml($languageUrl), 'LANGUAGE_NAME' => $language['name'], 'LANGUAGE_CSS' => \Env::get('init')->getBackendLangId() == $language['id'] ? 'active' : ''));
                         $this->template->parse('backend_language_navigation_item');
                     }
                     $this->template->parse('backend_language_navigation');
                 } else {
                     $this->template->hideBlock('backend_language_navigation');
                 }
             }
             $this->template->touchBlock('backend_metanavigation');
         }
         // page parsing
         $parsingTime = $this->stopTimer();
         //                var_dump($parsingTime);
         /*echo ($finishTime[0] - $startTime[0]) . '<br />';
           if (!isset($_SESSION['asdf1']) || isset($_GET['reset'])) {
               $_SESSION['asdf1'] = 0;
               $_SESSION['asdf2'] = 0;
           }
           echo $_SESSION['asdf1'] . '<br />';
           if ($_SESSION['asdf1'] > 0) {
               echo $_SESSION['asdf2'] / $_SESSION['asdf1'];
           }
           $_SESSION['asdf1']++;
           $_SESSION['asdf2'] += ($finishTime[0] - $startTime[0]);//*/
         $objAdminNav = new \adminMenu($plainCmd);
         $objAdminNav->getAdminNavbar();
         $this->template->setVariable(array('SUB_MENU_TITLE' => $subMenuTitle, 'FRONTEND_LANG_MENU' => \Env::get('init')->getUserFrontendLangMenu(), 'TXT_GENERATED_IN' => $_CORELANG['TXT_GENERATED_IN'], 'TXT_SECONDS' => $_CORELANG['TXT_SECONDS'], 'TXT_LOGOUT_WARNING' => $_CORELANG['TXT_LOGOUT_WARNING'], 'PARSING_TIME' => $parsingTime, 'LOGGED_NAME' => htmlentities($this->getUser()->objUser->getProfileAttribute('firstname') . ' ' . $this->getUser()->objUser->getProfileAttribute('lastname'), ENT_QUOTES, CONTREXX_CHARSET), 'TXT_LOGGED_IN_AS' => $_CORELANG['TXT_LOGGED_IN_AS'], 'TXT_LOG_OUT' => $_CORELANG['TXT_LOG_OUT'], 'MODULE_INDEX' => MODULE_INDEX, 'JAVASCRIPT' => \JS::getCode(), 'CX_EDITION' => $_CONFIG['coreCmsEdition'], 'CX_VERSION' => $_CONFIG['coreCmsVersion'], 'CX_CODE_NAME' => $_CONFIG['coreCmsCodeName'], 'CX_STATUS' => $_CONFIG['coreCmsStatus'], 'CX_RELEASE_DATE' => date(ASCMS_DATE_FORMAT_DATE, $_CONFIG['coreCmsReleaseDate']), 'CX_NAME' => $_CONFIG['coreCmsName']));
         // Style parsing
         if (file_exists($this->codeBaseAdminTemplatePath . '/css/' . $cmd . '.css')) {
             // check if there's a css file in the core section
             $this->template->setVariable('ADD_STYLE_URL', $this->codeBaseAdminTemplateWebPath . '/css/' . $cmd . '.css');
             $this->template->parse('additional_style');
         } elseif (file_exists($this->codeBaseModulePath . '/' . $cmd . '/template/backend.css')) {
             // of maybe in the current module directory
             $this->template->setVariable('ADD_STYLE_URL', $this->codeBaseModuleWebPath . '/' . $cmd . '/template/backend.css');
             $this->template->parse('additional_style');
         } elseif (file_exists($this->codeBaseCoreModulePath . '/' . $cmd . '/template/backend.css')) {
             // or in the core module directory
             $this->template->setVariable('ADD_STYLE_URL', $this->codeBaseCoreModuleWebPath . '/' . $cmd . '/template/backend.css');
             $this->template->parse('additional_style');
         } else {
             $this->template->hideBlock('additional_style');
         }
         /*echo '<pre>';
           print_r($_SESSION);
           /*echo '<b>Overall time: ' . (microtime(true) - $timeAtStart) . 's<br />';
           echo 'Max RAM usage: ' . formatBytes(memory_get_peak_usage()) . '<br />';
           echo 'End RAM usage: ' . formatBytes(memory_get_usage()) . '<br /></b>';*/
         $endcode = $this->template->get();
         // replace links from before contrexx 3
         $ls = new \LinkSanitizer($this, $this->getCodeBaseOffsetPath() . $this->getBackendFolderName() . '/', $endcode);
         $this->endcode = $ls->replace();
     }
     \DBG::log("(Cx: {$this->id}) Request parsing completed after {$parsingTime}");
 }
Example #15
0
 /**
  * shows the list of objects, also handles search requests
  * @return void
  */
 function _showImmoList()
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     //TODO
     //handle last step of quickSeach and DetailSearch here
     $this->_objTpl->setGlobalVariable(array('TXT_IMMO_BACK' => $_ARRAYLANG['TXT_IMMO_BACK'], 'TXT_IMMO_CURRENCY_PREFIX' => $this->arrSettings['currency_lang_' . $this->frontLang], 'TXT_IMMO_CURRENCY_SUFFIX' => $this->_currencySuffix, 'TXT_IMMO_MORE_INFOS' => $_ARRAYLANG['TXT_IMMO_MORE_INFOS']));
     $locations = contrexx_addslashes(strip_tags($_REQUEST['locations']));
     $obj_type = contrexx_addslashes(strip_tags($_REQUEST['obj_type']));
     $property_type = contrexx_addslashes(strip_tags($_REQUEST['property_type']));
     $new_building = contrexx_addslashes(strip_tags($_REQUEST['new_building']));
     $logo = contrexx_addslashes(strip_tags($_REQUEST['logo']));
     if (!empty($_REQUEST['foreigner_auth'])) {
         $foreigner_auth = intval($_REQUEST['foreigner_auth']) > 0 ? $_ARRAYLANG['TXT_IMMO_YES'] : $_ARRAYLANG['TXT_IMMO_NO'];
     }
     $fprice = contrexx_addslashes(strip_tags($_REQUEST['fprice']));
     $tprice = contrexx_addslashes(strip_tags($_REQUEST['tprice']));
     $frooms = contrexx_addslashes(strip_tags($_REQUEST['frooms']));
     $trooms = contrexx_addslashes(strip_tags($_REQUEST['trooms']));
     //show all
     $orderBy = !empty($_REQUEST['order_by']) ? contrexx_addslashes($_REQUEST['order_by']) : 'location';
     $query = 'SELECT     immo.id AS immo_id, reference, visibility,
                         a.fieldvalue AS location,
                         CAST(b.fieldvalue AS UNSIGNED) AS price,
                         c.fieldvalue AS header,
                         d.fieldvalue AS headline,
                         e.fieldvalue AS rooms,
                         f.fieldvalue AS address,
                         img.uri      AS imgsrc
                 FROM ' . DBPREFIX . 'module_immo AS immo
                 LEFT JOIN ' . DBPREFIX . 'module_immo_content AS a ON ( immo.id = a.immo_id
                                                             AND a.field_id = (
                                                                 SELECT field_id
                                                                 FROM ' . DBPREFIX . 'module_immo_fieldname
                                                                 WHERE name = "ort"
                                                                 AND lang_id = 1 )
                                                             AND a.lang_id = ' . $this->frontLang . ' )
                 LEFT JOIN ' . DBPREFIX . 'module_immo_content AS b ON ( immo.id = b.immo_id
                                                             AND b.field_id = (
                                                                 SELECT field_id
                                                                 FROM ' . DBPREFIX . 'module_immo_fieldname
                                                                 WHERE name = "preis"
                                                                 AND lang_id = 1 )
                                                             AND b.lang_id = ' . $this->frontLang . ' )
                 LEFT JOIN ' . DBPREFIX . 'module_immo_content AS c ON ( immo.id = c.immo_id
                                                             AND c.field_id = (
                                                                 SELECT field_id
                                                                 FROM ' . DBPREFIX . 'module_immo_fieldname
                                                                 WHERE name = "kopfzeile"
                                                                 AND lang_id = 1 )
                                                             AND c.lang_id = ' . $this->frontLang . ' )
                 LEFT JOIN ' . DBPREFIX . 'module_immo_content AS d ON ( immo.id = d.immo_id
                                                             AND d.field_id = (
                                                                 SELECT field_id
                                                                 FROM ' . DBPREFIX . 'module_immo_fieldname
                                                                 WHERE name = "headline"
                                                                 AND lang_id = 1 )
                                                             AND d.lang_id = ' . $this->frontLang . ' )
                 LEFT JOIN ' . DBPREFIX . 'module_immo_content AS e ON ( immo.id = e.immo_id
                                                             AND e.field_id = (
                                                                 SELECT field_id
                                                                 FROM ' . DBPREFIX . 'module_immo_fieldname
                                                                 WHERE name = "anzahl zimmer"
                                                                 AND lang_id = 1 )
                                                             AND e.lang_id = ' . $this->frontLang . ' )
                 LEFT JOIN ' . DBPREFIX . 'module_immo_content AS f ON ( immo.id = f.immo_id
                                                             AND f.field_id = (
                                                                 SELECT field_id
                                                                 FROM ' . DBPREFIX . 'module_immo_fieldname
                                                                 WHERE name = "adresse"
                                                                 AND lang_id = 1 )
                                                             AND f.lang_id = ' . $this->frontLang . ' )
                 LEFT JOIN ' . DBPREFIX . 'module_immo_image AS img ON ( immo.id = img.immo_id
                                                             AND img.field_id = (
                                                                 SELECT field_id
                                                                 FROM ' . DBPREFIX . 'module_immo_fieldname
                                                                 WHERE name = "übersichtsbild" )
                                                             )
                 WHERE  ( visibility = "listing"';
     if (!empty($_REQUEST['ref_nr'])) {
         $query .= " OR visibility = 'reference' ) ";
     } else {
         $query .= ") ORDER BY {$orderBy} ASC";
     }
     //request from search form?
     if (empty($_REQUEST['ref_nr'])) {
         //fulltext search
         $keys1 = array_filter(array_keys($_ARRAYLANG), array(&$this, "filterImmoType"));
         foreach ($keys1 as $key) {
             $keys[$key] = $_ARRAYLANG[$key];
         }
         array_walk($keys, array(&$this, 'arrStrToLower'));
         $searchterm = contrexx_addslashes($_REQUEST['search']);
         if (!empty($searchterm) && strlen($searchterm) <= 3) {
             $this->_objTpl->setVariable("TXT_IMMO_SEARCHTERM_TOO_SHORT", $_ARRAYLANG['TXT_IMMO_SEARCHTERM_TOO_SHORT']);
             return false;
         }
         $query = "  SELECT immo.id AS `immo_id`, immo.reference AS `reference`, immo.object_type AS otype, immo.new_building AS `new`, immo.property_type AS ptype, logo,\n                        a.fieldvalue as headline,\n                        CAST(b.fieldvalue AS UNSIGNED) as price,\n                        c.fieldvalue as header,\n                        d.fieldvalue as location,\n                        e.fieldvalue as rooms,\n                        f.fieldvalue as foreigner_authorization,\n                        g.fieldvalue as address,\n                        img.uri AS imgsrc\n                        FROM " . DBPREFIX . "module_immo AS immo";
         if (!empty($searchterm)) {
             $query .= " LEFT JOIN " . DBPREFIX . "module_immo_content AS content on ( content.immo_id = immo.id ) ";
         }
         $query .= " LEFT JOIN " . DBPREFIX . "module_immo_content AS a ON ( immo.id = a.immo_id\n                                                                AND a.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'headline'\n                                                                    AND lang_id = 1 )\n                                                                AND a.lang_id = " . $this->frontLang . " )\n                        LEFT JOIN " . DBPREFIX . "module_immo_content AS b ON ( immo.id = b.immo_id\n                                                                AND b.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'preis'\n                                                                    AND lang_id = 1 )\n                                                                AND b.lang_id = " . $this->frontLang . " )\n                        LEFT JOIN " . DBPREFIX . "module_immo_content AS c ON ( immo.id = c.immo_id\n                                                                AND c.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'kopfzeile'\n                                                                    AND lang_id = 1 )\n                                                                AND c.lang_id = " . $this->frontLang . " )\n                        LEFT JOIN " . DBPREFIX . "module_immo_content AS d ON ( immo.id = d.immo_id\n                                                                AND d.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'ort'\n                                                                    AND lang_id = 1 )\n                                                                AND d.lang_id = " . $this->frontLang . " )\n                        LEFT JOIN " . DBPREFIX . "module_immo_content AS e ON ( immo.id = e.immo_id\n                                                                AND e.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'anzahl zimmer'\n                                                                    AND lang_id = 1 )\n                                                                AND e.lang_id = " . $this->frontLang . " )\n                        LEFT JOIN " . DBPREFIX . "module_immo_content AS f ON ( immo.id = f.immo_id\n                                                                AND f.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'ausl�nder-bewilligung'\n                                                                    AND lang_id = 1 )\n                                                                AND f.lang_id = " . $this->frontLang . " )\n                        LEFT JOIN " . DBPREFIX . "module_immo_content AS g ON ( immo.id = g.immo_id\n                                                                AND g.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'adresse'\n                                                                    AND lang_id = 1 )\n                                                                AND g.lang_id = " . $this->frontLang . " )\n                        LEFT JOIN " . DBPREFIX . "module_immo_image AS img ON ( immo.id = img.immo_id\n                                                                AND img.field_id = (\n                                                                    SELECT field_id\n                                                                    FROM " . DBPREFIX . "module_immo_fieldname\n                                                                    WHERE name = 'übersichtsbild' )\n                                                                )\n                        WHERE TRUE\n                        ";
         if (!empty($searchterm)) {
             $query .= " AND content.fieldvalue LIKE '%" . $searchterm . "%' ";
         }
         $query .= " AND immo.visibility != 'disabled' ";
         if (!intval($_REQUEST['refnr'])) {
             $query .= " AND immo.visibility != 'reference' ";
         }
         if (!empty($locations) || !empty($obj_type) || !empty($property_type)) {
             if (!empty($locations)) {
                 $query .= " AND d.fieldvalue = '" . $locations . "'";
             }
             if (!empty($property_type)) {
                 $query .= " AND immo.property_type = '" . $property_type . "'";
             }
             if (!empty($obj_type)) {
                 $query .= " AND immo.object_type = '" . $obj_type . "'";
             }
             if (!empty($new_building)) {
                 $query .= " AND immo.new_building = '" . $new_building . "'";
             }
             if (!empty($foreigner_auth)) {
                 //max rooms
                 $query .= " AND f.fieldvalue = '" . $foreigner_auth . "' ";
             }
             if (!empty($fprice)) {
                 //min price
                 $query .= " AND b.fieldvalue >= " . $fprice . " ";
             }
             if (!empty($tprice)) {
                 //max price
                 $query .= " AND b.fieldvalue <= " . $tprice . " ";
             }
             if (!empty($frooms)) {
                 //min rooms
                 $query .= " AND e.fieldvalue >= '" . $frooms . "' ";
             }
             if (!empty($trooms)) {
                 //max rooms
                 $query .= " AND e.fieldvalue <= '" . $trooms . "' ";
             }
             if (!empty($logo)) {
                 //max rooms
                 $query .= " AND logo = '" . $logo . "' ";
             }
             $query .= ' GROUP BY immo.id ORDER BY ' . $orderBy . ' ASC';
         }
     } elseif (!empty($_REQUEST['ref_nr'])) {
         //advanced search
         $orderBy = !empty($_REQUEST['order_by']) ? contrexx_addslashes($_REQUEST['order_by']) : 'immo.id';
         $refnr = intval($_REQUEST['ref_nr']);
         $query .= ' AND reference = ' . $refnr . " GROUP BY immo.id ORDER BY {$orderBy} ASC";
     }
     //else { //no where clause => show all }
     $objRS = $objDatabase->Execute($query);
     if (!$objRS) {
         echo "DB error. file: " . __FILE__ . " line: " . __LINE__;
         return false;
     }
     if ($objRS->RecordCount() == 0) {
         if ($this->_objTpl->blockExists("no_results")) {
             $this->_objTpl->touchBlock("no_results");
             $this->_objTpl->parse("no_results");
         }
         return false;
     }
     while (!$objRS->EOF) {
         $imgdim = '';
         $img = $objRS->fields['imgsrc'];
         $imgdim = $this->_getImageDim($img, 80);
         $this->_objTpl->setVariable(array('IMMO_HEADER' => $objRS->fields['header'], 'IMMO_LOCATION' => $objRS->fields['location'], 'IMMO_PRICE' => $objRS->fields['price'], 'IMMO_REF_NR' => $objRS->fields['reference'], 'IMMO_HEADLINE' => $objRS->fields['headline'], 'IMMO_IMG_PREVIEW_DIM' => $imgdim[0], 'IMMO_IMG_PREVIEW_SRC' => $img, 'IMMO_ID' => $objRS->fields['immo_id']));
         if (!empty($objRS->fields['imgsrc'])) {
             $this->_objTpl->parse("previewImage");
         } else {
             $this->_objTpl->hideBlock("previewImage");
         }
         $this->_objTpl->setVariable('IMMO_HEADER', $objRS->fields['header']);
         $this->_objTpl->parse("objectRow");
         $objRS->MoveNext();
     }
     // TODO: Never used
     //        $limit = $_CONFIG['corePagingLimit'];
     $count = '';
     $pos = intval($_GET['pos']);
     $this->_objTpl->setVariable('IMMO_PAGING', getPaging($count, $pos, '&amp;search=' . $_REQUEST['search'], '', true));
     return true;
 }
Example #16
0
 /**
  * Sets up the Order statistics
  * @param   \Cx\Core\Html\Sigma     $objTemplate  The optional Template,
  *                                                by reference
  * @global  ADONewConnection        $objDatabase
  * @global  array                   $_ARRAYLANG
  * @todo    Rewrite the statistics in a seperate class, extending Order
  * @static
  */
 static function view_statistics(&$objTemplate = null)
 {
     global $objDatabase, $_ARRAYLANG;
     if (!$objTemplate || !$objTemplate->blockExists('no_order')) {
         $objTemplate = new \Cx\Core\Html\Sigma(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseModulePath() . '/Shop/View/Template/Backend');
         $objTemplate->loadTemplateFile('module_shop_statistic.html');
     }
     $objTemplate->setGlobalVariable($_ARRAYLANG);
     // Get the first order date; if its empty, no order has been placed yet
     $time_first_order = Order::getFirstOrderTime();
     if (!$time_first_order) {
         $objTemplate->touchBlock('no_order');
         return $objTemplate;
     }
     $year_first_order = date('Y', $time_first_order);
     $month_first_order = date('m', $time_first_order);
     $start_month = $end_month = $start_year = $end_year = NULL;
     if (isset($_REQUEST['submitdate'])) {
         // A range is requested
         $start_month = intval($_REQUEST['startmonth']);
         $end_month = intval($_REQUEST['stopmonth']);
         $start_year = intval($_REQUEST['startyear']);
         $end_year = intval($_REQUEST['stopyear']);
     } else {
         // Default range to one year, or back to the first order if less
         $start_month = $month_first_order;
         $end_month = Date('m');
         $start_year = $end_year = Date('Y');
         if ($year_first_order < $start_year) {
             $start_year -= 1;
             if ($year_first_order < $start_year || $month_first_order < $start_month) {
                 $start_month = $end_month;
             }
         }
     }
     $objTemplate->setVariable(array('SHOP_START_MONTH' => Shopmanager::getMonthDropdownMenu($start_month), 'SHOP_END_MONTH' => Shopmanager::getMonthDropdownMenu($end_month), 'SHOP_START_YEAR' => Shopmanager::getYearDropdownMenu($start_year, $year_first_order), 'SHOP_END_YEAR' => Shopmanager::getYearDropdownMenu($end_year, $year_first_order)));
     $start_date = date(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME, mktime(0, 0, 0, $start_month, 1, $start_year));
     // mktime() will fix the month from 13 to 01, see example 2
     // on http://php.net/manual/de/function.mktime.php.
     // Mind that this is exclusive and only used in the queries below
     // so that Order date < $end_date!
     $end_date = date(ASCMS_DATE_FORMAT_INTERNATIONAL_DATETIME, mktime(0, 0, 0, $end_month + 1, 1, $end_year));
     $selectedStat = isset($_REQUEST['selectstats']) ? intval($_REQUEST['selectstats']) : 0;
     if ($selectedStat == 2) {
         // Product statistic
         $objTemplate->setVariable(array('TXT_COLUMN_1_DESC' => $_ARRAYLANG['TXT_PRODUCT_NAME'], 'TXT_COLUMN_2_DESC' => $_ARRAYLANG['TXT_COUNT_ARTICLES'], 'TXT_COLUMN_3_DESC' => $_ARRAYLANG['TXT_STOCK'], 'SHOP_ORDERS_SELECTED' => '', 'SHOP_ARTICLES_SELECTED' => \Html::ATTRIBUTE_SELECTED, 'SHOP_CUSTOMERS_SELECTED' => ''));
         $arrSql = \Text::getSqlSnippets('`B`.`id`', FRONTEND_LANG_ID, 'Shop', array('title' => Product::TEXT_NAME));
         $query = "\n                SELECT A.product_id AS id,\n                       A.quantity AS shopColumn2,\n                       A.price AS sum,\n                       B.stock AS shopColumn3,\n                       C.currency_id, " . $arrSql['field'] . "\n                  FROM " . DBPREFIX . "module_shop" . MODULE_INDEX . "_order_items AS A\n                  JOIN " . DBPREFIX . "module_shop" . MODULE_INDEX . "_orders AS C\n                    ON A.order_id=C.id\n                  JOIN " . DBPREFIX . "module_shop" . MODULE_INDEX . "_products AS B\n                    ON A.product_id=B.id" . $arrSql['join'] . "\n                 WHERE C.date_time>='{$start_date}'\n                   AND C.date_time<'{$end_date}'\n                   AND (   C.status=" . Order::STATUS_CONFIRMED . "\n                        OR C.status=" . Order::STATUS_COMPLETED . ")\n                 ORDER BY shopColumn2 DESC";
     } elseif ($selectedStat == 3) {
         // Customer statistic
         $objTemplate->setVariable(array('TXT_COLUMN_1_DESC' => $_ARRAYLANG['TXT_NAME'], 'TXT_COLUMN_2_DESC' => $_ARRAYLANG['TXT_COMPANY'], 'TXT_COLUMN_3_DESC' => $_ARRAYLANG['TXT_COUNT_ARTICLES'], 'SHOP_ORDERS_SELECTED' => '', 'SHOP_ARTICLES_SELECTED' => '', 'SHOP_CUSTOMERS_SELECTED' => \Html::ATTRIBUTE_SELECTED));
         $query = "\n                SELECT A.sum AS sum,\n                       A.currency_id AS currency_id,\n                       sum(B.quantity) AS shopColumn3,\n                       A.customer_id AS id\n                  FROM " . DBPREFIX . "module_shop" . MODULE_INDEX . "_orders AS A\n                  JOIN " . DBPREFIX . "module_shop" . MODULE_INDEX . "_order_items AS B\n                    ON A.id=B.order_id\n                 WHERE A.date_time>='{$start_date}'\n                   AND A.date_time<'{$end_date}'\n                   AND (   A.status=" . Order::STATUS_CONFIRMED . "\n                        OR A.status=" . Order::STATUS_COMPLETED . ")\n                 GROUP BY B.order_id\n                 ORDER BY sum DESC";
     } else {
         // Order statistic (default); sales per month
         $objTemplate->setVariable(array('TXT_COLUMN_1_DESC' => $_ARRAYLANG['TXT_DATE'], 'TXT_COLUMN_2_DESC' => $_ARRAYLANG['TXT_COUNT_ORDERS'], 'TXT_COLUMN_3_DESC' => $_ARRAYLANG['TXT_COUNT_ARTICLES'], 'SHOP_ORDERS_SELECTED' => \Html::ATTRIBUTE_SELECTED, 'SHOP_ARTICLES_SELECTED' => '', 'SHOP_CUSTOMERS_SELECTED' => ''));
         $query = "\n                SELECT SUM(A.quantity) AS shopColumn3,\n                       COUNT(A.order_id) AS shopColumn2,\n                       B.currency_id,\n                       B.sum AS sum,\n                       DATE_FORMAT(B.date_time, '%m') AS month,\n                       DATE_FORMAT(B.date_time, '%Y') AS year\n                  FROM " . DBPREFIX . "module_shop" . MODULE_INDEX . "_order_items AS A,\n                       " . DBPREFIX . "module_shop" . MODULE_INDEX . "_orders AS B\n                 WHERE A.order_id=B.id\n                   AND B.date_time>='{$start_date}'\n                   AND B.date_time<'{$end_date}'\n                   AND (   B.status=" . Order::STATUS_CONFIRMED . "\n                        OR B.status=" . Order::STATUS_COMPLETED . ")\n                 GROUP BY B.id\n                 ORDER BY year DESC, month DESC";
     }
     $arrayResults = array();
     $objResult = $objDatabase->Execute($query);
     if (!$objResult) {
         return Order::errorHandler();
     }
     $sumColumn3 = $sumColumn4 = 0;
     $sumColumn2 = '';
     if ($selectedStat == 2) {
         // Product statistc
         while (!$objResult->EOF) {
             // set currency id
             Currency::setActiveCurrencyId($objResult->fields['currency_id']);
             $key = $objResult->fields['id'];
             if (!isset($arrayResults[$key])) {
                 $arrayResults[$key] = array('column1' => '<a href="index.php?cmd=Shop' . MODULE_INDEX . '&amp;act=products&amp;tpl=manage&amp;id=' . $objResult->fields['id'] . '" title="' . $objResult->fields['title'] . '">' . $objResult->fields['title'] . '</a>', 'column2' => 0, 'column3' => $objResult->fields['shopColumn3'], 'column4' => 0);
             }
             $arrayResults[$key]['column2'] += +$objResult->fields['shopColumn2'];
             $arrayResults[$key]['column4'] += +$objResult->fields['shopColumn2'] * Currency::getDefaultCurrencyPrice($objResult->fields['sum']);
             $objResult->MoveNext();
         }
         if (is_array($arrayResults)) {
             foreach ($arrayResults as $entry) {
                 $sumColumn2 = $sumColumn2 + $entry['column2'];
                 $sumColumn3 = $sumColumn3 + $entry['column3'];
                 $sumColumn4 = $sumColumn4 + $entry['column4'];
             }
             rsort($arrayResults);
         }
     } elseif ($selectedStat == 3) {
         // Customer statistic
         while (!$objResult->EOF) {
             Currency::setActiveCurrencyId($objResult->fields['currency_id']);
             $key = $objResult->fields['id'];
             if (!isset($arrayResults[$key])) {
                 $objUser = \FWUser::getFWUserObject()->objUser;
                 $objUser = $objUser->getUser($key);
                 $company = '';
                 $name = $_ARRAYLANG['TXT_SHOP_CUSTOMER_NOT_FOUND'];
                 if ($objUser) {
                     $company = $objUser->getProfileAttribute('company');
                     $name = $objUser->getProfileAttribute('firstname') . ' ' . $objUser->getProfileAttribute('lastname');
                 }
                 $arrayResults[$key] = array('column1' => '<a href="index.php?cmd=Shop' . MODULE_INDEX . '&amp;act=customerdetails&amp;customer_id=' . $objResult->fields['id'] . '">' . $name . '</a>', 'column2' => $company, 'column3' => 0, 'column4' => 0);
             }
             $arrayResults[$key]['column3'] += $objResult->fields['shopColumn3'];
             $arrayResults[$key]['column4'] += Currency::getDefaultCurrencyPrice($objResult->fields['sum']);
             $sumColumn3 += $objResult->fields['shopColumn3'];
             $sumColumn4 += Currency::getDefaultCurrencyPrice($objResult->fields['sum']);
             $objResult->MoveNext();
         }
     } else {
         // Order statistic (default)
         $arrayMonths = explode(',', $_ARRAYLANG['TXT_MONTH_ARRAY']);
         while (!$objResult->EOF) {
             $key = $objResult->fields['year'] . '.' . $objResult->fields['month'];
             if (!isset($arrayResults[$key])) {
                 $arrayResults[$key] = array('column1' => '', 'column2' => 0, 'column3' => 0, 'column4' => 0);
             }
             $arrayResults[$key]['column1'] = $arrayMonths[intval($objResult->fields['month']) - 1] . ' ' . $objResult->fields['year'];
             $arrayResults[$key]['column2'] = $arrayResults[$key]['column2'] + 1;
             $arrayResults[$key]['column3'] = $arrayResults[$key]['column3'] + $objResult->fields['shopColumn3'];
             $arrayResults[$key]['column4'] = $arrayResults[$key]['column4'] + Currency::getDefaultCurrencyPrice($objResult->fields['sum']);
             $sumColumn2 = $sumColumn2 + 1;
             $sumColumn3 = $sumColumn3 + $objResult->fields['shopColumn3'];
             $sumColumn4 = $sumColumn4 + Currency::getDefaultCurrencyPrice($objResult->fields['sum']);
             $objResult->MoveNext();
         }
         krsort($arrayResults, SORT_NUMERIC);
     }
     $objTemplate->setCurrentBlock('statisticRow');
     $i = 0;
     if (is_array($arrayResults)) {
         foreach ($arrayResults as $entry) {
             $objTemplate->setVariable(array('SHOP_ROWCLASS' => 'row' . (++$i % 2 + 1), 'SHOP_COLUMN_1' => $entry['column1'], 'SHOP_COLUMN_2' => $entry['column2'], 'SHOP_COLUMN_3' => $entry['column3'], 'SHOP_COLUMN_4' => Currency::formatPrice($entry['column4']) . ' ' . Currency::getDefaultCurrencySymbol()));
             $objTemplate->parse('statisticRow');
         }
     }
     $query_currency = "\n            SELECT currency_id, sum,\n                   DATE_FORMAT(date_time, '%m') AS month,\n                   DATE_FORMAT(date_time, '%Y') AS year\n              FROM " . DBPREFIX . "module_shop" . MODULE_INDEX . "_orders\n             WHERE status=" . Order::STATUS_CONFIRMED . "\n                OR status=" . Order::STATUS_COMPLETED . "\n             ORDER BY date_time DESC";
     $objResult = $objDatabase->Execute($query_currency);
     if (!$objResult) {
         return Order::errorHandler();
     }
     $totalSoldProducts = 0;
     $query_totalproducts = "\n            SELECT sum(A.quantity) AS shopTotalSoldProducts\n              FROM " . DBPREFIX . "module_shop" . MODULE_INDEX . "_order_items AS A,\n                   " . DBPREFIX . "module_shop" . MODULE_INDEX . "_orders AS B\n             WHERE A.order_id=B.id\n               AND (   B.status=" . Order::STATUS_CONFIRMED . "\n                    OR B.status=" . Order::STATUS_COMPLETED . ")";
     $objResult = $objDatabase->SelectLimit($query_totalproducts, 1);
     if ($objResult) {
         if (!$objResult->EOF) {
             $totalSoldProducts = $objResult->fields['shopTotalSoldProducts'];
             $objResult->MoveNext();
         }
     }
     $totalOrderSum = 0;
     $totalOrders = 0;
     $bestMonthSum = 0;
     $bestMonthDate = '';
     $arrShopMonthSum = array();
     $objResult = $objDatabase->Execute($query);
     while (!$objResult->EOF) {
         $orderSum = Currency::getDefaultCurrencyPrice($objResult->fields['sum']);
         if (!isset($arrShopMonthSum[$objResult->fields['year']][$objResult->fields['month']])) {
             $arrShopMonthSum[$objResult->fields['year']][$objResult->fields['month']] = 0;
         }
         $arrShopMonthSum[$objResult->fields['year']][$objResult->fields['month']] += $orderSum;
         $totalOrderSum += $orderSum;
         $totalOrders++;
         $objResult->MoveNext();
     }
     $months = explode(',', $_ARRAYLANG['TXT_MONTH_ARRAY']);
     foreach ($arrShopMonthSum as $year => $arrMonth) {
         foreach ($arrMonth as $month => $sum) {
             if ($bestMonthSum < $sum) {
                 $bestMonthSum = $sum;
                 $bestMonthDate = $months[$month - 1] . ' ' . $year;
             }
         }
     }
     $objTemplate->setVariable(array('SHOP_ROWCLASS' => 'row' . (++$i % 2 + 1), 'SHOP_TOTAL_SUM' => Currency::formatPrice($totalOrderSum) . ' ' . Currency::getDefaultCurrencySymbol(), 'SHOP_MONTH' => $bestMonthDate, 'SHOP_MONTH_SUM' => Currency::formatPrice($bestMonthSum) . ' ' . Currency::getDefaultCurrencySymbol(), 'SHOP_TOTAL_ORDERS' => $totalOrders, 'SHOP_SOLD_ARTICLES' => $totalSoldProducts, 'SHOP_SUM_COLUMN_2' => $sumColumn2, 'SHOP_SUM_COLUMN_3' => $sumColumn3, 'SHOP_SUM_COLUMN_4' => Currency::formatPrice($sumColumn4) . ' ' . Currency::getDefaultCurrencySymbol()));
     return true;
 }
 /**
  * Parses locale list in a template file
  * @todo Does language list only for now. Update as soon as locales are available
  * @param \Cx\Core\Html\Sigma $template Template file to parse locales in
  */
 public function parseLocaleList($template)
 {
     if (!$template->blockExists('locale_alternate_list')) {
         return;
     }
     $currentPage = $this->cx->getPage();
     $listProtectedPages = \Cx\Core\Setting\Controller\Setting::getValue('coreListProtectedPages', 'Config') == 'on';
     foreach (\FWLanguage::getActiveFrontendLanguages() as $lang) {
         $langId = $lang['id'];
         $lang = $lang['lang'];
         $langPage = $currentPage->getNode()->getPage($langId);
         // if page is not translated, inactive (incl. scheduled publishing) or protected
         if (!$langPage || !$langPage->isActive() || !$listProtectedPages && $langPage->isFrontendProtected() && !\Permission::checkAccess($langPage->getFrontendAccessId(), 'dynamic', true)) {
             continue;
         }
         $template->setVariable(array('PAGE_LINK' => contrexx_raw2xhtml(\Cx\Core\Routing\Url::fromPage($langPage)->toString()), 'PAGE_TITLE' => contrexx_raw2xhtml($langPage->getTitle()), 'LOCALE' => $lang, 'LANGUAGE_CODE' => $lang));
         $template->parse('locale_alternate_list');
     }
 }