当前位置: 首页>>代码示例>>PHP>>正文


PHP Country::containsStates方法代码示例

本文整理汇总了PHP中Country::containsStates方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::containsStates方法的具体用法?PHP Country::containsStates怎么用?PHP Country::containsStates使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Country的用法示例。


在下文中一共展示了Country::containsStates方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRpZone

 public function getRpZone($addr)
 {
     if (!Country::containsStates($addr->id_country)) {
         return 0;
     }
     if (!$addr->id_state) {
         return 0;
     }
     $row = Db::getInstance()->getRow("SELECT * FROM `{$this->tableWithPrefix}` WHERE `id_state` = {$addr->id_state} AND `active` = 1");
     if (!isset($row['id_post_zone'])) {
         return 0;
     }
     return $row['id_post_zone'];
 }
开发者ID:qant,项目名称:russianpostcarrier,代码行数:14,代码来源:RussianPost.php

示例2: getRpZone

 public function getRpZone($addr)
 {
     if (!Country::containsStates($addr->id_country)) {
         return 0;
     }
     if (!$addr->id_state) {
         return 0;
     }
     $row = RussianPost::$db->getRow("SELECT * FROM `{$this->tableWithPrefix}` WHERE `id_state` = {$addr->id_state} AND `active` = 1");
     if (!isset($row['id_post_zone'])) {
         return 0;
     }
     return $row['id_post_zone'];
     //$row = $this->dbconn->getRow("SELECT ");
 }
开发者ID:HueJack,项目名称:russianpostcarrier,代码行数:15,代码来源:RussianPost.php

示例3: getState

 private function getState()
 {
     $result = null;
     if ((int) $this->state == 0) {
         return $result;
     }
     if (Country::containsStates((int) $this->id_country)) {
         $state = new State((int) $this->id_state);
         if (!Validate::isLoadedObject($state)) {
             $result = null;
         } elseif (!$state->id_country == (int) $this->id_country) {
             $result = null;
         } else {
             $result = (int) $state->id;
         }
     }
     return $result;
 }
开发者ID:pedalracer,项目名称:free_modules_1.5,代码行数:18,代码来源:MoussiqFreeService.php

