Ejemplo n.º 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');
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 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);
     }
 }
Ejemplo n.º 4
0
 function _renderForm(&$page)
 {
     $pageName = $page->getAttribute('name');
     $tabPreview = array_slice($page->controller->_tabs, -2, 1);
     // can use either HTML_Template_Sigma or HTML_Template_ITX
     $tpl = new HTML_Template_Sigma('.', 'cache/');
     $tpl->loadTemplateFile('itdynamic.html');
     // on preview tab, add progress bar javascript and stylesheet
     if ($pageName == $tabPreview[0][0]) {
         $pb = $page->controller->createProgressBar();
         $tpl->setVariable(array('qf_style' => $pb->getStyle(), 'qf_script' => $pb->getScript()));
         $pbElement = $page->getElement('progressBar');
         $pbElement->setText($pb->toHtml() . '<br /><br />');
     }
     $renderer = new HTML_QuickForm_Renderer_ITDynamic($tpl);
     $renderer->setElementBlock(array('buttons' => 'qf_buttons'));
     $page->accept($renderer);
     $tpl->show();
 }
Ejemplo n.º 5
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;
 }
Ejemplo n.º 6
0
 public function startGroup(&$group, $required, $error)
 {
     $blockName = $this->_matchBlock($group);
     $this->_tpl->setCurrentBlock($blockName . '_loop');
     $this->_groupElementIdx = 0;
     $this->_groupSeparator = is_null($group->_separator) ? '&nbsp;' : $group->_separator;
     // show an '*' near the required element
     if ($required) {
         $this->_showRequired = true;
         if ($this->_tpl->blockExists($blockName . '_required')) {
             $this->_tpl->touchBlock($blockName . '_required');
         }
     }
     // show the error message or keep it for later use
     if (!empty($error)) {
         if ($this->_tpl->blockExists($blockName . '_error')) {
             $this->_tpl->setVariable('qf_error', $error);
         } else {
             $this->_errors[] = $error;
         }
     }
     $this->_tpl->setVariable('qf_group_label', $group->getLabel());
 }
Ejemplo n.º 7
0
<table{class}>
<!-- BEGIN label_2 --><tr><th>{label_2}</th><!-- END label_2 -->
<!-- BEGIN label_3 --><th>&nbsp;</th><th>{label_3}</th></tr><!-- END label_3 -->
<tr>
  <td valign="top">{unselected}</td>
  <td align="center">{add}{remove}</td>
  <td valign="top">{selected}</td>
</tr>
</table>
';
$ams->setElementTemplate($template);
if (isset($_POST['fruit'])) {
    $form->setDefaults(array('fruit' => $_POST['fruit']));
}
$form->addElement('submit', 'send', 'Send', array('class' => 'inputCommand'));
$form->addRule('name', 'Your name is required', 'required');
$form->addGroupRule('fruit', 'At least one fruit is required', 'required', null, 1);
$form->applyFilter('__ALL__', 'trim');
$form->applyFilter('__ALL__', 'strip_tags');
$valid = $form->validate();
$tpl = new HTML_Template_Sigma('.');
$tpl->loadTemplateFile('itdynamic.html');
$tpl->setVariable('ams_javascript', $ams->getElementJs(false));
$renderer = new HTML_QuickForm_Renderer_ITDynamic($tpl);
$form->accept($renderer);
if ($valid) {
    $clean = $form->getSubmitValues();
    $msg = sprintf("<p>Welcome <b>%s</b> you've selected these fruits:<br />%s</p>", $clean['name'], implode(', ', $clean['fruit']));
    $tpl->setVariable('message_form_validate', $msg);
}
$tpl->show();
Ejemplo n.º 8
0
 /**
  * setVariable()
  *
  * @access public
  * @param  mixed  $mVariable string | array
  * @param  mixed  $mValue    string | integer | float | array
  * @param  string $sConvert
  * @param  mixed  $mFormat   string | integer
  * @return void
  */
 function setVariable($mVariable, $mValue = '', $sConvert = '', $mFormat = 0)
 {
     if (is_array($mVariable)) {
         foreach ($mVariable as $sKey => $mRow) {
             $mVariable[$sKey] = _btplConvertValue($mRow, $sConvert, $mFormat);
         }
     } else {
         $mValue = _btplConvertValue($mValue, $sConvert, $mFormat);
     }
     parent::setVariable($mVariable, $mValue);
 }
Ejemplo n.º 9
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();
 }
Ejemplo n.º 10
0
$basePath = realpath(dirname(__FILE__));
if (!@(include_once $basePath . '/config/config.php')) {
    die('Unable to load file ' . $basePath . '/config/config.php');
}
require_once $basePath . '/classloader.inc.php';
@header('content-type: text/html; charset=' . ($useUtf8 ? 'UTF-8' : 'ISO-8859-1'));
if (!@(include_once ASCMS_LIBRARY_PATH . '/PEAR/HTML/Template/Sigma/Sigma.php')) {
    die('Unable to load file ' . ASCMS_LIBRARY_PATH . '/PEAR/HTML/Template/Sigma/Sigma.php');
}
if (!@(include_once $basePath . '/common.class.php')) {
    die('Unable to load file ' . $basePath . '/common.class.php');
}
if (!@(include_once $basePath . '/installer.class.php')) {
    die('Unable to load file ' . $basePath . '/installer.class.php');
}
if (!@(include_once $basePath . '/../core/Env.class.php')) {
    die('Unable to load file ' . $basePath . '/../core/Env.class.php');
}
$objCommon = new CommonFunctions();
$objInstaller = new Installer();
$objCommon->initLanguage();
$objTpl = new HTML_Template_Sigma($templatePath);
$objTpl->setErrorHandling(PEAR_ERROR_DIE);
$objTpl->loadTemplateFile('index.html');
$objTpl->setVariable('CHARSET', $useUtf8 ? 'UTF-8' : 'ISO-8859-1');
$objTpl->setVariable($_ARRLANG);
$objInstaller->checkOptions();
$objInstaller->getNavigation();
$objInstaller->getPage();
$objInstaller->getContentNavigation();
$objTpl->show();
Ejemplo n.º 11
0
 /**
  * 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;
 }