Example #1
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";
 }
Example #2
0
 /**
  * Edit a Customer
  * @author    Reto Kohli <*****@*****.**>
  */
 function view_customer_edit()
 {
     global $_ARRAYLANG;
     self::$objTemplate->loadTemplateFile("module_shop_edit_customer.html");
     $customer_id = isset($_REQUEST['customer_id']) ? intval($_REQUEST['customer_id']) : null;
     if (isset($_POST['store'])) {
         $customer_id = $this->storeCustomerFromPost();
     }
     $username = isset($_POST['username']) ? trim(strip_tags(contrexx_input2raw($_POST['username']))) : null;
     $password = isset($_POST['password']) ? trim(strip_tags(contrexx_input2raw($_POST['password']))) : null;
     $company = isset($_POST['company']) ? trim(strip_tags(contrexx_input2raw($_POST['company']))) : null;
     $gender = isset($_POST['gender']) ? trim(strip_tags(contrexx_input2raw($_POST['gender']))) : null;
     $firstname = isset($_POST['firstname']) ? trim(strip_tags(contrexx_input2raw($_POST['firstname']))) : null;
     $lastname = isset($_POST['lastname']) ? trim(strip_tags(contrexx_input2raw($_POST['lastname']))) : null;
     $address = isset($_POST['address']) ? trim(strip_tags(contrexx_input2raw($_POST['address']))) : null;
     $city = isset($_POST['city']) ? trim(strip_tags(contrexx_input2raw($_POST['city']))) : null;
     $zip = isset($_POST['zip']) ? trim(strip_tags(contrexx_input2raw($_POST['zip']))) : null;
     $country_id = isset($_POST['country_id']) ? intval($_POST['country_id']) : null;
     $phone = isset($_POST['phone']) ? trim(strip_tags(contrexx_input2raw($_POST['phone']))) : null;
     $fax = isset($_POST['fax']) ? trim(strip_tags(contrexx_input2raw($_POST['fax']))) : null;
     $email = isset($_POST['email']) ? trim(strip_tags(contrexx_input2raw($_POST['email']))) : null;
     $companynote = isset($_POST['companynote']) ? trim(strip_tags(contrexx_input2raw($_POST['companynote']))) : null;
     $is_reseller = isset($_POST['customer_type']) ? intval($_POST['customer_type']) : null;
     $registerdate = time();
     $active = !empty($_POST['active']);
     $customer_group_id = isset($_POST['customer_group_id']) ? intval($_POST['customer_group_id']) : null;
     $lang_id = isset($_POST['customer_lang_id']) ? intval($_POST['customer_lang_id']) : FRONTEND_LANG_ID;
     if ($customer_id) {
         $objCustomer = Customer::getById($customer_id);
         if (!$objCustomer) {
             return \Message::error($_ARRAYLANG['TXT_SHOP_CUSTOMER_ERROR_LOADING']);
         }
         self::$pageTitle = $_ARRAYLANG['TXT_EDIT_CUSTOMER'];
         $username = $objCustomer->username();
         $password = '';
         $company = $objCustomer->company();
         $gender = $objCustomer->gender();
         $firstname = $objCustomer->firstname();
         $lastname = $objCustomer->lastname();
         $address = $objCustomer->address();
         $city = $objCustomer->city();
         $zip = $objCustomer->zip();
         $country_id = $objCustomer->country_id();
         $phone = $objCustomer->phone();
         $fax = $objCustomer->fax();
         $email = $objCustomer->email();
         $companynote = $objCustomer->companynote();
         $is_reseller = $objCustomer->is_reseller();
         $registerdate = $objCustomer->getRegistrationDate();
         $active = $objCustomer->active();
         $customer_group_id = $objCustomer->group_id();
         $lang_id = $objCustomer->getFrontendLanguage();
     } else {
         self::$pageTitle = $_ARRAYLANG['TXT_ADD_NEW_CUSTOMER'];
         self::$objTemplate->setVariable('SHOP_SEND_LOGING_DATA_STATUS', \Html::ATTRIBUTE_CHECKED);
         $customer_id = null;
     }
     self::$objTemplate->setVariable(array('SHOP_CUSTOMERID' => $customer_id, 'SHOP_COMPANY' => $company, 'SHOP_GENDER_MENUOPTIONS' => Customers::getGenderMenuoptions($gender), 'SHOP_LASTNAME' => $lastname, 'SHOP_FIRSTNAME' => $firstname, 'SHOP_ADDRESS' => $address, 'SHOP_ZIP' => $zip, 'SHOP_CITY' => $city, 'SHOP_EMAIL' => $email, 'SHOP_PHONE' => $phone, 'SHOP_FAX' => $fax, 'SHOP_USERNAME' => $username, 'SHOP_PASSWORD' => $password, 'SHOP_COMPANY_NOTE' => $companynote, 'SHOP_REGISTER_DATE' => date(ASCMS_DATE_FORMAT_DATETIME, $registerdate), 'SHOP_COUNTRY_MENUOPTIONS' => \Cx\Core\Country\Controller\Country::getMenuoptions($country_id), 'SHOP_DISCOUNT_GROUP_CUSTOMER_MENUOPTIONS' => Discount::getMenuOptionsGroupCustomer($customer_group_id), 'SHOP_CUSTOMER_TYPE_MENUOPTIONS' => Customers::getTypeMenuoptions($is_reseller), 'SHOP_CUSTOMER_ACTIVE_MENUOPTIONS' => Customers::getActiveMenuoptions($active), 'SHOP_LANG_ID_MENUOPTIONS' => \FWLanguage::getMenuoptions($lang_id)));
     return true;
 }