function getInputfield($intView, $arrInputfield, $intEntryId = null) { global $objDatabase, $_LANGID, $objInit, $_ARRAYLANG; $intId = intval($arrInputfield['id']); switch ($intView) { default: case 1: if (isset($intEntryId) && $intEntryId != 0) { $objInputfieldValue = $objDatabase->Execute("\n SELECT\n `value`\n FROM\n " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_entry_inputfields\n WHERE\n field_id=" . $intId . "\n AND\n entry_id=" . $intEntryId . "\n LIMIT 1\n "); $strValue = intval($objInputfieldValue->fields['value']); } else { $strValue = null; } if (empty($strValue)) { if (substr($arrInputfield['default_value'][0], 0, 2) == '[[') { $objPlaceholder = new \Cx\Modules\MediaDir\Controller\MediaDirectoryPlaceholder($this->moduleName); $strValue = $objPlaceholder->getPlaceholder($arrInputfield['default_value'][0]); } else { $strValue = empty($arrInputfield['default_value'][$_LANGID]) ? $arrInputfield['default_value'][0] : $arrInputfield['default_value'][$_LANGID]; } } if (!empty($arrInputfield['info'][0])) { $strInfoValue = empty($arrInputfield['info'][$_LANGID]) ? 'title="' . $arrInputfield['info'][0] . '"' : 'title="' . $arrInputfield['info'][$_LANGID] . '"'; $strInfoClass = 'mediadirInputfieldHint'; } else { $strInfoValue = null; $strInfoClass = ''; } if ($objInit->mode == 'backend') { $strInputfield = '<select name="' . $this->moduleNameLC . 'Inputfield[' . $intId . ']" id="' . $this->moduleNameLC . 'Inputfield_' . $intId . '" class="' . $this->moduleNameLC . 'InputfieldDropdown" style="width: 302px">'; } else { $strInputfield = '<select name="' . $this->moduleNameLC . 'Inputfield[' . $intId . ']" id="' . $this->moduleNameLC . 'Inputfield_' . $intId . '" class="' . $this->moduleNameLC . 'InputfieldDropdown ' . $strInfoClass . '" ' . $strInfoValue . '>'; } $strInputfieldOptions = \Cx\Core\Country\Controller\Country::getMenuoptions($strValue); $strInputfield .= $strInputfieldOptions . '</select>'; return $strInputfield; break; case 2: //search View $country = \Cx\Core\Country\Controller\Country::getNameArray(true, $_LANGID); foreach ($country as $id => $name) { $strInputfieldOptions .= '<option value="' . $id . '">' . $name . '</option>'; } $strInputfield = '<select name="' . $intId . '" class="' . $this->moduleName . 'InputfieldSearch">'; $strInputfield .= '<option value="">' . $_ARRAYLANG['TXT_MEDIADIR_PLEASE_CHOOSE'] . '</option>'; $strInputfield .= $strInputfieldOptions . '</select>'; return $strInputfield; break; } }
/** * Adding Crm Contact and link it with crm company if possible * * @param Array $arrFormData form data's * @param int $userAccountId * @param int $frontendLanguage * @global <object> $objDatabase * @global int $_LANGID * */ function setContactPersonProfile($arrFormData = array(), $userAccountId = 0, $frontendLanguage) { global $objDatabase, $_LANGID; $this->contact = new \Cx\Modules\Crm\Model\Entity\CrmContact(); if (!empty($userAccountId)) { $userExists = $objDatabase->Execute("SELECT id FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_contacts` WHERE user_account = {$userAccountId}"); if ($userExists && $userExists->RecordCount()) { $id = (int) $userExists->fields['id']; $this->contact->load($id); $this->contact->customerName = !empty($arrFormData['firstname'][0]) ? contrexx_input2raw($arrFormData['firstname'][0]) : ''; $this->contact->family_name = !empty($arrFormData['lastname'][0]) ? contrexx_input2raw($arrFormData['lastname'][0]) : ''; $this->contact->contact_language = !empty($frontendLanguage) ? (int) $frontendLanguage : $_LANGID; $this->contact->contact_gender = !empty($arrFormData['gender'][0]) ? $arrFormData['gender'][0] == 'gender_female' ? 1 : ($arrFormData['gender'][0] == 'gender_male' ? 2 : '') : ''; $this->contact->contactType = 2; $this->contact->datasource = 2; $this->contact->account_id = $userAccountId; //set profile picture if (!empty($arrFormData['picture'][0])) { $picture = $arrFormData['picture'][0]; $cx = \Cx\Core\Core\Controller\Cx::instanciate(); if (!file_exists($cx->getWebsiteImagesCrmProfilePath() . '/' . $picture)) { $file = $cx->getWebsiteImagesAccessProfilePath() . '/'; $newFile = $cx->getWebsiteImagesCrmProfilePath() . '/'; if (copy($file . $picture, $newFile . $picture)) { if ($this->createThumbnailOfPicture($picture)) { $this->contact->profile_picture = $picture; } } } } else { $this->contact->profile_picture = 'profile_person_big.png'; } // save current setting values, so we can switch back to them after we got our used settings out of database $prevSection = \Cx\Core\Setting\Controller\Setting::getCurrentSection(); $prevGroup = \Cx\Core\Setting\Controller\Setting::getCurrentGroup(); $prevEngine = \Cx\Core\Setting\Controller\Setting::getCurrentEngine(); \Cx\Core\Setting\Controller\Setting::init('Crm', 'config'); if ($arrFormData["company"][0] != "") { $crmCompany = new \Cx\Modules\Crm\Model\Entity\CrmContact(); if ($this->contact->contact_customer != 0) { $crmCompany->load($this->contact->contact_customer); } $crmCompany->customerName = $arrFormData["company"][0]; $crmCompany->contactType = 1; $customerType = $arrFormData[\Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_customer_type', 'Crm')][0]; if ($customerType !== false) { $crmCompany->customerType = $customerType; } $companySize = $arrFormData[\Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_company_size', 'Crm')][0]; if ($companySize !== false) { $crmCompany->companySize = $companySize; } $industryType = $arrFormData[\Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_industry_type', 'Crm')][0]; if ($industryType !== false) { $crmCompany->industryType = $industryType; } if (isset($arrFormData["phone_office"])) { $crmCompany->phone = $arrFormData["phone_office"]; } // store/update the company profile $crmCompany->save(); // setting & storing the primary email address must be done after // the company has been saved for the case where the company is // being added as a new object without having an ID yet if (empty($crmCompany->email)) { $crmCompany->email = $this->contact->email; $crmCompany->storeEMail(); } $this->contact->contact_customer = $crmCompany->id; } if ($this->contact->save()) { // insert website if (!empty($arrFormData['website'][0])) { $webExists = $objDatabase->SelectLimit("SELECT 1 FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_websites` WHERE is_primary = '1' AND contact_id = '{$this->contact->id}'"); $fields = array('url' => $arrFormData['website'][0], 'url_profile' => '1', 'is_primary' => '1', 'contact_id' => $this->contact->id); if ($webExists) { $query = \SQL::update("module_{$this->moduleNameLC}_customer_contact_websites", $fields, array('escape' => true)) . " WHERE is_primary = '1' AND `contact_id` = {$this->contact->id}"; } else { $query = \SQL::insert("module_{$this->moduleNameLC}_customer_contact_websites", $fields, array('escape' => true)); } $db = $objDatabase->Execute($query); } //insert address if (!empty($arrFormData['address'][0]) || !empty($arrFormData['city'][0]) || !empty($arrFormData['zip'][0]) || !empty($arrFormData['country'][0])) { $addressExists = $objDatabase->SelectLimit("SELECT 1 FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_address` WHERE is_primary = '1' AND contact_id = '{$this->contact->id}'"); $country = \Cx\Core\Country\Controller\Country::getById($arrFormData['country'][0]); if ($addressExists && $addressExists->RecordCount()) { $query = "UPDATE `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_address` SET\n address = '" . contrexx_input2db($arrFormData['address'][0]) . "',\n city = '" . contrexx_input2db($arrFormData['city'][0]) . "',\n zip = '" . contrexx_input2db($arrFormData['zip'][0]) . "',\n country = '" . $country['name'] . "',\n Address_Type = '2'\n WHERE is_primary = '1' AND contact_id = '{$this->contact->id}'"; } else { $query = "INSERT INTO `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_address` SET\n address = '" . contrexx_input2db($arrFormData['address'][0]) . "',\n city = '" . contrexx_input2db($arrFormData['city'][0]) . "',\n state = '" . contrexx_input2db($arrFormData['city'][0]) . "',\n zip = '" . contrexx_input2db($arrFormData['zip'][0]) . "',\n country = '" . $country['name'] . "',\n Address_Type = '2',\n is_primary = '1',\n contact_id = '{$this->contact->id}'"; } $objDatabase->Execute($query); } // insert Phone $contactPhone = array(); if (!empty($arrFormData['phone_office'][0])) { $phoneExists = $objDatabase->SelectLimit("SELECT 1 FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_phone` WHERE is_primary = '1' AND contact_id = '{$this->contact->id}'"); $fields = array('phone' => $arrFormData['phone_office'][0], 'phone_type' => '1', 'is_primary' => '1', 'contact_id' => $this->contact->id); if ($phoneExists && $phoneExists->RecordCount()) { $query = \SQL::update("module_{$this->moduleNameLC}_customer_contact_phone", $fields, array('escape' => true)) . " WHERE is_primary = '1' AND `contact_id` = {$this->contact->id}"; } else { $query = \SQL::insert("module_{$this->moduleNameLC}_customer_contact_phone", $fields, array('escape' => true)); } $objDatabase->Execute($query); } } \Cx\Core\Setting\Controller\Setting::init($prevSection, $prevGroup, $prevEngine); } } }
/** * Check Country targeting option * * @param string $filter include => client country should exists in given country ids * exclude => client country should not exists in given country ids * @param array $countryIds Country ids to match * * @return boolean True when targeting country option matching to client country * False otherwise */ public function checkTargetingCountry($filter, $countryIds) { // getClient country using GeoIp component $geoIpComponentController = $this->getGeoIpComponent(); if (!$geoIpComponentController) { return false; } $clientRecord = $geoIpComponentController->getClientRecord(); if (!$clientRecord) { return false; } $clientCountryAlpha2 = $clientRecord->country->isoCode; $clientCountryId = \Cx\Core\Country\Controller\Country::getIdByAlpha2($clientCountryAlpha2); $isCountryExists = in_array($clientCountryId, $countryIds); if ($filter == 'include') { return $isCountryExists; } else { return !$isCountryExists; } }
/** * Returns the countries related payment ID array. * * If PayPal is the selected payment method, any Currencies not supported * will be removed from the Currency array. * Returns the Payment IDs allowed for the given Country ID. * Note that the Payment IDs are used for both the keys and values * of the array returned, like: * array( * payment_id => payment_id, * [...] * ) * @global ADONewConnection $objDatabase Database connection object * @param integer $countryId The country ID * @param array $arrCurrencies The currencies array, by reference * @return array Array of Payment IDs */ static function getCountriesRelatedPaymentIdArray($countryId, $arrCurrencies) { global $objDatabase; if (is_null(self::$arrPayments)) { self::init(); } if (isset($_SESSION['shop']['paymentId'])) { $payment_id = $_SESSION['shop']['paymentId']; $processor_id = self::getPaymentProcessorId($payment_id); if ($processor_id == 2) { foreach ($arrCurrencies as $index => $arrCurrency) { if (!\PayPal::isAcceptedCurrencyCode($arrCurrency['code'])) { unset($arrCurrencies[$index]); } } } } $arrPaymentId = array(); $query = "\n SELECT DISTINCT `payment`.`id`\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_rel_countries` AS `country`\n INNER JOIN `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_zones` AS `zone`\n ON `country`.`zone_id`=`zone`.`id`\n INNER JOIN `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_rel_payment` AS `rel_payment`\n ON `zone`.`id`=`rel_payment`.`zone_id`\n INNER JOIN `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_payment` AS `payment`\n ON `payment`.`id`=`rel_payment`.`payment_id`\n WHERE `country`.`country_id`=" . intval($countryId) . "\n AND `payment`.`active`=1\n AND `zone`.`active`=1"; $objResult = $objDatabase->Execute($query); while ($objResult && !$objResult->EOF) { if (isset(self::$arrPayments[$objResult->fields['id']]) && (self::$arrPayments[$objResult->fields['id']]['processor_id'] != 2 || count($arrCurrencies))) { $paymentId = $objResult->fields['id']; // the processor with the id 3 is postfinance and 11 is postfinance mobile // if it is one of them, it should only be able to order when it is Switzerland if (in_array(self::$arrPayments[$paymentId]['processor_id'], array(3, 11)) && \Cx\Core\Country\Controller\Country::getAlpha2ById($countryId) != 'CH') { $objResult->MoveNext(); continue; } $arrPaymentId[$paymentId] = $paymentId; } $objResult->MoveNext(); } return $arrPaymentId; }
/** * Returns an array containing all the active shipment conditions. * * The array has the form * array( * Shipper name => array( * 'countries' => array( * country ID => Country name, [...] * ), * 'conditions' => array( * Maximum weight => array( * 'max_weight' => maximum weight (formatted, or "unlimited"), * 'free_from' => no charge lower limit (amount), * 'fee' => shipping fee (amount), * ), * [... more ...] * ), * ), * [... more ...] * ) * Countries are ordered by ascending names. * Conditions are ordered by ascending maximum weight. * @global ADONewConnection $objDatabase * @global array $_ARRAYLANG * @return array Countries and conditions array on success, * false otherwise * @static */ static function getShipmentConditions() { global $objDatabase, $_ARRAYLANG; if (empty(self::$arrShippers)) { self::init(); } // Get shippers and associated countries (via zones). // Make an array(shipper_name => array( array(country, ...), array(conditions) ) // where the countries are listed as strings of their names, // and the conditions look like: array(max_weight, free_from, fee) // Return this $arrResult = array(); foreach (self::$arrShippers as $shipper_id => $shipper) { // Get countries covered by this shipper $arrSqlName = \Cx\Core\Country\Controller\Country::getSqlSnippets(); $objResult = $objDatabase->Execute("\n SELECT DISTINCT `country`.`id`," . $arrSqlName['field'] . "\n FROM `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_shipper` AS `shipper`\n INNER JOIN `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_rel_shipper` AS `rel_shipper`\n ON `shipper`.`id`=`rel_shipper`.`shipper_id`\n INNER JOIN `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_zones` AS `zone`\n ON `rel_shipper`.`zone_id`=`zone`.`id`\n INNER JOIN `" . DBPREFIX . "module_shop" . MODULE_INDEX . "_rel_countries` AS `rel_country`\n ON `zone`.`id`=`rel_country`.`zone_id`\n INNER JOIN `" . DBPREFIX . "core_country` AS `country`\n ON `rel_country`.`country_id`=`country`.`id`" . $arrSqlName['join'] . "\n WHERE `shipper`.`id`=?\n AND `zone`.`active`=1\n AND `shipper`.`active`=1\n AND `country`.`active`=1\n ORDER BY " . $arrSqlName['alias']['name'] . " ASC", $shipper_id); if (!$objResult) { return self::errorHandler(); } $arrCountries = array(); while (!$objResult->EOF) { $country_id = $objResult->fields['id']; $strName = $objResult->fields['name']; if (is_null($strName)) { $objText = \Text::getById($country_id, 'Shop', self::TEXT_NAME); if ($objText) { $strName = $objText->content(); } } $arrCountries[$country_id] = $strName; $objResult->MoveNext(); } // Now add the conditions, and order them by weight $arrConditions = array(); foreach (self::$arrShipments[$shipper_id] as $arrCond) { $arrConditions[$arrCond['max_weight']] = array('max_weight' => $arrCond['max_weight'] > 0 ? $arrCond['max_weight'] : $_ARRAYLANG['TXT_SHOP_WEIGHT_UNLIMITED'], 'free_from' => $arrCond['free_from'] > 0 ? $arrCond['free_from'] : '-', 'fee' => $arrCond['fee'] > 0 ? $arrCond['fee'] : $_ARRAYLANG['TXT_SHOP_COST_FREE']); } krsort($arrConditions); $arrResult[$shipper['name']] = array('countries' => $arrCountries, 'conditions' => $arrConditions); } return $arrResult; }
/** * Generate the form and show hints if necessary. * If user input validation is successful a new transaction will be added. * In this case the form will be hidden and only a status message will be shown. * * @access private */ private function renderForm() { global $objDatabase, $_ARRAYLANG, $_CORELANG; //check the payment service provider configuration $objSettingsGeneral = new SettingsGeneral($objDatabase); if (!$objSettingsGeneral->getEpaymentStatus()) { $this->arrStatusMessages['error'][] = $_ARRAYLANG['TXT_CHECKOUT_EPAYMENT_DEACTIVATED']; $this->objTemplate->hideblock('form'); $this->objTemplate->hideblock('redirect'); return; } //initialize variables $arrFieldValues = array(); $arrFieldsToHighlight = array(); $arrCssClasses = array(); $cssHighlightingClass = 'highlight'; $cssLabelClass = 'label'; $htmlRequiredField = ' *'; $arrSelectOptions[] = array(); //validate submitted user data if (isset($_REQUEST['submit'])) { $arrFieldValues['invoice_number'] = !empty($_REQUEST['invoice_number']) && $_REQUEST['invoice_number'] !== $_ARRAYLANG['TXT_CHECKOUT_INVOICE_NUMBER'] . $htmlRequiredField ? $_REQUEST['invoice_number'] : ''; $arrFieldValues['invoice_currency'] = !empty($_REQUEST['invoice_currency']) ? $_REQUEST['invoice_currency'] : ''; $arrFieldValues['invoice_amount'] = !empty($_REQUEST['invoice_amount']) && $_REQUEST['invoice_amount'] !== $_ARRAYLANG['TXT_CHECKOUT_INVOICE_AMOUNT'] . $htmlRequiredField ? $_REQUEST['invoice_amount'] : ''; $arrFieldValues['contact_title'] = !empty($_REQUEST['contact_title']) ? $_REQUEST['contact_title'] : ''; $arrFieldValues['contact_forename'] = !empty($_REQUEST['contact_forename']) && $_REQUEST['contact_forename'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_FORENAME'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_forename'])) : ''; $arrFieldValues['contact_surname'] = !empty($_REQUEST['contact_surname']) && $_REQUEST['contact_surname'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_SURNAME'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_surname'])) : ''; $arrFieldValues['contact_company'] = !empty($_REQUEST['contact_company']) && $_REQUEST['contact_company'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_COMPANY'] ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_company'])) : ''; $arrFieldValues['contact_street'] = !empty($_REQUEST['contact_street']) && $_REQUEST['contact_street'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_STREET'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_street'])) : ''; $arrFieldValues['contact_postcode'] = !empty($_REQUEST['contact_postcode']) && $_REQUEST['contact_postcode'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_POSTCODE'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_postcode'])) : ''; $arrFieldValues['contact_place'] = !empty($_REQUEST['contact_place']) && $_REQUEST['contact_place'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PLACE'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_place'])) : ''; $arrFieldValues['contact_country'] = !empty($_REQUEST['contact_country']) ? $_REQUEST['contact_country'] : ''; $arrFieldValues['contact_phone'] = !empty($_REQUEST['contact_phone']) && $_REQUEST['contact_phone'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PHONE'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_phone'])) : ''; $arrFieldValues['contact_email'] = !empty($_REQUEST['contact_email']) && $_REQUEST['contact_email'] !== $_ARRAYLANG['TXT_CHECKOUT_CONTACT_EMAIL'] . $htmlRequiredField ? contrexx_input2raw(contrexx_strip_tags($_REQUEST['contact_email'])) : ''; //get keys of passed data if (!isset($this->arrCurrencies[$invoiceCurrency]) && ($key = array_search(strtoupper($invoiceCurrency), $this->arrCurrencies))) { $invoiceCurrency = $key; } if (strtolower($contactTitle) !== self::MISTER && strtolower($contactTitle) !== self::MISS) { if (ucfirst(strtolower($contactTitle)) == $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISTER']) { $contactTitle = self::MISTER; } elseif (ucfirst(strtolower($contactTitle)) == $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISS']) { $contactTitle = self::MISS; } } else { $contactTitle = strtolower($contactTitle); } if (!isset($this->arrCountries[$contactCountry]) && ($key = array_search(ucfirst(strtolower($contactCountry)), $this->arrCountries))) { $contactCountry = $key; } $arrUserData['text']['invoice_number']['name'] = $_ARRAYLANG['TXT_CHECKOUT_INVOICE_NUMBER']; $arrUserData['text']['invoice_number']['value'] = $arrFieldValues['invoice_number']; $arrUserData['text']['invoice_number']['length'] = 255; $arrUserData['text']['invoice_number']['mandatory'] = 1; $arrUserData['selection']['invoice_currency']['name'] = $_ARRAYLANG['TXT_CHECKOUT_INVOICE_CURRENCY']; $arrUserData['selection']['invoice_currency']['value'] = $arrFieldValues['invoice_currency']; $arrUserData['selection']['invoice_currency']['options'] = $this->arrCurrencies; $arrUserData['selection']['invoice_currency']['mandatory'] = 1; $arrUserData['numeric']['invoice_amount']['name'] = $_ARRAYLANG['TXT_CHECKOUT_INVOICE_AMOUNT']; $arrUserData['numeric']['invoice_amount']['value'] = $arrFieldValues['invoice_amount']; $arrUserData['numeric']['invoice_amount']['length'] = 15; $arrUserData['numeric']['invoice_amount']['mandatory'] = 1; $arrUserData['selection']['contact_title']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE']; $arrUserData['selection']['contact_title']['value'] = $arrFieldValues['contact_title']; $arrUserData['selection']['contact_title']['options'] = array(self::MISTER => '', self::MISS => ''); $arrUserData['selection']['contact_title']['mandatory'] = 1; $arrUserData['text']['contact_forename']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_FORENAME']; $arrUserData['text']['contact_forename']['value'] = $arrFieldValues['contact_forename']; $arrUserData['text']['contact_forename']['length'] = 255; $arrUserData['text']['contact_forename']['mandatory'] = 1; $arrUserData['text']['contact_surname']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_SURNAME']; $arrUserData['text']['contact_surname']['value'] = $arrFieldValues['contact_surname']; $arrUserData['text']['contact_surname']['length'] = 255; $arrUserData['text']['contact_surname']['mandatory'] = 1; $arrUserData['text']['contact_company']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_COMPANY']; $arrUserData['text']['contact_company']['value'] = $arrFieldValues['contact_company']; $arrUserData['text']['contact_company']['length'] = 255; $arrUserData['text']['contact_company']['mandatory'] = 0; $arrUserData['text']['contact_street']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_STREET']; $arrUserData['text']['contact_street']['value'] = $arrFieldValues['contact_street']; $arrUserData['text']['contact_street']['length'] = 255; $arrUserData['text']['contact_street']['mandatory'] = 1; $arrUserData['text']['contact_postcode']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_POSTCODE']; $arrUserData['text']['contact_postcode']['value'] = $arrFieldValues['contact_postcode']; $arrUserData['text']['contact_postcode']['length'] = 255; $arrUserData['text']['contact_postcode']['mandatory'] = 1; $arrUserData['text']['contact_place']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PLACE']; $arrUserData['text']['contact_place']['value'] = $arrFieldValues['contact_place']; $arrUserData['text']['contact_place']['length'] = 255; $arrUserData['text']['contact_place']['mandatory'] = 1; $arrUserData['selection']['contact_country']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_COUNTRY']; $arrUserData['selection']['contact_country']['value'] = $arrFieldValues['contact_country']; $arrUserData['selection']['contact_country']['options'] = $this->arrCountries; $arrUserData['selection']['contact_country']['mandatory'] = 1; $arrUserData['text']['contact_phone']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PHONE']; $arrUserData['text']['contact_phone']['value'] = $arrFieldValues['contact_phone']; $arrUserData['text']['contact_phone']['length'] = 255; $arrUserData['text']['contact_phone']['mandatory'] = 1; $arrUserData['email']['contact_email']['name'] = $_ARRAYLANG['TXT_CHECKOUT_CONTACT_EMAIL']; $arrUserData['email']['contact_email']['value'] = $arrFieldValues['contact_email']; $arrUserData['email']['contact_email']['length'] = 255; $arrUserData['email']['contact_email']['mandatory'] = 1; $arrFieldsToHighlight = $this->validateUserData($arrUserData); if (empty($arrFieldsToHighlight)) { //validation was successful. now add a new transaction. $id = $this->objTransaction->add(self::WAITING, $arrUserData['text']['invoice_number']['value'], $arrUserData['selection']['invoice_currency']['value'], $arrUserData['numeric']['invoice_amount']['value'], $arrUserData['selection']['contact_title']['value'], $arrUserData['text']['contact_forename']['value'], $arrUserData['text']['contact_surname']['value'], $arrUserData['text']['contact_company']['value'], $arrUserData['text']['contact_street']['value'], $arrUserData['text']['contact_postcode']['value'], $arrUserData['text']['contact_place']['value'], $arrUserData['selection']['contact_country']['value'], $arrUserData['text']['contact_phone']['value'], $arrUserData['email']['contact_email']['value']); if ($id) { $objSettingsYellowpay = new SettingsYellowpay($objDatabase); $arrYellowpay = $objSettingsYellowpay->get(); $arrOrder = array('ORDERID' => $id, 'AMOUNT' => intval($arrFieldValues['invoice_amount'] * 100), 'CURRENCY' => $this->arrCurrencies[$arrFieldValues['invoice_currency']], 'PARAMPLUS' => 'section=Checkout'); $arrSettings['postfinance_shop_id']['value'] = $arrYellowpay['pspid']; $arrSettings['postfinance_hash_signature_in']['value'] = $arrYellowpay['sha_in']; $arrSettings['postfinance_authorization_type']['value'] = $arrYellowpay['operation']; $arrSettings['postfinance_use_testserver']['value'] = $arrYellowpay['testserver']; $landingPage = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page')->findOneByModuleCmdLang('Checkout', '', FRONTEND_LANG_ID); $this->objTemplate->setVariable('CHECKOUT_YELLOWPAY_FORM', \Yellowpay::getForm($arrOrder, $_ARRAYLANG['TXT_CHECKOUT_START_PAYMENT'], false, $arrSettings, $landingPage)); if (\Yellowpay::$arrError) { $this->arrStatusMessages['error'][] = $_ARRAYLANG['TXT_CHECKOUT_FAILED_TO_INITIALISE_YELLOWPAY']; } else { $this->arrStatusMessages['ok'][] = $_ARRAYLANG['TXT_CHECKOUT_ENTRY_SAVED_SUCCESSFULLY']; } $this->objTemplate->hideBlock('form'); $this->objTemplate->touchBlock('redirect'); return; } else { $this->arrStatusMessages['error'][] = $_ARRAYLANG['TXT_CHECKOUT_ENTRY_SAVED_ERROR']; } } } else { //get passed data $arrFieldValues['invoice_number'] = !empty($_REQUEST['invoice_number']) ? $_REQUEST['invoice_number'] : ''; $arrFieldValues['invoice_currency'] = !empty($_REQUEST['invoice_currency']) ? $_REQUEST['invoice_currency'] : ''; $arrFieldValues['invoice_amount'] = !empty($_REQUEST['invoice_amount']) ? $_REQUEST['invoice_amount'] : ''; $arrFieldValues['contact_title'] = !empty($_REQUEST['contact_title']) ? $_REQUEST['contact_title'] : ''; $arrFieldValues['contact_forename'] = !empty($_REQUEST['contact_forename']) ? $_REQUEST['contact_forename'] : ''; $arrFieldValues['contact_surname'] = !empty($_REQUEST['contact_surname']) ? $_REQUEST['contact_surname'] : ''; $arrFieldValues['contact_company'] = !empty($_REQUEST['contact_company']) ? $_REQUEST['contact_company'] : ''; $arrFieldValues['contact_street'] = !empty($_REQUEST['contact_street']) ? $_REQUEST['contact_street'] : ''; $arrFieldValues['contact_postcode'] = !empty($_REQUEST['contact_postcode']) ? $_REQUEST['contact_postcode'] : ''; $arrFieldValues['contact_place'] = !empty($_REQUEST['contact_place']) ? $_REQUEST['contact_place'] : ''; $arrFieldValues['contact_country'] = !empty($_REQUEST['contact_country']) ? $_REQUEST['contact_country'] : ''; $arrFieldValues['contact_phone'] = !empty($_REQUEST['contact_phone']) ? $_REQUEST['contact_phone'] : ''; $arrFieldValues['contact_email'] = !empty($_REQUEST['contact_email']) ? $_REQUEST['contact_email'] : ''; //get keys of passed options selection if (!isset($this->arrCurrencies[$arrFieldValues['invoice_currency']]) && ($key = array_search(strtoupper($arrFieldValues['invoice_currency']), $this->arrCurrencies))) { $arrFieldValues['invoice_currency'] = $key; } if (strtolower($arrFieldValues['contact_title']) !== self::MISTER && strtolower($arrFieldValues['contact_title']) !== self::MISS) { if (ucfirst(strtolower($arrFieldValues['contact_title'])) == $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISTER']) { $arrFieldValues['contact_title'] = self::MISTER; } elseif (ucfirst(strtolower($arrFieldValues['contact_title'])) == $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISS']) { $arrFieldValues['contact_title'] = self::MISS; } } else { $arrFieldValues['contact_title'] = strtolower($arrFieldValues['contact_title']); } if (!isset($this->arrCountries[$arrFieldValues['contact_country']]) && ($key = array_search(ucfirst(strtolower($arrFieldValues['contact_country'])), $this->arrCountries))) { $arrFieldValues['contact_country'] = $key; } } //get currency options $arrSelectOptions['currencies'][] = '<option value="0">' . $_ARRAYLANG['TXT_CHECKOUT_INVOICE_CURRENCY'] . $htmlRequiredField . '</option>'; foreach ($this->arrCurrencies as $id => $currency) { $selected = $id == $arrFieldValues['invoice_currency'] ? ' selected="selected"' : ''; $arrSelectOptions['currencies'][] = '<option value="' . $id . '"' . $selected . '>' . contrexx_raw2xhtml($currency) . '</option>'; } //get title options $selectedMister = self::MISTER == $arrFieldValues['contact_title'] ? ' selected="selected"' : ''; $selectedMiss = self::MISS == $arrFieldValues['contact_title'] ? ' selected="selected"' : ''; $arrSelectOptions['titles'][] = '<option value="0">' . $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE'] . $htmlRequiredField . '</option>'; $arrSelectOptions['titles'][] = '<option value="' . self::MISTER . '"' . $selectedMister . '>' . $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISTER'] . '</option>'; $arrSelectOptions['titles'][] = '<option value="' . self::MISS . '"' . $selectedMiss . '>' . $_ARRAYLANG['TXT_CHECKOUT_CONTACT_TITLE_MISS'] . '</option>'; //get country options if (!empty($this->arrCountries)) { //$arrSelectOptions['countries'][] = '<option value="0">'.$_ARRAYLANG['TXT_CHECKOUT_CONTACT_COUNTRY'].$htmlRequiredField.'</option>'; foreach ($this->arrCountries as $id => $name) { if (\Cx\Core\Country\Controller\Country::getAlpha2ById($id) != 'CH') { continue; } $selected = $id == $arrFieldValues['contact_country'] ? ' selected="selected"' : ''; $arrSelectOptions['countries'][] = '<option value="' . $id . '"' . $selected . '>' . contrexx_raw2xhtml($name) . '</option>'; } } // check wihch css classes have to be set foreach ($arrFieldValues as $name => $value) { if (isset($arrFieldsToHighlight[$name])) { $arrCssClasses[$name][] = $cssHighlightingClass; } if (empty($value)) { $arrCssClasses[$name][] = $cssLabelClass; } $arrCssClasses[$name] = implode(' ', $arrCssClasses[$name]); } \JS::activate('jquery'); \JS::registerCode($this->getJavascript($htmlRequiredField)); $this->objTemplate->setVariable(array('TXT_CHECKOUT_DESCRIPTION' => $_ARRAYLANG['TXT_CHECKOUT_DESCRIPTION'], 'TXT_CHECKOUT_BILL_DATA' => $_ARRAYLANG['TXT_CHECKOUT_BILL_DATA'], 'TXT_CHECKOUT_CONTACT_DATA' => $_ARRAYLANG['TXT_CHECKOUT_CONTACT_DATA'], 'CHECKOUT_INVOICE_NUMBER' => !empty($arrFieldValues['invoice_number']) ? $arrFieldValues['invoice_number'] : $_ARRAYLANG['TXT_CHECKOUT_INVOICE_NUMBER'] . $htmlRequiredField, 'CHECKOUT_INVOICE_CURRENCY_OPTIONS' => !empty($arrSelectOptions['currencies']) ? implode($arrSelectOptions['currencies']) : '', 'CHECKOUT_INVOICE_AMOUNT' => !empty($arrFieldValues['invoice_amount']) ? $arrFieldValues['invoice_amount'] : $_ARRAYLANG['TXT_CHECKOUT_INVOICE_AMOUNT'] . $htmlRequiredField, 'CHECKOUT_CONTACT_TITLE_OPTIONS' => !empty($arrSelectOptions['titles']) ? implode($arrSelectOptions['titles']) : '', 'CHECKOUT_CONTACT_FORENAME' => !empty($arrFieldValues['contact_forename']) ? $arrFieldValues['contact_forename'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_FORENAME'] . $htmlRequiredField, 'CHECKOUT_CONTACT_SURNAME' => !empty($arrFieldValues['contact_surname']) ? $arrFieldValues['contact_surname'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_SURNAME'] . $htmlRequiredField, 'CHECKOUT_CONTACT_COMPANY' => !empty($arrFieldValues['contact_company']) ? $arrFieldValues['contact_company'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_COMPANY'], 'CHECKOUT_CONTACT_STREET' => !empty($arrFieldValues['contact_street']) ? $arrFieldValues['contact_street'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_STREET'] . $htmlRequiredField, 'CHECKOUT_CONTACT_POSTCODE' => !empty($arrFieldValues['contact_postcode']) ? $arrFieldValues['contact_postcode'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_POSTCODE'] . $htmlRequiredField, 'CHECKOUT_CONTACT_PLACE' => !empty($arrFieldValues['contact_place']) ? $arrFieldValues['contact_place'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PLACE'] . $htmlRequiredField, 'CHECKOUT_CONTACT_COUNTRY_OPTIONS' => !empty($arrSelectOptions['countries']) ? implode($arrSelectOptions['countries']) : '', 'CHECKOUT_CONTACT_PHONE' => !empty($arrFieldValues['contact_phone']) ? $arrFieldValues['contact_phone'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_PHONE'] . $htmlRequiredField, 'CHECKOUT_CONTACT_EMAIL' => !empty($arrFieldValues['contact_email']) ? $arrFieldValues['contact_email'] : $_ARRAYLANG['TXT_CHECKOUT_CONTACT_EMAIL'] . $htmlRequiredField, 'CHECKOUT_INVOICE_NUMBER_CLASS' => $arrCssClasses['invoice_number'], 'CHECKOUT_INVOICE_CURRENCY_CLASS' => $arrCssClasses['invoice_currency'], 'CHECKOUT_INVOICE_AMOUNT_CLASS' => $arrCssClasses['invoice_amount'], 'CHECKOUT_CONTACT_TITLE_CLASS' => $arrCssClasses['contact_title'], 'CHECKOUT_CONTACT_FORENAME_CLASS' => $arrCssClasses['contact_forename'], 'CHECKOUT_CONTACT_SURNAME_CLASS' => $arrCssClasses['contact_surname'], 'CHECKOUT_CONTACT_COMPANY_CLASS' => $arrCssClasses['contact_company'], 'CHECKOUT_CONTACT_STREET_CLASS' => $arrCssClasses['contact_street'], 'CHECKOUT_CONTACT_POSTCODE_CLASS' => $arrCssClasses['contact_postcode'], 'CHECKOUT_CONTACT_PLACE_CLASS' => $arrCssClasses['contact_place'], 'CHECKOUT_CONTACT_COUNTRY_CLASS' => $arrCssClasses['contact_country'], 'CHECKOUT_CONTACT_PHONE_CLASS' => $arrCssClasses['contact_phone'], 'CHECKOUT_CONTACT_EMAIL_CLASS' => $arrCssClasses['contact_email'], 'TXT_CORE_SUBMIT' => $_CORELANG['TXT_CORE_SUBMIT'], 'TXT_CORE_RESET' => $_CORELANG['TXT_CORE_RESET'])); $this->objTemplate->hideBlock('redirect'); $this->objTemplate->parse('form'); }
/** * Get countries from given name * * @param array $params Get parameters, * * @return array Array of countries */ public function getCountries($params) { $countries = array(); $term = !empty($params['get']['term']) ? contrexx_input2raw($params['get']['term']) : ''; if (empty($term)) { return array('countries' => $countries); } $arrCountries = \Cx\Core\Country\Controller\Country::searchByName($term); foreach ($arrCountries as $country) { $countries[] = array('id' => $country['id'], 'label' => $country['name'], 'val' => $country['name']); } return array('countries' => $countries); }
public function __construct($attrs = array(), $options = array()) { global $_ARRAYLANG; if ($attrs instanceof \Cx\Core_Modules\Listing\Model\Entity\DataSet) { $hasMasterTableHeader = !empty($options['header']); // add master table-header-row if ($hasMasterTableHeader) { $this->addRow(array(0 => $options['header']), null, 'th'); } $first = true; $row = 1 + $hasMasterTableHeader; $sortBy = isset($options['functions']['sortBy']) && is_array($options['functions']['sortBy']) ? $options['functions']['sortBy'] : array(); $sortingKey = !empty($sortBy) && isset($sortBy['sortingKey']) ? $sortBy['sortingKey'] : ''; $sortField = !empty($sortingKey) && isset($sortBy['field']) ? key($sortBy['field']) : ''; $component = !empty($sortBy) && isset($sortBy['component']) ? $sortBy['component'] : ''; $entity = !empty($sortBy) && isset($sortBy['entity']) ? $sortBy['entity'] : ''; $sortOrder = !empty($sortBy) && isset($sortBy['sortOrder']) ? $sortBy['sortOrder'] : ''; $pagingPos = !empty($sortBy) && isset($sortBy['pagingPosition']) ? $sortBy['pagingPosition'] : ''; foreach ($attrs as $rowname => $rows) { $col = 0; $virtual = $rows['virtual']; unset($rows['virtual']); if (isset($options['multiActions'])) { $this->setCellContents($row, $col, '<input name="select-' . $rowname . '" value="' . $rowname . '" type="checkbox" />', 'TD', '0', false); $col++; } foreach ($rows as $header => $data) { if (!empty($sortingKey) && $header === $sortingKey) { //Add the additional attribute id, for getting the updated sort order after the row sorting $this->updateRowAttributes($row, array('id' => 'sorting' . $entity . '_' . $data), true); } $encode = true; if (isset($options['fields']) && isset($options['fields'][$header]) && isset($options['fields'][$header]['showOverview']) && !$options['fields'][$header]['showOverview']) { continue; } if (!empty($sortField) && $header === $sortField) { //Add the additional attribute class, to display the updated sort order after the row sorting $this->updateColAttributes($col, array('class' => 'sortBy' . $sortField)); } $origHeader = $header; if (isset($options['fields'][$header]['sorting'])) { $sorting = $options['fields'][$header]['sorting']; } else { if (isset($options['functions']['sorting'])) { $sorting = $options['functions']['sorting']; } } if ($first) { if (isset($options['fields'][$header]['header'])) { $header = $options['fields'][$header]['header']; } if (isset($_ARRAYLANG[$header])) { $header = $_ARRAYLANG[$header]; } if (is_array($options['functions']) && isset($options['functions']['sorting']) && $options['functions']['sorting'] && $sorting !== false) { $order = ''; $img = '↑↓'; $sortParamName = !empty($sortBy) ? $entity . 'Order' : 'order'; if (isset($_GET[$sortParamName])) { $supOrder = explode('/', $_GET[$sortParamName]); if (current($supOrder) == $origHeader) { $order = '/DESC'; $img = '↓'; if (count($supOrder) > 1 && $supOrder[1] == 'DESC') { $order = ''; $img = '↑'; } } } $header = '<a href="' . \Env::get('cx')->getRequest()->getUrl() . '&' . $sortParamName . '=' . $origHeader . $order . '" style="white-space: nowrap;">' . $header . ' ' . $img . '</a>'; } if ($hasMasterTableHeader) { $this->setCellContents(1, $col, $header, 'td', 0); } else { $this->setCellContents(0, $col, $header, 'th', 0); } } /* We use json to do parse the field function. The 'else if' is for backwards compatibility so you can declare * the function directly without using json. This is not recommended and not working over session */ if (isset($options['fields']) && isset($options['fields'][$origHeader]) && isset($options['fields'][$origHeader]['table']) && isset($options['fields'][$origHeader]['table']['parse'])) { $callback = $options['fields'][$origHeader]['table']['parse']; if (is_array($callback) && isset($callback['adapter']) && isset($callback['method'])) { $json = new \Cx\Core\Json\JsonData(); $jsonResult = $json->data($callback['adapter'], $callback['method'], array('data' => $data, 'rows' => $rows)); if ($jsonResult['status'] == 'success') { $data = $jsonResult["data"]; } } else { if (is_callable($callback)) { $data = $callback($data, $rows); } } $encode = false; // todo: this should be set by callback } else { if (is_object($data) && get_class($data) == 'DateTime') { $data = $data->format(ASCMS_DATE_FORMAT); } else { if (isset($options['fields'][$origHeader]) && isset($options['fields'][$origHeader]['type']) && $options['fields'][$origHeader]['type'] == '\\Country') { $data = \Cx\Core\Country\Controller\Country::getNameById($data); if (empty($data)) { $data = \Cx\Core\Country\Controller\Country::getNameById(204); } } else { if (gettype($data) == 'boolean') { $data = '<i>' . ($data ? $_ARRAYLANG['TXT_YES'] : $_ARRAYLANG['TXT_NO']) . '</i>'; $encode = false; } else { if ($data === null) { $data = '<i>' . $_ARRAYLANG['TXT_CORE_NONE'] . '</i>'; $encode = false; } else { if (empty($data)) { $data = '<i>(empty)</i>'; $encode = false; } } } } } } $this->setCellContents($row, $col, $data, 'TD', 0, $encode); $col++; } if ($this->hasRowFunctions($options['functions'], $virtual)) { if ($first) { $header = 'Functions'; if (isset($_ARRAYLANG['TXT_FUNCTIONS'])) { $header = $_ARRAYLANG['TXT_FUNCTIONS']; } if ($hasMasterTableHeader) { $this->setCellContents(1, $col, $header, 'td', 0, true); } else { $this->setCellContents(0, $col, $header, 'th', 0, true); } } $this->updateColAttributes($col, array('style' => 'text-align:right;')); if (empty($options['functions']['baseUrl'])) { $options['functions']['baseUrl'] = clone \Env::get('cx')->getRequest()->getUrl(); } $this->setCellContents($row, $col, $this->getFunctionsCode($rowname, $rows, $options['functions'], $virtual), 'TD', 0); } $first = false; $row++; } // adjust colspan of master-table-header-row if ($hasMasterTableHeader) { $this->setCellAttributes(0, 0, array('colspan' => $col + is_array($options['functions']))); $this->updateRowAttributes(1, array('class' => 'row3'), true); } // add multi-actions if (isset($options['multiActions'])) { $multiActionsCode = ' <img src="images/icons/arrow.gif" width="38" height="22" alt="^" title="^"> <a href="#" onclick="jQuery(\'input[type=checkbox]\').prop(\'checked\', true);return false;">' . $_ARRAYLANG['TXT_SELECT_ALL'] . '</a> / <a href="#" onclick="jQuery(\'input[type=checkbox]\').prop(\'checked\', false);return false;">' . $_ARRAYLANG['TXT_DESELECT_ALL'] . '</a> <img alt="-" title="-" src="images/icons/strike.gif"> '; $multiActions = array('' => $_ARRAYLANG['TXT_SUBMIT_SELECT']); foreach ($options['multiActions'] as $actionName => $actionProperties) { $actionTitle = $actionName; if (isset($actionProperties['title'])) { $actionTitle = $actionProperties['title']; } else { if (isset($_ARRAYLANG[$actionName])) { $actionTitle = $_ARRAYLANG[$actionName]; } } if (isset($actionProperties['jsEvent'])) { $actionName = $actionProperties['jsEvent']; } $multiActions[$actionName] = $actionTitle; } $select = new \Cx\Core\Html\Model\Entity\DataElement('cxMultiAction', \Html::getOptions($multiActions), \Cx\Core\Html\Model\Entity\DataElement::TYPE_SELECT); // this is not a nice place for this code // but we should cleanup this complete class and make // it base on templates $select->setAttribute('onchange', ' var regex = /([a-zA-Z\\/]+):([a-zA-Z\\/]+)/; var matches = jQuery(this).val().match(regex); if (!matches) { return false; } var checkboxes = jQuery(this).closest("table").find("input[type=checkbox]"); var activeRows = []; checkboxes.filter(":checked").each(function(el) { activeRows.push(jQuery(this).val()); }); cx.trigger(matches[1], matches[2], activeRows); checkboxes.prop("checked", false); jQuery(this).val(""); '); $this->setCellContents($row, 0, $multiActionsCode . $select, 'TD', 0); $this->setCellAttributes($row, 0, array('colspan' => $col + is_array($options['functions']))); } $attrs = array(); } //add the sorting parameters as table attribute //if the row sorting functionality is enabled $className = 'adminlist'; if (!empty($sortField)) { $className = '\'adminlist sortable\''; if (!empty($component)) { $attrs['data-component'] = $component; } if (!empty($entity)) { $attrs['data-entity'] = $entity; } if (!empty($sortOrder)) { $attrs['data-order'] = $sortOrder; } if (!empty($sortField)) { $attrs['data-field'] = $sortField; } if (isset($pagingPos)) { $attrs['data-pos'] = $pagingPos; } $attrs['data-object'] = 'Html'; $attrs['data-act'] = 'updateOrder'; if (isset($sortBy['jsonadapter']) && !empty($sortBy['jsonadapter']['object']) && !empty($sortBy['jsonadapter']['act'])) { $attrs['data-object'] = $sortBy['jsonadapter']['object']; $attrs['data-act'] = $sortBy['jsonadapter']['act']; } } parent::__construct(array_merge($attrs, array('class' => $className, 'width' => '100%'))); }
public function getDataElement($name, $type, $length, $value, $options) { global $_ARRAYLANG; if (isset($options['formfield']) && is_callable($options['formfield'])) { $formFieldGenerator = $options['formfield']; $formField = $formFieldGenerator($name, $type, $length, $value, $options); if (is_a($formField, 'Cx\\Core\\Html\\Model\\Entity\\HtmlElement')) { return $formField; } else { $value = $formField; } } if (isset($options['showDetail']) && $options['showDetail'] === false) { return ''; } switch ($type) { case 'bool': case 'boolean': // yes/no checkboxes $fieldset = new \Cx\Core\Html\Model\Entity\HtmlElement('div'); $inputYes = new \Cx\Core\Html\Model\Entity\DataElement($name, 'yes'); $inputYes->setAttribute('type', 'radio'); $inputYes->setAttribute('value', '1'); $inputYes->setAttribute('id', 'form-' . $this->formId . '-' . $name . '_yes'); if (isset($options['attributes'])) { $inputYes->setAttributes($options['attributes']); } $fieldset->addChild($inputYes); $labelYes = new \Cx\Core\Html\Model\Entity\HtmlElement('label'); $labelYes->setAttribute('for', 'form-' . $this->formId . '-' . $name . '_yes'); $labelYes->addChild(new \Cx\Core\Html\Model\Entity\TextElement($_ARRAYLANG['TXT_YES'])); $fieldset->addChild($labelYes); $inputNo = new \Cx\Core\Html\Model\Entity\DataElement($name, 'no'); $inputNo->setAttribute('id', 'form-' . $this->formId . '-' . $name . '_no'); $inputNo->setAttribute('type', 'radio'); $inputNo->setAttribute('value', '0'); if (isset($options['attributes'])) { $inputNo->setAttributes($options['attributes']); } $fieldset->addChild($inputNo); $labelNo = new \Cx\Core\Html\Model\Entity\HtmlElement('label'); $labelNo->setAttribute('for', 'form-' . $this->formId . '-' . $name . '_no'); $labelNo->addChild(new \Cx\Core\Html\Model\Entity\TextElement($_ARRAYLANG['TXT_NO'])); $fieldset->addChild($labelNo); if ($value) { $inputYes->setAttribute('checked'); } else { $inputNo->setAttribute('checked'); } return $fieldset; break; case 'int': case 'integer': // input field with type number $inputNumber = new \Cx\Core\Html\Model\Entity\DataElement($name, $value, \Cx\Core\Html\Model\Entity\DataElement::TYPE_INPUT, new \Cx\Core\Validate\Model\Entity\RegexValidator('/-?[0-9]*/')); if (isset($options['attributes'])) { $inputNumber->setAttributes($options['attributes']); } $inputNumber->setAttribute('type', 'number'); return $inputNumber; break; case 'Cx\\Model\\Base\\EntityBase': $entityClass = get_class($value); $entities = \Env::get('em')->getRepository($entityClass)->findAll(); $foreignMetaData = \Env::get('em')->getClassMetadata($entityClass); $primaryKeyName = $foreignMetaData->getSingleIdentifierFieldName(); $selected = $foreignMetaData->getFieldValue($value, $primaryKeyName); $arrEntities = array(); $closeMetaData = \Env::get('em')->getClassMetadata($this->entityClass); $assocMapping = $closeMetaData->getAssociationMapping($name); if (!isset($assocMapping['joinColumns'][0]['nullable']) || $assocMapping['joinColumns'][0]['nullable']) { $arrEntities['NULL'] = $_ARRAYLANG['TXT_CORE_NONE']; } foreach ($entities as $entity) { $arrEntities[\Env::get('em')->getClassMetadata($entityClass)->getFieldValue($entity, $primaryKeyName)] = $entity; } $select = new \Cx\Core\Html\Model\Entity\DataElement($name, \Html::getOptions($arrEntities, $selected), \Cx\Core\Html\Model\Entity\DataElement::TYPE_SELECT); if (isset($options['attributes'])) { $select->setAttributes($options['attributes']); } return $select; break; case 'Country': // this is for customizing only: $data = \Cx\Core\Country\Controller\Country::getNameById($value); if (empty($data)) { $value = 204; } $options = \Cx\Core\Country\Controller\Country::getMenuoptions($value); $select = new \Cx\Core\Html\Model\Entity\DataElement($name, $options, \Cx\Core\Html\Model\Entity\DataElement::TYPE_SELECT); if (isset($options['attributes'])) { $select->setAttributes($options['attributes']); } return $select; break; case 'DateTime': case 'datetime': case 'date': // input field with type text and class datepicker if ($value instanceof \DateTime) { $value = $value->format(ASCMS_DATE_FORMAT); } if (is_null($value)) { $value = ''; } $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value); $input->setAttribute('type', 'text'); $input->setAttribute('class', 'datepicker'); if (isset($options['readonly']) && $options['readonly']) { $input->setAttribute('disabled'); } if (isset($options['attributes'])) { $input->setAttributes($options['attributes']); } \DateTimeTools::addDatepickerJs(); \JS::registerCode(' cx.jQuery(function() { cx.jQuery(".datepicker").datetimepicker(); }); '); return $input; break; case 'multiselect': case 'select': $values = array(); if (isset($options['validValues'])) { if (is_array($options['validValues'])) { $values = $options['validValues']; } else { $values = explode(',', $options['validValues']); $values = array_combine($values, $values); } } if ($type == 'multiselect') { $value = explode(',', $value); $value = array_combine($value, $value); } $selectOptions = \Html::getOptions($values, $value); $select = new \Cx\Core\Html\Model\Entity\DataElement($name, $selectOptions, \Cx\Core\Html\Model\Entity\DataElement::TYPE_SELECT); if ($type == 'multiselect') { $select->setAttribute('multiple'); } if (isset($options['attributes'])) { $select->setAttributes($options['attributes']); } return $select; break; case 'slider': // this code should not be here // create sorrounding div $element = new \Cx\Core\Html\Model\Entity\HtmlElement('div'); // create div for slider $slider = new \Cx\Core\Html\Model\Entity\HtmlElement('div'); $slider->setAttribute('class', 'slider'); $element->addChild($slider); // create hidden input for slider value $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value + 0, \Cx\Core\Html\Model\Entity\DataElement::TYPE_INPUT); $input->setAttribute('type', 'hidden'); if (isset($options['attributes'])) { $input->setAttributes($options['attributes']); } $element->addChild($input); // add javascript to update input value $min = 0; $max = 10; if (isset($options['validValues'])) { $values = explode(',', $options['validValues']); $min = $values[0]; if (isset($values[1])) { $max = $values[1]; } } if (!isset($value)) { $value = 0; } $script = new \Cx\Core\Html\Model\Entity\HtmlElement('script'); $script->addChild(new \Cx\Core\Html\Model\Entity\TextElement(' cx.jQuery("#form-' . $this->formId . '-' . $name . ' .slider").slider({ value: ' . ($value + 0) . ', min: ' . ($min + 0) . ', max: ' . ($max + 0) . ', slide: function( event, ui ) { cx.jQuery("input[name=' . $name . ']").val(ui.value); cx.jQuery("input[name=' . $name . ']").change(); } }); ')); $element->addChild($script); return $element; break; case 'checkboxes': $dataElementGroupType = \Cx\Core\Html\Model\Entity\DataElementGroup::TYPE_CHECKBOX; case 'radio': $values = array(); if (isset($options['validValues'])) { $values = explode(',', $options['validValues']); $values = array_combine($values, $values); } if (!isset($dataElementGroupType)) { $dataElementGroupType = \Cx\Core\Html\Model\Entity\DataElementGroup::TYPE_RADIO; } $radio = new \Cx\Core\Html\Model\Entity\DataElementGroup($name, $values, $value, $dataElementGroupType); if (isset($options['attributes'])) { $radio->setAttributes($options['attributes']); } return $radio; break; case 'text': // textarea $textarea = new \Cx\Core\Html\Model\Entity\HtmlElement('textarea'); $textarea->setAttribute('name', $name); if (isset($options['readonly']) && $options['readonly']) { $textarea->setAttribute('disabled'); } $textarea->addChild(new \Cx\Core\Html\Model\Entity\TextElement($value)); if (isset($options['attributes'])) { $textarea->setAttributes($options['attributes']); } return $textarea; break; case 'phone': // input field with type phone $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value); $input->setAttribute('type', 'phone'); if (isset($options['readonly']) && $options['readonly']) { $input->setAttribute('disabled'); } if (isset($options['attributes'])) { $input->setAttributes($options['attributes']); } return $input; break; case 'mail': // input field with type mail $emailValidator = new \Cx\Core\Validate\Model\Entity\EmailValidator(); $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value, 'input', $emailValidator); $input->setAttribute('onkeyup', $emailValidator->getJavaScriptCode()); $input->setAttribute('type', 'mail'); if (isset($options['attributes'])) { $input->setAttributes($options['attributes']); } if (isset($options['readonly']) && $options['readonly']) { $input->setAttribute('disabled'); } return $input; break; case 'uploader': \JS::registerCode(' function javascript_callback_function(data) { if(data.type=="file") { cx.jQuery("#' . $name . '").val(data.data[0].datainfo.filepath); } } '); $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser(); $mediaBrowser->setOptions(array('type' => 'button')); $mediaBrowser->setCallback('javascript_callback_function'); $mediaBrowser->setOptions(array('data-cx-mb-views' => 'filebrowser,uploader', 'id' => 'page_target_browse', 'cxMbStartview' => 'MediaBrowserList')); $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value); $input->setAttribute('type', 'text'); $input->setAttribute('id', $name); $div = new \Cx\Core\Html\Model\Entity\HtmlElement('div'); $div->addChild($input); $div->addChild(new \Cx\Core\Html\Model\Entity\TextElement($mb = $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE']))); return $div; break; case 'image': \JS::registerCode(' function javascript_callback_function(data) { if ( data.data[0].datainfo.extension=="Jpg" || data.data[0].datainfo.extension=="Gif" || data.data[0].datainfo.extension=="Png" ) { cx.jQuery("#' . $name . '").attr(\'value\', data.data[0].datainfo.filepath); cx.jQuery("#' . $name . '").prevAll(\'.deletePreviewImage\').first().css(\'display\', \'inline-block\'); cx.jQuery("#' . $name . '").prevAll(\'.previewImage\').first().attr(\'src\', data.data[0].datainfo.filepath); } } jQuery(document).ready(function(){ jQuery(\'.deletePreviewImage\').click(function(){ cx.jQuery("#' . $name . '").attr(\'value\', \'\'); cx.jQuery(this).prev(\'img\').attr(\'src\', \'/images/Downloads/no_picture.gif\'); cx.jQuery(this).css(\'display\', \'none\'); cx.jQuery(this).nextAll(\'input\').first().attr(\'value\', \'\'); }); }); '); $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser(); $mediaBrowser->setOptions(array('type' => 'button')); $mediaBrowser->setCallback('javascript_callback_function'); $defaultOptions = array('data-cx-mb-views' => 'filebrowser,uploader', 'id' => 'page_target_browse', 'cxMbStartview' => 'MediaBrowserList'); $mediaBrowser->setOptions(is_array($options['options']) ? array_merge($defaultOptions, $options['options']) : $defaultOptions); // create hidden input to save image $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value); $input->setAttribute('type', 'hidden'); $input->setAttribute('id', $name); $div = new \Cx\Core\Html\Model\Entity\HtmlElement('div'); if (isset($value) && in_array(pathinfo($value, PATHINFO_EXTENSION), array('gif', 'jpg', 'png')) || $name == 'imagePath') { // this image is meant to be a preview of the selected image $previewImage = new \Cx\Core\Html\Model\Entity\HtmlElement('img'); $previewImage->setAttribute('class', 'previewImage'); $previewImage->setAttribute('src', $value != '' ? $value : '/images/Downloads/no_picture.gif'); // this image is uesd as delete function for the selected image over javascript $deleteImage = new \Cx\Core\Html\Model\Entity\HtmlElement('img'); $deleteImage->setAttribute('class', 'deletePreviewImage'); $deleteImage->setAttribute('src', '/core/Core/View/Media/icons/delete.gif'); $div->addChild($previewImage); $div->addChild($deleteImage); $div->addChild(new \Cx\Core\Html\Model\Entity\HtmlElement('br')); } $div->addChild($input); $div->addChild(new \Cx\Core\Html\Model\Entity\TextElement($mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE']))); return $div; break; case 'sourcecode': //set mode $mode = 'html'; if (isset($options['options']['mode'])) { switch ($options['options']['mode']) { case 'js': $mode = 'javascript'; break; case 'yml': case 'yaml': $mode = 'yaml'; break; } } //define textarea $textarea = new \Cx\Core\Html\Model\Entity\HtmlElement('textarea'); $textarea->setAttribute('name', $name); $textarea->setAttribute('id', $name); $textarea->setAttribute('style', 'display:none;'); $textarea->addChild(new \Cx\Core\Html\Model\Entity\TextElement($value)); //define pre $pre = new \Cx\Core\Html\Model\Entity\HtmlElement('pre'); $pre->setAttribute('id', 'editor-' . $name); $pre->addChild(new \Cx\Core\Html\Model\Entity\TextElement(contrexx_raw2xhtml($value))); //set readonly if necessary $readonly = ''; if (isset($options['readonly']) && $options['readonly']) { $readonly = 'editor.setReadOnly(true);'; $textarea->setAttribute('disabled'); } //create div and add all stuff $div = new \Cx\Core\Html\Model\Entity\HtmlElement('div'); $div->addChild($textarea); $div->addChild($pre); //register js $jsCode = <<<CODE var editor; \$J(function(){ if (\$J("#editor-{$name}").length) { editor = ace.edit("editor-{$name}"); editor.getSession().setMode("ace/mode/{$mode}"); editor.setShowPrintMargin(false); editor.focus(); editor.gotoLine(1); {$readonly} } \$J('form').submit(function(){ \$J('#{$name}').val(editor.getSession().getValue()); }); }); CODE; \JS::activate('ace'); \JS::registerCode($jsCode); return $div; break; case 'string': case 'hidden': default: // convert NULL to empty string if (is_null($value)) { $value = ''; } // input field with type text $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value); if (isset($options['validValues'])) { $input->setValidator(new \Cx\Core\Validate\Model\Entity\RegexValidator('/^' . $options['validValues'] . '$/')); } if ($type == 'hidden') { $input->setAttribute('type', 'hidden'); } else { $input->setAttribute('type', 'text'); $input->setClass('form-control'); } if (isset($options['readonly']) && $options['readonly']) { $input->setAttribute('disabled'); } if (isset($options['attributes'])) { $input->setAttributes($options['attributes']); } return $input; break; } }
protected function getCountryMenu($selectedCountry = 0, $mantatory = false) { global $_ARRAYLANG; $menu = '<select name="newsletter_country_id" size="1">'; $menu .= "<option value='0'>" . ($mantatory ? $_ARRAYLANG['TXT_NEWSLETTER_PLEASE_SELECT'] : $_ARRAYLANG['TXT_NEWSLETTER_NOT_SPECIFIED']) . "</option>"; $menu .= \Cx\Core\Country\Controller\Country::getMenuoptions($selectedCountry); $menu .= '</select>'; return $menu; }
/** * Show modify block * * Show the block modification page * * @access private * @global array * @see blockLibrary::_getBlockContent(), blockLibrary::blockNamePrefix */ private function _showModifyBlock($copy = false) { global $_ARRAYLANG; \JS::activate('cx'); \JS::activate('ckeditor'); \JS::activate('jqueryui'); \JS::registerJS('lib/javascript/tag-it/js/tag-it.min.js'); \JS::registerCss('lib/javascript/tag-it/css/tag-it.css'); $mediaBrowserCkeditor = new MediaBrowser(); $mediaBrowserCkeditor->setCallback('ckeditor_image_button'); $mediaBrowserCkeditor->setOptions(array('id' => 'ckeditor_image_button', 'type' => 'button', 'style' => 'display:none')); $blockId = !empty($_REQUEST['blockId']) ? intval($_REQUEST['blockId']) : 0; $blockCat = 0; $blockName = ''; $blockStart = 0; $blockEnd = 0; $blockRandom = 0; $blockRandom2 = 0; $blockRandom3 = 0; $blockRandom4 = 0; $blockGlobal = 0; $blockDirect = 0; $blockCategory = 0; $blockWysiwygEditor = 1; $blockContent = array(); $blockAssociatedPageIds = array(); $blockLangActive = array(); $blockGlobalAssociatedPageIds = array(); $blockDirectAssociatedPageIds = array(); $blockCategoryAssociatedPageIds = array(); $this->_objTpl->loadTemplateFile('module_block_modify.html'); $this->_objTpl->setGlobalVariable(array('TXT_BLOCK_CONTENT' => $_ARRAYLANG['TXT_BLOCK_CONTENT'], 'TXT_BLOCK_NAME' => $_ARRAYLANG['TXT_BLOCK_NAME'], 'TXT_BLOCK_RANDOM' => $_ARRAYLANG['TXT_BLOCK_RANDOM'], 'TXT_BLOCK_GLOBAL' => $_ARRAYLANG['TXT_BLOCK_SHOW_IN_GLOBAL'], 'TXT_BLOCK_SAVE' => $_ARRAYLANG['TXT_BLOCK_SAVE'], 'TXT_BLOCK_DEACTIVATE' => $_ARRAYLANG['TXT_BLOCK_DEACTIVATE'], 'TXT_BLOCK_ACTIVATE' => $_ARRAYLANG['TXT_BLOCK_ACTIVATE'], 'TXT_DONT_SHOW_ON_PAGES' => $_ARRAYLANG['TXT_DONT_SHOW_ON_PAGES'], 'TXT_SHOW_ON_ALL_PAGES' => $_ARRAYLANG['TXT_SHOW_ON_ALL_PAGES'], 'TXT_SHOW_ON_SELECTED_PAGES' => $_ARRAYLANG['TXT_SHOW_ON_SELECTED_PAGES'], 'TXT_BLOCK_CATEGORY' => $_ARRAYLANG['TXT_BLOCK_CATEGORY'], 'TXT_BLOCK_NONE' => $_ARRAYLANG['TXT_BLOCK_NONE'], 'TXT_BLOCK_SHOW_FROM' => $_ARRAYLANG['TXT_BLOCK_SHOW_FROM'], 'TXT_BLOCK_SHOW_UNTIL' => $_ARRAYLANG['TXT_BLOCK_SHOW_UNTIL'], 'TXT_BLOCK_SHOW_TIMED' => $_ARRAYLANG['TXT_BLOCK_SHOW_TIMED'], 'TXT_BLOCK_SHOW_ALWAYS' => $_ARRAYLANG['TXT_BLOCK_SHOW_ALWAYS'], 'TXT_BLOCK_LANG_SHOW' => $_ARRAYLANG['TXT_BLOCK_SHOW_BLOCK_IN_THIS_LANGUAGE'], 'TXT_BLOCK_BASIC_DATA' => $_ARRAYLANG['TXT_BLOCK_BASIC_DATA'], 'TXT_BLOCK_ADDITIONAL_OPTIONS' => $_ARRAYLANG['TXT_BLOCK_ADDITIONAL_OPTIONS'], 'TXT_BLOCK_SELECTED_PAGES' => $_ARRAYLANG['TXT_BLOCK_SELECTED_PAGES'], 'TXT_BLOCK_AVAILABLE_PAGES' => $_ARRAYLANG['TXT_BLOCK_AVAILABLE_PAGES'], 'TXT_BLOCK_SELECT_ALL' => $_ARRAYLANG['TXT_BLOCK_SELECT_ALL'], 'TXT_BLOCK_UNSELECT_ALL' => $_ARRAYLANG['TXT_BLOCK_UNSELECT_ALL'], 'TXT_BLOCK_GLOBAL_PLACEHOLDERS' => $_ARRAYLANG['TXT_BLOCK_GLOBAL_PLACEHOLDERS'], 'TXT_BLOCK_GLOBAL_PLACEHOLDERS_INFO' => $_ARRAYLANG['TXT_BLOCK_GLOBAL_PLACEHOLDERS_INFO'], 'TXT_BLOCK_DIRECT_PLACEHOLDERS' => $_ARRAYLANG['TXT_BLOCK_DIRECT_PLACEHOLDERS'], 'TXT_BLOCK_DIRECT_PLACEHOLDERS_INFO' => $_ARRAYLANG['TXT_BLOCK_DIRECT_PLACEHOLDERS_INFO'], 'TXT_BLOCK_CATEGORY_PLACEHOLDERS' => $_ARRAYLANG['TXT_BLOCK_CATEGORY_PLACEHOLDERS'], 'TXT_BLOCK_CATEGORY_PLACEHOLDERS_INFO' => $_ARRAYLANG['TXT_BLOCK_CATEGORY_PLACEHOLDERS_INFO'], 'TXT_BLOCK_DISPLAY_TIME' => $_ARRAYLANG['TXT_BLOCK_DISPLAY_TIME'], 'TXT_BLOCK_FORM_DESC' => $_ARRAYLANG['TXT_BLOCK_CONTENT'], 'TXT_BLOCK_USE_WYSIWYG_EDITOR' => $_ARRAYLANG['TXT_BLOCK_USE_WYSIWYG_EDITOR'], 'TXT_BLOCK_TARGETING' => $_ARRAYLANG['TXT_BLOCK_TARGETING'], 'TXT_BLOCK_TARGETING_SHOW_PANE' => $_ARRAYLANG['TXT_BLOCK_TARGETING_SHOW_PANE'], 'TXT_BLOCK_TARGETING_ALL_USERS' => $_ARRAYLANG['TXT_BLOCK_TARGETING_ALL_USERS'], 'TXT_BLOCK_TARGETING_VISITOR_CONDITION_BELOW' => $_ARRAYLANG['TXT_BLOCK_TARGETING_VISITOR_CONDITION_BELOW'], 'TXT_BLOCK_TARGETING_INCLUDE' => $_ARRAYLANG['TXT_BLOCK_TARGETING_INCLUDE'], 'TXT_BLOCK_TARGETING_EXCLUDE' => $_ARRAYLANG['TXT_BLOCK_TARGETING_EXCLUDE'], 'TXT_BLOCK_TARGETING_TYPE_LOCATION' => $_ARRAYLANG['TXT_BLOCK_TARGETING_TYPE_LOCATION'], 'TXT_BLOCK_TARGETING_GEOIP_DISABLED_WARNING' => $_ARRAYLANG['TXT_BLOCK_TARGETING_GEOIP_DISABLED_WARNING'])); $targetingStatus = isset($_POST['targeting_status']) ? contrexx_input2int($_POST['targeting_status']) : 0; $targeting = array(); foreach ($this->availableTargeting as $targetingType) { $targetingArr = isset($_POST['targeting'][$targetingType]) ? $_POST['targeting'][$targetingType] : array(); if (empty($targetingArr)) { continue; } $targeting[$targetingType] = array('filter' => !empty($targetingArr['filter']) && in_array($targetingArr['filter'], array('include', 'exclude')) ? contrexx_input2raw($targetingArr['filter']) : 'include', 'value' => isset($targetingArr['value']) ? contrexx_input2raw($targetingArr['value']) : array()); } if (isset($_POST['block_save_block'])) { $blockCat = !empty($_POST['blockCat']) ? intval($_POST['blockCat']) : 0; $blockContent = isset($_POST['blockFormText_']) ? array_map('contrexx_input2raw', $_POST['blockFormText_']) : array(); $blockName = !empty($_POST['blockName']) ? contrexx_input2raw($_POST['blockName']) : $_ARRAYLANG['TXT_BLOCK_NO_NAME']; $blockStart = strtotime($_POST['inputStartDate']); $blockEnd = strtotime($_POST['inputEndDate']); $blockRandom = !empty($_POST['blockRandom']) ? intval($_POST['blockRandom']) : 0; $blockRandom2 = !empty($_POST['blockRandom2']) ? intval($_POST['blockRandom2']) : 0; $blockRandom3 = !empty($_POST['blockRandom3']) ? intval($_POST['blockRandom3']) : 0; $blockRandom4 = !empty($_POST['blockRandom4']) ? intval($_POST['blockRandom4']) : 0; $blockWysiwygEditor = isset($_POST['wysiwyg_editor']) ? 1 : 0; $blockLangActive = isset($_POST['blockFormLanguages']) ? array_map('intval', $_POST['blockFormLanguages']) : array(); // placeholder configurations // global block // 0 = not activated , 1 = on all pages , 2 = selected pages $blockGlobal = !empty($_POST['blockGlobal']) ? intval($_POST['blockGlobal']) : 0; // direct block and category block placeholders // 0 = on all pages , 1 = selected pages $blockDirect = !empty($_POST['blockDirect']) ? intval($_POST['blockDirect']) : 0; $blockCategory = !empty($_POST['blockCategory']) ? intval($_POST['blockCategory']) : 0; // block on page relations for each placeholder $blockGlobalAssociatedPageIds = isset($_POST['globalSelectedPagesList']) ? array_map('intval', explode(",", $_POST['globalSelectedPagesList'])) : array(); $blockDirectAssociatedPageIds = isset($_POST['directSelectedPagesList']) ? array_map('intval', explode(",", $_POST['directSelectedPagesList'])) : array(); $blockCategoryAssociatedPageIds = isset($_POST['categorySelectedPagesList']) ? array_map('intval', explode(",", $_POST['categorySelectedPagesList'])) : array(); if ($blockId) { if ($this->_updateBlock($blockId, $blockCat, $blockContent, $blockName, $blockStart, $blockEnd, $blockRandom, $blockRandom2, $blockRandom3, $blockRandom4, $blockWysiwygEditor, $blockLangActive)) { if ($this->storePlaceholderSettings($blockId, $blockGlobal, $blockDirect, $blockCategory, $blockGlobalAssociatedPageIds, $blockDirectAssociatedPageIds, $blockCategoryAssociatedPageIds)) { $this->storeTargetingSettings($blockId, $targetingStatus, $targeting); \Cx\Core\Csrf\Controller\Csrf::header('location: index.php?cmd=Block&modified=true&blockname=' . $blockName); exit; } } $this->_strErrMessage = $_ARRAYLANG['TXT_BLOCK_BLOCK_COULD_NOT_BE_UPDATED']; } else { if ($blockId = $this->_addBlock($blockCat, $blockContent, $blockName, $blockStart, $blockEnd, $blockRandom, $blockRandom2, $blockRandom3, $blockRandom4, $blockWysiwygEditor, $blockLangActive)) { if ($this->storePlaceholderSettings($blockId, $blockGlobal, $blockDirect, $blockCategory, $blockGlobalAssociatedPageIds, $blockDirectAssociatedPageIds, $blockCategoryAssociatedPageIds)) { $this->storeTargetingSettings($blockId, $targetingStatus, $targeting); \Cx\Core\Csrf\Controller\Csrf::header('location: index.php?cmd=Block&added=true&blockname=' . $blockName); exit; } } $this->_strErrMessage = $_ARRAYLANG['TXT_BLOCK_BLOCK_COULD_NOT_BE_ADDED']; } } elseif (($arrBlock = $this->_getBlock($blockId)) !== false) { $blockStart = $arrBlock['start']; $blockEnd = $arrBlock['end']; $blockCat = $arrBlock['cat']; $blockRandom = $arrBlock['random']; $blockRandom2 = $arrBlock['random2']; $blockRandom3 = $arrBlock['random3']; $blockRandom4 = $arrBlock['random4']; $blockWysiwygEditor = $arrBlock['wysiwyg_editor']; $blockContent = $arrBlock['content']; $blockLangActive = $arrBlock['lang_active']; $blockName = $arrBlock['name']; $blockGlobal = $arrBlock['global']; $blockDirect = $arrBlock['direct']; $blockCategory = $arrBlock['category']; $blockGlobalAssociatedPageIds = $this->_getAssociatedPageIds($blockId, 'global'); $blockDirectAssociatedPageIds = $this->_getAssociatedPageIds($blockId, 'direct'); $blockCategoryAssociatedPageIds = $this->_getAssociatedPageIds($blockId, 'category'); $targeting = $this->loadTargetingSettings($blockId); if (!empty($targeting)) { $targetingStatus = 1; } } $pageTitle = $blockId != 0 ? sprintf($copy ? $_ARRAYLANG['TXT_BLOCK_COPY_BLOCK'] : $_ARRAYLANG['TXT_BLOCK_MODIFY_BLOCK'], contrexx_raw2xhtml($blockName)) : $_ARRAYLANG['TXT_BLOCK_ADD_BLOCK']; $this->_pageTitle = $pageTitle; if ($copy) { $blockId = 0; } $this->_objTpl->setVariable(array('BLOCK_ID' => $blockId, 'BLOCK_MODIFY_TITLE' => $pageTitle, 'BLOCK_NAME' => contrexx_raw2xhtml($blockName), 'BLOCK_CATEGORIES_PARENT_DROPDOWN' => $this->_getCategoriesDropdown($blockCat), 'BLOCK_START' => !empty($blockStart) ? strftime('%Y-%m-%d %H:%M', $blockStart) : $blockStart, 'BLOCK_END' => !empty($blockEnd) ? strftime('%Y-%m-%d %H:%M', $blockEnd) : $blockEnd, 'BLOCK_WYSIWYG_EDITOR' => $blockWysiwygEditor == 1 ? 'checked="checked"' : '', 'BLOCK_RANDOM' => $blockRandom == '1' ? 'checked="checked"' : '', 'BLOCK_RANDOM_2' => $blockRandom2 == '1' ? 'checked="checked"' : '', 'BLOCK_RANDOM_3' => $blockRandom3 == '1' ? 'checked="checked"' : '', 'BLOCK_RANDOM_4' => $blockRandom4 == '1' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_0' => $blockGlobal == '0' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_1' => $blockGlobal == '1' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_2' => $blockGlobal == '2' ? 'checked="checked"' : '', 'BLOCK_GLOBAL_SHOW_PAGE_SELECTOR' => $blockGlobal == '2' ? 'block' : 'none', 'BLOCK_DIRECT_0' => $blockDirect == '0' ? 'checked="checked"' : '', 'BLOCK_DIRECT_1' => $blockDirect == '1' ? 'checked="checked"' : '', 'BLOCK_DIRECT_SHOW_PAGE_SELECTOR' => $blockDirect == '1' ? 'block' : 'none', 'BLOCK_CATEGORY_0' => $blockCategory == '0' ? 'checked="checked"' : '', 'BLOCK_CATEGORY_1' => $blockCategory == '1' ? 'checked="checked"' : '', 'BLOCK_CATEGORY_SHOW_PAGE_SELECTOR' => $blockCategory == '1' ? 'block' : 'none', 'BLOCK_WYSIWYG_MEDIABROWSER' => $mediaBrowserCkeditor->getXHtml(), 'BLOCK_TARGETING_ALL_USERS' => $targetingStatus == 0 ? 'checked="checked"' : '', 'BLOCK_TARGETING_VISITOR_CONDITION_BELOW' => $targetingStatus == 1 ? 'checked="checked"' : '', 'BLOCK_TARGETING_COUNTRY_INCLUDE' => !empty($targeting['country']) && $targeting['country']['filter'] == 'include' ? 'selected="selected"' : '', 'BLOCK_TARGETING_COUNTRY_EXCLUDE' => !empty($targeting['country']) && $targeting['country']['filter'] == 'exclude' ? 'selected="selected"' : '')); if (!empty($targeting['country']) && !empty($targeting['country']['value'])) { foreach ($targeting['country']['value'] as $countryId) { $countryName = \Cx\Core\Country\Controller\Country::getNameById($countryId); if (empty($countryName)) { continue; } $this->_objTpl->setVariable(array('BLOCK_TARGET_COUNTRY_ID' => contrexx_raw2xhtml($countryId), 'BLOCK_TARGET_COUNTRY_NAME' => contrexx_raw2xhtml($countryName))); $this->_objTpl->parse('block_targeting_country'); } } $jsonData = new \Cx\Core\Json\JsonData(); $pageTitlesTree = $jsonData->data('node', 'getPageTitlesTree'); $pageTitlesTree = $pageTitlesTree['data']; $objJs = \ContrexxJavascript::getInstance(); $blockGlobalPageSelects = $this->getPageSelections($pageTitlesTree, $blockGlobalAssociatedPageIds); $blockDirectPageSelects = $this->getPageSelections($pageTitlesTree, $blockDirectAssociatedPageIds); $blockCategoryPageSelects = $this->getPageSelections($pageTitlesTree, $blockCategoryAssociatedPageIds); $objJs->setVariable('globalPagesUnselectedOptions', $jsonData->json($blockGlobalPageSelects[1]), 'block'); $objJs->setVariable('globalPagesSelectedOptions', $jsonData->json($blockGlobalPageSelects[0]), 'block'); $objJs->setVariable('directPagesUnselectedOptions', $jsonData->json($blockDirectPageSelects[1]), 'block'); $objJs->setVariable('directPagesSelectedOptions', $jsonData->json($blockDirectPageSelects[0]), 'block'); $objJs->setVariable('categoryPagesUnselectedOptions', $jsonData->json($blockCategoryPageSelects[1]), 'block'); $objJs->setVariable('categoryPagesSelectedOptions', $jsonData->json($blockCategoryPageSelects[0]), 'block'); $objJs->setVariable('ckeditorconfigpath', substr(\Env::get('ClassLoader')->getFilePath(ASCMS_CORE_PATH . '/Wysiwyg/ckeditor.config.js.php'), strlen(ASCMS_DOCUMENT_ROOT) + 1), 'block'); $arrActiveSystemFrontendLanguages = \FWLanguage::getActiveFrontendLanguages(); $this->parseLanguageOptionsByPlaceholder($arrActiveSystemFrontendLanguages, 'global'); $this->parseLanguageOptionsByPlaceholder($arrActiveSystemFrontendLanguages, 'direct'); $this->parseLanguageOptionsByPlaceholder($arrActiveSystemFrontendLanguages, 'category'); if (count($arrActiveSystemFrontendLanguages) > 0) { $intLanguageCounter = 0; $arrLanguages = array(0 => '', 1 => '', 2 => ''); $strJsTabToDiv = ''; foreach ($arrActiveSystemFrontendLanguages as $langId => $arrLanguage) { $boolLanguageIsActive = $blockId == 0 && $intLanguageCounter == 0 ? true : (isset($blockLangActive[$langId]) && $blockLangActive[$langId] == 1 ? true : false); $arrLanguages[$intLanguageCounter % 3] .= '<input id="languagebar_' . $langId . '" ' . ($boolLanguageIsActive ? 'checked="checked"' : '') . ' type="checkbox" name="blockFormLanguages[' . $langId . ']" value="1" onclick="switchBoxAndTab(this, \'lang_blockContent_' . $langId . '\');" /><label for="languagebar_' . $langId . '">' . contrexx_raw2xhtml($arrLanguage['name']) . ' [' . $arrLanguage['lang'] . ']</label><br />'; $strJsTabToDiv .= 'arrTabToDiv["lang_blockContent_' . $langId . '"] = "langTab_' . $langId . '";' . "\n"; ++$intLanguageCounter; } $this->_objTpl->setVariable(array('TXT_BLOCK_LANGUAGE' => $_ARRAYLANG['TXT_BLOCK_LANGUAGE'], 'EDIT_LANGUAGES_1' => $arrLanguages[0], 'EDIT_LANGUAGES_2' => $arrLanguages[1], 'EDIT_LANGUAGES_3' => $arrLanguages[2], 'EDIT_JS_TAB_TO_DIV' => $strJsTabToDiv)); } $arrLanguages = \FWLanguage::getLanguageArray(); $i = 0; $activeFlag = 0; foreach ($arrLanguages as $langId => $arrLanguage) { if ($arrLanguage['frontend'] != 1) { continue; } $tmpBlockContent = isset($blockContent[$langId]) ? $blockContent[$langId] : ''; $tmpBlockLangActive = isset($blockLangActive[$langId]) ? $blockLangActive[$langId] : 0; $tmpBlockContent = preg_replace('/\\{([A-Z0-9_-]+)\\}/', '[[\\1]]', $tmpBlockContent); if ($blockId != 0) { if (!$activeFlag && isset($blockLangActive[$langId])) { $activeClass = 'active'; $activeFlag = 1; } } elseif (!$activeFlag) { $activeClass = 'active'; $activeFlag = 1; } $this->_objTpl->setVariable(array('BLOCK_LANG_TAB_LANG_ID' => intval($langId), 'BLOCK_LANG_TAB_CLASS' => isset($activeClass) ? $activeClass : '', 'TXT_BLOCK_LANG_TAB_LANG_NAME' => contrexx_raw2xhtml($arrLanguage['name']), 'BLOCK_LANGTAB_DISPLAY' => $tmpBlockLangActive == 1 ? 'display:inline;' : ($blockId == 0 && $i == 0 ? 'display:inline;' : 'display:none;'))); $this->_objTpl->parse('block_language_tabs'); $this->_objTpl->setVariable(array('BLOCK_LANG_ID' => intval($langId), 'BLOCK_CONTENT_TEXT_HIDDEN' => contrexx_raw2xhtml($tmpBlockContent))); $this->_objTpl->parse('block_language_content'); $activeClass = ''; $i++; } if (!$this->getGeoIpComponent() || !$this->getGeoIpComponent()->getGeoIpServiceStatus()) { $this->_objTpl->touchBlock('warning_geoip_disabled'); } else { $this->_objTpl->hideBlock('warning_geoip_disabled'); } }
function _getFormFieldAttribute($id, $type, $attr, $show = true, $langid = 0) { global $_ARRAYLANG, $objDatabase; $field = ""; $display = $show ? "block" : "none"; switch ($type) { case 'text': case 'hidden': case 'special': $field .= "<div style=\"display: " . $display . ";\" id=\"fieldValueTab_" . $id . "_" . $langid . "\" class=\"fieldValueTabs_" . $id . "\">"; $field .= "<input style=\"width:308px;background: #FFFFFF;\" type=\"text\" name=\"contactFormFieldValue[" . $id . "][" . $langid . "]\" value=\"" . $attr . "\" />\n"; $field .= "</div>"; return $field; break; case 'label': $field .= "<div style=\"display: " . $display . ";\" id=\"fieldValueTab_" . $id . "_" . $langid . "\" class=\"fieldValueTabs_" . $id . "\">"; $field .= "<textarea style=\"width: 90%;background: #FFFFFF\" name=\"contactFormFieldValue[" . $id . "][" . $langid . "]\">" . $attr . "</textarea>\n"; $field .= "</div>"; return $field; break; case 'checkbox': /* Only one instance of checkbox is allowed for any number of active language */ if ($show) { return "<select style=\"width:331px;\" name=\"contactFormFieldValue[" . $id . "]\">\n\n <option value=\"0\"" . ($attr == 0 ? ' selected="selected"' : '') . ">" . $_ARRAYLANG['TXT_CONTACT_NOT_SELECTED'] . "</option>\n\n <option value=\"1\"" . ($attr == 1 ? ' selected="selected"' : '') . ">" . $_ARRAYLANG['TXT_CONTACT_SELECTED'] . "</option>\n\n </select>"; } break; case 'country': case 'access_country': /* Only one instance of country select is allowed for any number of active language */ if ($show) { $field = "<select style=\"width:331px;\" name=\"contactFormFieldValue[" . $id . "]\">\n"; $field .= "<option value=\"" . $_ARRAYLANG['TXT_CONTACT_PLEASE_SELECT'] . "\" >" . $_ARRAYLANG['TXT_CONTACT_PLEASE_SELECT'] . "</option>\n"; $country = \Cx\Core\Country\Controller\Country::getNameArray(true, $langid); foreach ($country as $id => $name) { $sourcecode[] = "<option value=\"" . $name . "\" " . ($attr == $name ? 'selected="selected"' : '') . ">" . $name . "</option>"; } $field .= "</select>"; return $field; } break; case 'checkboxGroup': case 'select': case 'radio': $field .= "<div style=\"display: " . $display . ";\" id=\"fieldValueTab_" . $id . "_" . $langid . "\" class=\"fieldValueTabs_" . $id . "\">"; $field .= "<input style=\"width:308px;background: #FFFFFF;\" type=\"text\" name=\"contactFormFieldValue[" . $id . "][" . $langid . "]\" value=\"" . $attr . "\" /> <span class=\"tooltip-trigger icon-info\"></span><span class=\"tooltip-message multiple-values-by-comma\">{TXT_CONTACT_SEPARATE_MULTIPLE_VALUES_BY_COMMA}</span>\n"; $field .= "</div>"; return $field; break; default: return ''; break; } }
/** * Handles database errors * * Also migrates the old database structure to the new one * @return boolean False. Always. */ static function errorHandler() { // Order ShopSettings::errorHandler(); \Cx\Core\Country\Controller\Country::errorHandler(); $table_name = DBPREFIX . 'module_shop_order_items'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'order_items_id'), 'order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'orderid'), 'product_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'productid'), 'product_name' => array('type' => 'VARCHAR(255)', 'default' => ''), 'price' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00'), 'quantity' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'vat_rate' => array('type' => 'DECIMAL(5,2)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'vat_percent'), 'weight' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0')); $table_index = array('order' => array('fields' => array('order_id'))); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); $table_name = DBPREFIX . 'module_shop_order_attributes'; if (!\Cx\Lib\UpdateUtil::table_exist($table_name)) { $table_name_old = DBPREFIX . 'module_shop_order_items_attributes'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'orders_items_attributes_id'), 'item_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'order_items_id'), 'attribute_name' => array('type' => 'VARCHAR(255)', 'default' => '', 'renamefrom' => 'product_option_name'), 'option_name' => array('type' => 'VARCHAR(255)', 'default' => '', 'renamefrom' => 'product_option_value'), 'price' => array('type' => 'DECIMAL(9,2)', 'unsigned' => false, 'default' => '0.00', 'renamefrom' => 'product_option_values_price')); $table_index = array('item_id' => array('fields' => array('item_id'))); \Cx\Lib\UpdateUtil::table($table_name_old, $table_structure, $table_index); \Cx\Lib\UpdateUtil::table_rename($table_name_old, $table_name); } // LSV $table_name = DBPREFIX . 'module_shop_lsv'; $table_structure = array('order_id' => array('type' => 'INT(10)', 'unsigned' => true, 'primary' => true, 'renamefrom' => 'id'), 'holder' => array('type' => 'tinytext', 'default' => ''), 'bank' => array('type' => 'tinytext', 'default' => ''), 'blz' => array('type' => 'tinytext', 'default' => '')); $table_index = array(); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); $table_name = DBPREFIX . 'module_shop_orders'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true, 'renamefrom' => 'orderid'), 'customer_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'customerid'), 'currency_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'selected_currency_id'), 'shipment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'shipping_id'), 'payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'lang_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'customer_lang'), 'status' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'order_status'), 'sum' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00', 'renamefrom' => 'currency_order_sum'), 'vat_amount' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00', 'renamefrom' => 'tax_price'), 'shipment_amount' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00', 'renamefrom' => 'currency_ship_price'), 'payment_amount' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0.00', 'renamefrom' => 'currency_payment_price'), 'billing_gender' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null), 'billing_company' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => null), 'billing_firstname' => array('type' => 'VARCHAR(40)', 'notnull' => false, 'default' => null), 'billing_lastname' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => null), 'billing_address' => array('type' => 'VARCHAR(40)', 'notnull' => false, 'default' => null), 'billing_city' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null), 'billing_zip' => array('type' => 'VARCHAR(10)', 'notnull' => false, 'default' => null), 'billing_country_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'billing_phone' => array('type' => 'VARCHAR(20)', 'notnull' => false, 'default' => null), 'billing_fax' => array('type' => 'VARCHAR(20)', 'notnull' => false, 'default' => null), 'billing_email' => array('type' => 'VARCHAR(255)', 'notnull' => false, 'default' => null), 'gender' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_prefix'), 'company' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_company'), 'firstname' => array('type' => 'VARCHAR(40)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_firstname'), 'lastname' => array('type' => 'VARCHAR(100)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_lastname'), 'address' => array('type' => 'VARCHAR(40)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_address'), 'city' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_city'), 'zip' => array('type' => 'VARCHAR(10)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_zip'), 'country_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_country_id'), 'phone' => array('type' => 'VARCHAR(20)', 'notnull' => false, 'default' => null, 'renamefrom' => 'ship_phone'), 'ip' => array('type' => 'VARCHAR(50)', 'default' => '', 'renamefrom' => 'customer_ip'), 'host' => array('type' => 'VARCHAR(100)', 'default' => '', 'renamefrom' => 'customer_host'), 'browser' => array('type' => 'VARCHAR(255)', 'default' => '', 'renamefrom' => 'customer_browser'), 'note' => array('type' => 'TEXT', 'default' => '', 'renamefrom' => 'customer_note'), 'date_time' => array('type' => 'TIMESTAMP', 'default' => '0000-00-00 00:00:00', 'renamefrom' => 'order_date'), 'modified_on' => array('type' => 'TIMESTAMP', 'default' => null, 'notnull' => false, 'renamefrom' => 'last_modified'), 'modified_by' => array('type' => 'VARCHAR(50)', 'notnull' => false, 'default' => null)); $table_index = array('status' => array('fields' => array('status'))); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // TODO: TEST // Migrate present Customer addresses to the new billing address fields. // Note that this method is also called in Customer::errorHandler() *before* // any Customer is modified. Thus, we can safely depend on the old // Customer table in one way -- if it doesn't exist, all Orders and Customers // have been successfully migrated already. $table_name_customer = DBPREFIX . "module_shop_customers"; if (\Cx\Lib\UpdateUtil::table_exist($table_name_customer)) { // On the other hand, there may have been an error somewhere in between // altering the Orders table and moving Customers to the Users table. // So, to be on the safe side, we will only update Orders where the billing // address fields are all NULL, as is the case just after the alteration // of the Orders table above. // Also note that any inconsistencies involving missing Customer records will // be left over as-is and may later be handled in the backend. $objResult = \Cx\Lib\UpdateUtil::sql("\n SELECT DISTINCT `customer_id`,\n `customer`.`prefix`,\n `customer`.`firstname`, `customer`.`lastname`,\n `customer`.`company`, `customer`.`address`,\n `customer`.`city`, `customer`.`zip`,\n `customer`.`country_id`,\n `customer`.`phone`, `customer`.`fax`,\n `customer`.`email`\n FROM `{$table_name}`\n JOIN `{$table_name_customer}` AS `customer`\n ON `customerid`=`customer_id`\n WHERE `billing_gender` IS NULL\n AND `billing_company` IS NULL\n AND `billing_firstname` IS NULL\n AND `billing_lastname` IS NULL\n AND `billing_address` IS NULL\n AND `billing_city` IS NULL\n AND `billing_zip` IS NULL\n AND `billing_country_id` IS NULL\n AND `billing_phone` IS NULL\n AND `billing_fax` IS NULL\n AND `billing_email` IS NULL"); while ($objResult && !$objResult->EOF) { $customer_id = $objResult->fields['customer_id']; $gender = 'gender_unknown'; if (preg_match('/^(?:frau|mad|mme|signora|miss)/i', $objResult->fields['prefix'])) { $gender = 'gender_female'; } elseif (preg_match('/^(?:herr|mon|signore|mister|mr)/i', $objResult->fields['prefix'])) { $gender = 'gender_male'; } \Cx\Lib\UpdateUtil::sql("\n UPDATE `{$table_name}`\n SET `billing_gender`='" . addslashes($gender) . "',\n `billing_company`='" . addslashes($objResult->fields['company']) . "',\n `billing_firstname`='" . addslashes($objResult->fields['firstname']) . "',\n `billing_lastname`='" . addslashes($objResult->fields['lastname']) . "',\n `billing_address`='" . addslashes($objResult->fields['address']) . "',\n `billing_city`='" . addslashes($objResult->fields['city']) . "',\n `billing_zip`='" . addslashes($objResult->fields['zip']) . "',\n `billing_country_id`=" . intval($objResult->fields['country_id']) . ",\n `billing_phone`='" . addslashes($objResult->fields['phone']) . "',\n `billing_fax`='" . addslashes($objResult->fields['fax']) . "',\n `billing_email`='" . addslashes($objResult->fields['email']) . "'\n WHERE `customer_id`={$customer_id}\n AND `billing_gender` IS NULL\n AND `billing_company` IS NULL\n AND `billing_firstname` IS NULL\n AND `billing_lastname` IS NULL\n AND `billing_address` IS NULL\n AND `billing_city` IS NULL\n AND `billing_zip` IS NULL\n AND `billing_country_id` IS NULL\n AND `billing_phone` IS NULL\n AND `billing_fax` IS NULL\n AND `billing_email` IS NULL"); $objResult->MoveNext(); } } // Finally, update the migrated Order records with the proper gender // strings as used in the User class hierarchy as well $objResult = \Cx\Lib\UpdateUtil::sql("\n SELECT `id`, `gender`\n FROM `{$table_name}`\n WHERE `gender` NOT IN\n ('gender_male', 'gender_female', 'gender_undefined')"); while ($objResult && !$objResult->EOF) { $gender = 'gender_unknown'; if (preg_match('/^(?:frau|mad|mme|signora|miss)/i', $objResult->fields['gender'])) { $gender = 'gender_female'; } elseif (preg_match('/^(?:herr|mon|signore|mister|mr)/i', $objResult->fields['gender'])) { $gender = 'gender_male'; } \Cx\Lib\UpdateUtil::sql("\n UPDATE `{$table_name}`\n SET `gender`='" . addslashes($gender) . "'\n WHERE `id`=" . $objResult->fields['id']); $objResult->MoveNext(); } // Always return false; }
/** * Initialize countries. * * @access public */ public function __construct() { $this->arrCountries = \Cx\Core\Country\Controller\Country::getNameArray(); }
/** * Returns an array with all placeholders and their values to be * replaced in any shop mailtemplate for the given order ID. * * You only have to set the 'substitution' index value of your MailTemplate * array to the array returned. * Customer data is not included here. See {@see Customer::getSubstitutionArray()}. * Note that this method is now mostly independent of the current session. * The language of the mail template is determined by the browser * language range stored with the order. * @access private * @static * @param integer $order_id The order ID * @param boolean $create_accounts If true, creates User accounts * and Coupon codes. Defaults to true * @return array The array with placeholders as keys * and values from the order on success, * false otherwise */ static function getSubstitutionArray($order_id, $create_accounts = true) { global $_ARRAYLANG; /* $_ARRAYLANG['TXT_SHOP_URI_FOR_DOWNLOAD'].":\r\n". 'http://'.$_SERVER['SERVER_NAME']. "/index.php?section=download\r\n"; */ $objOrder = Order::getById($order_id); if (!$objOrder) { // Order not found return false; } $lang_id = $objOrder->lang_id(); if (!intval($lang_id)) { $lang_id = \FWLanguage::getLangIdByIso639_1($lang_id); } $status = $objOrder->status(); $customer_id = $objOrder->customer_id(); $customer = Customer::getById($customer_id); $payment_id = $objOrder->payment_id(); $shipment_id = $objOrder->shipment_id(); $arrSubstitution = array('CUSTOMER_COUNTRY_ID' => $objOrder->billing_country_id(), 'LANG_ID' => $lang_id, 'NOW' => date(ASCMS_DATE_FORMAT_DATETIME), 'TODAY' => date(ASCMS_DATE_FORMAT_DATE), 'ORDER_ID' => $order_id, 'ORDER_ID_CUSTOM' => ShopLibrary::getCustomOrderId($order_id), 'ORDER_DATE' => date(ASCMS_DATE_FORMAT_DATE, strtotime($objOrder->date_time())), 'ORDER_TIME' => date(ASCMS_DATE_FORMAT_TIME, strtotime($objOrder->date_time())), 'ORDER_STATUS_ID' => $status, 'ORDER_STATUS' => $_ARRAYLANG['TXT_SHOP_ORDER_STATUS_' . $status], 'MODIFIED' => date(ASCMS_DATE_FORMAT_DATETIME, strtotime($objOrder->modified_on())), 'REMARKS' => $objOrder->note(), 'ORDER_SUM' => sprintf('% 9.2f', $objOrder->sum()), 'CURRENCY' => Currency::getCodeById($objOrder->currency_id())); $arrSubstitution += $customer->getSubstitutionArray(); if ($shipment_id) { $arrSubstitution += array('SHIPMENT' => array(0 => array('SHIPMENT_NAME' => sprintf('%-40s', Shipment::getShipperName($shipment_id)), 'SHIPMENT_PRICE' => sprintf('% 9.2f', $objOrder->shipment_amount()))), 'SHIPPING_ADDRESS' => array(0 => array('SHIPPING_COMPANY' => $objOrder->company(), 'SHIPPING_TITLE' => $_ARRAYLANG['TXT_SHOP_' . strtoupper($objOrder->gender())], 'SHIPPING_FIRSTNAME' => $objOrder->firstname(), 'SHIPPING_LASTNAME' => $objOrder->lastname(), 'SHIPPING_ADDRESS' => $objOrder->address(), 'SHIPPING_ZIP' => $objOrder->zip(), 'SHIPPING_CITY' => $objOrder->city(), 'SHIPPING_COUNTRY_ID' => $objOrder->country_id(), 'SHIPPING_COUNTRY' => \Cx\Core\Country\Controller\Country::getNameById($objOrder->country_id()), 'SHIPPING_PHONE' => $objOrder->phone()))); } if ($payment_id) { $arrSubstitution += array('PAYMENT' => array(0 => array('PAYMENT_NAME' => sprintf('%-40s', Payment::getNameById($payment_id)), 'PAYMENT_PRICE' => sprintf('% 9.2f', $objOrder->payment_amount())))); } $arrItems = $objOrder->getItems(); if (!$arrItems) { \Message::warning($_ARRAYLANG['TXT_SHOP_ORDER_WARNING_NO_ITEM']); } // Deduct Coupon discounts, either from each Product price, or // from the items total. Mind that the Coupon has already been // stored with the Order, but not redeemed yet. This is done // in this method, but only if $create_accounts is true. $coupon_code = NULL; $coupon_amount = 0; $objCoupon = Coupon::getByOrderId($order_id); if ($objCoupon) { $coupon_code = $objCoupon->code(); } $orderItemCount = 0; $total_item_price = 0; // Suppress Coupon messages (see Coupon::available()) \Message::save(); foreach ($arrItems as $item) { $product_id = $item['product_id']; $objProduct = Product::getById($product_id); if (!$objProduct) { //die("Product ID $product_id not found"); continue; } //DBG::log("Orders::getSubstitutionArray(): Item: Product ID $product_id"); $product_name = substr($item['name'], 0, 40); $item_price = $item['price']; $quantity = $item['quantity']; // TODO: Add individual VAT rates for Products // $orderItemVatPercent = $objResultItem->fields['vat_percent']; // Decrease the Product stock count, // applies to "real", shipped goods only $objProduct->decreaseStock($quantity); $product_code = $objProduct->code(); // Pick the order items attributes $str_options = ''; // Any attributes? if ($item['attributes']) { $str_options = ' '; // '['; $attribute_name_previous = ''; foreach ($item['attributes'] as $attribute_name => $arrAttribute) { //DBG::log("Attribute /$attribute_name/ => ".var_export($arrAttribute, true)); // NOTE: The option price is optional and may be left out foreach ($arrAttribute as $arrOption) { $option_name = $arrOption['name']; $option_price = $arrOption['price']; $item_price += $option_price; // Recognize the names of uploaded files, // verify their presence and use the original name $option_name_stripped = ShopLibrary::stripUniqidFromFilename($option_name); $path = Order::UPLOAD_FOLDER . $option_name; if ($option_name != $option_name_stripped && \File::exists($path)) { $option_name = $option_name_stripped; } if ($attribute_name != $attribute_name_previous) { if ($attribute_name_previous) { $str_options .= '; '; } $str_options .= $attribute_name . ': ' . $option_name; $attribute_name_previous = $attribute_name; } else { $str_options .= ', ' . $option_name; } // TODO: Add proper formatting with sprintf() and language entries if ($option_price != 0) { $str_options .= ' ' . Currency::formatPrice($option_price) . ' ' . Currency::getActiveCurrencyCode(); } } } // $str_options .= ']'; } // Product details $arrProduct = array('PRODUCT_ID' => $product_id, 'PRODUCT_CODE' => $product_code, 'PRODUCT_QUANTITY' => $quantity, 'PRODUCT_TITLE' => $product_name, 'PRODUCT_OPTIONS' => $str_options, 'PRODUCT_ITEM_PRICE' => sprintf('% 9.2f', $item_price), 'PRODUCT_TOTAL_PRICE' => sprintf('% 9.2f', $item_price * $quantity)); //DBG::log("Orders::getSubstitutionArray($order_id, $create_accounts): Adding article: ".var_export($arrProduct, true)); $orderItemCount += $quantity; $total_item_price += $item_price * $quantity; if ($create_accounts) { // Add an account for every single instance of every Product for ($instance = 1; $instance <= $quantity; ++$instance) { $validity = 0; // Default to unlimited validity // In case there are protected downloads in the cart, // collect the group IDs $arrUsergroupId = array(); if ($objProduct->distribution() == 'download') { $usergroupIds = $objProduct->usergroup_ids(); if ($usergroupIds != '') { $arrUsergroupId = explode(',', $usergroupIds); $validity = $objProduct->weight(); } } // create an account that belongs to all collected // user groups, if any. if (count($arrUsergroupId) > 0) { // The login names are created separately for // each product instance $username = self::usernamePrefix . "_{$order_id}_{$product_id}_{$instance}"; $userEmail = $username . '-' . $arrSubstitution['CUSTOMER_EMAIL']; $userpass = \User::make_password(); $objUser = new \User(); $objUser->setUsername($username); $objUser->setPassword($userpass); $objUser->setEmail($userEmail); $objUser->setAdminStatus(false); $objUser->setActiveStatus(true); $objUser->setGroups($arrUsergroupId); $objUser->setValidityTimePeriod($validity); $objUser->setFrontendLanguage(FRONTEND_LANG_ID); $objUser->setBackendLanguage(FRONTEND_LANG_ID); $objUser->setProfile(array('firstname' => array(0 => $arrSubstitution['CUSTOMER_FIRSTNAME']), 'lastname' => array(0 => $arrSubstitution['CUSTOMER_LASTNAME']), 'company' => array(0 => $arrSubstitution['CUSTOMER_COMPANY']), 'address' => array(0 => $arrSubstitution['CUSTOMER_ADDRESS']), 'zip' => array(0 => $arrSubstitution['CUSTOMER_ZIP']), 'city' => array(0 => $arrSubstitution['CUSTOMER_CITY']), 'country' => array(0 => $arrSubstitution['CUSTOMER_COUNTRY_ID']), 'phone_office' => array(0 => $arrSubstitution['CUSTOMER_PHONE']), 'phone_fax' => array(0 => $arrSubstitution['CUSTOMER_FAX']))); if (!$objUser->store()) { \Message::error(implode('<br />', $objUser->getErrorMsg())); return false; } if (empty($arrProduct['USER_DATA'])) { $arrProduct['USER_DATA'] = array(); } $arrProduct['USER_DATA'][] = array('USER_NAME' => $username, 'USER_PASS' => $userpass); } //echo("Instance $instance"); if ($objProduct->distribution() == 'coupon') { if (empty($arrProduct['COUPON_DATA'])) { $arrProduct['COUPON_DATA'] = array(); } //DBG::log("Orders::getSubstitutionArray(): Getting code"); $code = Coupon::getNewCode(); //DBG::log("Orders::getSubstitutionArray(): Got code: $code, calling Coupon::addCode($code, 0, 0, 0, $item_price)"); Coupon::storeCode($code, 0, 0, 0, $item_price, 0, 0, 10000000000.0, true); $arrProduct['COUPON_DATA'][] = array('COUPON_CODE' => $code); } } // Redeem the *product* Coupon, if possible for the Product if ($coupon_code) { $objCoupon = Coupon::available($coupon_code, $item_price * $quantity, $customer_id, $product_id, $payment_id); if ($objCoupon) { $coupon_code = NULL; $coupon_amount = $objCoupon->getDiscountAmount($item_price, $customer_id); if ($create_accounts) { $objCoupon->redeem($order_id, $customer_id, $item_price * $quantity); } } //\DBG::log("Orders::getSubstitutionArray(): Got Product Coupon $coupon_code"); } } if (empty($arrSubstitution['ORDER_ITEM'])) { $arrSubstitution['ORDER_ITEM'] = array(); } $arrSubstitution['ORDER_ITEM'][] = $arrProduct; } $arrSubstitution['ORDER_ITEM_SUM'] = sprintf('% 9.2f', $total_item_price); $arrSubstitution['ORDER_ITEM_COUNT'] = sprintf('% 4u', $orderItemCount); // Redeem the *global* Coupon, if possible for the Order if ($coupon_code) { $objCoupon = Coupon::available($coupon_code, $total_item_price, $customer_id, null, $payment_id); if ($objCoupon) { $coupon_amount = $objCoupon->getDiscountAmount($total_item_price, $customer_id); if ($create_accounts) { $objCoupon->redeem($order_id, $customer_id, $total_item_price); } } } \Message::restore(); // Fill in the Coupon block with proper discount and amount if ($objCoupon) { $coupon_code = $objCoupon->code(); //\DBG::log("Orders::getSubstitutionArray(): Coupon $coupon_code, amount $coupon_amount"); } if ($coupon_amount) { //\DBG::log("Orders::getSubstitutionArray(): Got Order Coupon $coupon_code"); $arrSubstitution['DISCOUNT_COUPON'][] = array('DISCOUNT_COUPON_CODE' => sprintf('%-40s', $coupon_code), 'DISCOUNT_COUPON_AMOUNT' => sprintf('% 9.2f', -$coupon_amount)); } else { //\DBG::log("Orders::getSubstitutionArray(): No Coupon for Order ID $order_id"); } Products::deactivate_soldout(); if (Vat::isEnabled()) { //DBG::log("Orders::getSubstitutionArray(): VAT amount: ".$objOrder->vat_amount()); $arrSubstitution['VAT'] = array(0 => array('VAT_TEXT' => sprintf('%-40s', Vat::isIncluded() ? $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_INCL'] : $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_EXCL']), 'VAT_PRICE' => $objOrder->vat_amount())); } return $arrSubstitution; }
public function testGetAll() { $objCountries = Country::getNameArray(); $this->assertNotEmpty($objCountries); }
function getSourceCode($id, $lang, $preview = false, $show = false) { global $_ARRAYLANG, $objInit, $objDatabase; $hasFileInput = false; //remember if we added a file input -> this would need the uploader to be initialized $arrFields = $this->getFormFields($id); $sourcecode = array(); $this->initContactForms(); $sourcecode[] = '<div class="text-warning" id="contactFeedback">{CONTACT_FEEDBACK_TEXT}</div> <div id="contactDescription"><!-- BEGIN formText -->' . ($preview ? $this->arrForms[$id]['lang'][$lang]['text'] : '{' . $id . '_FORM_TEXT}') . '<!-- END formText --></div> <div class="text-danger" id="contactFormError">' . ($preview ? $_ARRAYLANG['TXT_NEW_ENTRY_ERORR'] : '{TXT_NEW_ENTRY_ERORR}') . '</div> <!-- BEGIN contact_form --> <form role="form" id="contactForm' . ($this->arrForms[$id]['useCustomStyle'] > 0 ? '_' . $id : '') . '" class="contactForm' . ($this->arrForms[$id]['useCustomStyle'] > 0 ? '_' . $id : '') . '" action="' . ($preview ? '../' : '') . 'index.php?section=Contact&cmd=' . $id . '" method="post" enctype="multipart/form-data" onsubmit="return checkAllFields();"> <fieldset id="contactFrame"> <legend>' . ($preview ? $this->arrForms[$id]['lang'][$lang]['name'] : '{' . $id . '_FORM_NAME}') . '</legend>'; foreach ($arrFields as $fieldId => $arrField) { if ($arrField['is_required']) { $required = '<strong class="is_required">*</strong>'; } else { $required = ''; } if ($arrField['type'] != 'fieldset' && $arrField['type'] != 'hidden') { $sourcecode[] = '<div class="contact row form-group">'; } switch ($arrField['type']) { case 'label': case 'hidden': case 'horizontalLine': case 'checkbox': break; case 'fieldset': $sourcecode[] = '</fieldset>'; $sourcecode[] = '<fieldset id="contactFormFieldId_' . $fieldId . '">'; $sourcecode[] = "<legend>" . ($preview ? contrexx_raw2xhtml($arrField['lang'][$lang]['name']) : "{" . $fieldId . "_LABEL}") . "</legend>"; break; case 'checkboxGroup': case 'radio': $sourcecode[] = '<label>' . ($preview ? contrexx_raw2xhtml($arrField['lang'][$lang]['name']) : "{" . $fieldId . "_LABEL}") . $required . '</label>'; break; case 'date': $sourcecode[] = '<label for="contactFormFieldId_' . $fieldId . '">' . ($preview ? contrexx_raw2xhtml($arrField['lang'][$lang]['name']) : "{" . $fieldId . "_LABEL}") . $required . '</label>'; break; case 'datetime': $sourcecode[] = '<label for="contactFormFieldId_' . $fieldId . '">' . ($preview ? contrexx_raw2xhtml($arrField['lang'][$lang]['name']) : "{" . $fieldId . "_LABEL}") . $required . '</label>'; break; default: $sourcecode[] = '<label for="contactFormFieldId_' . $fieldId . '">' . ($preview ? contrexx_raw2xhtml($arrField['lang'][$lang]['name']) : "{" . $fieldId . "_LABEL}") . $required . '</label>'; } $arrField['lang'][$lang]['value'] = preg_replace('/\\[\\[([A-Z0-9_]+)\\]\\]/', '{$1}', $arrField['lang'][$lang]['value']); $fieldType = $arrField['type'] != 'special' ? $arrField['type'] : $arrField['special_type']; switch ($fieldType) { case 'label': $sourcecode[] = '<div class="contactFormClass_' . $arrField['type'] . '">' . contrexx_raw2xhtml($arrField['lang'][$lang]['value']) . '</div>'; break; case 'checkbox': $sourcecode[] = '<div class="checkbox"><label for="contactFormFieldId_' . $fieldId . '"><input class="contactFormClass_' . $arrField['type'] . '" id="contactFormFieldId_' . $fieldId . '" type="checkbox" name="contactFormField_' . $fieldId . '" value="1" {SELECTED_' . $fieldId . '} />' . ($preview ? contrexx_raw2xhtml($arrField['lang'][$lang]['name']) : "{" . $fieldId . "_LABEL}") . $required . '</label></div>'; break; case 'checkboxGroup': $selectedLang = $preview ? FRONTEND_LANG_ID : $lang; $sourcecode[] = '<div class="contactFormGroup" id="contactFormFieldId_' . $fieldId . '">'; $options = explode(',', $arrField['lang'][$selectedLang]['value']); foreach ($options as $index => $option) { $sourcecode[] = '<div class="checkbox"><label class="noCaption" for="contactFormField_' . $index . '_' . $fieldId . '"><input type="checkbox" class="contactFormClass_' . $arrField['type'] . '" name="contactFormField_' . $fieldId . '[]" id="contactFormField_' . $index . '_' . $fieldId . '" value="' . contrexx_raw2xhtml($option) . '" {SELECTED_' . $fieldId . '_' . $index . '}/>' . ($preview ? contrexx_raw2xhtml($option) : '{' . $fieldId . '_' . $index . '_VALUE}') . '</label></div>'; } $sourcecode[] = '</div>'; break; case 'country': case 'access_country': $sourcecode[] = '<select class="contactFormClass_' . $arrField['type'] . '" name="contactFormField_' . $fieldId . '" id="contactFormFieldId_' . $fieldId . '">'; if ($arrField['is_required'] == 1) { $sourcecode[] = "<option value=\"" . ($preview ? $_ARRAYLANG['TXT_CONTACT_PLEASE_SELECT'] : '{TXT_CONTACT_PLEASE_SELECT}') . "\">" . ($preview ? $_ARRAYLANG['TXT_CONTACT_PLEASE_SELECT'] : '{TXT_CONTACT_PLEASE_SELECT}') . "</option>"; } else { $sourcecode[] = "<option value=\"" . ($preview ? $_ARRAYLANG['TXT_CONTACT_NOT_SPECIFIED'] : '{TXT_CONTACT_NOT_SPECIFIED}') . "\">" . ($preview ? $_ARRAYLANG['TXT_CONTACT_NOT_SPECIFIED'] : '{TXT_CONTACT_NOT_SPECIFIED}') . "</option>"; } if ($preview) { $lang = $arrField['lang'][$lang]['name']; $country = \Cx\Core\Country\Controller\Country::getNameArray(true, $lang); foreach ($country as $id => $name) { $sourcecode[] = "<option value=\"" . $name . "\" >" . $name . "</option>"; } } else { $sourcecode[] = "<!-- BEGIN field_" . $fieldId . " -->"; $sourcecode[] = "<option value=\"{" . $fieldId . "_VALUE}\" {SELECTED_" . $fieldId . "} >{" . $fieldId . "_VALUE}</option>"; $sourcecode[] = "<!-- END field_" . $fieldId . " -->"; } $sourcecode[] = "</select>"; break; case 'date': $sourcecode[] = '<input class="contactFormClass_' . $arrField['type'] . ' date" type="text" name="contactFormField_' . $fieldId . '" id="contactFormFieldId_' . $fieldId . '" value="{' . $fieldId . '_VALUE}" />'; break; case 'datetime': $sourcecode[] = '<input class="contactFormClass_' . $arrField['type'] . ' datetime" type="text" name="contactFormField_' . $fieldId . '" id="contactFormFieldId_' . $fieldId . '" value="{' . $fieldId . '_VALUE}" />'; break; case 'access_birthday': $sourcecode[] = '<input class="contactFormClass_' . $arrField['type'] . ' date" id="contactFormFieldId_' . $fieldId . '" type="text" name="contactFormField_' . $fieldId . '" value="' . ($preview ? contrexx_raw2xhtml($arrField['lang'][$lang]['value']) : '{' . $fieldId . '_VALUE}') . '" />'; break; case 'file': case 'multi_file': $sourcecode[] = '<div class="contactFormUpload" id="contactFormUpload_' . $fieldId . '">{CONTACT_UPLOADER_FOLDER_WIDGET_' . $fieldId . '}<input type="hidden" name="contactFormUploadId_' . $fieldId . '" value = "{CONTACT_UPLOADER_ID_' . $fieldId . '}"/>'; $sourcecode[] = '<input class="contactFormClass_' . $arrField['type'] . '" id="contactFormFieldId_' . $fieldId . '" type="file" name="contactFormField_' . $fieldId . '" disabled="disabled"/></div>'; break; case 'hidden': $sourcecode[] = '<input class="contactFormClass_' . $arrField['type'] . '" id="contactFormFieldId_' . $fieldId . '" type="hidden" name="contactFormField_' . $fieldId . '" value="' . ($preview ? contrexx_raw2xhtml($arrField['lang'][$lang]['value']) : "{" . $fieldId . "_VALUE}") . '" />'; break; case 'horizontalLine': $sourcecode[] = '<hr />'; break; case 'password': $sourcecode[] = '<input class="contactFormClass_' . $arrField['type'] . '" id="contactFormFieldId_' . $fieldId . '" type="password" name="contactFormField_' . $fieldId . '" value="" />'; break; case 'radio': $selectedLang = $preview ? FRONTEND_LANG_ID : $lang; $sourcecode[] = '<div class="contactFormGroup" id="contactFormFieldId_' . $fieldId . '">'; $options = explode(',', $arrField['lang'][$selectedLang]['value']); foreach ($options as $index => $option) { $sourcecode[] .= '<div class="radio"><label class="noCaption" for="contactFormField_' . $index . '_' . $fieldId . '"><input class="contactFormClass_' . $arrField['type'] . '" type="radio" name="contactFormField_' . $fieldId . '" id="contactFormField_' . $index . '_' . $fieldId . '" value="' . ($preview ? contrexx_raw2xhtml($option) : '{' . $fieldId . '_' . $index . '_VALUE}') . '" {SELECTED_' . $fieldId . '_' . $index . '} />' . ($preview ? contrexx_raw2xhtml($option) : '{' . $fieldId . '_' . $index . '_VALUE}') . '</label></div>'; } $sourcecode[] = '</div>'; break; case 'access_title': case 'access_gender': // collect user attribute options $arrOptions = array(); $accessAttributeId = str_replace('access_', '', $fieldType); $objAttribute = \FWUser::getFWUserObject()->objUser->objAttribute->getById($accessAttributeId); // get options $arrAttribute = $objAttribute->getChildren(); foreach ($arrAttribute as $attributeId) { $objAttribute = \FWUser::getFWUserObject()->objUser->objAttribute->getById($attributeId); $arrOptions[] = $objAttribute->getName(FRONTEND_LANG_ID); } // options will be used for select input generation $arrField['lang'][FRONTEND_LANG_ID]['value'] = implode(',', $arrOptions); case 'select': $sourcecode[] = '<select class="contactFormClass_' . $arrField['type'] . '" name="contactFormField_' . $fieldId . '" id="contactFormFieldId_' . $fieldId . '">'; if ($preview) { $options = explode(',', $arrField['lang'][FRONTEND_LANG_ID]['value']); foreach ($options as $index => $option) { $sourcecode[] = "<option value='" . contrexx_raw2xhtml($option) . "'>" . contrexx_raw2xhtml($option) . "</option>"; } } else { $sourcecode[] = "<!-- BEGIN field_" . $fieldId . " -->"; $sourcecode[] = "<option value='{" . $fieldId . "_VALUE}' {SELECTED_" . $fieldId . "}>" . '{' . $fieldId . '_VALUE}' . "</option>"; $sourcecode[] = "<!-- END field_" . $fieldId . " -->"; } $sourcecode[] = "</select>"; break; case 'textarea': $sourcecode[] = '<textarea class="contactFormClass_' . $arrField['type'] . '" name="contactFormField_' . $fieldId . '" id="contactFormFieldId_' . $fieldId . '" rows="5" cols="20">{' . $fieldId . '_VALUE}</textarea>'; break; case 'recipient': $sourcecode[] = '<select class="contactFormClass_' . $arrField['type'] . '" name="contactFormField_' . $fieldId . '" id="contactFormFieldId_' . $fieldId . '">'; if ($preview) { foreach ($this->arrForms[$id]['recipients'] as $index => $arrRecipient) { $sourcecode[] = "<option value='" . $index . "'>" . $arrRecipient['lang'][$lang] . "</option>"; } } else { $sourcecode[] = "<!-- BEGIN field_" . $fieldId . " -->"; $sourcecode[] = "<option value='{" . $fieldId . "_VALUE_ID}' {SELECTED_" . $fieldId . "} >" . '{' . $fieldId . '_VALUE}' . "</option>"; $sourcecode[] = "<!-- END field_" . $fieldId . " -->"; } $sourcecode[] = "</select>"; break; case 'fieldset': break; default: $sourcecode[] = '<input class="contactFormClass_' . $arrField['type'] . '" id="contactFormFieldId_' . $fieldId . '" type="text" name="contactFormField_' . $fieldId . '" value="' . ($preview ? contrexx_raw2xhtml($arrField['lang'][$lang]['value']) : '{' . $fieldId . '_VALUE}') . '" />'; break; } if ($arrField['type'] != 'fieldset' && $arrField['type'] != 'hidden') { $sourcecode[] = '</div>'; } } if ($preview) { $themeId = $objInit->arrLang[FRONTEND_LANG_ID]['themesid']; if (($objRS = $objDatabase->SelectLimit("SELECT `foldername` FROM `" . DBPREFIX . "skins` WHERE `id` = " . $themeId, 1)) !== false) { $themePath = $objRS->fields['foldername']; } $sourcecode[] = '<link href="../core_modules/Contact/View/Style/form.css" rel="stylesheet" type="text/css" />'; if ($this->arrForms[$id]['useCaptcha']) { $sourcecode[] = '<div class="contact row form-group">'; $sourcecode[] = '<label>' . $_ARRAYLANG["TXT_CONTACT_CAPTCHA"] . '</label>'; $sourcecode[] = \Cx\Core_Modules\Captcha\Controller\Captcha::getInstance()->getCode(); $sourcecode[] = '</div>'; } } else { $sourcecode[] = "<!-- BEGIN contact_form_captcha -->"; $sourcecode[] = '<div class="contact row form-group">'; $sourcecode[] = '<label>{TXT_CONTACT_CAPTCHA}</label>'; $sourcecode[] = '{CONTACT_CAPTCHA_CODE}'; $sourcecode[] = '</div>'; $sourcecode[] = "<!-- END contact_form_captcha -->"; } $sourcecode[] = '<div class="contact row form-group">'; $sourcecode[] = '<input class="contactFormClass_button btn btn-default" type="submit" name="submitContactForm" value="' . ($preview ? $_ARRAYLANG['TXT_CONTACT_SUBMIT'] : '{TXT_CONTACT_SUBMIT}') . '" /><input class="contactFormClass_button btn btn-default" type="reset" value="' . ($preview ? $_ARRAYLANG['TXT_CONTACT_RESET'] : '{TXT_CONTACT_RESET}') . '" />'; $sourcecode[] = '<input type="hidden" name="unique_id" value="{CONTACT_UNIQUE_ID}" />'; $sourcecode[] = '</div>'; $sourcecode[] = "</fieldset>"; $sourcecode[] = "</form>"; $sourcecode[] = "<!-- END contact_form -->"; $sourcecode[] = $preview ? $this->_getJsSourceCode($id, $arrFields, $preview, $show) : "{CONTACT_JAVASCRIPT}"; if ($show) { $sourcecode = preg_replace('/\\{([A-Z0-9_-]+)\\}/', '[[\\1]]', $sourcecode); } return implode("\n", $sourcecode); }
function loadCoreAttributeCountry() { global $objDatabase; $countries = \Cx\Core\Country\Controller\Country::getArray($count, $this->langId); foreach ($countries as $country) { $this->arrAttributes['country_' . $country['id']] = array('type' => 'menu_option', 'multiline' => false, 'mandatory' => false, 'sort_type' => 'asc', 'parent_id' => 'country', 'desc' => $country['name'], 'names' => array($this->langId => $country['name']), 'value' => $country['id'], 'order_id' => 0); } }
/** * Generates an overview of the Order for the Customer to confirm * * Forward her to the processing of the Order after the button has been * clicked. * @return boolean True on success, false otherwise */ static function confirm() { global $_ARRAYLANG; // If the cart or address is missing, return to the shop if (!self::verifySessionAddress()) { \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', '')); } self::$show_currency_navbar = false; // The Customer clicked the confirm button; this must not be the case // the first time this method is called. if (isset($_POST['process'])) { return self::process(); } // Show confirmation page. self::$objTemplate->hideBlock('shopProcess'); self::$objTemplate->setGlobalVariable($_ARRAYLANG); // It may be necessary to refresh the cart here, as the customer // may return to the cart, then press "Back". self::_initPaymentDetails(); foreach (Cart::get_products_array() as $arrProduct) { $objProduct = Product::getById($arrProduct['id']); if (!$objProduct) { // TODO: Implement a proper method // unset(Cart::get_product_id($cart_id]); continue; } $price_options = 0; $attributes = Attributes::getAsStrings($arrProduct['options'], $price_options); $attributes = $attributes[0]; // Note: The Attribute options' price is added // to the price here! $price = $objProduct->get_custom_price(self::$objCustomer, $price_options, $arrProduct['quantity']); // Test the distribution method for delivery $productDistribution = $objProduct->distribution(); $weight = $productDistribution == 'delivery' ? Weight::getWeightString($objProduct->weight()) : '-'; $vatId = $objProduct->vat_id(); $vatRate = Vat::getRate($vatId); $vatPercent = Vat::getShort($vatId); $vatAmount = Vat::amount($vatRate, $price * $arrProduct['quantity']); self::$objTemplate->setVariable(array('SHOP_PRODUCT_ID' => $arrProduct['id'], 'SHOP_PRODUCT_CUSTOM_ID' => $objProduct->code(), 'SHOP_PRODUCT_TITLE' => contrexx_raw2xhtml($objProduct->name()), 'SHOP_PRODUCT_PRICE' => Currency::formatPrice($price * $arrProduct['quantity']), 'SHOP_PRODUCT_QUANTITY' => $arrProduct['quantity'], 'SHOP_PRODUCT_ITEMPRICE' => Currency::formatPrice($price), 'SHOP_UNIT' => Currency::getActiveCurrencySymbol())); if ($attributes && self::$objTemplate->blockExists('attributes')) { self::$objTemplate->setVariable('SHOP_PRODUCT_OPTIONS', $attributes); } if (\Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop')) { self::$objTemplate->setVariable(array('SHOP_PRODUCT_WEIGHT' => $weight, 'TXT_WEIGHT' => $_ARRAYLANG['TXT_WEIGHT'])); } if (Vat::isEnabled()) { self::$objTemplate->setVariable(array('SHOP_PRODUCT_TAX_RATE' => $vatPercent, 'SHOP_PRODUCT_TAX_AMOUNT' => Currency::formatPrice($vatAmount) . ' ' . Currency::getActiveCurrencySymbol())); } self::$objTemplate->parse("shopCartRow"); } $total_discount_amount = 0; if (Cart::get_discount_amount()) { $total_discount_amount = Cart::get_discount_amount(); self::$objTemplate->setVariable(array('SHOP_DISCOUNT_COUPON_TOTAL' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_TOTAL'], 'SHOP_DISCOUNT_COUPON_TOTAL_AMOUNT' => Currency::formatPrice(-$total_discount_amount))); } self::$objTemplate->setVariable(array('SHOP_UNIT' => Currency::getActiveCurrencySymbol(), 'SHOP_TOTALITEM' => Cart::get_item_count(), 'SHOP_PAYMENT_PRICE' => Currency::formatPrice($_SESSION['shop']['payment_price']), 'SHOP_TOTALPRICE' => Currency::formatPrice(Cart::get_price()), 'SHOP_PAYMENT' => Payment::getProperty($_SESSION['shop']['paymentId'], 'name'), 'SHOP_GRAND_TOTAL' => Currency::formatPrice($_SESSION['shop']['grand_total_price']), 'SHOP_COMPANY' => stripslashes($_SESSION['shop']['company']), 'SHOP_TITLE' => stripslashes($_SESSION['shop']['gender']), 'SHOP_GENDER' => stripslashes($_SESSION['shop']['gender']), 'SHOP_LASTNAME' => stripslashes($_SESSION['shop']['lastname']), 'SHOP_FIRSTNAME' => stripslashes($_SESSION['shop']['firstname']), 'SHOP_ADDRESS' => stripslashes($_SESSION['shop']['address']), 'SHOP_ZIP' => stripslashes($_SESSION['shop']['zip']), 'SHOP_CITY' => stripslashes($_SESSION['shop']['city']), 'SHOP_COUNTRY' => \Cx\Core\Country\Controller\Country::getNameById($_SESSION['shop']['countryId']), 'SHOP_EMAIL' => stripslashes($_SESSION['shop']['email']), 'SHOP_PHONE' => stripslashes($_SESSION['shop']['phone']), 'SHOP_FAX' => stripslashes($_SESSION['shop']['fax']))); if (!empty($_SESSION['shop']['lastname2'])) { self::$objTemplate->setVariable(array('SHOP_COMPANY2' => stripslashes($_SESSION['shop']['company2']), 'SHOP_TITLE2' => stripslashes($_SESSION['shop']['gender2']), 'SHOP_LASTNAME2' => stripslashes($_SESSION['shop']['lastname2']), 'SHOP_FIRSTNAME2' => stripslashes($_SESSION['shop']['firstname2']), 'SHOP_ADDRESS2' => stripslashes($_SESSION['shop']['address2']), 'SHOP_ZIP2' => stripslashes($_SESSION['shop']['zip2']), 'SHOP_CITY2' => stripslashes($_SESSION['shop']['city2']), 'SHOP_COUNTRY2' => \Cx\Core\Country\Controller\Country::getNameById($_SESSION['shop']['countryId2']), 'SHOP_PHONE2' => stripslashes($_SESSION['shop']['phone2']))); } if (!empty($_SESSION['shop']['note'])) { self::$objTemplate->setVariable(array('SHOP_CUSTOMERNOTE' => $_SESSION['shop']['note'])); } if (Vat::isEnabled()) { self::$objTemplate->setVariable(array('TXT_TAX_RATE' => $_ARRAYLANG['TXT_SHOP_VAT_RATE'], 'SHOP_TAX_PRICE' => Currency::formatPrice($_SESSION['shop']['vat_price']), 'SHOP_TAX_PRODUCTS_TXT' => $_SESSION['shop']['vat_products_txt'], 'SHOP_TAX_GRAND_TXT' => $_SESSION['shop']['vat_grand_txt'], 'TXT_TAX_PREFIX' => Vat::isIncluded() ? $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_INCL'] : $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_EXCL'])); if (Vat::isIncluded()) { self::$objTemplate->setVariable(array('SHOP_GRAND_TOTAL_EXCL_TAX' => Currency::formatPrice($_SESSION['shop']['grand_total_price'] - $_SESSION['shop']['vat_price']))); } } // TODO: Make sure in payment() that those two are either both empty or // both non-empty! if (!Cart::needs_shipment() && empty($_SESSION['shop']['shipperId'])) { if (self::$objTemplate->blockExists('shipping_address')) { self::$objTemplate->hideBlock('shipping_address'); } } else { // Shipment is required, so if (empty($_SESSION['shop']['shipperId'])) { \Cx\Core\Csrf\Controller\Csrf::redirect(\Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'payment')); } self::$objTemplate->setVariable(array('SHOP_SHIPMENT_PRICE' => Currency::formatPrice($_SESSION['shop']['shipment_price']), 'SHOP_SHIPMENT' => Shipment::getShipperName($_SESSION['shop']['shipperId']))); } // Custom. // Enable if Discount class is customized and in use. //self::showCustomerDiscount(Cart::get_price()); return true; }
public function __construct($attrs = array(), $options = array()) { global $_ARRAYLANG; if ($attrs instanceof \Cx\Core_Modules\Listing\Model\Entity\DataSet) { $hasMasterTableHeader = !empty($options['header']); // add master table-header-row if ($hasMasterTableHeader) { $this->addRow(array(0 => $options['header']), null, 'th'); } $first = true; $row = 1 + $hasMasterTableHeader; foreach ($attrs as $rowname => $rows) { $col = 0; $virtual = $rows['virtual']; unset($rows['virtual']); if (isset($options['multiActions'])) { $this->setCellContents($row, $col, '<input name="select-' . $rowname . '" value="' . $rowname . '" type="checkbox" />', 'TD', '0', false); $col++; } foreach ($rows as $header => $data) { $encode = true; if (isset($options['fields']) && isset($options['fields'][$header]) && isset($options['fields'][$header]['showOverview']) && !$options['fields'][$header]['showOverview']) { continue; } $origHeader = $header; if (isset($options['fields'][$header]['sorting'])) { $sorting = $options['fields'][$header]['sorting']; } else { if (isset($options['functions']['sorting'])) { $sorting = $options['functions']['sorting']; } } if ($first) { if (isset($options['fields'][$header]['header'])) { $header = $options['fields'][$header]['header']; } if (isset($_ARRAYLANG[$header])) { $header = $_ARRAYLANG[$header]; } if (is_array($options['functions']) && isset($options['functions']['sorting']) && $options['functions']['sorting'] && $sorting !== false) { $order = ''; $img = '↑↓'; if (isset($_GET['order'])) { $supOrder = explode('/', $_GET['order']); if (current($supOrder) == $origHeader) { $order = '/DESC'; $img = '↓'; if (count($supOrder) > 1 && $supOrder[1] == 'DESC') { $order = ''; $img = '↑'; } } } $header = '<a href="' . \Env::get('cx')->getRequest()->getUrl() . '&order=' . $origHeader . $order . '" style="white-space: nowrap;">' . $header . ' ' . $img . '</a>'; } if ($hasMasterTableHeader) { $this->setCellContents(1, $col, $header, 'td', 0); } else { $this->setCellContents(0, $col, $header, 'th', 0); } } if (isset($options['fields']) && isset($options['fields'][$origHeader]) && isset($options['fields'][$origHeader]['table']) && isset($options['fields'][$origHeader]['table']['parse']) && is_callable($options['fields'][$origHeader]['table']['parse'])) { $callback = $options['fields'][$origHeader]['table']['parse']; $data = $callback($data, $rows); $encode = false; // todo: this should be set by callback } else { if (is_object($data) && get_class($data) == 'DateTime') { $data = $data->format(ASCMS_DATE_FORMAT); } else { if (isset($options['fields'][$origHeader]) && isset($options['fields'][$origHeader]['type']) && $options['fields'][$origHeader]['type'] == '\\Country') { $data = \Cx\Core\Country\Controller\Country::getNameById($data); if (empty($data)) { $data = \Cx\Core\Country\Controller\Country::getNameById(204); } } else { if (gettype($data) == 'boolean') { $data = '<i>' . ($data ? $_ARRAYLANG['TXT_YES'] : $_ARRAYLANG['TXT_NO']) . '</i>'; $encode = false; } else { if ($data === null) { $data = '<i>' . $_ARRAYLANG['TXT_CORE_NONE'] . '</i>'; $encode = false; } else { if (empty($data)) { $data = '<i>(empty)</i>'; $encode = false; } } } } } } $this->setCellContents($row, $col, $data, 'TD', 0, $encode); $col++; } if ($this->hasRowFunctions($options['functions'], $virtual)) { if ($first) { $header = 'Functions'; if (isset($_ARRAYLANG['TXT_FUNCTIONS'])) { $header = $_ARRAYLANG['TXT_FUNCTIONS']; } if ($hasMasterTableHeader) { $this->setCellContents(1, $col, $header, 'td', 0, true); } else { $this->setCellContents(0, $col, $header, 'th', 0, true); } } $this->updateColAttributes($col, array('style' => 'text-align:right;')); if (empty($options['functions']['baseUrl'])) { $options['functions']['baseUrl'] = clone \Env::get('cx')->getRequest()->getUrl(); } $this->setCellContents($row, $col, $this->getFunctionsCode($rowname, $rows, $options['functions'], $virtual), 'TD', 0); } $first = false; $row++; } // adjust colspan of master-table-header-row if ($hasMasterTableHeader) { $this->setCellAttributes(0, 0, array('colspan' => $col + is_array($options['functions']))); $this->updateRowAttributes(1, array('class' => 'row3'), true); } // add multi-actions if (isset($options['multiActions'])) { $multiActionsCode = ' <img src="images/icons/arrow.gif" width="38" height="22" alt="^" title="^"> <a href="#" onclick="jQuery(\'input[type=checkbox]\').prop(\'checked\', true);return false;">' . $_ARRAYLANG['TXT_SELECT_ALL'] . '</a> / <a href="#" onclick="jQuery(\'input[type=checkbox]\').prop(\'checked\', false);return false;">' . $_ARRAYLANG['TXT_DESELECT_ALL'] . '</a> <img alt="-" title="-" src="images/icons/strike.gif"> '; $multiActions = array('' => $_ARRAYLANG['TXT_SUBMIT_SELECT']); foreach ($options['multiActions'] as $actionName => $actionProperties) { $actionTitle = $actionName; if (isset($actionProperties['title'])) { $actionTitle = $actionProperties['title']; } else { if (isset($_ARRAYLANG[$actionName])) { $actionTitle = $_ARRAYLANG[$actionName]; } } if (isset($actionProperties['jsEvent'])) { $actionName = $actionProperties['jsEvent']; } $multiActions[$actionName] = $actionTitle; } $select = new \Cx\Core\Html\Model\Entity\DataElement('cxMultiAction', \Html::getOptions($multiActions), \Cx\Core\Html\Model\Entity\DataElement::TYPE_SELECT); // this is not a nice place for this code // but we should cleanup this complete class and make // it base on templates $select->setAttribute('onchange', ' var regex = /([a-zA-Z\\/]+):([a-zA-Z\\/]+)/; var matches = jQuery(this).val().match(regex); if (!matches) { return false; } var checkboxes = jQuery(this).closest("table").find("input[type=checkbox]"); var activeRows = []; checkboxes.filter(":checked").each(function(el) { activeRows.push(jQuery(this).val()); }); cx.trigger(matches[1], matches[2], activeRows); checkboxes.prop("checked", false); jQuery(this).val(""); '); $this->setCellContents($row, 0, $multiActionsCode . $select, 'TD', 0); $this->setCellAttributes($row, 0, array('colspan' => $col + is_array($options['functions']))); } $attrs = array(); } parent::__construct(array_merge($attrs, array('class' => 'adminlist', 'width' => '100%'))); }
function modifyEntry() { global $_ARRAYLANG, $_CORELANG, $objDatabase, $_LANGID; \JS::activate('cx'); \JS::activate('jqueryui'); $this->_objTpl->loadTemplateFile('module_' . $this->moduleNameLC . '_modify_entry.html', true, true); $this->pageTitle = $_ARRAYLANG['TXT_MEDIADIR_ENTRIES']; //get seting values parent::getSettings(); $intEntryDourationAlways = ''; $intEntryDourationPeriod = ''; $intEntryDourationShowPeriod = 'none'; $intEntryDourationEnd = 0; $intEntryDourationStart = 0; $strOnSubmit = ''; if (!empty($_GET['id'])) { \Permission::checkAccess(MediaDirectoryAccessIDs::ModifyEntry, 'static'); $pageTitle = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . " " . $_ARRAYLANG['TXT_MEDIADIR_EDIT']; $intEntryId = intval($_GET['id']); } else { \Permission::checkAccess(MediaDirectoryAccessIDs::AddEntry, 'static'); $pageTitle = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . " " . $_ARRAYLANG['TXT_MEDIADIR_ADD']; $intEntryId = null; } //count forms $objForms = new MediaDirectoryForm(null, $this->moduleName); $arrActiveForms = array(); foreach ($objForms->arrForms as $intFormId => $arrForm) { if ($arrForm['formActive'] == 1) { $arrActiveForms[] = $intFormId; } } $intCountForms = count($arrActiveForms); if ($intCountForms > 0) { if (intval($intEntryId) == 0 && (empty($_POST['selectedFormId']) && empty($_POST['formId'])) && $intCountForms > 1) { $intFormId = null; //get form selector $objForms->listForms($this->_objTpl, 2, $intFormId); //parse blocks $this->_objTpl->hideBlock($this->moduleNameLC . 'EntryStatus'); $this->_objTpl->hideBlock($this->moduleNameLC . 'InputfieldList'); $this->_objTpl->hideBlock($this->moduleNameLC . 'SpezfieldList'); } else { //save entry data if (isset($_POST['submitEntryModfyForm']) && !empty($_POST['formId'])) { $objEntry = new MediaDirectoryEntry($this->moduleName); $intEntryId = intval($_POST['entryId']); $intEntryId = $objEntry->saveEntry($_POST, $intEntryId); if (!empty($_POST['entryId'])) { if ($intEntryId) { $this->strOkMessage = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . ' ' . $_ARRAYLANG['TXT_MEDIADIR_SUCCESSFULLY_EDITED']; } else { $intEntryId = intval($_POST['entryId']); $this->strErrMessage = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . ' ' . $_ARRAYLANG['TXT_MEDIADIR_CORRUPT_EDITED']; } } else { if ($intEntryId) { $this->strOkMessage = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . ' ' . $_ARRAYLANG['TXT_MEDIADIR_SUCCESSFULLY_ADDED']; } else { $this->strErrMessage = $_ARRAYLANG['TXT_MEDIADIR_ENTRY'] . ' ' . $_ARRAYLANG['TXT_MEDIADIR_CORRUPT_ADDED']; } } } //get form id if (intval($intEntryId) != 0) { //get entry data $objEntry = new MediaDirectoryEntry($this->moduleName); $objEntry->getEntries($intEntryId, null, null, null, null, false, false); if (empty($objEntry->arrEntries)) { $objEntry->getEntries($intEntryId, null, null, null, null, true, false); } $intFormId = $objEntry->arrEntries[$intEntryId]['entryFormId']; } else { //set form id if ($intCountForms == 1) { $intFormId = intval($arrActiveForms[0]); } else { $intFormId = intval($_POST['selectedFormId']); } if (!empty($_POST['formId'])) { $intFormId = intval($_POST['formId']); } } //get inputfield object $objInputfields = new MediaDirectoryInputfield($intFormId, false, null, $this->moduleName); //list inputfields $objInputfields->listInputfields($this->_objTpl, 2, $intEntryId); //get translation status date if ($this->arrSettings['settingsTranslationStatus'] == 1) { $ownerRowClass = "row1"; foreach ($this->arrFrontendLanguages as $key => $arrLang) { $strLangStatus = ''; if ($intEntryId != 0) { if (in_array($arrLang['id'], $objEntry->arrEntries[$intEntryId]['entryTranslationStatus'])) { $strLangStatus = 'checked="checked"'; } } $this->_objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_TRANSLATION_LANG_NAME' => htmlspecialchars($arrLang['name'], ENT_QUOTES, CONTREXX_CHARSET), $this->moduleLangVar . '_TRANSLATION_LANG_ID' => intval($arrLang['id']), $this->moduleLangVar . '_TRANSLATION_LANG_STATUS' => $strLangStatus)); $this->_objTpl->parse($this->moduleNameLC . 'TranslationLangList'); } $this->_objTpl->parse($this->moduleNameLC . 'TranslationStatus'); } else { $ownerRowClass = "row2"; $this->_objTpl->hideBlock($this->moduleNameLC . 'TranslationStatus'); } //get user data $objFWUser = \FWUser::getFWUserObject(); $addedBy = isset($objEntry) ? $objEntry->arrEntries[$intEntryId]['entryAddedBy'] : ''; if (!empty($addedBy) && ($objUser = $objFWUser->objUser->getUser($addedBy))) { $userId = $objUser->getId(); } else { $userId = $objFWUser->objUser->getId(); } $this->_objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_OWNER' => $_ARRAYLANG['TXT_MEDIADIR_OWNER'], $this->moduleLangVar . '_OWNER_ROW' => $ownerRowClass, $this->moduleLangVar . '_OWNER_ID' => $userId)); \FWUser::getUserLiveSearch(); if ($intEntryId != 0) { $intEntryDourationStart = 1; $intEntryDourationEnd = 2; //parse contact data $objUser = $objFWUser->objUser; $intUserId = intval($objUser->getId()); $strUserMail = '<a href="mailto:' . contrexx_raw2xhtml($objUser->getEmail()) . '">' . contrexx_raw2xhtml($objUser->getEmail()) . '</a>'; $intUserLang = intval($objUser->getFrontendLanguage()); if ($objUser = $objUser->getUser($id = $intUserId)) { //get lang foreach ($this->arrFrontendLanguages as $intKey => $arrLang) { if ($arrLang['id'] == $intUserLang) { $strUserLang = $arrLang['name']; } } //get country $arrCountry = \Cx\Core\Country\Controller\Country::getById(intval($objUser->getProfileAttribute('country'))); $strCountry = $arrCountry['name']; //get title $objTitle = $objDatabase->Execute("SELECT `title` FROM " . DBPREFIX . "access_user_title WHERE id = '" . intval($objUser->getProfileAttribute('title')) . "' LIMIT 1"); $strTitle = $objTitle->fields['title']; $this->_objTpl->setVariable(array('TXT_' . $this->moduleLangVar . '_CONTACT_DATA' => "Kontaktangaben", $this->moduleLangVar . '_CONTACT_ATTRIBUT_TITLE' => contrexx_raw2xhtml($strTitle), $this->moduleLangVar . '_CONTACT_ATTRIBUT_FIRSTNAME' => contrexx_raw2xhtml($objUser->getProfileAttribute('firstname')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_LASTNAME' => contrexx_raw2xhtml($objUser->getProfileAttribute('lastname')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_COMPANY' => contrexx_raw2xhtml($objUser->getProfileAttribute('company')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_ADRESS' => contrexx_raw2xhtml($objUser->getProfileAttribute('address')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_CITY' => contrexx_raw2xhtml($objUser->getProfileAttribute('city')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_ZIP' => contrexx_raw2xhtml($objUser->getProfileAttribute('zip')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_COUNTRY' => contrexx_raw2xhtml($strCountry), $this->moduleLangVar . '_CONTACT_ATTRIBUT_PHONE' => contrexx_raw2xhtml($objUser->getProfileAttribute('phone_office')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_FAX' => contrexx_raw2xhtml($objUser->getProfileAttribute('phone_fax')), $this->moduleLangVar . '_CONTACT_ATTRIBUT_WEBSITE' => '<a href="' . contrexx_raw2xhtml($objUser->getProfileAttribute('website')) . '" target="_blank">' . contrexx_raw2xhtml($objUser->getProfileAttribute('website')) . '</a>', $this->moduleLangVar . '_CONTACT_ATTRIBUT_MAIL' => $strUserMail, $this->moduleLangVar . '_CONTACT_ATTRIBUT_LANG' => $strUserLang)); } $this->_objTpl->parse($this->moduleNameLC . 'ContactData'); } else { $intEntryDourationStart = 1; $intEntryDourationEnd = 2; $this->_objTpl->hideBlock($this->moduleNameLC . 'ContactData'); } //get display duration data switch ($this->arrSettings['settingsEntryDisplaydurationValueType']) { case 1: $intDiffDay = $this->arrSettings['settingsEntryDisplaydurationValue']; $intDiffMonth = 0; $intDiffYear = 0; break; case 2: $intDiffDay = 0; $intDiffMonth = $this->arrSettings['settingsEntryDisplaydurationValue']; $intDiffYear = 0; break; case 3: $intDiffDay = 0; $intDiffMonth = 0; $intDiffYear = $this->arrSettings['settingsEntryDisplaydurationValue']; break; } if ($intEntryId != 0) { if (intval($objEntry->arrEntries[$intEntryId]['entryDurationType']) == 1) { $intEntryDourationAlways = 'selected="selected"'; $intEntryDourationStart = date("d.m.Y", mktime()); $intEntryDourationEnd = date("d.m.Y", mktime(0, 0, 0, date("m") + $intDiffMonth, date("d") + $intDiffDay, date("Y") + $intDiffYear)); } else { $intEntryDourationPeriod = 'selected="selected"'; $intEntryDourationShowPeriod = 'inline'; $intEntryDourationStart = date("d.m.Y", $objEntry->arrEntries[$intEntryId]['entryDurationStart']); $intEntryDourationEnd = date("d.m.Y", $objEntry->arrEntries[$intEntryId]['entryDurationEnd']); } if (intval($objEntry->arrEntries[$intEntryId]['entryDurationNotification']) == 1) { $this->_objTpl->setVariable(array($this->moduleLangVar . '_DISPLAYDURATION_RESET_NOTIFICATION_STATUS' => '<br /><input type="checkbox" name="durationResetNotification" value="1" /> ' . $_ARRAYLANG['TXT_MEDIADIR_DISPLAYDURATION_RESET_NOTIFICATION_STATUS'])); } } else { if (intval($this->arrSettings['settingsEntryDisplaydurationType']) == 1) { $intEntryDourationAlways = 'selected="selected"'; } else { $intEntryDourationPeriod = 'selected="selected"'; $intEntryDourationShowPeriod = 'inline'; } $intEntryDourationStart = date("d.m.Y", mktime()); $intEntryDourationEnd = date("d.m.Y", mktime(0, 0, 0, date("m") + $intDiffMonth, date("d") + $intDiffDay, date("Y") + $intDiffYear)); } //parse spez fields $this->_objTpl->touchBlock($this->moduleNameLC . 'SpezfieldList'); //generate javascript parent::setJavascript($this->getSelectorJavascript()); parent::setJavascript($objInputfields->getInputfieldJavascript()); //get form onsubmit $strOnSubmit = parent::getFormOnSubmit($objInputfields->arrJavascriptFormOnSubmit); $this->_objTpl->setVariable(array($this->moduleLangVar . '_ENTRY_STATUS' => $intEntryId && intval($objEntry->arrEntries[$intEntryId]['entryActive']) ? 'checked="checked"' : '', $this->moduleLangVar . '_MEDIABROWSER_BUTTON' => $this->getMediaBrowserButton($_ARRAYLANG['TXT_BROWSE'], array('type' => 'button', 'id' => 'mediabrowser_button', 'style' => 'display:none;')))); //parse blocks $this->_objTpl->hideBlock($this->moduleNameLC . 'FormList'); } //parse global variables $this->_objTpl->setGlobalVariable(array('TXT_' . $this->moduleLangVar . '_PAGE_TITLE' => $pageTitle, $this->moduleLangVar . '_ENTRY_ID' => $intEntryId, $this->moduleLangVar . '_FORM_ID' => $intFormId, 'TXT_' . $this->moduleLangVar . '_SUBMIT' => $_ARRAYLANG['TXT_' . $this->moduleLangVar . '_SUBMIT'], $this->moduleLangVar . '_JAVASCRIPT' => $this->getJavascript(), $this->moduleLangVar . '_FORM_ONSUBMIT' => $strOnSubmit, 'TXT_' . $this->moduleLangVar . '_PLEASE_CHECK_INPUT' => $_ARRAYLANG['TXT_MEDIADIR_PLEASE_CHECK_INPUT'], $this->moduleLangVar . '_DEFAULT_LANG_ID' => $_LANGID, 'TXT_' . $this->moduleLangVar . '_SPEZ_FIELDS' => $_ARRAYLANG['TXT_MEDIADIR_SPEZ_FIELDS'], 'TXT_' . $this->moduleLangVar . '_DISPLAYDURATION' => $_ARRAYLANG['TXT_MEDIADIR_DISPLAYDURATION'], 'TXT_' . $this->moduleLangVar . '_DISPLAYDURATION_ALWAYS' => $_ARRAYLANG['TXT_MEDIADIR_DISPLAYDURATION_ALWAYS'], 'TXT_' . $this->moduleLangVar . '_DISPLAYDURATION_PERIOD' => $_ARRAYLANG['TXT_MEDIADIR_DISPLAYDURATION_PERIOD'], 'TXT_' . $this->moduleLangVar . '_DISPLAYDURATION_FROM' => $_CORELANG['TXT_FROM'], 'TXT_' . $this->moduleLangVar . '_DISPLAYDURATION_TO' => $_CORELANG['TXT_TO'], $this->moduleLangVar . '_DISPLAYDURATION_START' => $intEntryDourationStart, $this->moduleLangVar . '_DISPLAYDURATION_END' => $intEntryDourationEnd, $this->moduleLangVar . '_DISPLAYDURATION_SELECT_ALWAYS' => $intEntryDourationAlways, $this->moduleLangVar . '_DISPLAYDURATION_SELECT_PERIOD' => $intEntryDourationPeriod, $this->moduleLangVar . '_DISPLAYDURATION_SHOW_PERIOD' => $intEntryDourationShowPeriod, 'TXT_' . $this->moduleLangVar . '_TRANSLATION_STATUS' => $_ARRAYLANG['TXT_MEDIADIR_TRANSLATION_STATUS'], 'TXT_' . $this->moduleLangVar . '_ENTRY_STATUS' => $_ARRAYLANG['TXT_MEDIADIR_ACTIVE'])); } else { \Cx\Core\Csrf\Controller\Csrf::header("Location: index.php?cmd=" . $this->moduleName . "&act=settings&tpl=forms"); exit; } }
/** * Returns an array of Customer data for MailTemplate substitution * * The password is no longer available in the session if the confirmation * is sent after paying with some external PSP that uses some form of * instant payment notification (i.e. PayPal)! * In that case, it is *NOT* included in the template produced. * Call {@see Shop::sendLogin()} while processing the Order instead. * @return array The Customer data substitution array * @see MailTemplate::substitute() */ function getSubstitutionArray() { global $_ARRAYLANG; // See below. // $index_notes = \Cx\Core\Setting\Controller\Setting::getValue('user_profile_attribute_notes','Shop'); // $index_type = \Cx\Core\Setting\Controller\Setting::getValue('user_attribute_customer_type','Shop'); // $index_reseller = \Cx\Core\Setting\Controller\Setting::getValue('user_attribute_reseller_status','Shop'); $gender = strtoupper($this->gender()); $title = $_ARRAYLANG['TXT_SHOP_TITLE_' . $gender]; $format_salutation = $_ARRAYLANG['TXT_SHOP_SALUTATION_' . $gender]; $salutation = sprintf($format_salutation, $this->firstname(), $this->lastname(), $this->company(), $title); $arrSubstitution = array('CUSTOMER_SALUTATION' => $salutation, 'CUSTOMER_ID' => $this->id(), 'CUSTOMER_EMAIL' => $this->email(), 'CUSTOMER_COMPANY' => $this->company(), 'CUSTOMER_FIRSTNAME' => $this->firstname(), 'CUSTOMER_LASTNAME' => $this->lastname(), 'CUSTOMER_ADDRESS' => $this->address(), 'CUSTOMER_ZIP' => $this->zip(), 'CUSTOMER_CITY' => $this->city(), 'CUSTOMER_COUNTRY' => \Cx\Core\Country\Controller\Country::getNameById($this->country_id()), 'CUSTOMER_PHONE' => $this->phone(), 'CUSTOMER_FAX' => $this->fax(), 'CUSTOMER_USERNAME' => $this->username()); //DBG::log("Login: "******"/".$_SESSION['shop']['password']); if (isset($_SESSION['shop']['password'])) { $arrSubstitution['CUSTOMER_LOGIN'] = array(0 => array('CUSTOMER_USERNAME' => $this->username(), 'CUSTOMER_PASSWORD' => $_SESSION['shop']['password'])); } return $arrSubstitution; }
/** * Stores countries settings * * Returns null if nothing is changed. * @return boolean True on success, false on failure, * or null on noop. */ private static function storeCountries() { // Skip if not submitted or if the list is empty. // At least one Country needs to be active. // "list1" contains the active Country IDs if (empty($_POST['countries']) || empty($_POST['list1'])) { return null; } $list = contrexx_input2raw($_POST['list1']); sort($list); $arrCountryIdActive = array_keys(\Cx\Core\Country\Controller\Country::getNameArray(true)); sort($arrCountryIdActive); if ($list == $arrCountryIdActive) { return null; } self::$changed = true; $strCountryIdActive = join(',', $list); return \Cx\Core\Country\Controller\Country::activate($strCountryIdActive); }
/** * 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('"', '"', 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'] . ' ' . 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() . ' ' . Currency::getActiveCurrencySymbol())); if (Vat::isIncluded()) { $objTemplate->setVariable(array('SHOP_GRAND_TOTAL_EXCL_TAX' => Currency::formatPrice(self::get_price() - self::get_vat_amount()) . ' ' . 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']); } }
/** * This function returns the DataElement * * @param string $name name of the DataElement * @param string $type type of the DataElement * @param int $length length of the DataElement * @param mixed $value value of the DataElement * @param array $options options for the DataElement * @param int $entityId id of the DataElement * @return \Cx\Core\Html\Model\Entity\DataElement */ public function getDataElement($name, $type, $length, $value, &$options, $entityId) { global $_ARRAYLANG, $_CORELANG; if (isset($options['formfield'])) { $formFieldGenerator = $options['formfield']; $formField = ''; /* We use json to do the callback. The 'else if' is for backwards compatibility so you can declare * the function directly without using json. This is not recommended and not working over session */ if (is_array($formFieldGenerator) && isset($formFieldGenerator['adapter']) && isset($formFieldGenerator['method'])) { $json = new \Cx\Core\Json\JsonData(); $jsonResult = $json->data($formFieldGenerator['adapter'], $formFieldGenerator['method'], array('name' => $name, 'type' => $type, 'length' => $length, 'value' => $value, 'options' => $options)); if ($jsonResult['status'] == 'success') { $formField = $jsonResult["data"]; } } else { if (is_callable($formFieldGenerator)) { $formField = $formFieldGenerator($name, $type, $length, $value, $options); } } if (is_a($formField, 'Cx\\Core\\Html\\Model\\Entity\\HtmlElement')) { return $formField; } else { $value = $formField; } } if (isset($options['showDetail']) && $options['showDetail'] === false) { return ''; } switch ($type) { case 'bool': case 'boolean': // yes/no checkboxes $fieldset = new \Cx\Core\Html\Model\Entity\HtmlElement('div'); $inputYes = new \Cx\Core\Html\Model\Entity\DataElement($name, 'yes'); $inputYes->setAttribute('type', 'radio'); $inputYes->setAttribute('value', '1'); $inputYes->setAttribute('id', 'form-' . $this->formId . '-' . $name . '_yes'); if (isset($options['attributes'])) { $inputYes->setAttributes($options['attributes']); } $fieldset->addChild($inputYes); $labelYes = new \Cx\Core\Html\Model\Entity\HtmlElement('label'); $labelYes->setAttribute('for', 'form-' . $this->formId . '-' . $name . '_yes'); $labelYes->addChild(new \Cx\Core\Html\Model\Entity\TextElement($_ARRAYLANG['TXT_YES'])); $fieldset->addChild($labelYes); $inputNo = new \Cx\Core\Html\Model\Entity\DataElement($name, 'no'); $inputNo->setAttribute('id', 'form-' . $this->formId . '-' . $name . '_no'); $inputNo->setAttribute('type', 'radio'); $inputNo->setAttribute('value', '0'); if (isset($options['attributes'])) { $inputNo->setAttributes($options['attributes']); } $fieldset->addChild($inputNo); $labelNo = new \Cx\Core\Html\Model\Entity\HtmlElement('label'); $labelNo->setAttribute('for', 'form-' . $this->formId . '-' . $name . '_no'); $labelNo->addChild(new \Cx\Core\Html\Model\Entity\TextElement($_ARRAYLANG['TXT_NO'])); $fieldset->addChild($labelNo); if ($value) { $inputYes->setAttribute('checked'); } else { $inputNo->setAttribute('checked'); } return $fieldset; break; case 'int': case 'integer': // input field with type number $inputNumber = new \Cx\Core\Html\Model\Entity\DataElement($name, $value, \Cx\Core\Html\Model\Entity\DataElement::TYPE_INPUT, new \Cx\Core\Validate\Model\Entity\RegexValidator('/-?[0-9]*/')); if (isset($options['attributes'])) { $inputNumber->setAttributes($options['attributes']); } $inputNumber->setAttribute('type', 'number'); return $inputNumber; break; case 'Cx\\Model\\Base\\EntityBase': $associatedClass = get_class($value); \JS::registerJS('core/Html/View/Script/Backend.js'); \ContrexxJavascript::getInstance()->setVariable('Form/Error', $_ARRAYLANG['TXT_CORE_HTML_FORM_VALIDATION_ERROR'], 'core/Html/lang'); if (\Env::get('em')->getClassMetadata($this->entityClass)->isSingleValuedAssociation($name)) { // this case is used to create a select field for 1 to 1 associations $entities = \Env::get('em')->getRepository($associatedClass)->findAll(); $foreignMetaData = \Env::get('em')->getClassMetadata($associatedClass); $primaryKeyName = $foreignMetaData->getSingleIdentifierFieldName(); $selected = $foreignMetaData->getFieldValue($value, $primaryKeyName); $arrEntities = array(); $closeMetaData = \Env::get('em')->getClassMetadata($this->entityClass); $assocMapping = $closeMetaData->getAssociationMapping($name); $validator = null; if (!isset($assocMapping['joinColumns'][0]['nullable']) || $assocMapping['joinColumns'][0]['nullable']) { $arrEntities['NULL'] = $_ARRAYLANG['TXT_CORE_NONE']; } else { $validator = new \Cx\Core\Validate\Model\Entity\RegexValidator('/^(?!null$|$)/'); } foreach ($entities as $entity) { $arrEntities[\Env::get('em')->getClassMetadata($associatedClass)->getFieldValue($entity, $primaryKeyName)] = $entity; } $select = new \Cx\Core\Html\Model\Entity\DataElement($name, \Html::getOptions($arrEntities, $selected), \Cx\Core\Html\Model\Entity\DataElement::TYPE_SELECT, $validator); if (isset($options['attributes'])) { $select->setAttributes($options['attributes']); } return $select; } else { // this case is used to list all existing values and show an add button for 1 to many associations $closeMetaData = \Env::get('em')->getClassMetadata($this->entityClass); $assocMapping = $closeMetaData->getAssociationMapping($name); $mainDiv = new \Cx\Core\Html\Model\Entity\HtmlElement('div'); $mainDiv->setAttribute('class', 'entityList'); $addButton = new \Cx\Core\Html\Model\Entity\HtmlElement('input'); $addButton->setAttribute('type', 'button'); $addButton->setClass(array('form-control', 'add_' . $this->createCssClassNameFromEntity($associatedClass), 'mappedAssocciationButton')); $addButton->setAttribute('value', $_CORELANG['TXT_ADD']); $addButton->setAttribute('data-params', 'entityClass:' . $associatedClass . ';' . 'mappedBy:' . $assocMapping['mappedBy'] . ';' . 'cssName:' . $this->createCssClassNameFromEntity($associatedClass) . ';' . 'sessionKey:' . $this->entityClass); if (!isset($_SESSION['vgOptions'])) { $_SESSION['vgOptions'] = array(); } $_SESSION['vgOptions'][$this->entityClass] = $this->componentOptions; if ($entityId != 0) { // if we edit the main form, we also want to show the existing associated values we already have $existingValues = $this->getIdentifyingDisplayValue($assocMapping, $associatedClass, $entityId); } if (!empty($existingValues)) { foreach ($existingValues as $existingValue) { $mainDiv->addChild($existingValue); } } $mainDiv->addChild($addButton); // if standard tooltip is not disabled, we load the one to n association text if (!isset($options['showstanardtooltip']) || $options['showstanardtooltip']) { if (!empty($options['tooltip'])) { $options['tooltip'] = $options['tooltip'] . '<br /><br /> ' . $_ARRAYLANG['TXT_CORE_RECORD_ONE_TO_N_ASSOCIATION']; } else { $options['tooltip'] = $_ARRAYLANG['TXT_CORE_RECORD_ONE_TO_N_ASSOCIATION']; } } $cxjs = \ContrexxJavascript::getInstance(); $cxjs->setVariable('TXT_CANCEL', $_CORELANG['TXT_CANCEL'], 'Html/lang'); $cxjs->setVariable('TXT_SUBMIT', $_CORELANG['TXT_SUBMIT'], 'Html/lang'); $cxjs->setVariable('TXT_EDIT', $_CORELANG['TXT_EDIT'], 'Html/lang'); $cxjs->setVariable('TXT_DELETE', $_CORELANG['TXT_DELETE'], 'Html/lang'); return $mainDiv; } break; case 'Country': // this is for customizing only: $data = \Cx\Core\Country\Controller\Country::getNameById($value); if (empty($data)) { $value = 204; } $options = \Cx\Core\Country\Controller\Country::getMenuoptions($value); $select = new \Cx\Core\Html\Model\Entity\DataElement($name, $options, \Cx\Core\Html\Model\Entity\DataElement::TYPE_SELECT); if (isset($options['attributes'])) { $select->setAttributes($options['attributes']); } return $select; break; case 'DateTime': case 'datetime': case 'date': // input field with type text and class datepicker if ($value instanceof \DateTime) { $value = $value->format(ASCMS_DATE_FORMAT); } if (is_null($value)) { $value = ''; } $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value); $input->setAttribute('type', 'text'); $input->setAttribute('class', 'datepicker'); if (isset($options['readonly']) && $options['readonly']) { $input->setAttribute('disabled'); } if (isset($options['attributes'])) { $input->setAttributes($options['attributes']); } \DateTimeTools::addDatepickerJs(); \JS::registerCode(' cx.jQuery(function() { cx.jQuery(".datepicker").datetimepicker(); }); '); return $input; break; case 'multiselect': case 'select': $values = array(); if (isset($options['validValues'])) { if (is_array($options['validValues'])) { $values = $options['validValues']; } else { $values = explode(',', $options['validValues']); $values = array_combine($values, $values); } } if ($type == 'multiselect') { $value = explode(',', $value); $value = array_combine($value, $value); } $selectOptions = \Html::getOptions($values, $value); $select = new \Cx\Core\Html\Model\Entity\DataElement($name, $selectOptions, \Cx\Core\Html\Model\Entity\DataElement::TYPE_SELECT); if ($type == 'multiselect') { $select->setAttribute('multiple'); } if (isset($options['attributes'])) { $select->setAttributes($options['attributes']); } return $select; break; case 'slider': // this code should not be here // create sorrounding div $element = new \Cx\Core\Html\Model\Entity\HtmlElement('div'); // create div for slider $slider = new \Cx\Core\Html\Model\Entity\HtmlElement('div'); $slider->setAttribute('class', 'slider'); $element->addChild($slider); // create hidden input for slider value $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value + 0, \Cx\Core\Html\Model\Entity\DataElement::TYPE_INPUT); $input->setAttribute('type', 'hidden'); if (isset($options['attributes'])) { $input->setAttributes($options['attributes']); } $element->addChild($input); // add javascript to update input value $min = 0; $max = 10; if (isset($options['validValues'])) { $values = explode(',', $options['validValues']); $min = $values[0]; if (isset($values[1])) { $max = $values[1]; } } if (!isset($value)) { $value = 0; } $script = new \Cx\Core\Html\Model\Entity\HtmlElement('script'); $script->addChild(new \Cx\Core\Html\Model\Entity\TextElement(' cx.jQuery("#form-' . $this->formId . '-' . $name . ' .slider").slider({ value: ' . ($value + 0) . ', min: ' . ($min + 0) . ', max: ' . ($max + 0) . ', slide: function( event, ui ) { cx.jQuery("input[name=' . $name . ']").val(ui.value); cx.jQuery("input[name=' . $name . ']").change(); } }); ')); $element->addChild($script); return $element; break; case 'checkboxes': $dataElementGroupType = \Cx\Core\Html\Model\Entity\DataElementGroup::TYPE_CHECKBOX; case 'radio': $values = array(); if (isset($options['validValues'])) { $values = explode(',', $options['validValues']); $values = array_combine($values, $values); } if (!isset($dataElementGroupType)) { $dataElementGroupType = \Cx\Core\Html\Model\Entity\DataElementGroup::TYPE_RADIO; } $radio = new \Cx\Core\Html\Model\Entity\DataElementGroup($name, $values, $value, $dataElementGroupType); if (isset($options['attributes'])) { $radio->setAttributes($options['attributes']); } return $radio; break; case 'text': // textarea $textarea = new \Cx\Core\Html\Model\Entity\HtmlElement('textarea'); $textarea->setAttribute('name', $name); if (isset($options['readonly']) && $options['readonly']) { $textarea->setAttribute('disabled'); } $textarea->addChild(new \Cx\Core\Html\Model\Entity\TextElement($value)); if (isset($options['attributes'])) { $textarea->setAttributes($options['attributes']); } return $textarea; break; case 'phone': // input field with type phone $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value); $input->setAttribute('type', 'phone'); if (isset($options['readonly']) && $options['readonly']) { $input->setAttribute('disabled'); } if (isset($options['attributes'])) { $input->setAttributes($options['attributes']); } return $input; break; case 'mail': // input field with type mail $emailValidator = new \Cx\Core\Validate\Model\Entity\EmailValidator(); $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value, 'input', $emailValidator); $input->setAttribute('onkeyup', $emailValidator->getJavaScriptCode()); $input->setAttribute('type', 'mail'); if (isset($options['attributes'])) { $input->setAttributes($options['attributes']); } if (isset($options['readonly']) && $options['readonly']) { $input->setAttribute('disabled'); } return $input; break; case 'uploader': \JS::registerCode(' function javascript_callback_function(data) { if(data.type=="file") { cx.jQuery("#' . $name . '").val(data.data[0].datainfo.filepath); } } '); $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser(); $mediaBrowser->setOptions(array('type' => 'button')); $mediaBrowser->setCallback('javascript_callback_function'); $mediaBrowser->setOptions(array('data-cx-mb-views' => 'filebrowser,uploader', 'id' => 'page_target_browse', 'cxMbStartview' => 'MediaBrowserList')); $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value); $input->setAttribute('type', 'text'); $input->setAttribute('id', $name); $div = new \Cx\Core\Html\Model\Entity\HtmlElement('div'); $div->addChild($input); $div->addChild(new \Cx\Core\Html\Model\Entity\TextElement($mb = $mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE']))); return $div; break; case 'image': \JS::registerCode(' function javascript_callback_function(data) { if ( data.data[0].datainfo.extension=="Jpg" || data.data[0].datainfo.extension=="Gif" || data.data[0].datainfo.extension=="Png" ) { cx.jQuery("#' . $name . '").attr(\'value\', data.data[0].datainfo.filepath); cx.jQuery("#' . $name . '").prevAll(\'.deletePreviewImage\').first().css(\'display\', \'inline-block\'); cx.jQuery("#' . $name . '").prevAll(\'.previewImage\').first().attr(\'src\', data.data[0].datainfo.filepath); } } jQuery(document).ready(function(){ jQuery(\'.deletePreviewImage\').click(function(){ cx.jQuery("#' . $name . '").attr(\'value\', \'\'); cx.jQuery(this).prev(\'img\').attr(\'src\', \'/images/Downloads/no_picture.gif\'); cx.jQuery(this).css(\'display\', \'none\'); cx.jQuery(this).nextAll(\'input\').first().attr(\'value\', \'\'); }); }); '); $mediaBrowser = new \Cx\Core_Modules\MediaBrowser\Model\Entity\MediaBrowser(); $mediaBrowser->setOptions(array('type' => 'button')); $mediaBrowser->setCallback('javascript_callback_function'); $defaultOptions = array('data-cx-mb-views' => 'filebrowser,uploader', 'id' => 'page_target_browse', 'cxMbStartview' => 'MediaBrowserList'); $mediaBrowser->setOptions(is_array($options['options']) ? array_merge($defaultOptions, $options['options']) : $defaultOptions); // create hidden input to save image $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value); $input->setAttribute('type', 'hidden'); $input->setAttribute('id', $name); $div = new \Cx\Core\Html\Model\Entity\HtmlElement('div'); if (isset($value) && in_array(pathinfo($value, PATHINFO_EXTENSION), array('gif', 'jpg', 'png')) || $name == 'imagePath') { // this image is meant to be a preview of the selected image $previewImage = new \Cx\Core\Html\Model\Entity\HtmlElement('img'); $previewImage->setAttribute('class', 'previewImage'); $previewImage->setAttribute('src', $value != '' ? $value : '/images/Downloads/no_picture.gif'); // this image is uesd as delete function for the selected image over javascript $deleteImage = new \Cx\Core\Html\Model\Entity\HtmlElement('img'); $deleteImage->setAttribute('class', 'deletePreviewImage'); $deleteImage->setAttribute('src', '/core/Core/View/Media/icons/delete.gif'); $div->addChild($previewImage); $div->addChild($deleteImage); $div->addChild(new \Cx\Core\Html\Model\Entity\HtmlElement('br')); } $div->addChild($input); $div->addChild(new \Cx\Core\Html\Model\Entity\TextElement($mediaBrowser->getXHtml($_ARRAYLANG['TXT_CORE_CM_BROWSE']))); return $div; break; case 'sourcecode': //set mode $mode = 'html'; if (isset($options['options']['mode'])) { switch ($options['options']['mode']) { case 'js': $mode = 'javascript'; break; case 'yml': case 'yaml': $mode = 'yaml'; break; } } //define textarea $textarea = new \Cx\Core\Html\Model\Entity\HtmlElement('textarea'); $textarea->setAttribute('name', $name); $textarea->setAttribute('id', $name); $textarea->setAttribute('style', 'display:none;'); $textarea->addChild(new \Cx\Core\Html\Model\Entity\TextElement($value)); //define pre $pre = new \Cx\Core\Html\Model\Entity\HtmlElement('pre'); $pre->setAttribute('id', 'editor-' . $name); $pre->addChild(new \Cx\Core\Html\Model\Entity\TextElement(contrexx_raw2xhtml($value))); //set readonly if necessary $readonly = ''; if (isset($options['readonly']) && $options['readonly']) { $readonly = 'editor.setReadOnly(true);'; $textarea->setAttribute('disabled'); } //create div and add all stuff $div = new \Cx\Core\Html\Model\Entity\HtmlElement('div'); // required for the Ace editor to work. Otherwise // it won't be visible as the DIV does have a width of 0px. $div->setAttribute('style', 'display:block;'); $div->addChild($textarea); $div->addChild($pre); //register js $jsCode = <<<CODE var editor; \$J(function(){ if (\$J("#editor-{$name}").length) { editor = ace.edit("editor-{$name}"); editor.getSession().setMode("ace/mode/{$mode}"); editor.setShowPrintMargin(false); editor.focus(); editor.gotoLine(1); {$readonly} } \$J('form').submit(function(){ \$J('#{$name}').val(editor.getSession().getValue()); }); }); CODE; \JS::activate('ace'); \JS::registerCode($jsCode); return $div; break; case 'string': case 'hidden': default: // convert NULL to empty string if (is_null($value)) { $value = ''; } // input field with type text $input = new \Cx\Core\Html\Model\Entity\DataElement($name, $value); if (isset($options['validValues'])) { $input->setValidator(new \Cx\Core\Validate\Model\Entity\RegexValidator('/^' . $options['validValues'] . '$/')); } if ($type == 'hidden') { $input->setAttribute('type', 'hidden'); } else { $input->setAttribute('type', 'text'); $input->setClass('form-control'); } if (isset($options['readonly']) && $options['readonly']) { $input->setAttribute('disabled'); } if (isset($options['attributes'])) { $input->setAttributes($options['attributes']); } return $input; break; } }
/** * Get all countries. * * @access public * @param array $arrIDs ids of requested transactions * @param integer $offset paging offset * @param integer $limit paging limit * @return array $arrTransactions contains all transactions * @return boolean contains false if there are no transactions */ public function get($arrIDs = array(), $offset = 0, $limit = 0) { $SQLWhere = ''; if (is_array($arrIDs) && !empty($arrIDs)) { $arrIDs = array_map('intval', $arrIDs); $SQLWhere = ' WHERE (`transactions`.`id`=' . implode(' OR `transactions`.`id`=', $arrIDs) . ')'; } $SQLLimit = ''; if (!empty($offset) && !empty($limit)) { $SQLLimit = ' LIMIT ' . intval($offset) . ', ' . intval($limit); } else { if (empty($offset) && !empty($limit)) { $SQLLimit = ' LIMIT ' . intval($limit); } } $countries = \Cx\Core\Country\Controller\Country::getNameArray(); $arrTransactions = array(); $objResult = $this->objDatabase->Execute(' SELECT `transactions`.`id`, `transactions`.`time`, `transactions`.`status`, `transactions`.`invoice_number`, `transactions`.`invoice_currency`, `transactions`.`invoice_amount`, `transactions`.`contact_title`, `transactions`.`contact_forename`, `transactions`.`contact_surname`, `transactions`.`contact_company`, `transactions`.`contact_street`, `transactions`.`contact_postcode`, `transactions`.`contact_place`, `countries`.`name` as `contact_country`, `transactions`.`contact_phone`, `transactions`.`contact_email` FROM `' . DBPREFIX . 'module_checkout_transactions` as `transactions` ' . $SQLWhere . ' ORDER BY `transactions`.`id` DESC' . $SQLLimit); if ($objResult) { $i = 0; while (!$objResult->EOF) { $arrTransactions[$i]['id'] = $objResult->fields['id']; $arrTransactions[$i]['time'] = $objResult->fields['time']; $arrTransactions[$i]['status'] = $objResult->fields['status']; $arrTransactions[$i]['invoice_number'] = $objResult->fields['invoice_number']; $arrTransactions[$i]['invoice_currency'] = $objResult->fields['invoice_currency']; $arrTransactions[$i]['invoice_amount'] = $objResult->fields['invoice_amount'] / 100; $arrTransactions[$i]['contact_title'] = $objResult->fields['contact_title']; $arrTransactions[$i]['contact_forename'] = $objResult->fields['contact_forename']; $arrTransactions[$i]['contact_surname'] = $objResult->fields['contact_surname']; $arrTransactions[$i]['contact_company'] = $objResult->fields['contact_company']; $arrTransactions[$i]['contact_street'] = $objResult->fields['contact_street']; $arrTransactions[$i]['contact_postcode'] = $objResult->fields['contact_postcode']; $arrTransactions[$i]['contact_place'] = $objResult->fields['contact_place']; $arrTransactions[$i]['contact_country'] = $countries[$objResult->fields['contact_country']]; $arrTransactions[$i]['contact_phone'] = $objResult->fields['contact_phone']; $arrTransactions[$i]['contact_email'] = $objResult->fields['contact_email']; $objResult->MoveNext(); $i++; } } if (!empty($arrTransactions)) { return $arrTransactions; } else { return false; } }
/** * Show the contact page * * Parse a contact form submit request and show the contact page * @see _getContactFormData(), _checkValues(), _insertIntoDatabase(), sendMail(), _showError(), _showFeedback(), \Cx\Core\Html\Sigma::get(), \Cx\Core\Html\Sigma::blockExists(), \Cx\Core\Html\Sigma::hideBlock(), \Cx\Core\Html\Sigma::touchBlock() * @return string Parse contact form page */ function getContactPage() { global $_ARRAYLANG, $_LANGID, $objDatabase; \JS::activate('cx'); $formId = isset($_GET['cmd']) ? intval($_GET['cmd']) : 0; $arrFields = $this->getFormFields($formId); $isLoggedin = $this->setProfileData(); $useCaptcha = !$isLoggedin && $this->getContactFormCaptchaStatus($formId); $this->handleUniqueId(); $uploaderCode = ''; // load requested form's source code if required if ($this->objTemplate->placeholderExists('APPLICATION_DATA')) { // load form's source code $applicationTemplate = $this->getSourceCode($formId, $_LANGID); \LinkGenerator::parseTemplate($applicationTemplate); $this->objTemplate->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate); } $this->objTemplate->setVariable(array('TXT_NEW_ENTRY_ERORR' => $_ARRAYLANG['TXT_NEW_ENTRY_ERORR'], 'TXT_CONTACT_SUBMIT' => $_ARRAYLANG['TXT_CONTACT_SUBMIT'], 'TXT_CONTACT_RESET' => $_ARRAYLANG['TXT_CONTACT_RESET'])); if ($this->objTemplate->blockExists('contact_form')) { $recipients = $this->getRecipients($formId); foreach ($arrFields as $fieldId => $arrField) { /* * Set values for special field types if the user is authenticated */ if ($isLoggedin && empty($_GET[$fieldId]) && empty($_POST['contactFormField_' . $fieldId])) { switch ($arrField['special_type']) { case 'access_email': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_USER_EMAIL]]'; break; case 'access_gender': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_GENDER]]'; break; case 'access_title': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_TITLE]]'; break; case 'access_firstname': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_FIRSTNAME]]'; break; case 'access_lastname': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_LASTNAME]]'; break; case 'access_company': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_COMPANY]]'; break; case 'access_address': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_ADDRESS]]'; break; case 'access_city': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_CITY]]'; break; case 'access_zip': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_ZIP]]'; break; case 'access_country': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_COUNTRY]]'; break; case 'access_phone_office': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_PHONE_OFFICE]]'; break; case 'access_phone_private': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_PHONE_PRIVATE]]'; break; case 'access_phone_mobile': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_PHONE_MOBILE]]'; break; case 'access_phone_fax': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_PHONE_FAX]]'; break; case 'access_birthday': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_BIRTHDAY]]'; break; case 'access_website': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_WEBSITE]]'; break; case 'access_profession': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_PROFESSION]]'; break; case 'access_interests': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_INTERESTS]]'; break; case 'access_signature': $arrField['lang'][$_LANGID]['value'] = '[[ACCESS_PROFILE_ATTRIBUTE_SIGNATURE]]'; break; default: break; } } $arrField['lang'][$_LANGID]['value'] = preg_replace('/\\[\\[([A-Z0-9_]+)\\]\\]/', '{$1}', $arrField['lang'][$_LANGID]['value']); $this->objTemplate->setVariable(array($formId . '_FORM_NAME' => wordwrap($this->arrForms[$formId]['lang'][$_LANGID]['name'], 90, "<br/>\n", true), $formId . '_FORM_TEXT' => $this->arrForms[$formId]['lang'][$_LANGID]['text'], $fieldId . '_LABEL' => $arrField['lang'][$_LANGID]['name'] != "" ? wordwrap($arrField['lang'][$_LANGID]['name'], 90, "<br/>\n", true) : " ")); /* * Generate values for dropdown checkbox and radio fields */ $userProfileRegExp = '/\\{([A-Z_]+)\\}/'; $accessAttributeId = null; $fieldType = $arrField['type'] != 'special' ? $arrField['type'] : $arrField['special_type']; switch ($fieldType) { case 'checkbox': if ($arrField['lang'][$_LANGID]['value'] == 1 || !empty($_POST['contactFormField_' . $fieldId])) { $this->objTemplate->setVariable('SELECTED_' . $fieldId, 'checked="checked"'); } break; case 'checkboxGroup': case 'radio': $options = explode(',', $arrField['lang'][$_LANGID]['value']); foreach ($options as $index => $option) { if (preg_match($userProfileRegExp, $option)) { $valuePlaceholderBlock = 'contact_value_placeholder_block_' . $fieldId . '_' . $index; $this->objTemplate->addBlock($fieldId . '_' . $index . '_VALUE', $valuePlaceholderBlock, contrexx_raw2xhtml($option)); } else { $this->objTemplate->setVariable($fieldId . '_' . $index . '_VALUE', contrexx_raw2xhtml($option)); } if (!empty($_POST['contactFormField_' . $fieldId])) { if (in_array($option, $_POST['contactFormField_' . $fieldId]) || $option == $_POST['contactFormField_' . $fieldId]) { $this->objTemplate->setVariable('SELECTED_' . $fieldId . '_' . $index, 'checked="checked"'); } } elseif (!empty($_GET[$fieldId])) { if ($option == $_GET[$fieldId]) { $this->objTemplate->setVariable('SELECTED_' . $fieldId . '_' . $index, 'checked="checked"'); } } } break; case 'access_title': case 'access_gender': // collect user attribute options $arrOptions = array(); $accessAttributeId = str_replace('access_', '', $fieldType); $objAttribute = \FWUser::getFWUserObject()->objUser->objAttribute->getById($accessAttributeId); // get options $arrAttribute = $objAttribute->getChildren(); foreach ($arrAttribute as $attributeId) { // in case the selection of the field is mandatory, we shall skip the unknown option of the user profile attribute if ($arrField['is_required'] && strpos($attributeId, '_undefined')) { continue; } $objAttribute = \FWUser::getFWUserObject()->objUser->objAttribute->getById($attributeId); $arrOptions[] = $objAttribute->getName(FRONTEND_LANG_ID); } // options will be used for select input generation $arrField['lang'][FRONTEND_LANG_ID]['value'] = implode(',', $arrOptions); // intentionally no break here!! // intentionally no break here!! case 'select': $options = explode(',', $arrField['lang'][$_LANGID]['value']); $inexOffset = 0; if ($arrField['is_required']) { $options = array_merge(array($_ARRAYLANG['TXT_CONTACT_PLEASE_SELECT']), $options); $inexOffset = 1; } foreach ($options as $index => $option) { if (preg_match($userProfileRegExp, $option)) { $valuePlaceholderBlock = 'contact_value_placeholder_block_' . $fieldId . '_' . $index; $this->objTemplate->addBlock($fieldId . '_VALUE', $valuePlaceholderBlock, contrexx_raw2xhtml($option)); } else { $this->objTemplate->setVariable($fieldId . '_VALUE', contrexx_raw2xhtml($option)); } // pre-selection, based on $_POST value if (!empty($_POST['contactFormField_' . $fieldId])) { if ($index == array_search($_POST['contactFormField_' . $fieldId], explode(',', $arrField['lang'][$_LANGID]['value'])) + $inexOffset) { $this->objTemplate->setVariable('SELECTED_' . $fieldId, 'selected = "selected"'); } // pre-selection, based on $_GET value } elseif (!empty($_GET[$fieldId])) { if ($index == array_search(contrexx_input2raw($_GET[$fieldId]), explode(',', $arrField['lang'][$_LANGID]['value']))) { $this->objTemplate->setVariable('SELECTED_' . $fieldId, 'selected = "selected"'); } // pre-selection, based on profile data of currently signed in user } elseif (isset($this->objTemplate->_globalVariables['ACCESS_PROFILE_ATTRIBUTE_' . strtoupper($accessAttributeId)]) && $option == $this->objTemplate->_globalVariables['ACCESS_PROFILE_ATTRIBUTE_' . strtoupper($accessAttributeId)]) { $this->objTemplate->setVariable('SELECTED_' . $fieldId, 'selected = "selected"'); } $this->objTemplate->parse('field_' . $fieldId); } break; case 'recipient': foreach ($recipients as $index => $recipient) { $recipient['lang'][$_LANGID] = preg_replace('/\\[\\[([A-Z0-9_]+)\\]\\]/', '{$1}', $recipient['lang'][$_LANGID]); if (preg_match($userProfileRegExp, $recipient['lang'][$_LANGID])) { $valuePlaceholderBlock = 'contact_value_placeholder_block_' . $fieldId . '_' . $index; $this->objTemplate->addBlock($fieldId . '_VALUE', $valuePlaceholderBlock, $recipient['lang'][$_LANGID]); } else { $this->objTemplate->setVariable(array($fieldId . '_VALUE' => $recipient['lang'][$_LANGID])); } $this->objTemplate->setVariable(array($fieldId . '_VALUE_ID' => $index)); if (!empty($_POST['contactFormField_' . $fieldId]) && $recipient['lang'][$_LANGID] == $_POST['contactFormField_' . $fieldId]) { $this->objTemplate->setVariable(array('SELECTED_' . $fieldId => 'selected = "selected"')); } elseif (!empty($_GET[$fieldId]) && $recipient['lang'][$_LANGID] == $_GET[$fieldId]) { $this->objTemplate->setVariable(array('SELECTED_' . $fieldId => 'selected = "selected"')); } $this->objTemplate->parse('field_' . $fieldId); } break; case 'access_country': case 'country': if (preg_match($userProfileRegExp, $arrField['lang'][$_LANGID]['value'])) { $arrField['lang'][$_LANGID]['value'] = $this->objTemplate->_globalVariables[trim($arrField['lang'][$_LANGID]['value'], '{}')]; } $lang = $arrField['lang'][$_LANGID]['value']; $country = \Cx\Core\Country\Controller\Country::getNameArray(true, $lang); foreach ($country as $id => $name) { $this->objTemplate->setVariable($fieldId . '_VALUE', $name); if (!empty($_POST['contactFormField_' . $fieldId])) { if (strcasecmp($name, $_POST['contactFormField_' . $fieldId]) == 0) { $this->objTemplate->setVariable('SELECTED_' . $fieldId, 'selected = "selected"'); } } elseif (!empty($_GET[$fieldId])) { if (strcasecmp($name, $_GET[$fieldId]) == 0) { $this->objTemplate->setVariable('SELECTED_' . $fieldId, 'selected = "selected"'); } } elseif ($name == $arrField['lang'][$_LANGID]['value']) { $this->objTemplate->setVariable('SELECTED_' . $fieldId, 'selected = "selected"'); } $this->objTemplate->parse('field_' . $fieldId); } $this->objTemplate->setVariable(array('TXT_CONTACT_PLEASE_SELECT' => $_ARRAYLANG['TXT_CONTACT_PLEASE_SELECT'], 'TXT_CONTACT_NOT_SPECIFIED' => $_ARRAYLANG['TXT_CONTACT_NOT_SPECIFIED'])); break; case 'file': $this->hasFileField = true; $uploaderCode .= $this->initUploader($fieldId, true); break; case 'multi_file': $this->hasFileField = true; $uploaderCode .= $this->initUploader($fieldId, false); break; default: /* * Set default field value through User profile attribute */ $arrField['lang'][$_LANGID]['value'] = preg_replace('/\\[\\[([A-Z0-9_]+)\\]\\]/', '{$1}', $arrField['lang'][$_LANGID]['value']); if (preg_match($userProfileRegExp, $arrField['lang'][$_LANGID]['value'])) { $valuePlaceholderBlock = 'contact_value_placeholder_block_' . $fieldId; $this->objTemplate->addBlock($fieldId . '_VALUE', $valuePlaceholderBlock, contrexx_raw2xhtml($arrField['lang'][$_LANGID]['value'])); } elseif (!empty($_POST['contactFormField_' . $fieldId])) { $this->objTemplate->setVariable($fieldId . '_VALUE', contrexx_raw2xhtml($_POST['contactFormField_' . $fieldId])); } elseif (!empty($_GET[$fieldId])) { $this->objTemplate->setVariable($fieldId . '_VALUE', contrexx_raw2xhtml($_GET[$fieldId])); } else { $this->objTemplate->setVariable($fieldId . '_VALUE', contrexx_raw2xhtml($arrField['lang'][$_LANGID]['value'])); } break; } /* * Parse the blocks created for parsing user profile data using addBlock() */ if (!empty($valuePlaceholderBlock) && $this->objTemplate->blockExists($valuePlaceholderBlock)) { $this->objTemplate->touchBlock($valuePlaceholderBlock); } } } if (isset($_POST['submitContactForm']) || isset($_POST['Submit'])) { //form submitted $this->checkLegacyMode(); $showThanks = isset($_GET['cmd']) && $_GET['cmd'] == 'thanks' ? true : false; $arrFormData = $this->_getContactFormData(); if ($arrFormData) { if ($this->_checkValues($arrFormData, $useCaptcha) && $this->_insertIntoDatabase($arrFormData)) { //validation ok if (!empty($arrFormData['saveDataInCRM'])) { $objCrmLibrary = new \Cx\Modules\Crm\Controller\CrmLibrary('Crm'); $objCrmLibrary->addCrmContact($arrFormData); } $this->sendMail($arrFormData); if (isset($arrFormData['showForm']) && !$arrFormData['showForm']) { $this->objTemplate->hideBlock("formText"); $this->objTemplate->hideBlock('contact_form'); } } else { //found errors while validating $this->setCaptcha($useCaptcha); return $this->_showError(); } if (!$showThanks) { $this->_showFeedback($arrFormData); } else { if ($this->objTemplate->blockExists("formText")) { $this->objTemplate->hideBlock("formText"); } } } } else { //fresh display if ($this->objTemplate->blockExists('formText')) { $this->objTemplate->touchBlock('formText'); } $this->setCaptcha($useCaptcha); } $this->objTemplate->setVariable('CONTACT_JAVASCRIPT', $this->_getJsSourceCode($formId, $arrFields) . $uploaderCode); return $this->objTemplate->get(); }
/** * 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; }