コード例 #1
0
 function renderEntry($node, $level, $type)
 {
     if (in_array($this->_menuType, array('tree', 'sitemap', 'rows')) && $this->_tpl->blockExists($this->_prefix . ($level + 1) . '_' . $this->_typeNames[$type])) {
         $blockName = $this->_prefix . ($level + 1) . '_' . $this->_typeNames[$type];
     } else {
         $blockName = $this->_prefix . $this->_typeNames[$type];
     }
     if (('tree' == $this->_menuType || 'sitemap' == $this->_menuType) && $this->_tpl->blockExists($blockName . '_indent')) {
         for ($i = 0; $i < $level; $i++) {
             $this->_tpl->touchBlock($blockName . '_indent');
             $this->_tpl->parse($blockName . '_indent');
         }
     }
     foreach ($node as $k => $v) {
         if ('sub' != $k && $this->_tpl->placeholderExists($this->_prefix . $k, $blockName)) {
             $this->_tpl->setVariable($this->_prefix . $k, $v);
         }
     }
     $this->_tpl->parse($blockName);
     if ('rows' == $this->_menuType && $this->_tpl->blockExists($this->_prefix . ($level + 1) . '_entry_loop')) {
         $this->_tpl->parse($this->_prefix . ($level + 1) . '_entry_loop');
     } else {
         $this->_tpl->parse($this->_prefix . 'entry_loop');
     }
 }
コード例 #2
0
 /**
  * Parses randomized include code
  * @param \HTML_Template_Sigma $template Template to parse
  * @param array $urls List of URLs to get random include tag for
  */
 protected function parseRandomizedIncludeCode($template, $urls)
 {
     foreach ($urls as $i => $url) {
         $template->setVariable('CONTENT', $url);
         $block = 'content';
         if ($i == 0) {
             $block = 'first_content';
         }
         $template->parse($block);
     }
 }
コード例 #3
0
 /**
  * Parses randomized include code
  * @param \HTML_Template_Sigma $template Template to parse
  * @param array $urls List of URLs to get random include tag for
  */
 protected function parseRandomizedIncludeCode($template, $urls)
 {
     for ($i = 0; $i < 60; $i++) {
         $index = $i % count($urls);
         $url = $urls[$index];
         $template->setVariable(array('I' => $i, 'CONTENT' => $url));
         $block = 'content';
         if ($i == 0) {
             $block = 'first_content';
         }
         $template->parse($block);
     }
 }
コード例 #4
0
 function renderEntry($node, $level, $type)
 {
     // Close the entry if previous was on same or higher level
     if ($this->_level >= $level) {
         if ($this->_tpl->blockExists($this->_prefix . ($level + 1) . '_entry_close')) {
             $this->_tpl->touchBlock($this->_prefix . ($level + 1) . '_entry_close');
         } else {
             $this->_tpl->touchBlock($this->_prefix . 'entry_close');
         }
         $this->_tpl->parse($this->_prefix . 'tree_loop');
         // If the new level is higher then open the level
     } else {
         if ($this->_tpl->blockExists($this->_prefix . ($level + 1) . '_level_open')) {
             $this->_tpl->touchBlock($this->_prefix . ($level + 1) . '_level_open');
         } else {
             $this->_tpl->touchBlock($this->_prefix . 'level_open');
         }
         $this->_tpl->parse($this->_prefix . 'tree_loop');
     }
     // Open the entry
     if ($this->_tpl->blockExists($this->_prefix . ($level + 1) . '_entry_open')) {
         $this->_tpl->touchBlock($this->_prefix . ($level + 1) . '_entry_open');
     } else {
         $this->_tpl->touchBlock($this->_prefix . 'entry_open');
     }
     $this->_tpl->parse($this->_prefix . 'tree_loop');
     if ($this->_tpl->blockExists($this->_prefix . ($level + 1) . '_' . $this->_typeNames[$type])) {
         $blockName = $this->_prefix . ($level + 1) . '_' . $this->_typeNames[$type];
     } else {
         $blockName = $this->_prefix . $this->_typeNames[$type];
     }
     foreach ($node as $k => $v) {
         if ('sub' != $k && $this->_tpl->placeholderExists($this->_prefix . $k, $blockName)) {
             $this->_tpl->setVariable($this->_prefix . $k, $v);
         }
     }
     $this->_tpl->parse($blockName);
     $this->_tpl->parse($this->_prefix . 'tree_loop');
     $this->_level = $level;
 }