示例4: generate

 public function generate()
 {
     $this->tpl = $this->createTemplate($this->base_tpl);
     if (is_null($this->submit_action)) {
         $this->submit_action = 'submitAdd' . $this->table;
     }
     $this->context->controller->addJS(_PS_JS_DIR_ . 'form.js');
     $categories = true;
     $color = true;
     $date = true;
     $tinymce = true;
     foreach ($this->fields_form as $fieldset_key => &$fieldset) {
         if (isset($fieldset['form']['input'])) {
             foreach ($fieldset['form']['input'] as $key => &$params) {
                 // If the condition is not met, the field will not be displayed
                 if (isset($params['condition']) && !$params['condition']) {
                     unset($this->fields_form[$fieldset_key]['form']['input'][$key]);
                 }
                 switch ($params['type']) {
                     case 'categories':
                         if ($categories) {
                             // Added Jquery plugin treeview (css and js files)
                             $this->context->controller->addJqueryPlugin('treeview-categories');
                             // Added JS files
                             $this->context->controller->addJS(_PS_JS_DIR_ . 'jquery/plugins/treeview-categories/jquery.treeview-categories.async.js');
                             $this->context->controller->addJS(_PS_JS_DIR_ . 'jquery/plugins/treeview-categories/jquery.treeview-categories.edit.js');
                             $this->context->controller->addJS(_PS_JS_DIR_ . 'admin-categories-tree.js');
                             if (isset($params['use_search']) && $params['use_search']) {
                                 $this->context->controller->addJS(_PS_JS_DIR_ . 'jquery/plugins/autocomplete/jquery.autocomplete.js');
                             }
                             $categories = false;
                         }
                         break;
                     case 'color':
                         if ($color) {
                             // Added JS file
                             $this->context->controller->addJS(_PS_JS_DIR_ . 'jquery/plugins/jquery.colorpicker.js');
                             $color = false;
                         }
                         break;
                     case 'date':
                         if ($date) {
                             $this->context->controller->addJqueryUI('ui.datepicker');
                             $date = false;
                         }
                         break;
                     case 'textarea':
                         if ($tinymce) {
                             $iso = $this->context->language->iso_code;
                             $this->tpl_vars['iso'] = file_exists(_PS_ROOT_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en';
                             $this->tpl_vars['path_css'] = _THEME_CSS_DIR_;
                             $this->tpl_vars['ad'] = dirname($_SERVER['PHP_SELF']);
                             $this->tpl_vars['tinymce'] = true;
                             $this->context->controller->addJS(_PS_JS_DIR_ . 'tiny_mce/tiny_mce.js');
                             $this->context->controller->addJS(_PS_JS_DIR_ . 'tinymce.inc.js');
                             $tinymce = false;
                         }
                         break;
                     case 'shop':
                         $disable_shops = isset($params['disable_shared']) ? $params['disable_shared'] : false;
                         $params['html'] = $this->renderAssoShop($disable_shops);
                         if (Shop::getTotalShops(false) == 1) {
                             unset($this->fields_form[$fieldset_key]['form']['input'][$key]);
                         }
                         break;
                 }
             }
         }
     }
     $this->tpl->assign(array('title' => $this->title, 'toolbar_btn' => $this->toolbar_btn, 'show_toolbar' => $this->show_toolbar, 'toolbar_scroll' => $this->toolbar_scroll, 'submit_action' => $this->submit_action, 'firstCall' => $this->first_call, 'current' => $this->currentIndex, 'token' => $this->token, 'table' => $this->table, 'identifier' => $this->identifier, 'name_controller' => $this->name_controller, 'languages' => $this->languages, 'defaultFormLanguage' => $this->default_form_language, 'allowEmployeeFormLang' => $this->allow_employee_form_lang, 'form_id' => $this->id, 'fields' => $this->fields_form, 'fields_value' => $this->fields_value, 'required_fields' => $this->getFieldsRequired(), 'vat_number' => file_exists(_PS_MODULE_DIR_ . 'vatnumber/ajax.php'), 'module_dir' => _MODULE_DIR_, 'contains_states' => isset($this->fields_value['id_country']) && isset($this->fields_value['id_state']) ? Country::containsStates($this->fields_value['id_country']) : null));
     return parent::generate();
 }
开发者ID:jicheng17,项目名称:vipinsg,代码行数:72,代码来源:HelperForm.php

示例5: createSellerInfo

 public static function createSellerInfo($customer, $address, $seller_emp)
 {
     ${"GLOBALS"}["qjdqsmikhyx"] = "sellerinfo";
     $yhqkobb = "id_sellerinfo";
     global $cookie;
     ${${"GLOBALS"}["xgwqqivqgrf"]} = SellerInfo::getIdBSellerId($seller_emp->id);
     ${${"GLOBALS"}["qjdqsmikhyx"]} = new SellerInfo(${$yhqkobb});
     $sellerinfo->id_customer = $customer->id;
     $sellerinfo->id_seller = $seller_emp->id;
     $sellerinfo->approved = intval(Configuration::get("AGILE_MS_SELLER_APPROVAL")) == 1 ? 0 : 1;
     if (Tools::getValue("signin")) {
         $qilskqt = "languages";
         $sellerinfo->id_country = intval(Tools::getValue("id_country"));
         ${"GLOBALS"}["cjvrzut"] = "languages";
         if (Country::containsStates($sellerinfo->id_country)) {
             $sellerinfo->id_state = intval(Tools::getValue("id_state"));
         }
         $sellerinfo->postcode = Tools::getValue("postcode");
         $sellerinfo->phone = Tools::getValue("phone");
         ${$qilskqt} = Language::getLanguages(false);
         foreach (${${"GLOBALS"}["cjvrzut"]} as ${${"GLOBALS"}["vdilblgqwe"]}) {
             ${"GLOBALS"}["egyhwy"] = "lang";
             $parkrxwevda = "lang";
             $sellerinfo->company[${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]] = Tools::getValue("company_" . ${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]);
             $sellerinfo->city[${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]] = Tools::getValue("city_" . ${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]);
             $sellerinfo->address1[${${"GLOBALS"}["egyhwy"]}["id_lang"]] = Tools::getValue("address1_" . ${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]);
             $sellerinfo->address2[${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]] = Tools::getValue("address2_" . ${$parkrxwevda}["id_lang"]);
         }
     } else {
         $fuyjkdnrw = "languages";
         $sellerinfo->id_country = $address->id_country;
         $sellerinfo->id_state = $address->id_state;
         $sellerinfo->postcode = $address->postcode;
         $sellerinfo->phone = $address->phone;
         ${${"GLOBALS"}["wcurgtbzth"]} = empty($address->company) ? $customer->firstname . " " . $customer->lastname : $address->company;
         ${$fuyjkdnrw} = Language::getLanguages(false);
         foreach (${${"GLOBALS"}["lchilkwh"]} as ${${"GLOBALS"}["vdilblgqwe"]}) {
             $sellerinfo->company[${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]] = ${${"GLOBALS"}["wcurgtbzth"]};
             $sellerinfo->city[${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]] = $address->city;
             $sellerinfo->address1[${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]] = $address->address1;
             $sellerinfo->address2[${${"GLOBALS"}["vdilblgqwe"]}["id_lang"]] = $address->address2;
         }
     }
     $sellerinfo->longitude = 0;
     $sellerinfo->latitude = 0;
     $sellerinfo->ams_custom_date1 = "1900-01-01";
     $sellerinfo->ams_custom_date2 = "1900-01-01";
     $sellerinfo->ams_custom_date3 = "1900-01-01";
     $sellerinfo->ams_custom_date4 = "1900-01-01";
     $sellerinfo->ams_custom_date5 = "1900-01-01";
     if ($sellerinfo->save()) {
         if (Module::isInstalled("agilemultipleshop") && $sellerinfo->id_shop <= 0) {
             ${"GLOBALS"}["wbhwjpwmjrh"] = "shop_name";
             ${"GLOBALS"}["plelmru"] = "shop_name";
             include_once _PS_ROOT_DIR_ . "/modules/agilemultipleshop/agilemultipleshop.php";
             ${${"GLOBALS"}["wbhwjpwmjrh"]} = $sellerinfo->company[$cookie->id_lang];
             $jpxkuueptq = "shop_name";
             if (empty(${$jpxkuueptq})) {
                 ${${"GLOBALS"}["plelmru"]} = $seller_emp->firstname . "-" . $seller_emp->lastname;
             }
             $sellerinfo->id_shop = AgileMultipleShop::create_new_shop($sellerinfo->id_seller, $sellerinfo->company[$cookie->id_lang]);
             $sellerinfo->update();
         }
     }
     ${"GLOBALS"}["ciniqzqxiff"] = "sellerinfo";
     return ${${"GLOBALS"}["ciniqzqxiff"]};
 }
开发者ID:sho5kubota,项目名称:guidingyou2,代码行数:67,代码来源:AgileMultipleSellerBase.php

示例6: generate


//.........这里部分代码省略.........
                         if ($categories) {
                             if (!isset($params['tree']['id'])) {
                                 throw new PrestaShopException('Id must be filled for categories tree');
                             }
                             $tree = new HelperTreeCategories($params['tree']['id'], isset($params['tree']['title']) ? $params['tree']['title'] : null);
                             if (isset($params['name'])) {
                                 $tree->setInputName($params['name']);
                             }
                             if (isset($params['tree']['selected_categories'])) {
                                 $tree->setSelectedCategories($params['tree']['selected_categories']);
                             }
                             if (isset($params['tree']['disabled_categories'])) {
                                 $tree->setDisabledCategories($params['tree']['disabled_categories']);
                             }
                             if (isset($params['tree']['root_category'])) {
                                 $tree->setRootCategory($params['tree']['root_category']);
                             }
                             if (isset($params['tree']['use_search'])) {
                                 $tree->setUseSearch($params['tree']['use_search']);
                             }
                             if (isset($params['tree']['use_checkbox'])) {
                                 $tree->setUseCheckBox($params['tree']['use_checkbox']);
                             }
                             if (isset($params['tree']['set_data'])) {
                                 $tree->setData($params['tree']['set_data']);
                             }
                             $this->context->smarty->assign('categories_tree', $tree->render());
                             $categories = false;
                         }
                         break;
                     case 'file':
                         $uploader = new HelperUploader();
                         $uploader->setId(isset($params['id']) ? $params['id'] : null);
                         $uploader->setName($params['name']);
                         $uploader->setUrl(isset($params['url']) ? $params['url'] : null);
                         $uploader->setMultiple(isset($params['multiple']) ? $params['multiple'] : false);
                         $uploader->setUseAjax(isset($params['ajax']) ? $params['ajax'] : false);
                         $uploader->setMaxFiles(isset($params['max_files']) ? $params['max_files'] : null);
                         if (isset($params['files']) && $params['files']) {
                             $uploader->setFiles($params['files']);
                         } elseif (isset($params['image']) && $params['image']) {
                             // Use for retrocompatibility
                             $uploader->setFiles(array(0 => array('type' => HelperUploader::TYPE_IMAGE, 'image' => isset($params['image']) ? $params['image'] : null, 'size' => isset($params['size']) ? $params['size'] : null, 'delete_url' => isset($params['delete_url']) ? $params['delete_url'] : null)));
                         }
                         if (isset($params['file']) && $params['file']) {
                             // Use for retrocompatibility
                             $uploader->setFiles(array(0 => array('type' => HelperUploader::TYPE_FILE, 'size' => isset($params['size']) ? $params['size'] : null, 'delete_url' => isset($params['delete_url']) ? $params['delete_url'] : null, 'download_url' => isset($params['file']) ? $params['file'] : null)));
                         }
                         if (isset($params['thumb']) && $params['thumb']) {
                             // Use for retrocompatibility
                             $uploader->setFiles(array(0 => array('type' => HelperUploader::TYPE_IMAGE, 'image' => isset($params['thumb']) ? '<img src="' . $params['thumb'] . '" alt="' . (isset($params['title']) ? $params['title'] : '') . '" title="' . (isset($params['title']) ? $params['title'] : '') . '" />' : null)));
                         }
                         $uploader->setTitle(isset($params['title']) ? $params['title'] : null);
                         $params['file'] = $uploader->render();
                         break;
                     case 'color':
                         if ($color) {
                             // Added JS file
                             $this->context->controller->addJqueryPlugin('colorpicker');
                             $color = false;
                         }
                         break;
                     case 'date':
                         if ($date) {
                             $this->context->controller->addJqueryUI('ui.datepicker');
                             $date = false;
                         }
                         break;
                     case 'textarea':
                         if ($tinymce) {
                             $iso = $this->context->language->iso_code;
                             $this->tpl_vars['iso'] = file_exists(_PS_CORE_DIR_ . '/js/tiny_mce/langs/' . $iso . '.js') ? $iso : 'en';
                             $this->tpl_vars['path_css'] = _THEME_CSS_DIR_;
                             $this->tpl_vars['ad'] = __PS_BASE_URI__ . basename(_PS_ADMIN_DIR_);
                             $this->tpl_vars['tinymce'] = true;
                             $this->context->controller->addJS(_PS_JS_DIR_ . 'tiny_mce/tiny_mce.js');
                             $this->context->controller->addJS(_PS_JS_DIR_ . 'admin/tinymce.inc.js');
                             $tinymce = false;
                         }
                         if ($textarea_autosize) {
                             $this->context->controller->addJqueryPlugin('autosize');
                             $textarea_autosize = false;
                         }
                         break;
                     case 'shop':
                         $disable_shops = isset($params['disable_shared']) ? $params['disable_shared'] : false;
                         $params['html'] = $this->renderAssoShop($disable_shops);
                         if (Shop::getTotalShops(false) == 1) {
                             if (isset($this->fields_form[$fieldset_key]['form']['force']) && !$this->fields_form[$fieldset_key]['form']['force'] || !isset($this->fields_form[$fieldset_key]['form']['force'])) {
                                 unset($this->fields_form[$fieldset_key]['form']['input'][$key]);
                             }
                         }
                         break;
                 }
             }
         }
     }
     $this->tpl->assign(array('title' => $this->title, 'toolbar_btn' => $this->toolbar_btn, 'show_toolbar' => $this->show_toolbar, 'toolbar_scroll' => $this->toolbar_scroll, 'submit_action' => $this->submit_action, 'firstCall' => $this->first_call, 'current' => $this->currentIndex, 'token' => $this->token, 'table' => $this->table, 'identifier' => $this->identifier, 'name_controller' => $this->name_controller, 'languages' => $this->languages, 'current_id_lang' => $this->context->language->id, 'defaultFormLanguage' => $this->default_form_language, 'allowEmployeeFormLang' => $this->allow_employee_form_lang, 'form_id' => $this->id, 'tabs' => isset($tabs) ? $tabs : null, 'fields' => $this->fields_form, 'fields_value' => $this->fields_value, 'required_fields' => $this->getFieldsRequired(), 'vat_number' => Module::isInstalled('vatnumber') && file_exists(_PS_MODULE_DIR_ . 'vatnumber/ajax.php'), 'module_dir' => _MODULE_DIR_, 'base_url' => $this->context->shop->getBaseURL(), 'contains_states' => isset($this->fields_value['id_country']) && isset($this->fields_value['id_state']) ? Country::containsStates($this->fields_value['id_country']) : null, 'show_cancel_button' => $this->show_cancel_button, 'back_url' => $this->back_url));
     return parent::generate();
 }
