本文整理汇总了PHP中Shop::isFeatureActive方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::isFeatureActive方法的具体用法?PHP Shop::isFeatureActive怎么用?PHP Shop::isFeatureActive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shop
的用法示例。
在下文中一共展示了Shop::isFeatureActive方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
public function install()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
return parent::install() && $this->registerHook('actionObjectCustomerUpdateAfter') && $this->registerHook('actionObjectCustomerUpdateBefore');
}
示例2: getContent
public function getContent()
{
$output = '';
$output .= '<div style="display:block;" class="hint">
On some versions you have to disable Cache save than open your shop home page than go back and enable it.<br/>
Advanced Parameters > Performance > Clear Smarty cache<br /><br/>
Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL off -> Save<br />
Go to back office -> Preferences -> SEO and URLs -> Set userfriendly URL on -> Save<br />
</div><br />';
$sql = 'SELECT * FROM `' . _DB_PREFIX_ . 'product_lang`
WHERE `link_rewrite`
IN (SELECT `link_rewrite` FROM `' . _DB_PREFIX_ . 'product_lang`
GROUP BY `link_rewrite`, `id_lang`
HAVING count(`link_rewrite`) > 1)';
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
$sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
}
if ($results = Db::getInstance()->ExecuteS($sql)) {
$output .= 'You need to fix duplicate URL entries<br/>';
foreach ($results as $row) {
$language_info = $this->context->language->getLanguage($row['id_lang']);
$output .= $row['name'] . ' (' . $row['id_product'] . ') - ' . $row['link_rewrite'] . '<br/>';
$shop_info = $this->context->shop->getShop($language_info['id_shop']);
$output .= 'Language:' . $language_info['name'] . '<br /> Shop:' . $shop_info['name'] . '<br/><br/>';
}
} else {
$output .= 'Nice you don\'t have any duplicate URL entries.';
}
return $output;
}
示例3: init
public function init()
{
if ($product_rewrite = Tools::getValue('product_rewrite')) {
$url_id_pattern = '/.*?([0-9]+)\\-([a-zA-Z0-9-]*)(\\.html)?/';
$lang_id = (int) Context::getContext()->language->id;
$sql = 'SELECT `id_product`
FROM `' . _DB_PREFIX_ . 'product_lang`
WHERE `link_rewrite` = \'' . pSQL(str_replace('.html', '', $product_rewrite)) . '\' AND `id_lang` = ' . $lang_id;
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
$sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
}
$id_product = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
if ($id_product > 0) {
$_GET['id_product'] = $id_product;
} elseif (preg_match($url_id_pattern, $this->request_uri, $url_parts)) {
$sql = 'SELECT `id_product`
FROM `' . _DB_PREFIX_ . 'product_lang`
WHERE `id_product` = \'' . pSQL($url_parts[1]) . '\' AND `id_lang` = ' . $lang_id;
if (Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP) {
$sql .= ' AND `id_shop` = ' . (int) Shop::getContextShopID();
}
$id_product = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($sql);
if ($id_product > 0) {
$_GET['id_product'] = $id_product;
}
}
}
parent::init();
}
示例4: __construct
public function __construct()
{
$this->name = 'magicredirect';
$this->tab = 'seo';
$this->version = '1.1.4';
$this->author = 'AgenceMalttt';
$this->secure_key = Tools::encrypt($this->name);
$this->need_instance = 0;
$this->bootstrap = true;
$this->module_key = 'a3e63c648fcae16db808f68e1eb18448';
$this->ps_versions_compliancy = array('min' => '1.6.0.0', 'max' => _PS_VERSION_);
$this->tabs_form = array('general' => $this->l('General Settings'), 'cache' => $this->l('Cache Settings'));
$models = glob(_PS_MODULE_DIR_ . $this->name . '/models/*.php');
if (!empty($models)) {
foreach ($models as $file) {
if (!strpos($file, 'index.php')) {
require_once $file;
}
}
}
if (Shop::isFeatureActive()) {
Shop::addTableAssociation('redirect', array('type' => 'shop'));
}
$this->fields_form = array(array('name' => 'MGRT_AUTOCATCH', 'type' => 'radio', 'desc' => $this->l('Catch all 404 Url\'s and log them for future redirections'), 'label' => $this->l('Catch 404 and log them'), 'default' => '1', 'tab' => 'general', 'values' => array(array('id' => 'type_4_0', 'value' => 0, 'label' => $this->l('No')), array('id' => 'type_4_1', 'value' => 1, 'label' => $this->l('Yes')))), array('name' => 'MGRT_AUTOACTIVE', 'type' => 'radio', 'desc' => $this->l('Activate all generated rules by automatic catcher'), 'label' => $this->l('Activate all generated rules'), 'default' => '0', 'tab' => 'general', 'values' => array(array('id' => 'type_5_0', 'value' => 0, 'label' => $this->l('No')), array('id' => 'type_5_1', 'value' => 1, 'label' => $this->l('Yes')))), array('name' => 'MGRT_DELPARENTREDIR', 'type' => 'radio', 'desc' => $this->l('Redirect dead object (product, category, manufacturer, supplier, cms page, cms category) to their natural parent.'), 'label' => $this->l('Redirect to parent if deleted.'), 'default' => '1', 'tab' => 'general', 'values' => array(array('id' => 'type_6_0', 'value' => 0, 'label' => $this->l('No')), array('id' => 'type_6_1', 'value' => 1, 'label' => $this->l('Yes')))), array('name' => 'MGRT_AUTOPARENTREDIR', 'type' => 'radio', 'desc' => $this->l('Redirect disabled object (product, category, cms page, cms category, supplier, manufacturer) to their natural parent.'), 'label' => $this->l('Redirect to parent if disabled'), 'default' => '1', 'tab' => 'general', 'values' => array(array('id' => 'type_707_0', 'value' => 0, 'label' => $this->l('No')), array('id' => 'type_707_1', 'value' => 1, 'label' => $this->l('Yes')))), array('name' => 'MGRT_HOOKDISP', 'type' => 'radio', 'desc' => $this->l('Display an remember on admin dashboard when there is new 404 to take a look.'), 'label' => $this->l('Display new 404 alert on Admin Dashboard'), 'default' => '1', 'tab' => 'general', 'values' => array(array('id' => 'type_d_0', 'value' => 0, 'label' => $this->l('No')), array('id' => 'type_d_1', 'value' => 1, 'label' => $this->l('Yes')))), array('name' => 'MGRT_URLCACHE', 'type' => 'radio', 'desc' => $this->l('Enable cache for URL rules'), 'label' => $this->l('Faster redirects with cache'), 'default' => '1', 'tab' => 'cache', 'values' => array(array('id' => 'type_4_0', 'value' => 0, 'label' => $this->l('No')), array('id' => 'type_4_1', 'value' => 1, 'label' => $this->l('Yes')))), array('name' => 'MGRT_CACHETIME', 'type' => 'text', 'desc' => $this->l('Cache time (in minutes)'), 'label' => $this->l('Cache time (in minutes)'), 'default' => '60', 'validate' => 'isInt', 'tab' => 'cache'));
$this->hooks = array('header', 'dashboardZoneOne', 'actionObjectUpdateAfter', 'actionObjectDeleteBefore');
$this->cache_folder = _PS_CACHE_DIR_ . $this->name . '/cache/';
$this->secure_key = Tools::encrypt($this->name);
parent::__construct();
$this->displayName = $this->l('Magic Redirect');
$this->description = $this->l('Predictive and easy redirect tools (Multishop/Multilang)');
}
示例5: __construct
public function __construct()
{
$this->table = 'smart_blog_comment';
$this->className = 'Blogcomment';
$this->module = 'smartblog';
$this->context = Context::getContext();
$this->bootstrap = true;
if (Shop::isFeatureActive()) {
Shop::addTableAssociation($this->table, array('type' => 'shop'));
}
parent::__construct();
$this->fields_list = array('id_smart_blog_comment' => array('title' => $this->l('Id'), 'width' => 50, 'type' => 'text'), 'email' => array('title' => $this->l('Email'), 'width' => 50, 'type' => 'text', 'lang' => true), 'meta_title' => array('title' => $this->l('Post Title'), 'filter_key' => 'smp!meta_title', 'align' => 'center'), 'name' => array('title' => $this->l('Name'), 'width' => 150, 'type' => 'text'), 'content' => array('title' => $this->l('Comment'), 'width' => 200, 'type' => 'text', 'callback' => 'getCommentClean'), 'created' => array('title' => $this->l('Date'), 'width' => 60, 'type' => 'text', 'lang' => true), 'active' => array('title' => $this->l('Status'), 'width' => '70', 'align' => 'center', 'active' => 'status', 'type' => 'bool', 'orderby' => false));
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'icon' => 'icon-trash', 'confirm' => $this->l('Delete selected items?')));
$this->_join = ' LEFT JOIN ' . _DB_PREFIX_ . 'smart_blog_comment_shop sbs ON a.id_smart_blog_comment=sbs.id_smart_blog_comment && sbs.id_shop IN(' . implode(',', Shop::getContextListShopID()) . ')';
$this->_join .= ' LEFT JOIN ' . _DB_PREFIX_ . 'smart_blog_post_lang smp ON a.id_post=smp.id_smart_blog_post and smp.id_lang = ' . (int) Context::getContext()->language->id;
$this->_select = 'sbs.id_shop';
$this->_defaultOrderBy = 'a.id_smart_blog_comment';
$this->_defaultOrderWay = 'DESC';
$this->_select = 'smp.meta_title';
//$this->_defaultOrderBy = 'a.id_smart_blog_comment';
if (Shop::isFeatureActive() && Shop::getContext() != Shop::CONTEXT_SHOP) {
$this->_group = 'GROUP BY a.id_smart_blog_comment';
}
parent::__construct();
}
示例6: renderForm
public function renderForm()
{
$this->fields_form = array('legend' => array('title' => $this->l('Stores'), 'image' => '../img/admin/home.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'size' => 33, 'required' => false, 'hint' => sprintf($this->l('Allowed characters: letters, spaces and %s'), '().-'), 'desc' => $this->l('Store name (e.g. Citycentre Mall Store)')), array('type' => 'text', 'label' => $this->l('Address'), 'name' => 'address1', 'size' => 33, 'required' => true), array('type' => 'text', 'label' => $this->l('Address (2)'), 'name' => 'address2', 'size' => 33), array('type' => 'text', 'label' => $this->l('Postal Code/Zip Code'), 'name' => 'postcode', 'size' => 6, 'required' => true), array('type' => 'text', 'label' => $this->l('City'), 'name' => 'city', 'size' => 33, 'required' => true), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => true, 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'required' => true, 'options' => array('id' => 'id_state', 'name' => 'name', 'query' => null)), array('type' => 'latitude', 'label' => $this->l('Latitude / Longitude'), 'name' => 'latitude', 'required' => true, 'size' => 11, 'maxlength' => 12, 'desc' => $this->l('Store coordinates (e.g. 45.265469/-47.226478)')), array('type' => 'text', 'label' => $this->l('Phone'), 'name' => 'phone', 'size' => 33), array('type' => 'text', 'label' => $this->l('Fax'), 'name' => 'fax', 'size' => 33), array('type' => 'text', 'label' => $this->l('E-mail address'), 'name' => 'email', 'size' => 33), array('type' => 'textarea', 'label' => $this->l('Note'), 'name' => 'note', 'cols' => 42, 'rows' => 4), array('type' => 'radio', 'label' => $this->l('Status'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Whether or not to display this store'))), 'rightCols' => array('input' => array('type' => 'file', 'label' => $this->l('Picture'), 'name' => 'image', 'desc' => $this->l('Storefront picture'))), 'submit' => array('title' => $this->l(' Save '), 'class' => 'button'));
if (Shop::isFeatureActive()) {
$this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
}
if (!($obj = $this->loadObject(true))) {
return;
}
$image = ImageManager::thumbnail(_PS_STORE_IMG_DIR_ . '/' . $obj->id . '.jpg', $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true);
$days = array();
$days[1] = $this->l('Monday');
$days[2] = $this->l('Tuesday');
$days[3] = $this->l('Wednesday');
$days[4] = $this->l('Thursday');
$days[5] = $this->l('Friday');
$days[6] = $this->l('Saturday');
$days[7] = $this->l('Sunday');
$hours = $this->getFieldValue($obj, 'hours');
if (!empty($hours)) {
$hours_unserialized = Tools::unSerialize($hours);
}
$this->fields_value = array('latitude' => $this->getFieldValue($obj, 'latitude') ? $this->getFieldValue($obj, 'latitude') : Configuration::get('PS_STORES_CENTER_LAT'), 'longitude' => $this->getFieldValue($obj, 'longitude') ? $this->getFieldValue($obj, 'longitude') : Configuration::get('PS_STORES_CENTER_LONG'), 'image' => $image ? $image : false, 'size' => $image ? filesize(_PS_STORE_IMG_DIR_ . '/' . $obj->id . '.jpg') / 1000 : false, 'days' => $days, 'hours' => isset($hours_unserialized) ? $hours_unserialized : false);
return parent::renderForm();
}
示例7: install
public function install()
{
$e = get_headers(ERP_WS);
if ($e[0] == 'HTTP/1.1 200 OK') {
if ($this->isCurlInstalled() == false) {
$this->_errors[] = $this->l('Error while installing the module. CURL Extension is not active on your server. Please contact your server administrator.');
return false;
}
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
if (!Configuration::hasKey('ERP_ADMIN_PARENT_ORDERS_TAB_ID')) {
Configuration::updateValue('ERP_ADMIN_PARENT_ORDERS_TAB_ID', Tab::getIdFromClassName('AdminParentOrders'));
}
if (parent::install() != false && $this->parseSQL('install.sql') != false && $this->installStockMvtReason() != false && $this->installErpTab() != false && $this->addTrashCategory() != false && $this->addOrderState($this->l('Order to the supplier')) != false && $this->registerHook('actionOrderStatusUpdate') != false && $this->registerHook('displayBackOfficeHeader') != false) {
foreach ($this->field_name_configuration as $field_name => $param) {
Configuration::updateValue(Tools::strtoupper($field_name), $param['default']);
}
// load a licence if exits
$this->loadLicenceIfExists();
// save the first install date
if (!Configuration::hasKey('ERP_FIRST_INSTALL_DATE') || Configuration::get('ERP_FIRST_INSTALL_DATE') == '' || Configuration::get('ERP_FIRST_INSTALL_DATE') == false) {
Configuration::updateValue('ERP_FIRST_INSTALL_DATE', date("Y-m-d H:i:s"));
}
return true;
}
return false;
} else {
$this->_errors[] = $this->l('Error while getting headers of WS ! Please contact the customer service.');
return false;
}
}
示例8: getProductByCode
/**
* Get Product object by code
* @param string $code Code
* @return Product Product object
*/
public static function getProductByCode($code, $id_lang)
{
$powatag_sku = Configuration::get('POWATAG_SKU');
switch ($powatag_sku) {
case Powatag::EAN:
$id_product = (int) self::getProductIdByEan13($code);
break;
case Powatag::UPC:
$id_product = (int) self::getProductIdByUPC($code);
break;
case Powatag::REFERENCE:
$id_product = (int) self::getProductIdByReference($code);
break;
default:
$id_product = (int) self::getProductIdByIdProduct($code);
break;
}
$product = new Product($id_product, true, (int) $id_lang);
//Check if multishop is enabled
if (Shop::isFeatureActive() && $product) {
//Check that product exists in current shop
$id_shops = Product::getShopsByProduct($product->id);
$product_exists = false;
foreach ($id_shops as $id_shop) {
if ($id_shop['id_shop'] == Context::getContext()->shop->id) {
$product_exists = true;
break;
}
}
if (!$product_exists) {
$product = false;
}
}
return $product;
}
示例9: renderForm
public function renderForm()
{
if (!$this->object->id) {
$this->object->price = -1;
}
$this->fields_form = array('legend' => array('title' => $this->l('Catalog price rules'), 'icon' => 'icon-dollar'), 'input' => array(array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'maxlength' => 32, 'required' => true, 'hint' => $this->l('Forbidden characters') . ' <>;=#{}'), array('type' => 'select', 'label' => $this->l('Shop'), 'name' => 'shop_id', 'options' => array('query' => Shop::getShops(), 'id' => 'id_shop', 'name' => 'name'), 'condition' => Shop::isFeatureActive(), 'default_value' => Shop::getContextShopID()), array('type' => 'select', 'label' => $this->l('Currency'), 'name' => 'id_currency', 'options' => array('query' => array_merge(array(0 => array('id_currency' => 0, 'name' => $this->l('All currencies'))), Currency::getCurrencies()), 'id' => 'id_currency', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'options' => array('query' => array_merge(array(0 => array('id_country' => 0, 'name' => $this->l('All countries'))), Country::getCountries((int) $this->context->language->id)), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Group'), 'name' => 'id_group', 'options' => array('query' => array_merge(array(0 => array('id_group' => 0, 'name' => $this->l('All groups'))), Group::getGroups((int) $this->context->language->id)), 'id' => 'id_group', 'name' => 'name')), array('type' => 'text', 'label' => $this->l('From quantity'), 'name' => 'from_quantity', 'maxlength' => 10, 'required' => true), array('type' => 'text', 'label' => $this->l('Price (tax excl.)'), 'name' => 'price', 'disabled' => $this->object->price == -1 ? 1 : 0, 'maxlength' => 10, 'suffix' => $this->context->currency->getSign('right')), array('type' => 'checkbox', 'name' => 'leave_bprice', 'values' => array('query' => array(array('id' => 'on', 'name' => $this->l('Leave base price'), 'val' => '1', 'checked' => '1')), 'id' => 'id', 'name' => 'name')), array('type' => 'datetime', 'label' => $this->l('From'), 'name' => 'from'), array('type' => 'datetime', 'label' => $this->l('To'), 'name' => 'to'), array('type' => 'select', 'label' => $this->l('Reduction type'), 'name' => 'reduction_type', 'options' => array('query' => array(array('reduction_type' => 'amount', 'name' => $this->l('Amount')), array('reduction_type' => 'percentage', 'name' => $this->l('Percentage'))), 'id' => 'reduction_type', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('Reduction with or without taxes'), 'name' => 'reduction_tax', 'align' => 'center', 'options' => array('query' => array(array('lab' => $this->l('Tax included'), 'val' => 1), array('lab' => $this->l('Tax excluded'), 'val' => 0)), 'id' => 'val', 'name' => 'lab')), array('type' => 'text', 'label' => $this->l('Reduction'), 'name' => 'reduction', 'required' => true)), 'submit' => array('title' => $this->l('Save')));
if (($value = $this->getFieldValue($this->object, 'price')) != -1) {
$price = number_format($value, 6);
} else {
$price = '';
}
$this->fields_value = array('price' => $price, 'from_quantity' => ($value = $this->getFieldValue($this->object, 'from_quantity')) ? $value : 1, 'reduction' => number_format(($value = $this->getFieldValue($this->object, 'reduction')) ? $value : 0, 6), 'leave_bprice_on' => $price ? 0 : 1);
$attribute_groups = array();
$attributes = Attribute::getAttributes((int) $this->context->language->id);
foreach ($attributes as $attribute) {
if (!isset($attribute_groups[$attribute['id_attribute_group']])) {
$attribute_groups[$attribute['id_attribute_group']] = array('id_attribute_group' => $attribute['id_attribute_group'], 'name' => $attribute['attribute_group']);
}
$attribute_groups[$attribute['id_attribute_group']]['attributes'][] = array('id_attribute' => $attribute['id_attribute'], 'name' => $attribute['name']);
}
$features = Feature::getFeatures((int) $this->context->language->id);
foreach ($features as &$feature) {
$feature['values'] = FeatureValue::getFeatureValuesWithLang((int) $this->context->language->id, $feature['id_feature'], true);
}
$this->tpl_form_vars = array('manufacturers' => Manufacturer::getManufacturers(), 'suppliers' => Supplier::getSuppliers(), 'attributes_group' => $attribute_groups, 'features' => $features, 'categories' => Category::getSimpleCategories((int) $this->context->language->id), 'conditions' => $this->object->getConditions(), 'is_multishop' => Shop::isFeatureActive());
return parent::renderForm();
}
示例10: install
/**
* @return boolean
*/
public function install()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
// Install invisible tab
$tab = new Tab();
$tab->name[$this->context->language->id] = $this->l('SecurionPay');
$tab->class_name = 'AdminSecurionPay';
$tab->id_parent = -1;
// No parent tab
$tab->module = $this->name;
$tab->add();
//Init
Configuration::updateValue('SECURIONPAY_CONF', '');
if (!parent::install()) {
return false;
}
if (!Configuration::updateValue(self::MODE, self::MODE_TEST)) {
return false;
}
if (!$this->registerHook('payment') || !$this->registerHook('displayAdminOrder')) {
return false;
}
return true;
}
示例11: install
public function install()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
return parent::install() && $this->registerHook('header') && Configuration::updateValue('FKVSEOTK_HREFLANG_ENABLED', false) && Configuration::updateValue('FKVSEOTK_CANONICAL_ENABLED', false) && Configuration::updateValue('FKVSEOTK_NOBOTS_ENABLED', false);
}
示例12: install
public function install()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
return parent::install() && $this->registerHook('lampAccessories') && $this->registerHook('header') && Configuration::updateValue('LAMPACCESSORIES_NAME', 'Lamp Accessories');
}
示例13: install
public function install()
{
if (Shop::isFeatureActive()) {
Shop::setContext(Shop::CONTEXT_ALL);
}
return parent::install() && $this->registerHook('invoice') && $this->registerHook('payment') && $this->registerHook('paymentReturn') && $this->createDebitNoteTable() && $this->createOrderState() && Configuration::updateValue('DEBITNOTE_CREDITOR_IDENTIFIER', DEXXXX);
}
示例14: renderForm
public function renderForm()
{
if (!($obj = $this->loadObject(true))) {
return;
}
$address_layout = AddressFormat::getAddressCountryFormat($obj->id);
if ($value = Tools::getValue('address_layout')) {
$address_layout = $value;
}
$default_layout = '';
$default_layout_tab = array(array('firstname', 'lastname'), array('company'), array('vat_number'), array('address1'), array('address2'), array('postcode', 'city'), array('Country:name'), array('phone'), array('phone_mobile'));
foreach ($default_layout_tab as $line) {
$default_layout .= implode(' ', $line) . "\r\n";
}
$this->fields_form = array('legend' => array('title' => $this->l('Countries'), 'image' => '../img/admin/world.gif'), 'input' => array(array('type' => 'text', 'label' => $this->l('Country:'), 'name' => 'name', 'lang' => true, 'size' => 30, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}', 'desc' => $this->l('Country name')), array('type' => 'text', 'label' => $this->l('ISO code:'), 'name' => 'iso_code', 'size' => 4, 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('Two -- or three -- letter ISO code (e.g. U.S. for United States)') . '.
<a href="http://www.iso.org/iso/country_codes/iso_3166_code_lists/country_names_and_code_elements.htm" target="_blank">' . $this->l('Official list here') . '
</a>.'), array('type' => 'text', 'label' => $this->l('Call prefix:'), 'name' => 'call_prefix', 'size' => 4, 'maxlength' => 3, 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('International call prefix, (e.g. 1 for United States)')), array('type' => 'select', 'label' => $this->l('Default currency:'), 'name' => 'id_currency', 'options' => array('query' => Currency::getCurrencies(), 'id' => 'id_currency', 'name' => 'name', 'default' => array('label' => $this->l('Default store currency'), 'value' => 0))), array('type' => 'select', 'label' => $this->l('Zone:'), 'name' => 'id_zone', 'options' => array('query' => Zone::getZones(), 'id' => 'id_zone', 'name' => 'name'), 'desc' => $this->l('Geographical region')), array('type' => 'radio', 'label' => $this->l('Need zip/postal code:'), 'name' => 'need_zip_code', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'need_zip_code_on', 'value' => 1, 'label' => $this->l('Yes')), array('id' => 'need_zip_code_off', 'value' => 0, 'label' => $this->l('No')))), array('type' => 'text', 'label' => $this->l('Zip/post code format:'), 'name' => 'zip_code_format', 'class' => 'uppercase', 'required' => true, 'desc' => $this->l('Zip Code format (L for a letter, N for a number and C for the ISO code). For example, NNNNN for the United States. No verification if undefined.')), array('type' => 'address_layout', 'label' => $this->l('Address format:'), 'name' => 'address_layout', 'address_layout' => $address_layout, 'encoding_address_layout' => urlencode($address_layout), 'encoding_default_layout' => urlencode($default_layout), 'display_valid_fields' => $this->displayValidFields()), array('type' => 'radio', 'label' => $this->l('Address Standardization:'), 'name' => 'standardization', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'standardization_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'standardization_off', 'value' => 0, 'label' => $this->l('Disabled')))), array('type' => 'radio', 'label' => $this->l('Active:'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Display this country to your customers (the selected country will always be displayed in the Back Office)')), array('type' => 'radio', 'label' => $this->l('Contains following states:'), 'name' => 'contains_states', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'contains_states_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'contains_states_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'radio', 'label' => $this->l('Do you need a tax identification number?'), 'name' => 'need_identification_number', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'need_identification_number_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'need_identification_number_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No')))), array('type' => 'radio', 'label' => $this->l('Display tax label (e.g. "Tax incl."):'), 'name' => 'display_tax_label', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'display_tax_label_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Yes') . '" title="' . $this->l('Yes') . '" />' . $this->l('Yes')), array('id' => 'display_tax_label_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('No') . '" title="' . $this->l('No') . '" />' . $this->l('No'))))));
if (Shop::isFeatureActive()) {
$this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso');
}
$this->fields_form['submit'] = array('title' => $this->l('Save '), 'class' => 'button');
if ($this->object->iso_code == 'US') {
$this->object->standardization = Configuration::get('PS_TAASC');
}
return parent::renderForm();
}
示例15: renderForm
public function renderForm()
{
// loads current warehouse
if (!($obj = $this->loadObject(true))) {
return;
}
$image = _PS_SUPP_IMG_DIR_ . $obj->id . '.jpg';
$image_url = ImageManager::thumbnail($image, $this->table . '_' . (int) $obj->id . '.' . $this->imageType, 350, $this->imageType, true, true);
$image_size = file_exists($image) ? filesize($image) / 1000 : false;
$tmp_addr = new Address();
$res = $tmp_addr->getFieldsRequiredDatabase();
$required_fields = array();
foreach ($res as $row) {
$required_fields[(int) $row['id_required_field']] = $row['field_name'];
}
$this->fields_form = array('legend' => array('title' => $this->l('Suppliers'), 'icon' => 'icon-truck'), 'input' => array(array('type' => 'hidden', 'name' => 'id_address'), array('type' => 'text', 'label' => $this->l('Name'), 'name' => 'name', 'required' => true, 'col' => 4, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}'), in_array('company', $required_fields) ? array('type' => 'text', 'label' => $this->l('Company'), 'name' => 'company', 'display' => in_array('company', $required_fields), 'required' => in_array('company', $required_fields), 'maxlength' => 16, 'col' => 4, 'hint' => $this->l('Company name for this supplier')) : null, array('type' => 'textarea', 'label' => $this->l('Description'), 'name' => 'description', 'lang' => true, 'hint' => array($this->l('Invalid characters:') . ' <>;=#{}', $this->l('Will appear in the list of suppliers.')), 'autoload_rte' => 'rte'), array('type' => 'text', 'label' => $this->l('Phone'), 'name' => 'phone', 'required' => in_array('phone', $required_fields), 'maxlength' => 16, 'col' => 4, 'hint' => $this->l('Phone number for this supplier')), array('type' => 'text', 'label' => $this->l('Mobile phone'), 'name' => 'phone_mobile', 'required' => in_array('phone_mobile', $required_fields), 'maxlength' => 16, 'col' => 4, 'hint' => $this->l('Mobile phone number for this supplier.')), array('type' => 'text', 'label' => $this->l('Address'), 'name' => 'address', 'maxlength' => 128, 'col' => 6, 'required' => true), array('type' => 'text', 'label' => $this->l('Address') . ' (2)', 'name' => 'address2', 'required' => in_array('address2', $required_fields), 'col' => 6, 'maxlength' => 128), array('type' => 'text', 'label' => $this->l('Zip/postal code'), 'name' => 'postcode', 'required' => in_array('postcode', $required_fields), 'maxlength' => 12, 'col' => 2), array('type' => 'text', 'label' => $this->l('City'), 'name' => 'city', 'maxlength' => 32, 'col' => 4, 'required' => true), array('type' => 'select', 'label' => $this->l('Country'), 'name' => 'id_country', 'required' => true, 'col' => 4, 'default_value' => (int) $this->context->country->id, 'options' => array('query' => Country::getCountries($this->context->language->id, false), 'id' => 'id_country', 'name' => 'name')), array('type' => 'select', 'label' => $this->l('State'), 'name' => 'id_state', 'col' => 4, 'options' => array('id' => 'id_state', 'query' => array(), 'name' => 'name')), array('type' => 'file', 'label' => $this->l('Logo'), 'name' => 'logo', 'display_image' => true, 'image' => $image_url ? $image_url : false, 'size' => $image_size, 'hint' => $this->l('Upload a supplier logo from your computer.')), array('type' => 'text', 'label' => $this->l('Meta title'), 'name' => 'meta_title', 'lang' => true, 'col' => 4, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'text', 'label' => $this->l('Meta description'), 'name' => 'meta_description', 'lang' => true, 'col' => 6, 'hint' => $this->l('Forbidden characters:') . ' <>;=#{}'), array('type' => 'tags', 'label' => $this->l('Meta keywords'), 'name' => 'meta_keywords', 'lang' => true, 'col' => 6, 'hint' => array($this->l('To add "tags" click in the field, write something and then press "Enter".'), $this->l('Forbidden characters:') . ' <>;=#{}')), array('type' => 'switch', 'label' => $this->l('Enable'), 'name' => 'active', 'required' => false, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled'))))), 'submit' => array('title' => $this->l('Save')));
// loads current address for this supplier - if possible
$address = null;
if (isset($obj->id)) {
$id_address = Address::getAddressIdBySupplierId($obj->id);
if ($id_address > 0) {
$address = new Address((int) $id_address);
}
}
// force specific fields values (address)
if ($address != null) {
$this->fields_value = array('id_address' => $address->id, 'phone' => $address->phone, 'phone_mobile' => $address->phone_mobile, 'address' => $address->address1, 'address2' => $address->address2, 'postcode' => $address->postcode, 'city' => $address->city, 'id_country' => $address->id_country, 'id_state' => $address->id_state);
} else {
$this->fields_value = array('id_address' => 0, 'id_country' => Configuration::get('PS_COUNTRY_DEFAULT'));
}
if (Shop::isFeatureActive()) {
$this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association'), 'name' => 'checkBoxShopAsso');
}
return parent::renderForm();
}