コード例 #5
0
 public function finishGroup(&$group)
 {
     $this->_tpl->parse($this->_matchBlock($group));
     $this->_tpl->setCurrentBlock('qf_main_loop');
     $this->_tpl->parseCurrentBlock();
 }
コード例 #6
0
 private function getTreeCode()
 {
     if (count($this->arrMigrateLangIds) === 1) {
         return true;
     }
     $jsSimilarPages = array();
     $this->similarPages = $this->findSimilarPages();
     foreach ($this->similarPages as $nodeId => $arrPageIds) {
         $jsSimilarPages[$nodeId] = array_values($arrPageIds);
         foreach ($this->arrMigrateLangIds as $migrateLangId) {
             if (!isset($arrPageIds[$migrateLangId])) {
                 $this->similarPages[$nodeId][$migrateLangId] = 0;
             }
         }
         ksort($this->similarPages[$nodeId]);
     }
     $objCx = \ContrexxJavascript::getInstance();
     $objCx->setVariable('similarPages', json_encode($jsSimilarPages), 'update/contentMigration');
     $objTemplate = new \HTML_Template_Sigma(UPDATE_TPL);
     $objTemplate->setErrorHandling(PEAR_ERROR_DIE);
     $objTemplate->loadTemplateFile('page_grouping.html');
     $groupedBorderWidth = count($this->arrMigrateLangIds) * 325 - 48;
     $objTemplate->setGlobalVariable(array('USERNAME' => $_SESSION['contrexx_update']['username'], 'PASSWORD' => $_SESSION['contrexx_update']['password'], 'CMS_VERSION' => $_SESSION['contrexx_update']['version'], 'MIGRATE_LANG_IDS' => $this->migrateLangIds, 'LANGUAGE_WRAPPER_WIDTH' => 'width: ' . count($this->arrMigrateLangIds) * 330 . 'px;', 'GROUPED_SCROLL_WIDTH' => 'width: ' . count($this->arrMigrateLangIds) * 325 . 'px;', 'GROUPED_BORDER_WIDTH' => 'width: ' . $groupedBorderWidth . 'px;'));
     $cl = \Env::get('ClassLoader');
     $cl->loadFile(ASCMS_CORE_PATH . '/Tree.class.php');
     $cl->loadFile(UPDATE_CORE . '/UpdateTree.class.php');
     $pageRepo = self::$em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
     $nodeRepo = self::$em->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node');
     foreach ($this->arrMigrateLangIds as $lang) {
         $objContentTree = new \UpdateContentTree($lang);
         foreach ($objContentTree->getTree() as $arrPage) {
             $pageId = $arrPage['catid'];
             $nodeId = $arrPage['node_id'];
             $langId = $arrPage['lang'];
             $level = $arrPage['level'];
             $title = $arrPage['catname'];
             $sort = $nodeRepo->find($nodeId)->getLft();
             $grouped = $this->isGrouppedPage($this->similarPages, $pageId) ? 'grouped' : '';
             $objTemplate->setVariable(array('TITLE' => $title, 'ID' => $pageId, 'NODE' => $nodeId, 'LANG' => strtoupper(\FWLanguage::getLanguageCodeById($langId)), 'LEVEL' => $level + 1, 'SORT' => $sort, 'GROUPED' => $grouped, 'MARGIN' => 'margin-left: ' . $level * 15 . 'px;'));
             $objTemplate->parse('page');
         }
         $langFull = \FWLanguage::getLanguageParameter($lang, 'name');
         $langShort = strtoupper(\FWLanguage::getLanguageParameter($lang, 'lang'));
         $objTemplate->setVariable(array('LANG_FULL' => $langFull, 'LANG_SHORT' => $langShort));
         $objTemplate->parse('language');
     }
     $groupedBorderWidth -= 2;
     foreach ($this->similarPages as $nodeId => $arrPageIds) {
         $node = $nodeRepo->find($nodeId);
         $margin = ($node->getLvl() - 1) * 15;
         $nodeWidth = $groupedBorderWidth - $margin;
         $width = ($groupedBorderWidth - 10) / count($this->arrMigrateLangIds);
         $index = 0;
         $last = count($arrPageIds) - 1;
         foreach ($arrPageIds as $pageLangId => $pageId) {
             if ($index === 0) {
                 $pageWidth = $width - 24;
             } elseif ($index === $last) {
                 $pageWidth = $width - $margin;
             } else {
                 $pageWidth = $width;
             }
             $index++;
             $page = $pageRepo->find($pageId);
             if ($page) {
                 $langCode = strtoupper(\FWLanguage::getLanguageCodeById($page->getLang()));
                 $objTemplate->setVariable(array('CLASS' => '', 'DATA_ID' => 'data-id="' . $pageId . '"', 'DATA_LANG' => 'data-lang="' . $langCode . '"', 'TITLE' => $page->getTitle(), 'LANG' => $langCode, 'WIDTH' => 'width: ' . $pageWidth . 'px;'));
             } else {
                 $langCode = strtoupper(\FWLanguage::getLanguageCodeById($pageLangId));
                 $objTemplate->setVariable(array('CLASS' => 'no-page', 'DATA_ID' => '', 'DATA_LANG' => '', 'TITLE' => 'Keine Seite', 'LANG' => $langCode, 'WIDTH' => 'width: ' . $pageWidth . 'px;'));
             }
             $objTemplate->parse('groupedPage');
         }
         $objTemplate->setVariable(array('ID' => $nodeId, 'LEVEL' => $node->getLvl(), 'SORT' => $node->getLft(), 'STYLE' => 'width: ' . $nodeWidth . 'px; margin-left: ' . $margin . 'px;'));
         $objTemplate->parse('groupedNode');
     }
     return $objTemplate->get();
 }