开发者ID:prestanesia,项目名称:PrestaShop,代码行数:101,代码来源:HelperForm.php

示例7: defined

<?php

defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);
require_once dirname(__FILE__) . '../../config/config.inc.php';
require_once dirname(__FILE__) . '../../init.php';
$data = array();
$id_country = Country::getIdByName(1, Tools::getValue('country'));
$contain_state = Country::containsStates($id_country);
if ($contain_state) {
    $states = State::getStatesByIdCountry($id_country);
    $data['states'] = $states;
}
$data['id_country'] = $id_country;
$data['contain_state'] = $contain_state;
echo json_encode($data);
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:15,代码来源:ajax_state_prod.php

示例8: setCustomerAddress

/**
 * Set customer address (when not logged in)
 * Used to create user address with PayPal account information
 */
function setCustomerAddress($ppec, $customer, $id = null)
{
    $address = new Address($id);
    $address->id_country = Country::getByIso($ppec->result['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE']);
    if ($id == null) {
        $address->alias = 'Paypal_Address';
    }
    $address->lastname = $customer->lastname;
    $address->firstname = $customer->firstname;
    $address->address1 = $ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET'];
    if (isset($ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET2'])) {
        $address->address2 = $ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET2'];
    }
    $address->city = $ppec->result['PAYMENTREQUEST_0_SHIPTOCITY'];
    if (Country::containsStates($address->id_country)) {
        $address->id_state = (int) State::getIdByIso($ppec->result['PAYMENTREQUEST_0_SHIPTOSTATE'], $address->id_country);
    }
    $address->postcode = $ppec->result['PAYMENTREQUEST_0_SHIPTOZIP'];
    if (isset($ppec->result['PAYMENTREQUEST_0_SHIPTOPHONENUM'])) {
        $address->phone = $ppec->result['PAYMENTREQUEST_0_SHIPTOPHONENUM'];
    }
    $address->id_customer = $customer->id;
    return $address;
}
开发者ID:pacxs,项目名称:pacxscom,代码行数:28,代码来源:payment.php

示例9: displayForm


//.........这里部分代码省略.........
					<div class="margin-form">
					<input type="text" size="33" name="address1" value="' . htmlentities($this->getFieldValue($obj, 'address1'), ENT_COMPAT, 'UTF-8') . '" /> <sup>*</sup>
					</div>';
            } elseif ($addr_field_item == 'address2') {
                echo '
					<label>' . $this->l('Address') . ' (2)</label>
									     <div class="margin-form">
												      <input type="text" size="33" name="address2" value="' . htmlentities($this->getFieldValue($obj, 'address2'), ENT_COMPAT, 'UTF-8') . '" />
															      </div>';
            } elseif ($addr_field_item == 'postcode') {
                echo '
					<label>' . $this->l('Postcode/ Zip Code') . '</label>
					<div class="margin-form">
					<input type="text" size="33" name="postcode" value="' . htmlentities($this->getFieldValue($obj, 'postcode'), ENT_COMPAT, 'UTF-8') . '" />
					</div>';
            } elseif ($addr_field_item == 'city') {
                echo '
					<label>' . $this->l('City') . '</label>
					<div class="margin-form">
					<input type="text" size="33" name="city" value="' . htmlentities($this->getFieldValue($obj, 'city'), ENT_COMPAT, 'UTF-8') . '" style="text-transform: uppercase;" /> <sup>*</sup>
					</div>';
            } elseif ($addr_field_item == 'country' || $addr_field_item == 'Country:name') {
                echo '
					<label>' . $this->l('Country') . '</label>
					<div class="margin-form">
					<select name="id_country" id="id_country" />';
                $selectedCountry = $this->getFieldValue($obj, 'id_country');
                foreach ($this->countriesArray as $id_country => $name) {
                    echo '		<option value="' . $id_country . '"' . ((!$selectedCountry and Configuration::get('PS_COUNTRY_DEFAULT') == $id_country) ? ' selected="selected"' : ($selectedCountry == $id_country ? ' selected="selected"' : '')) . '>' . $name . '</option>';
                }
                echo '		</select> <sup>*</sup>
					</div>';
                echo '
				<div id="contains_states" ' . (!Country::containsStates((int) $selectedCountry) ? 'style="display:none;"' : '') . '>
				<label>' . $this->l('State') . '</label>
				<div class="margin-form">
				<select name="id_state" id="id_state">
				</select>
				<sup>*</sup>
				</div>
				</div>';
                $id_country_ajax = (int) $this->getFieldValue($obj, 'id_country');
                echo '
					<script type="text/javascript">
					$(document).ready(function(){
							ajaxStates ();
							$(\'#id_country\').change(function() {
								ajaxStates ();
								});
							function ajaxStates ()
							{
								$.ajax({
									url: "ajax.php",
									cache: false,
									data: "ajaxStates=1&id_country="+$(\'#id_country\').val()+"&id_state="+$(\'#id_state\').val(),
									success: function(html)
										{
											if (html == \'false\')
											{
												$("#contains_states").fadeOut();
												$(\'#id_state option[value=0]\').attr("selected", "selected");
}
											else
											{
												$("#id_state").html(html);
												$("#contains_states").fadeIn();
开发者ID:nicolasjeol,项目名称:hec-ecommerce,代码行数:67,代码来源:AdminAddresses.php

示例10: getCsvDefaults

 public static function getCsvDefaults($serviceId)
 {
     $sql = '
     SELECT *
     FROM `' . _DB_PREFIX_ . 'moussiqfree_service`
     WHERE `id_moussiqfree_service` = ' . (int) $serviceId;
     if (!($result = Db::getInstance()->getRow($sql))) {
         return false;
     }
     $configuration = Configuration::getMultiple(array('EXPORTFREE_COUNTRY', 'EXPORTFREE_STATE', 'EXPORTFREE_CARRIER', 'EXPORTFREE_STORE', 'EXPORTFREE_SHOP', 'EXPORTFREE_GROUP', 'EXPORTFREE_DELIMITER', 'EXPORTFREE_HEADER', 'EXPORTFREE_INACTIVE', 'EXPORTFREE_LANGUAGE', 'EXPORTFREE_ENCLOSURE'));
     $data = $result;
     $data['id_country'] = (int) self::findCorrectDefault($result['id_country'], $configuration['EXPORTFREE_COUNTRY']);
     $data['id_state'] = (int) self::findCorrectDefault($result['id_state'], $configuration['EXPORTFREE_STATE']);
     $data['id_carrier'] = (int) self::findCorrectDefault($result['id_carrier'], $configuration['EXPORTFREE_CARRIER']);
     $data['id_store'] = (int) self::findCorrectDefault($result['id_store'], $configuration['EXPORTFREE_STORE']);
     $data['id_shop'] = (int) self::findCorrectDefault($result['id_shop'], $configuration['EXPORTFREE_SHOP']);
     $data['id_group'] = (int) self::findCorrectDefault($result['id_group'], $configuration['EXPORTFREE_GROUP']);
     $data['header'] = (int) self::findCorrectDefault($result['header'], $configuration['EXPORTFREE_HEADER']);
     $data['id_lang'] = (int) self::findCorrectDefault($result['id_lang'], $configuration['EXPORTFREE_LANGUAGE']);
     $data['export_inactive'] = self::findCorrectDefault($result['export_inactive'], $configuration['EXPORTFREE_INACTIVE'], true);
     $data['name'] = pSQL($result['name']);
     $data['template'] = ExportTools::jsonDecode(addcslashes(base64_decode($result['template']), "\\"));
     if (!Country::containsStates($data['id_country'])) {
         $data['id_state'] = false;
     }
     return $data;
 }
开发者ID:pedalracer,项目名称:free_modules_1.5,代码行数:27,代码来源:Export.php

示例11: createPredefServices

 public function createPredefServices($dir = 'templates_predef')
 {
     // create predefined services from templates_predef directory
     $cdir = dirname(__FILE__);
     $sdir = dir($cdir . '/' . $dir);
     while (($item = $sdir->read()) !== false) {
         if (!is_dir($cdir . '/' . $dir . '/' . $item)) {
             $file = $cdir . '/' . $dir . '/' . $item;
             $extension = strrchr($file, '.');
             if ($extension == '.mtpl') {
                 $template = file($file, FILE_SKIP_EMPTY_LINES);
                 $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT');
                 $defaultCarrier = 0;
                 $defaultCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
                 $defaultState = 0;
                 $defaultCondition = 'new:used:refurbished';
                 $defaultStore = (int) Db::getInstance()->getValue('SELECT `id_store` FROM `' . _DB_PREFIX_ . 'store`');
                 $defaultGroup = (int) Db::getInstance()->getValue('SELECT `id_group` FROM `' . _DB_PREFIX_ . 'group`');
                 $engine = 'ExportCSV';
                 if (Country::containsStates($defaultCountry)) {
                     $states = State::getStatesByIdCountry($defaultCountry);
                     if (sizeof($states)) {
                         $defaultState = (int) $states[0]['id_state'];
                     }
                 }
                 $carriers = Carrier::getCarriers($defaultLanguage, true);
                 if ($carriers && sizeof($carriers)) {
                     $defaultCarrier = (int) $carriers[0]['id_carrier'];
                 }
                 $additionalProperties = array('id_lang' => $defaultLanguage, 'id_country' => $defaultCountry, 'id_state' => $defaultState, 'id_carrier' => $defaultCarrier, 'id_store' => $defaultStore, 'id_group' => $defaultGroup, 'export_engine' => $engine, 'condition' => $defaultCondition);
                 if (sizeof($template) > 0) {
                     $obj = new MoussiqFreeService();
                     foreach ($template as $line) {
                         $line = explode(':', $line);
                         $field = pSQL(base64_decode($line[0]));
                         if ($field == 'template') {
                             $line[1] = base64_decode($line[1]);
                         }
                         $value = base64_decode($line[1]);
                         //print_r(pSQL(base64_decode($line[1])));
                         //print_r($value);
                         if (property_exists($obj, $field)) {
                             $obj->{$field} = $value;
                         }
                         foreach ($additionalProperties as $prop => $val) {
                             if (property_exists($obj, $prop)) {
                                 $obj->{$prop} = $val;
                             }
                         }
                     }
                     if (!$obj->save()) {
                         return false;
                     }
                 }
             }
         }
     }
 }
开发者ID:pedalracer,项目名称:free_modules_1.5,代码行数:58,代码来源:moussiqfree.php

示例12: createServiceFromTemplate

 protected function createServiceFromTemplate($file)
 {
     if (empty($file['name'])) {
         $this->_errors[] = $this->l('Please select a file from your computer');
         return false;
     }
     $extension = strrchr($file['name'], '.');
     if ($extension == '.gz' && !function_exists('gzopen')) {
         $this->_errors[] = $this->l('Your server does not support gz functions, please unpack the file locally and upload again');
         return false;
     }
     if ($extension == '.mtpl') {
         $template = file($file['tmp_name'], FILE_SKIP_EMPTY_LINES);
     } elseif ($extension == '.gz') {
         $template = gzfile($file['tmp_name']);
     } else {
         $this->_errors[] = $this->l('Unknown file format');
         return false;
     }
     $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT');
     $defaultCarrier = 0;
     $defaultCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
     $defaultState = 0;
     $defaultCondition = 'new:used:refurbished';
     $defaultStore = (int) Db::getInstance()->getValue('SELECT `id_store` FROM `' . _DB_PREFIX_ . 'store`');
     $defaultGroup = (int) Db::getInstance()->getValue('SELECT `id_group` FROM `' . _DB_PREFIX_ . 'group`');
     $engines = self::getExportEnginesForSetup();
     if (!sizeof($engines)) {
         $this->_errors[] = $this->l('Please add export engines first');
         return false;
     }
     $engine = $engines[0]['engine'];
     if (Country::containsStates($defaultCountry)) {
         $states = State::getStatesByIdCountry($defaultCountry);
         if (sizeof($states)) {
             $defaultState = (int) $states[0]['id_state'];
         }
     }
     $carriers = Carrier::getCarriers($defaultLanguage, true);
     if ($carriers && sizeof($carriers)) {
         $defaultCarrier = (int) $carriers[0]['id_carrier'];
     }
     $additionalProperties = array('id_lang' => $defaultLanguage, 'id_country' => $defaultCountry, 'id_state' => $defaultState, 'id_carrier' => $defaultCarrier, 'id_store' => $defaultStore, 'export_engine' => $engine, 'condition' => $defaultCondition);
     if (sizeof($template) > 0) {
         $obj = new $this->className();
         foreach ($template as $line) {
             $line = explode(':', $line);
             $field = pSQL(base64_decode($line[0]));
             if ($field == 'template') {
                 $line[1] = base64_decode($line[1]);
             }
             $value = base64_decode($line[1]);
             //print_r(pSQL(base64_decode($line[1])));
             //print_r($value);
             if (property_exists($obj, $field)) {
                 $obj->{$field} = $value;
             }
             foreach ($additionalProperties as $prop => $val) {
                 if (property_exists($obj, $prop)) {
                     $obj->{$prop} = $val;
                 }
             }
         }
         if (!$obj->save()) {
             $this->_errors[] = $this->l('A service could not be added, an error occured during an attemt to copy file data into module');
             return false;
         }
     }
 }
开发者ID:pedalracer,项目名称:free_modules_1.5,代码行数:69,代码来源:AdminMoussiqFree.php


注:本文中的Country::containsStates方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。