Example #1
0
 /**
  * Edit a pricelist
  * @global  ADOConnection   $objDatabase
  * @global  array           $_ARRAYLANG
  * @return  boolean                         True on success, false otherwise
  */
 static function view_pricelist_edit()
 {
     global $_ARRAYLANG;
     $list_id = null;
     $objList = PriceList::getFromPost();
     if ($objList) {
         $result = $objList->store();
         if ($result) {
             if (isset($_REQUEST['list_id'])) {
                 unset($_REQUEST['list_id']);
             }
             //die("Showing lists");
             return self::view_pricelists();
         }
     }
     $list_id = isset($_GET['list_id']) ? $_GET['list_id'] : null;
     $objList = PriceList::getById($list_id);
     if (!$objList) {
         $objList = new PriceList(null);
     }
     $list_id = $objList->id();
     self::$objTemplate->loadTemplateFile("module_shop_pricelist_details.html");
     self::$objTemplate->setGlobalVariable($_ARRAYLANG);
     self::$objTemplate->setVariable(array('SHOP_PRICELIST_EDIT' => $_ARRAYLANG[$list_id ? 'TXT_SHOP_PRICELIST_EDIT' : 'TXT_SHOP_PRICELIST_ADD'], 'SHOP_PRICELIST_ID' => $list_id, 'SHOP_PRICELIST_LINK_PDF' => $list_id ? PriceList::getUrl($list_id) : '', 'SHOP_PRICELIST_NAME' => $objList->name(), 'SHOP_PRICELIST_LANGUAGE_MENUOPTIONS' => \Html::getOptions(\FWLanguage::getNameArray(), $objList->lang_id()), 'SHOP_PRICELIST_BORDER_CHECKED' => $objList->border() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_PRICELIST_HEADER_CHECKED' => $objList->header() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_PRICELIST_HEADER_LEFT' => $objList->header_left(), 'SHOP_PRICELIST_HEADER_RIGHT' => $objList->header_right(), 'SHOP_PRICELIST_FOOTER_CHECKED' => $objList->footer() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_PRICELIST_FOOTER_LEFT' => $objList->footer_left(), 'SHOP_PRICELIST_FOOTER_RIGHT' => $objList->footer_right()));
     $category_ids = $objList->category_ids();
     $category_all = false;
     if (empty($category_ids) || $category_ids == '*') {
         $category_all = true;
         self::$objTemplate->setVariable('SHOP_PRICELIST_CATEGORY_ALL_CHECKED', \Html::ATTRIBUTE_CHECKED);
     }
     // Get all categories
     $arrCategories = ShopCategories::getTreeArray(true, false);
     if (empty($arrCategories)) {
         Message::warning($_ARRAYLANG['TXT_SHOP_WARNING_NO_CATEGORIES']);
     }
     $i = 0;
     foreach ($arrCategories as $objCategory) {
         $category_id = $objCategory['id'];
         $selected = $category_all || preg_match('/(?:^|,)\\s*' . $category_id . '\\s*(?:,|$)/', $category_ids);
         //DBG::log("Category ID $category_id, ".($selected ? "selected" : "NOT"));
         self::$objTemplate->setVariable(array('SHOP_CATEGORY_ID' => contrexx_raw2xhtml($category_id), 'SHOP_CATEGORY_NAME' => contrexx_raw2xhtml($objCategory['name']), 'SHOP_CATEGORY_LEVELSPACE' => str_repeat('|----', $objCategory['level']), 'SHOP_CATEGORY_DISABLED' => $category_all ? \Html::ATTRIBUTE_DISABLED : '', 'SHOP_CATEGORY_CHECKED' => $selected ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_CATEGORY_ROWCLASS' => 'row' . (++$i % 2 + 1)));
         self::$objTemplate->parse('shop_category');
     }
     return true;
 }
Example #2
0
 /**
  * Returns the HTML for the frontend language selection dropdown menu
  *
  * Backend use only.
  * @internal    Note to Shop (and other newish module) programmers:
  *  Registers javascript for handling the currently active tab.
  *  Set the _active_tab global index variable in your onchange handler
  *  whenever the user switches the tab.  This value is posted in the
  *  active_tab parameter when the language is changed.
  *  See {@see getJavascript_activetab()} for details, and
  *  {@see \Cx\Core\Setting\Controller\Setting::show()} and {@see \Cx\Core\Setting\Controller\Setting::show_external()}
  *  for implementations.
  * @return  string            The HTML language dropdown menu code
  */
 function getUserFrontendLangMenu()
 {
     global $_ARRAYLANG;
     $arrLanguageName = FWLanguage::getNameArray();
     // No dropdown at all if there is a single active frontend language
     if (count($arrLanguageName) == 1) {
         return '';
     }
     $action = CONTREXX_DIRECTORY_INDEX;
     $command = isset($_REQUEST['cmd']) ? contrexx_input2raw($_REQUEST['cmd']) : '';
     switch ($command) {
         /*case 'xyzzy':
           // Variant 1:  Use selected GET parameters only
           // Currently unused, but this could be extended by a few required
           // parameters and might prove useful for some modules.
           $query_string = '';
           // Add more as needed
           $arrParameter = array('cmd', 'act', 'tpl', 'key', );
           foreach ($arrParameter as $parameter) {
               $value = (isset($_GET[$parameter])
                 ? $_GET[$parameter] : null);
               if (isset($value)) {
                   $query_string .= "&$parameter=".contrexx_input2raw($value);
               }
           }
           Html::replaceUriParameter($action, $query_string);
           // The dropdown is built below
           break;*/
         case 'Shop':
         case 'country':
             // Variant 2:  Use any (GET) request parameters
             // Note that this is generally unsafe, as most modules/methods do
             // not rely on posted data only!
             $arrParameter = null;
             $uri = $_SERVER['QUERY_STRING'];
             Html::stripUriParam($uri, 'userFrontendLangId');
             parse_str($uri, $arrParameter);
             $first = true;
             foreach ($arrParameter as $name => $value) {
                 $action .= ($first ? '?' : '&') . $name . '=' . urlencode(contrexx_input2raw($value));
                 $first = false;
             }
             // The dropdown is built below
             break;
             // TODO: Add your case here if variant 1 is enabled, too
             //case 'foobar':
         // TODO: Add your case here if variant 1 is enabled, too
         //case 'foobar':
         case 'DocSys':
         case 'Recommend':
         case 'Jobs':
         case 'alias':
             // The old way
             $i = 0;
             $arrVars = array();
             if (isset($_SERVER['QUERY_STRING'])) {
                 parse_str($_SERVER['QUERY_STRING'], $arrVars);
             }
             $query = isset($arrVars['cmd']) ? "?cmd=" . $arrVars['cmd'] : "";
             $return = "\n<form action='index.php" . $query . "' method='post' name='userFrontendLangIdForm'>\n";
             $return .= "<select name='userFrontendLangId' size='1' class='chzn-select' onchange=\"document.forms['userFrontendLangIdForm'].submit()\">\n";
             foreach ($this->arrLang as $id => $value) {
                 if ($this->arrLang[$id]['frontend'] == 1) {
                     $i++;
                     if ($id == $this->userFrontendLangId) {
                         $return .= "<option value='" . $id . "' selected='selected'>Frontend [" . htmlentities($value['name'], ENT_QUOTES, CONTREXX_CHARSET) . "]</option>\n";
                     } else {
                         $return .= "<option value='" . $id . "'>Frontend [" . htmlentities($value['name'], ENT_QUOTES, CONTREXX_CHARSET) . "]</option>\n";
                     }
                 }
             }
             $return .= "</select>\n</form>\n";
             return $i > 1 ? $return : "";
         default:
             return '';
             break;
     }
     // For those views that support it, update the selected tab index
     JS::registerCode('function submitUserFrontendLanguage() {' . ' $J("[name=active_tab]").val(_active_tab);' . ' document.forms.userFrontendLangIdForm.submit(); ' . '}');
     // For variants 1 and 2:  Build the dropdown
     return "\n" . '<form id="userFrontendLangIdForm" name="userFrontendLangIdForm"' . ' action="' . $action . '"' . ' method="post">' . "\n" . Html::getHidden_activetab() . "\n" . Html::getSelectCustom('userFrontendLangId', FWLanguage::getMenuoptions($this->userFrontendLangId), false, 'submitUserFrontendLanguage();', 'size="1" class="chzn-select"') . "\n</form>\n";
 }
 /**
  * Show on overview of the mail templates for the given section and group
  *
  * If empty, the $limit defaults to the
  * "numof_mailtemplate_per_page_backend" setting for the given section
  * and group.
  * @param   string    $section      The section
  * @param   string    $group        The group
  * @param   integer   $limit        The optional limit for the number
  *                                  of templates to be shown
  * @param   string   $act           The action of the mail template
  *                                  default set to mailtemplate_overview
  * @return  \Cx\Core\Html\Sigma     The template object
  */
 static function overview($section, $group, $limit = 0, $useDefaultActs = true, $act = 'mailtemplate_edit')
 {
     global $_CORELANG;
     $objTemplateLocal = new \Cx\Core\Html\Sigma(\Env::get('cx')->getCodeBaseCorePath() . '/MailTemplate/View/Template/Generic');
     $objTemplateLocal->setErrorHandling(PEAR_ERROR_DIE);
     \Cx\Core\Csrf\Controller\Csrf::add_placeholder($objTemplateLocal);
     if (!$objTemplateLocal->loadTemplateFile('Overview.html')) {
         die("Failed to load template Overview.html");
     }
     if (empty($section) || empty($group)) {
         \Message::error($_CORELANG['TXT_CORE_MAILTEMPLATE_ERROR_NO_SECTION_OR_GROUP']);
         return false;
     }
     if (empty($limit)) {
         \Cx\Core\Setting\Controller\Setting::init($section, $group);
         $limit = \Cx\Core\Setting\Controller\Setting::getValue('numof_mailtemplate_per_page_backend', $section);
         // TODO: TEMPORARY
         if (is_null($limit)) {
             $limit = 25;
             \Cx\Core\Setting\Controller\Setting::add('numof_mailtemplate_per_page_backend', $limit, 1001, 'text', '', $group);
         }
     }
     $uri = \Html::getRelativeUri_entities();
     $tab_index = \Cx\Core\Setting\Controller\Setting::tab_index();
     \Html::replaceUriParameter($uri, 'active_tab=' . $tab_index);
     \Html::replaceUriParameter($uri, 'userFrontendLangId=' . FRONTEND_LANG_ID);
     //echo("Made uri for sorting: ".htmlentities($uri)."<br />");
     \Html::stripUriParam($uri, 'key');
     \Html::stripUriParam($uri, 'delete_mailtemplate_key');
     $uri_edit = $uri_overview = $uri;
     //echo("Made uri for sorting: ".htmlentities($uri)."<br />");
     if ($useDefaultActs) {
         \Html::stripUriParam($uri, 'act');
         \Html::replaceUriParameter($uri_edit, 'act=mailtemplate_edit');
         \Html::replaceUriParameter($uri_overview, 'act=mailtemplate_overview');
     }
     $objSorting = new \Sorting($uri_overview, array('name' => $_CORELANG['TXT_CORE_MAILTEMPLATE_NAME'], 'key' => $_CORELANG['TXT_CORE_MAILTEMPLATE_KEY'], 'html' => $_CORELANG['TXT_CORE_MAILTEMPLATE_IS_HTML'], 'protected' => $_CORELANG['TXT_CORE_MAILTEMPLATE_PROTECTED']), true, 'order_mailtemplate');
     $count = 0;
     // Template titles are shown in the current language only, no need
     // (and no way either) to load them all.  Names are shown in the
     // currently active frontend language only.
     $pagingParameterName = $section . '_' . $group;
     $arrTemplates = self::getArray($section, FRONTEND_LANG_ID, $objSorting->getOrder(), \Paging::getPosition($pagingParameterName), $limit, $count);
     $arrLanguageName = \FWLanguage::getNameArray();
     $objTemplateLocal->setGlobalVariable($_CORELANG + array('CORE_MAILTEMPLATE_NAME' => $objSorting->getHeaderForField('name'), 'CORE_MAILTEMPLATE_KEY' => $objSorting->getHeaderForField('key'), 'CORE_MAILTEMPLATE_HTML' => $objSorting->getHeaderForField('html'), 'CORE_MAILTEMPLATE_PROTECTED' => $objSorting->getHeaderForField('protected'), 'PAGING' => \Paging::get($uri_overview, $_CORELANG['TXT_CORE_MAILTEMPLATE_PAGING'], $count, $limit, true, null, $pagingParameterName), 'URI_BASE' => $uri, 'URI_EDIT' => $uri_edit, 'CORE_MAILTEMPLATE_COLSPAN' => 5 + count($arrLanguageName)));
     foreach ($arrLanguageName as $language_name) {
         $objTemplateLocal->setVariable('MAILTEMPLATE_LANGUAGE_HEADER', $language_name);
         $objTemplateLocal->parse('core_mailtemplate_language_header');
     }
     if (empty($arrTemplates)) {
         \Message::information($_CORELANG['TXT_CORE_MAILTEMPLATE_WARNING_NONE']);
         $arrTemplates = array();
     }
     // Load *all* templates and languages
     self::init($section);
     $i = 0;
     foreach ($arrTemplates as $arrTemplate) {
         $key = $arrTemplate['key'];
         $objTemplateLocal->setVariable(array('MAILTEMPLATE_ROWCLASS' => ++$i % 2 + 1, 'MAILTEMPLATE_PROTECTED' => \Html::getCheckmark($arrTemplate['protected']), 'MAILTEMPLATE_HTML' => \Html::getCheckmark($arrTemplate['html']), 'MAILTEMPLATE_NAME' => '<a href="' . $uri_edit . '&amp;key=' . urlencode($key) . '">' . contrexx_raw2xhtml($arrTemplate['name']) . '</a>', 'MAILTEMPLATE_KEY' => $arrTemplate['key'], 'MAILTEMPLATE_FUNCTIONS' => \Html::getBackendFunctions(array('copy' => $uri_edit . '&amp;copy=1&amp;key=' . $arrTemplate['key'], 'edit' => $uri_edit . '&amp;key=' . $arrTemplate['key'], 'delete' => $arrTemplate['protected'] ? '' : $uri_overview . '&amp;delete_mailtemplate_key=' . $arrTemplate['key'] . '&amp;csrf=' . \Cx\Core\Csrf\Controller\Csrf::code()), array('delete' => $_CORELANG['TXT_CORE_MAILTEMPLATE_DELETE_CONFIRM']))));
         foreach (array_keys($arrLanguageName) as $lang_id) {
             $available = isset(self::$arrTemplates[$lang_id][$key]) && self::$arrTemplates[$lang_id][$key]['available'];
             $title = $available ? $_CORELANG['TXT_CORE_MAILTEMPLATE_EDIT'] : $_CORELANG['TXT_CORE_MAILTEMPLATE_NEW'];
             $icon = '<a href="' . CONTREXX_DIRECTORY_INDEX . "?cmd={$section}&amp;act=" . $act . '&amp;key=' . $key . '&amp;userFrontendLangId=' . $lang_id . '"' . ' title="' . $title . '">' . '<img src="../core/Core/View/Media/icons/' . ($available ? 'edit.gif' : 'add.png') . '"' . ' width="16" height="16" alt="' . $title . '" border="0" /></a>';
             $objTemplateLocal->setVariable('MAILTEMPLATE_LANGUAGE', $icon);
             $objTemplateLocal->parse('core_mailtemplate_language_column');
         }
         $objTemplateLocal->parse('core_mailtemplate_row');
     }
     return $objTemplateLocal;
 }