コード例 #7
0
ファイル: Sigma.class.php プロジェクト: Cloudrexx/cloudrexx
 /**
  * Check if the given block exist and if it exist the given block is parsed.
  * Otherwise an error is logged.
  *
  * @param    string    block name
  * @param    boolean   true if the function is called recursively (do not set this to true yourself!)
  * @param    boolean   true if parsing a "hidden" block (do not set this to true yourself!)
  * @return   boolean   true if block is not empty
  */
 function parse($block = '__global__', $flagRecursion = false, $fakeParse = false)
 {
     if (!$this->blockExists($block)) {
         \DBG::log('The SIGMA-Block ' . $block . ' does not exist');
         return false;
     }
     return parent::parse($block, $flagRecursion, $fakeParse);
 }
コード例 #8
0
ファイル: Order.class.php プロジェクト: Niggu/cloudrexx
 /**
  * View of this Orders' items
  * @global  ADONewConnection    $objDatabase
  * @global  array               $_ARRAYLANG
  * @param   HTML_Template_Sigma $objTemplate    The template
  * @param   type                $edit           If true, items are editable
  * @param   type                $total_weight   Initial value for the
  *                                              total item weight, by
  *                                              reference.
  *                                              Usually empty or zero
  * @param   type                $i              Initial value for the row
  *                                              count, by reference.
  *                                              Usually empty or zero.
  * @return  float                               The net item sum on success,
  *                                              false otherwise
  */
 function view_items($objTemplate, $edit, &$total_weight = 0, $i = 0)
 {
     global $objDatabase, $_ARRAYLANG;
     // Order items
     // c_sp
     // Mind the custom price calculation
     $objCustomer = Customer::getById($this->customer_id);
     if (!$objCustomer) {
         \Message::error(sprintf($_ARRAYLANG['TXT_SHOP_ORDER_ERROR_MISSING_CUSTOMER'], $this->customer_id));
         $objCustomer = new Customer();
     }
     $query = "\n            SELECT `id`, `product_id`, `product_name`,\n                   `price`, `quantity`, `vat_rate`, `weight`\n              FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_order_items`\n             WHERE `order_id`=?";
     $objResult = $objDatabase->Execute($query, array($this->id));
     if (!$objResult) {
         return self::errorHandler();
     }
     $arrProductOptions = $this->getOptionArray();
     $total_vat_amount = 0;
     $total_net_price = 0;
     // Orders with Attributes cannot currently be edited
     // (this would spoil all the options!)
     //        $have_option = false;
     while (!$objResult->EOF) {
         $item_id = $objResult->fields['id'];
         $name = $objResult->fields['product_name'];
         $price = $objResult->fields['price'];
         $quantity = $objResult->fields['quantity'];
         $vat_rate = $objResult->fields['vat_rate'];
         $product_id = $objResult->fields['product_id'];
         // Get missing product details
         $objProduct = Product::getById($product_id);
         if (!$objProduct) {
             \Message::warning(sprintf($_ARRAYLANG['TXT_SHOP_PRODUCT_NOT_FOUND'], $product_id));
             $objProduct = new Product('', 0, $name, '', $price, 0, 0, 0, $product_id);
         }
         $code = $objProduct->code();
         $distribution = $objProduct->distribution();
         if (isset($arrProductOptions[$item_id])) {
             if ($edit) {
                 // Edit options
             } else {
                 //DBG::log("Order::view_items(): Item ID $item_id, Attributes: ".var_export($arrProductOptions[$item_id], true));
                 // Verify that options are properly shown
                 foreach ($arrProductOptions[$item_id] as $attribute_id => $attribute) {
                     //DBG::log("Order::view_items(): Added option, price: $options_price");
                     foreach ($attribute as $a) {
                         $name .= '<i><br />- ' . $attribute_id . ': ' . $a['name'] . ' (' . $a['price'] . ')</i>';
                         $price += $a['price'];
                     }
                 }
             }
         }
         // c_sp
         $row_net_price = $price * $quantity;
         $row_price = $row_net_price;
         // VAT added later, if applicable
         $total_net_price += $row_net_price;
         // Here, the VAT has to be recalculated before setting up the
         // fields.  If the VAT is excluded, it must be added here.
         // Note: the old Order.vat_amount field is no longer valid,
         // individual shop_order_items *MUST* have been UPDATEd by the
         // time PHP parses this line.
         // Also note that this implies that the vat_id and
         // country_id can be ignored, as they are considered when the
         // order is placed and the VAT is applied to the order
         // accordingly.
         // Calculate the VAT amount per row, included or excluded
         $row_vat_amount = Vat::amount($vat_rate, $row_net_price);
         //\DBG::log("$row_vat_amount = Vat::amount($vat_rate, $row_net_price)");
         // and add it to the total VAT amount
         $total_vat_amount += $row_vat_amount;
         if (!Vat::isIncluded()) {
             // Add tax to price
             $row_price += $row_vat_amount;
         }
         //else {
         // VAT is disabled.
         // There shouldn't be any non-zero percentages in the order_items!
         // but if there are, there probably has been a change and we *SHOULD*
         // still treat them as if VAT had been enabled at the time the order
         // was placed!
         // That's why the else {} block is commented out.
         //}
         $weight = '-';
         if ($distribution != 'download') {
             $weight = $objResult->fields['weight'];
             if (intval($weight) > 0) {
                 $total_weight += $weight * $quantity;
             }
         }
         $itemHasOptions = !empty($arrProductOptions[$item_id]);
         $objTemplate->setVariable(array('SHOP_PRODUCT_ID' => $product_id, 'SHOP_ROWCLASS' => 'row' . (++$i % 2 + 1), 'SHOP_QUANTITY' => $quantity, 'SHOP_PRODUCT_NAME' => $name, 'SHOP_PRODUCT_PRICE' => Currency::formatPrice($price), 'SHOP_PRODUCT_SUM' => Currency::formatPrice($row_net_price), 'SHOP_P_ID' => $edit ? $item_id : $objResult->fields['product_id'], 'SHOP_PRODUCT_CODE' => $code, 'SHOP_PRODUCT_TAX_RATE' => $edit ? $vat_rate : Vat::format($vat_rate), 'SHOP_PRODUCT_TAX_AMOUNT' => Currency::formatPrice($row_vat_amount), 'SHOP_PRODUCT_WEIGHT' => Weight::getWeightString($weight), 'SHOP_ACCOUNT_VALIDITY' => \FWUser::getValidityString($weight)));
         // Get a product menu for each Product if $edit-ing.
         // Preselect the current Product ID.
         if ($edit) {
             if ($itemHasOptions && $objTemplate->blockExists('order_item_product_options_tooltip')) {
                 $objTemplate->touchBlock('order_item_product_options_tooltip');
             }
             $objTemplate->setVariable('SHOP_PRODUCT_IDS_MENU', Products::getMenuoptions($product_id, null, +$_ARRAYLANG['TXT_SHOP_PRODUCT_MENU_FORMAT'], false));
         }
         $objTemplate->parse('order_item');
         $objResult->MoveNext();
     }
     return $total_net_price;
 }