本文整理汇总了PHP中Shop::getTotalShops方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::getTotalShops方法的具体用法?PHP Shop::getTotalShops怎么用?PHP Shop::getTotalShops使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shop
的用法示例。
在下文中一共展示了Shop::getTotalShops方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRenderedShopList
/**
* Render shop list
*
* @return string
*/
public function getRenderedShopList()
{
if (!Shop::isFeatureActive() || Shop::getTotalShops(false, null) < 2) {
return '';
}
$shop_context = Shop::getContext();
$context = Context::getContext();
$tree = Shop::getTree();
if ($shop_context == Shop::CONTEXT_ALL || $context->controller->multishop_context_group == false && $shop_context == Shop::CONTEXT_GROUP) {
$current_shop_value = '';
$current_shop_name = Translate::getAdminTranslation('All shops');
} elseif ($shop_context == Shop::CONTEXT_GROUP) {
$current_shop_value = 'g-' . Shop::getContextShopGroupID();
$current_shop_name = sprintf(Translate::getAdminTranslation('%s group'), $tree[Shop::getContextShopGroupID()]['name']);
} else {
$current_shop_value = 's-' . Shop::getContextShopID();
foreach ($tree as $group_id => $group_data) {
foreach ($group_data['shops'] as $shop_id => $shop_data) {
if ($shop_id == Shop::getContextShopID()) {
$current_shop_name = $shop_data['name'];
break;
}
}
}
}
$tpl = $this->createTemplate('helpers/shops_list/list.tpl');
$tpl->assign(array('tree' => $tree, 'current_shop_name' => $current_shop_name, 'current_shop_value' => $current_shop_value, 'multishop_context' => $context->controller->multishop_context, 'multishop_context_group' => $context->controller->multishop_context_group, 'is_shop_context' => $context->controller->multishop_context & Shop::CONTEXT_SHOP, 'is_group_context' => $context->controller->multishop_context & Shop::CONTEXT_GROUP, 'shop_context' => $shop_context, 'url' => $_SERVER['REQUEST_URI'] . ($_SERVER['QUERY_STRING'] ? '&' : '?') . 'setShopContext='));
return $tpl->fetch();
}
示例2: renderForm
public function renderForm()
{
$this->fields_form = array('legend' => array('title' => $this->l('Shop Group')), 'description' => $this->l('Warning: it is not recommended to enable the "share customers" and "share orders" options, because once they are activated and customers or orders are created, you will not be able to disable these options. If you need these options, try to first consider using several categories instead on several shops.'), 'input' => array(array('type' => 'text', 'label' => $this->l('Shop group name:'), 'name' => 'name', 'required' => true), array('type' => 'radio', 'label' => $this->l('Share customers:'), 'name' => 'share_customer', 'required' => true, 'class' => 't', 'is_bool' => true, 'disabled' => $this->id_object && $this->display == 'edit' && ShopGroup::hasDependency($this->id_object, 'customer') ? true : false, 'values' => array(array('id' => 'share_customer_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'share_customer_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Once the option is enabled, the shops in this group will share their customers: if a customer registers on one of this group\'s shops, the account will automatically be available on the others shops of this goup. Warning: you will not be able to disable this option once you have customers registered on at least one shop of this group.')), array('type' => 'radio', 'label' => $this->l('Share available quantities to sell:'), 'name' => 'share_stock', 'required' => true, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'share_stock_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'share_stock_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Share available quantities to sell between shops of this group. When changing this option, all products available quantities for this group will be reset to 0.')), array('type' => 'radio', 'label' => $this->l('Share orders:'), 'name' => 'share_order', 'required' => true, 'class' => 't', 'is_bool' => true, 'disabled' => $this->id_object && $this->display == 'edit' && ShopGroup::hasDependency($this->id_object, 'order') ? true : false, 'values' => array(array('id' => 'share_order_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'share_order_off', 'value' => 0, 'label' => $this->l('Disabled'))), 'desc' => $this->l('Once this option is enabled (which is only possible if customers and available quantities are shared among shops), the customer\'s cart will be shared among all the shops in this group. This way, any purchase started on one of the shops in this group will be able to be finished in another shop from the same shop group. Warning: you will not be able to disable this option once you have orders on at least one shop of this group.')), array('type' => 'radio', 'label' => $this->l('Status:'), 'name' => 'active', 'required' => true, '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('Enable or disable group shop'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
if (!($obj = $this->loadObject(true))) {
return;
}
if (Shop::getTotalShops() > 1 && $obj->id) {
$disabled = array('share_customer' => true, 'share_stock' => true, 'share_order' => true, 'active' => false);
} else {
$disabled = false;
}
$default_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
$this->tpl_form_vars = array('disabled' => $disabled, 'checked' => Tools::getValue('addshop_group') !== false ? true : false, 'defaultGroup' => $default_shop->id_shop_group);
$this->fields_value = array('active' => true);
return parent::renderForm();
}
示例3: renderForm
public function renderForm()
{
$this->fields_form = array('legend' => array('title' => $this->l('Shop group'), 'icon' => 'icon-shopping-cart'), 'description' => $this->l('Warning: Enabling the "share customers" and "share orders" options is not recommended. Once activated and orders are created, you will not be able to disable these options. If you need these options, we recommend using several categories rather than several shops.'), 'input' => array(array('type' => 'text', 'label' => $this->l('Shop group name'), 'name' => 'name', 'required' => true), array('type' => 'switch', 'label' => $this->l('Share customers'), 'name' => 'share_customer', 'required' => true, 'class' => 't', 'is_bool' => true, 'disabled' => $this->id_object && $this->display == 'edit' && ShopGroup::hasDependency($this->id_object, 'customer') ? true : false, 'values' => array(array('id' => 'share_customer_on', 'value' => 1), array('id' => 'share_customer_off', 'value' => 0)), 'desc' => $this->l('Once this option is enabled, the shops in this group will share customers. If a customer registers in any one of these shops, the account will automatically be available in the others shops of this group.') . '<br/>' . $this->l('Warning: you will not be able to disable this option once you have registered customers.')), array('type' => 'switch', 'label' => $this->l('Share available quantities to sell'), 'name' => 'share_stock', 'required' => true, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'share_stock_on', 'value' => 1), array('id' => 'share_stock_off', 'value' => 0)), 'desc' => $this->l('Share available quantities between shops of this group. When changing this option, all available products quantities will be reset to 0.')), array('type' => 'switch', 'label' => $this->l('Share orders'), 'name' => 'share_order', 'required' => true, 'class' => 't', 'is_bool' => true, 'disabled' => $this->id_object && $this->display == 'edit' && ShopGroup::hasDependency($this->id_object, 'order') ? true : false, 'values' => array(array('id' => 'share_order_on', 'value' => 1), array('id' => 'share_order_off', 'value' => 0)), 'desc' => $this->l('Once this option is enabled (which is only possible if customers and available quantities are shared among shops), the customer\'s cart will be shared by all shops in this group. This way, any purchase started in one shop will be able to be completed in another shop from the same group.') . '<br/>' . $this->l('Warning: You will not be able to disable this option once you\'ve started to accept orders.')), array('type' => 'switch', 'label' => $this->l('Status'), 'name' => 'active', 'required' => true, 'class' => 't', 'is_bool' => true, 'values' => array(array('id' => 'active_on', 'value' => 1), array('id' => 'active_off', 'value' => 0)), 'desc' => $this->l('Enable or disable this shop group?'))), 'submit' => array('title' => $this->l('Save')));
if (!($obj = $this->loadObject(true))) {
return;
}
if (Shop::getTotalShops() > 1 && $obj->id) {
$disabled = array('share_customer' => true, 'share_stock' => true, 'share_order' => true, 'active' => false);
} else {
$disabled = false;
}
$default_shop = new Shop(Configuration::get('PS_SHOP_DEFAULT'));
$this->tpl_form_vars = array('disabled' => $disabled, 'checked' => Tools::getValue('addshop_group') !== false ? true : false, 'defaultGroup' => $default_shop->id_shop_group);
$this->fields_value = array('active' => true);
return parent::renderForm();
}
示例4: getRenderedShopList
/**
* Render shop list
*
* @return string
*/
public function getRenderedShopList()
{
if (!Shop::isFeatureActive() || Shop::getTotalShops(false, null) < 2) {
return '';
}
$shop_context = Shop::getContext();
$context = Context::getContext();
if ($this->noShopSelection()) {
$current_shop_value = '';
} elseif ($shop_context == Shop::CONTEXT_GROUP) {
$current_shop_value = 'g-' . Shop::getContextShopGroupID();
} else {
$current_shop_value = 's-' . Shop::getContextShopID();
}
$tpl = $this->createTemplate('helpers/shops_list/list.tpl');
$tpl->assign(array('tree' => Shop::getTree(), 'current_shop_name' => $this->getCurrentShopName(), 'current_shop_value' => $current_shop_value, 'multishop_context' => $context->controller->multishop_context, 'multishop_context_group' => $context->controller->multishop_context_group, 'is_shop_context' => $context->controller->multishop_context & Shop::CONTEXT_SHOP, 'is_group_context' => $context->controller->multishop_context & Shop::CONTEXT_GROUP, 'shop_context' => $shop_context, 'url' => $_SERVER['REQUEST_URI'] . ($_SERVER['QUERY_STRING'] ? '&' : '?') . 'setShopContext='));
return $tpl->fetch();
}
示例5: 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();
}
示例6: renderForm
public function renderForm()
{
if (!($obj = $this->loadObject(true))) {
return;
}
$this->fields_form = array('legend' => array('title' => $this->l('Shop'), 'icon' => 'icon-shopping-cart'), 'input' => array(array('type' => 'text', 'label' => $this->l('Shop name'), 'desc' => array($this->l('This field does not refer to the shop name visible in the front office.'), sprintf($this->l('Follow %sthis link%s to edit the shop name used on the Front Office.'), '<a href="' . $this->context->link->getAdminLink('AdminStores') . '#store_fieldset_general">', '</a>')), 'name' => 'name', 'required' => true)));
$display_group_list = true;
if ($this->display == 'edit') {
$group = new ShopGroup($obj->id_shop_group);
if ($group->share_customer || $group->share_order || $group->share_stock) {
$display_group_list = false;
}
}
if ($display_group_list) {
$options = array();
foreach (ShopGroup::getShopGroups() as $group) {
if ($this->display == 'edit' && ($group->share_customer || $group->share_order || $group->share_stock) && ShopGroup::hasDependency($group->id)) {
continue;
}
$options[] = array('id_shop_group' => $group->id, 'name' => $group->name);
}
if ($this->display == 'add') {
$group_desc = $this->l('Warning: You won\'t be able to change the group of this shop if this shop belongs to a group with one of these options activated: Share Customers, Share Quantities or Share Orders.');
} else {
$group_desc = $this->l('You can only move your shop to a shop group with all "share" options disabled -- or to a shop group with no customers/orders.');
}
$this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Shop group'), 'desc' => $group_desc, 'name' => 'id_shop_group', 'options' => array('query' => $options, 'id' => 'id_shop_group', 'name' => 'name'));
} else {
$this->fields_form['input'][] = array('type' => 'hidden', 'name' => 'id_shop_group', 'default' => $group->name);
$this->fields_form['input'][] = array('type' => 'textShopGroup', 'label' => $this->l('Shop group'), 'desc' => $this->l('You can\'t edit the shop group because the current shop belongs to a group with the "share" option enabled.'), 'name' => 'id_shop_group', 'value' => $group->name);
}
$categories = Category::getRootCategories($this->context->language->id);
$this->fields_form['input'][] = array('type' => 'select', 'label' => $this->l('Category root'), 'desc' => $this->l('This is the root category of the store that you\'ve created. To define a new root category for your store,') . ' <a href="' . $this->context->link->getAdminLink('AdminCategories') . '&addcategoryroot" target="_blank">' . $this->l('Please click here') . '</a>', 'name' => 'id_category', 'options' => array('query' => $categories, 'id' => 'id_category', 'name' => 'name'));
if (Tools::isSubmit('id_shop')) {
$shop = new Shop((int) Tools::getValue('id_shop'));
$id_root = $shop->id_category;
} else {
$id_root = $categories[0]['id_category'];
}
$id_shop = (int) Tools::getValue('id_shop');
self::$currentIndex = self::$currentIndex . '&id_shop_group=' . (int) (Tools::getValue('id_shop_group') ? Tools::getValue('id_shop_group') : (isset($obj->id_shop_group) ? $obj->id_shop_group : Shop::getContextShopGroupID()));
$shop = new Shop($id_shop);
$selected_cat = Shop::getCategories($id_shop);
if (empty($selected_cat)) {
// get first category root and preselect all these children
$root_categories = Category::getRootCategories();
$root_category = new Category($root_categories[0]['id_category']);
$children = $root_category->getAllChildren($this->context->language->id);
$selected_cat[] = $root_categories[0]['id_category'];
foreach ($children as $child) {
$selected_cat[] = $child->id;
}
}
if (Shop::getContext() == Shop::CONTEXT_SHOP && Tools::isSubmit('id_shop')) {
$root_category = new Category($shop->id_category);
} else {
$root_category = new Category($id_root);
}
$this->fields_form['input'][] = array('type' => 'categories', 'name' => 'categoryBox', 'label' => $this->l('Associated categories'), 'tree' => array('id' => 'categories-tree', 'selected_categories' => $selected_cat, 'root_category' => $root_category->id, 'use_search' => true, 'use_checkbox' => true), 'desc' => $this->l('By selecting associated categories, you are choosing to share the categories between shops. Once associated between shops, any alteration of this category will impact every shop.'));
/*$this->fields_form['input'][] = array(
'type' => 'switch',
'label' => $this->l('Enabled'),
'name' => 'active',
'required' => true,
'is_bool' => true,
'values' => array(
array(
'id' => 'active_on',
'value' => 1
),
array(
'id' => 'active_off',
'value' => 0
)
),
'desc' => $this->l('Enable or disable your store?')
);*/
$themes = Theme::getThemes();
if (!isset($obj->id_theme)) {
foreach ($themes as $theme) {
if (isset($theme->id)) {
$id_theme = $theme->id;
break;
}
}
}
$this->fields_form['input'][] = array('type' => 'theme', 'label' => $this->l('Theme'), 'name' => 'theme', 'values' => $themes);
$this->fields_form['submit'] = array('title' => $this->l('Save'));
if (Shop::getTotalShops() > 1 && $obj->id) {
$disabled = array('active' => false);
} else {
$disabled = false;
}
$import_data = array('carrier' => $this->l('Carriers'), 'cms' => $this->l('CMS pages'), 'contact' => $this->l('Contact information'), 'country' => $this->l('Countries'), 'currency' => $this->l('Currencies'), 'discount' => $this->l('Discount prices'), 'employee' => $this->l('Employees'), 'image' => $this->l('Images'), 'lang' => $this->l('Languages'), 'manufacturer' => $this->l('Manufacturers'), 'module' => $this->l('Modules'), 'hook_module' => $this->l('Module hooks'), 'meta_lang' => $this->l('Meta'), 'product' => $this->l('Products'), 'product_attribute' => $this->l('Combinations'), 'scene' => $this->l('Scenes'), 'stock_available' => $this->l('Available quantities for sale'), 'store' => $this->l('Stores'), 'warehouse' => $this->l('Warehouses'), 'webservice_account' => $this->l('Webservice accounts'), 'attribute_group' => $this->l('Attribute groups'), 'feature' => $this->l('Features'), 'group' => $this->l('Customer groups'), 'tax_rules_group' => $this->l('Tax rules groups'), 'supplier' => $this->l('Suppliers'), 'referrer' => $this->l('Referrers/affiliates'), 'zone' => $this->l('Zones'), 'cart_rule' => $this->l('Cart rules'));
// Hook for duplication of shop data
$modules_list = Hook::getHookModuleExecList('actionShopDataDuplication');
if (is_array($modules_list) && count($modules_list) > 0) {
foreach ($modules_list as $m) {
$import_data['Module' . ucfirst($m['module'])] = Module::getModuleName($m['module']);
}
//.........这里部分代码省略.........
示例7: getSelectedAssoShop
/**
* Returns an array with selected shops and type (group or boutique shop)
*
* @param string $table
* @return array
*/
protected function getSelectedAssoShop($table)
{
if (!Shop::isFeatureActive() || !Shop::isTableAssociated($table)) {
return array();
}
$shops = Shop::getShops(true, null, true);
if (count($shops) == 1 && isset($shops[0])) {
return array($shops[0], 'shop');
}
$assos = array();
if (Tools::isSubmit('checkBoxShopAsso_' . $table)) {
foreach (Tools::getValue('checkBoxShopAsso_' . $table) as $id_shop => $value) {
$assos[] = (int) $id_shop;
}
} elseif (Shop::getTotalShops(false) == 1) {
// if we do not have the checkBox multishop, we can have an admin with only one shop and being in multishop
$assos[] = (int) Shop::getContextShopID();
}
return $assos;
}
示例8: renderShopList
public static function renderShopList()
{
if (!Shop::isFeatureActive() || Shop::getTotalShops(false, null) < 2) {
return null;
}
$tree = Shop::getTree();
$context = Context::getContext();
// Get default value
$shop_context = Shop::getContext();
if ($shop_context == Shop::CONTEXT_ALL || $context->controller->multishop_context_group == false && $shop_context == Shop::CONTEXT_GROUP) {
$value = '';
} else {
if ($shop_context == Shop::CONTEXT_GROUP) {
$value = 'g-' . Shop::getContextShopGroupID();
} else {
$value = 's-' . Shop::getContextShopID();
}
}
// Generate HTML
$url = $_SERVER['REQUEST_URI'] . ($_SERVER['QUERY_STRING'] ? '&' : '?') . 'setShopContext=';
$shop = new Shop(Shop::getContextShopID());
// $html = '<a href="#"><i class="icon-home"></i> '.$shop->name.'</a>';
$html = '<select class="shopList" onchange="location.href = \'' . htmlspecialchars($url) . '\'+$(this).val();">';
$html .= '<option value="" class="first">' . Translate::getAdminTranslation('All shops') . '</option>';
foreach ($tree as $gID => $group_data) {
if (!isset($context->controller->multishop_context) || $context->controller->multishop_context & Shop::CONTEXT_GROUP) {
$html .= '<option class="group" value="g-' . $gID . '"' . (empty($value) && $shop_context == Shop::CONTEXT_GROUP || $value == 'g-' . $gID ? ' selected="selected"' : '') . ($context->controller->multishop_context_group == false ? ' disabled="disabled"' : '') . '>' . Translate::getAdminTranslation('Group:') . ' ' . htmlspecialchars($group_data['name']) . '</option>';
} else {
$html .= '<optgroup class="group" label="' . Translate::getAdminTranslation('Group:') . ' ' . htmlspecialchars($group_data['name']) . '"' . ($context->controller->multishop_context_group == false ? ' disabled="disabled"' : '') . '>';
}
if (!isset($context->controller->multishop_context) || $context->controller->multishop_context & Shop::CONTEXT_SHOP) {
foreach ($group_data['shops'] as $sID => $shopData) {
if ($shopData['active']) {
$html .= '<option value="s-' . $sID . '" class="shop"' . ($value == 's-' . $sID ? ' selected="selected"' : '') . '>' . ($context->controller->multishop_context_group == false ? htmlspecialchars($group_data['name']) . ' - ' : '') . $shopData['name'] . '</option>';
}
}
}
if (!(!isset($context->controller->multishop_context) || $context->controller->multishop_context & Shop::CONTEXT_GROUP)) {
$html .= '</optgroup>';
}
}
$html .= '</select>';
return $html;
}
示例9: 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();
}
示例10: generateOptions
/**
* Generate a form for options
* @param array $option_list
* @return string html
*/
public function generateOptions($option_list)
{
$this->tpl = $this->createTemplate($this->base_tpl);
$tab = Tab::getTab($this->context->language->id, $this->id);
if (!isset($languages)) {
$languages = Language::getLanguages(false);
}
$use_multishop = false;
$hide_multishop_checkbox = Shop::getTotalShops(false, null) < 2 ? true : false;
foreach ($option_list as $category => $category_data) {
if (!is_array($category_data)) {
continue;
}
if (!isset($category_data['image'])) {
$category_data['image'] = (!empty($tab['module']) && file_exists($_SERVER['DOCUMENT_ROOT'] . _MODULE_DIR_ . $tab['module'] . '/' . $tab['class_name'] . '.gif') ? _MODULE_DIR_ . $tab['module'] . '/' : '../img/t/') . $tab['class_name'] . '.gif';
}
if (!isset($category_data['fields'])) {
$category_data['fields'] = array();
}
$category_data['hide_multishop_checkbox'] = true;
if (isset($category_data['tabs'])) {
$tabs[$category] = $category_data['tabs'];
$tabs[$category]['misc'] = $this->l('Miscellaneous');
}
foreach ($category_data['fields'] as $key => $field) {
if (empty($field['no_multishop_checkbox']) && !$hide_multishop_checkbox) {
$category_data['hide_multishop_checkbox'] = false;
}
// Set field value unless explicitly denied
if (!isset($field['auto_value']) || $field['auto_value']) {
$field['value'] = $this->getOptionValue($key, $field);
}
// Check if var is invisible (can't edit it in current shop context), or disable (use default value for multishop)
$is_disabled = $is_invisible = false;
if (Shop::isFeatureActive()) {
if (isset($field['visibility']) && $field['visibility'] > Shop::getContext()) {
$is_disabled = true;
$is_invisible = true;
} elseif (Shop::getContext() != Shop::CONTEXT_ALL && !Configuration::isOverridenByCurrentContext($key)) {
$is_disabled = true;
}
}
$field['is_disabled'] = $is_disabled;
$field['is_invisible'] = $is_invisible;
$field['required'] = isset($field['required']) ? $field['required'] : $this->required;
if ($field['type'] == 'color') {
$this->context->controller->addJqueryPlugin('colorpicker');
}
if ($field['type'] == 'texarea' || $field['type'] == 'textareaLang') {
$this->context->controller->addJqueryPlugin('autosize');
}
if ($field['type'] == 'file') {
$uploader = new HelperUploader();
$uploader->setId(isset($field['id']) ? $field['id'] : null);
$uploader->setName($field['name']);
$uploader->setUrl(isset($field['url']) ? $field['url'] : null);
$uploader->setMultiple(isset($field['multiple']) ? $field['multiple'] : false);
$uploader->setUseAjax(isset($field['ajax']) ? $field['ajax'] : false);
$uploader->setMaxFiles(isset($field['max_files']) ? $field['max_files'] : null);
if (isset($field['files']) && $field['files']) {
$uploader->setFiles($field['files']);
} elseif (isset($field['image']) && $field['image']) {
// Use for retrocompatibility
$uploader->setFiles(array(0 => array('type' => HelperUploader::TYPE_IMAGE, 'image' => isset($field['image']) ? $field['image'] : null, 'size' => isset($field['size']) ? $field['size'] : null, 'delete_url' => isset($field['delete_url']) ? $field['delete_url'] : null)));
}
if (isset($field['file']) && $field['file']) {
// Use for retrocompatibility
$uploader->setFiles(array(0 => array('type' => HelperUploader::TYPE_FILE, 'size' => isset($field['size']) ? $field['size'] : null, 'delete_url' => isset($field['delete_url']) ? $field['delete_url'] : null, 'download_url' => isset($field['file']) ? $field['file'] : null)));
}
if (isset($field['thumb']) && $field['thumb']) {
// Use for retrocompatibility
$uploader->setFiles(array(0 => array('type' => HelperUploader::TYPE_IMAGE, 'image' => isset($field['thumb']) ? '<img src="' . $field['thumb'] . '" alt="' . $field['title'] . '" title="' . $field['title'] . '" />' : null)));
}
$uploader->setTitle(isset($field['title']) ? $field['title'] : null);
$field['file'] = $uploader->render();
}
// Cast options values if specified
if ($field['type'] == 'select' && isset($field['cast'])) {
foreach ($field['list'] as $option_key => $option) {
$field['list'][$option_key][$field['identifier']] = $field['cast']($option[$field['identifier']]);
}
}
// Fill values for all languages for all lang fields
if (substr($field['type'], -4) == 'Lang') {
foreach ($languages as $language) {
if ($field['type'] == 'textLang') {
$value = Tools::getValue($key . '_' . $language['id_lang'], Configuration::get($key, $language['id_lang']));
} elseif ($field['type'] == 'textareaLang') {
$value = Configuration::get($key, $language['id_lang']);
} elseif ($field['type'] == 'selectLang') {
$value = Configuration::get($key, $language['id_lang']);
}
$field['languages'][$language['id_lang']] = $value;
$field['value'][$language['id_lang']] = $this->getOptionValue($key . '_' . strtoupper($language['iso_code']), $field);
}
//.........这里部分代码省略.........
示例11: checkDefaultAttributes
/**
* Check if there is no default attribute and create it if not
*/
public function checkDefaultAttributes()
{
if (!$this->id) {
return false;
}
if (Db::getInstance()->getValue('SELECT COUNT(*)
FROM `' . _DB_PREFIX_ . 'product_attribute` pa
' . Shop::addSqlAssociation('product_attribute', 'pa') . '
WHERE product_attribute_shop.`default_on` = 1
AND pa.`id_product` = ' . (int) $this->id) > Shop::getTotalShops(true)) {
Db::getInstance()->execute('UPDATE ' . _DB_PREFIX_ . 'product_attribute_shop product_attribute_shop, ' . _DB_PREFIX_ . 'product_attribute pa
SET product_attribute_shop.default_on=NULL, pa.default_on = NULL
WHERE product_attribute_shop.id_product_attribute=pa.id_product_attribute AND pa.id_product=' . (int) $this->id . Shop::addSqlRestriction(false, 'product_attribute_shop'));
}
$row = Db::getInstance()->getRow('
SELECT pa.id_product
FROM `' . _DB_PREFIX_ . 'product_attribute` pa
' . Shop::addSqlAssociation('product_attribute', 'pa') . '
WHERE product_attribute_shop.`default_on` = 1
AND pa.`id_product` = ' . (int) $this->id);
if ($row) {
return true;
}
$mini = Db::getInstance()->getRow('
SELECT MIN(pa.id_product_attribute) as `id_attr`
FROM `' . _DB_PREFIX_ . 'product_attribute` pa
' . Shop::addSqlAssociation('product_attribute', 'pa') . '
WHERE pa.`id_product` = ' . (int) $this->id);
if (!$mini) {
return false;
}
if (!ObjectModel::updateMultishopTable('Combination', array('default_on' => 1), 'a.id_product_attribute = ' . (int) $mini['id_attr'])) {
return false;
}
return true;
}
示例12: getModuleAndSiteInfos
/**
* Get module and site infos
* Private function, do not use it. This function is called in setModuleConfiguration and getModuleConfiguration
* @param $post_data
* @return array with info data
*/
function getModuleAndSiteInfos($id_shop = null, $group_name = null)
{
$module_version = new NetReviews();
$module_version = $module_version->version;
$order_statut_list = OrderState::getOrderStates((int) Configuration::get('PS_LANG_DEFAULT'));
$perms = fileperms(_PS_MODULE_DIR_ . 'netreviews');
if (($perms & 0xc000) == 0xc000) {
// Socket
$info = 's';
} elseif (($perms & 0xa000) == 0xa000) {
// Symbolic link
$info = 'l';
} elseif (($perms & 0x8000) == 0x8000) {
// Regular
$info = '-';
} elseif (($perms & 0x6000) == 0x6000) {
// Block special
$info = 'b';
} elseif (($perms & 0x4000) == 0x4000) {
// Repository
$info = 'd';
} elseif (($perms & 0x2000) == 0x2000) {
// Special characters
$info = 'c';
} elseif (($perms & 0x1000) == 0x1000) {
// pipe FIFO
$info = 'p';
} else {
// Unknow
$info = 'u';
}
// Others
$info .= $perms & 0x100 ? 'r' : '-';
$info .= $perms & 0x80 ? 'w' : '-';
$info .= $perms & 0x40 ? $perms & 0x800 ? 's' : 'x' : ($perms & 0x800 ? 'S' : '-');
// Group
$info .= $perms & 0x20 ? 'r' : '-';
$info .= $perms & 0x10 ? 'w' : '-';
$info .= $perms & 0x8 ? $perms & 0x400 ? 's' : 'x' : ($perms & 0x400 ? 'S' : '-');
// All
$info .= $perms & 0x4 ? 'r' : '-';
$info .= $perms & 0x2 ? 'w' : '-';
$info .= $perms & 0x1 ? $perms & 0x200 ? 't' : 'x' : ($perms & 0x200 ? 'T' : '-');
if (!empty($id_shop)) {
if (Configuration::get('AV_MULTILINGUE', null, null, $id_shop) == 'checked') {
$explode_secret_key = explode('-', Configuration::get('AV_CLESECRETE' . $group_name, null, null, $id_shop));
$return = array('Version_PS' => _PS_VERSION_, 'Version_Module' => $module_version, 'idWebsite' => Configuration::get('AV_IDWEBSITE' . $group_name, null, null, $id_shop), 'Nb_Multiboutique' => '', 'Mode_multilingue' => '1', 'list_iso_lang_multilingue' => '', 'Websites' => '', 'Id_Website_encours' => '', 'Cle_Secrete' => $explode_secret_key[0] . '-xxxx-xxxx-' . $explode_secret_key[3], 'Delay' => Configuration::get('AV_DELAY' . $group_name, null, null, $id_shop), 'Initialisation_du_Processus' => Configuration::get('AV_PROCESSINIT' . $group_name, null, null, $id_shop), 'Statut_choisi' => Configuration::get('AV_ORDERSTATESCHOOSEN' . $group_name, null, null, $id_shop), 'Recuperation_Avis_Produits' => Configuration::get('AV_GETPRODREVIEWS' . $group_name, null, null, $id_shop), 'Affiche_Avis_Produits' => Configuration::get('AV_DISPLAYPRODREVIEWS' . $group_name, null, null, $id_shop), 'Affichage_Widget_Flottant' => Configuration::get('AV_SCRIPTFLOAT_ALLOWED' . $group_name, null, null, $id_shop), 'Script_Widget_Flottant' => Configuration::get('AV_SCRIPTFLOAT' . $group_name, null, null, $id_shop), 'Affichage_Widget_Fixe' => Configuration::get('AV_SCRIPTFIXE_ALLOWED' . $group_name, null, null, $id_shop), 'Position_Widget_Fixe' => Configuration::get('AV_SCRIPTFIXE_POSITION' . $group_name, null, null, $id_shop), 'Script_Widget_Fixe' => Configuration::get('AV_SCRIPTFIXE' . $group_name, null, null, $id_shop), 'Emails_Interdits' => Configuration::get('AV_FORBIDDEN_EMAIL' . $group_name, null, null, $id_shop), 'Liste_des_statuts' => $order_statut_list, 'Droit_du_dossier_AV' => $info, 'Date_Recuperation_Config' => date('Y-m-d H:i:s'));
$sql = 'SELECT value FROM ' . _DB_PREFIX_ . "configuration where name = 'AV_GROUP_CONF" . pSQL($group_name) . "' and id_shop like '(int){$id_shop}' ";
if ($row = Db::getInstance()->getRow($sql)) {
$return['list_iso_lang_multilingue'] = unserialize($row['value']);
}
} else {
$explode_secret_key = explode('-', Configuration::get('AV_CLESECRETE', null, null, $id_shop));
$return = array('Version_PS' => _PS_VERSION_, 'Version_Module' => $module_version, 'idWebsite' => Configuration::get('AV_IDWEBSITE', null, null, $id_shop), 'Nb_Multiboutique' => '', 'Mode_multilingue' => '', 'list_iso_lang_multilingue' => '', 'Websites' => '', 'Id_Website_encours' => '', 'Cle_Secrete' => $explode_secret_key[0] . '-xxxx-xxxx-' . $explode_secret_key[3], 'Delay' => Configuration::get('AV_DELAY', null, null, $id_shop), 'Initialisation_du_Processus' => Configuration::get('AV_PROCESSINIT', null, null, $id_shop), 'Statut_choisi' => Configuration::get('AV_ORDERSTATESCHOOSEN', null, null, $id_shop), 'Recuperation_Avis_Produits' => Configuration::get('AV_GETPRODREVIEWS', null, null, $id_shop), 'Affiche_Avis_Produits' => Configuration::get('AV_DISPLAYPRODREVIEWS', null, null, $id_shop), 'Affichage_Widget_Flottant' => Configuration::get('AV_SCRIPTFLOAT_ALLOWED', null, null, $id_shop), 'Script_Widget_Flottant' => Configuration::get('AV_SCRIPTFLOAT', null, null, $id_shop), 'Affichage_Widget_Fixe' => Configuration::get('AV_SCRIPTFIXE_ALLOWED', null, null, $id_shop), 'Position_Widget_Fixe' => Configuration::get('AV_SCRIPTFIXE_POSITION', null, null, $id_shop), 'Script_Widget_Fixe' => Configuration::get('AV_SCRIPTFIXE', null, null, $id_shop), 'Emails_Interdits' => Configuration::get('AV_FORBIDDEN_EMAIL', null, null, $id_shop), 'Liste_des_statuts' => $order_statut_list, 'Droit_du_dossier_AV' => $info, 'Date_Recuperation_Config' => date('Y-m-d H:i:s'));
}
} else {
if (Configuration::get('AV_MULTILINGUE') == 'checked') {
$explode_secret_key = explode('-', Configuration::get('AV_CLESECRETE' . $group_name));
$return = array('Version_PS' => _PS_VERSION_, 'Version_Module' => $module_version, 'idWebsite' => Configuration::get('AV_IDWEBSITE' . $group_name), 'Nb_Multiboutique' => '', 'Mode_multilingue' => '1', 'list_iso_lang_multilingue' => '', 'Websites' => '', 'Id_Website_encours' => '', 'Cle_Secrete' => $explode_secret_key[0] . '-xxxx-xxxx-' . $explode_secret_key[3], 'Delay' => Configuration::get('AV_DELAY' . $group_name), 'Initialisation_du_Processus' => Configuration::get('AV_PROCESSINIT' . $group_name), 'Statut_choisi' => Configuration::get('AV_ORDERSTATESCHOOSEN' . $group_name), 'Recuperation_Avis_Produits' => Configuration::get('AV_GETPRODREVIEWS' . $group_name), 'Affiche_Avis_Produits' => Configuration::get('AV_DISPLAYPRODREVIEWS' . $group_name), 'Affichage_Widget_Flottant' => Configuration::get('AV_SCRIPTFLOAT_ALLOWED' . $group_name), 'Script_Widget_Flottant' => Configuration::get('AV_SCRIPTFLOAT' . $group_name), 'Affichage_Widget_Fixe' => Configuration::get('AV_SCRIPTFIXE_ALLOWED' . $group_name), 'Position_Widget_Fixe' => Configuration::get('AV_SCRIPTFIXE_POSITION' . $group_name), 'Script_Widget_Fixe' => Configuration::get('AV_SCRIPTFIXE' . $group_name), 'Emails_Interdits' => Configuration::get('AV_FORBIDDEN_EMAIL' . $group_name), 'Liste_des_statuts' => $order_statut_list, 'Droit_du_dossier_AV' => $info, 'Date_Recuperation_Config' => date('Y-m-d H:i:s'));
$sql = 'SELECT value FROM ' . _DB_PREFIX_ . "configuration where name = 'AV_GROUP_CONF" . pSQL($group_name) . "' and id_shop is NULL";
if ($row = Db::getInstance()->getRow($sql)) {
$return['list_iso_lang_multilingue'] = unserialize($row['value']);
}
} else {
$explode_secret_key = explode('-', Configuration::get('AV_CLESECRETE'));
$return = array('Version_PS' => _PS_VERSION_, 'Version_Module' => $module_version, 'idWebsite' => Configuration::get('AV_IDWEBSITE'), 'Nb_Multiboutique' => '', 'Websites' => '', 'Id_Website_encours' => '', 'Cle_Secrete' => $explode_secret_key[0] . '-xxxx-xxxx-' . $explode_secret_key[3], 'Delay' => Configuration::get('AV_DELAY'), 'Initialisation_du_Processus' => Configuration::get('AV_PROCESSINIT'), 'Statut_choisi' => Configuration::get('AV_ORDERSTATESCHOOSEN'), 'Recuperation_Avis_Produits' => Configuration::get('AV_GETPRODREVIEWS'), 'Affiche_Avis_Produits' => Configuration::get('AV_DISPLAYPRODREVIEWS'), 'Affichage_Widget_Flottant' => Configuration::get('AV_SCRIPTFLOAT_ALLOWED'), 'Script_Widget_Flottant' => Configuration::get('AV_SCRIPTFLOAT'), 'Affichage_Widget_Fixe' => Configuration::get('AV_SCRIPTFIXE_ALLOWED'), 'Position_Widget_Fixe' => Configuration::get('AV_SCRIPTFIXE_POSITION'), 'Script_Widget_Fixe' => Configuration::get('AV_SCRIPTFIXE'), 'Emails_Interdits' => Configuration::get('AV_FORBIDDEN_EMAIL'), 'Liste_des_statuts' => $order_statut_list, 'Droit_du_dossier_AV' => $info, 'Date_Recuperation_Config' => date('Y-m-d H:i:s'));
}
}
if (Configuration::get('PS_MULTISHOP_FEATURE_ACTIVE') == 1) {
$return['Nb_Multiboutique'] = Shop::getTotalShops();
$return['Websites'] = Shop::getShops();
}
return $return;
}