本文整理汇总了PHP中Shop::getTree方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::getTree方法的具体用法?PHP Shop::getTree怎么用?PHP Shop::getTree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Shop
的用法示例。
在下文中一共展示了Shop::getTree方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: initContent
public function initContent()
{
parent::initContent();
$this->addJqueryPlugin('cooki-plugin');
$data = Shop::getTree();
foreach ($data as $key_group => &$group) {
foreach ($group['shops'] as $key_shop => &$shop) {
$current_shop = new Shop($shop['id_shop']);
$urls = $current_shop->getUrls();
foreach ($urls as $key_url => &$url) {
$title = $url['domain'] . $url['physical_uri'] . $url['virtual_uri'];
if (strlen($title) > 23) {
$title = substr($title, 0, 23) . '...';
}
$url['name'] = $title;
$shop['urls'][$url['id_shop_url']] = $url;
}
}
}
$shops_tree = new HelperTreeShops('shops-tree', 'Multistore tree');
$shops_tree->setNodeFolderTemplate('shop_tree_node_folder.tpl')->setNodeItemTemplate('shop_tree_node_item.tpl')->setHeaderTemplate('shop_tree_header.tpl')->setActions(array(new TreeToolbarLink('Collapse All', '#', '$(\'#' . $shops_tree->getId() . '\').tree(\'collapseAll\'); return false;', 'icon-collapse-alt'), new TreeToolbarLink('Expand All', '#', '$(\'#' . $shops_tree->getId() . '\').tree(\'expandAll\'); return false;', 'icon-expand-alt')))->setAttribute('url_shop_group', $this->context->link->getAdminLink('AdminShopGroup'))->setAttribute('url_shop', $this->context->link->getAdminLink('AdminShop'))->setAttribute('url_shop_url', $this->context->link->getAdminLink('AdminShopUrl'))->setData($data);
$shops_tree = $shops_tree->render(null, false, false);
if ($this->display == 'edit') {
$this->toolbar_title[] = $this->object->name;
}
$this->context->smarty->assign(array('toolbar_scroll' => 1, 'toolbar_btn' => $this->toolbar_btn, 'title' => $this->toolbar_title, 'shops_tree' => $shops_tree));
}
示例3: getData
public function getData()
{
if (!isset($this->_data)) {
$this->setData(Shop::getTree());
}
return $this->_data;
}
示例4: getCurrentShopName
public function getCurrentShopName()
{
$shop_context = Shop::getContext();
$tree = Shop::getTree();
if ($this->noShopSelection()) {
$current_shop_name = Translate::getAdminTranslation('All shops');
} elseif ($shop_context == Shop::CONTEXT_GROUP) {
$current_shop_name = sprintf(Translate::getAdminTranslation('%s group'), $tree[Shop::getContextShopGroupID()]['name']);
} else {
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;
}
}
}
}
return $current_shop_name;
}
示例5: renderForm
public function renderForm()
{
$update_htaccess = Tools::modRewriteActive() && (file_exists('.htaccess') && is_writable('.htaccess') || is_writable(dirname('.htaccess')));
$this->multiple_fieldsets = true;
if (!$update_htaccess) {
$desc_virtual_uri = array('<span class="warning_mod_rewrite">' . $this->l('You need to activate URL Rewriting if you want to add a virtual URL.') . '</span>');
} else {
$desc_virtual_uri = array($this->l('You can use this option if you want to create a store with a URL that doesn\'t exist on your server (e.g. if you want your store to be available with the URL www.my-prestashop.com/my-store/shoes/, you have to set shoes/ in this field, assuming that my-store/ is your Physical URL).'), '<strong>' . $this->l('URL rewriting must be activated on your server to use this feature.') . '</strong>');
}
$this->fields_form = array(array('form' => array('legend' => array('title' => $this->l('URL options')), 'input' => array(array('type' => 'select', 'label' => $this->l('Shop:'), 'name' => 'id_shop', 'onchange' => 'checkMainUrlInfo(this.value);', 'options' => array('optiongroup' => array('query' => Shop::getTree(), 'label' => 'name'), 'options' => array('query' => 'shops', 'id' => 'id_shop', 'name' => 'name'))), array('type' => 'radio', 'label' => $this->l('Main URL:'), 'name' => 'main', 'class' => 't', 'values' => array(array('id' => 'main_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" />'), array('id' => 'main_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" />')), 'desc' => array($this->l('If you set this URL as the Main URL for the selected shop, all URLs set to this shop will be redirected to this URL (you can only have one Main URL per shop).'), array('text' => $this->l('Since the selected shop has no main URL, you have to set this URL as the Main URL.'), 'id' => 'mainUrlInfo'), array('text' => $this->l('The selected shop already has a Main URL. Therefore, if you set this one as the Main URL, the older of the two will be set as the normal URL.'), 'id' => 'mainUrlInfoExplain'))), array('type' => 'radio', 'label' => $this->l('Status:'), 'name' => 'active', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'active_on', 'value' => 1, 'label' => '<img src="../img/admin/enabled.gif" alt="' . $this->l('Enabled') . '" title="' . $this->l('Enabled') . '" />'), array('id' => 'active_off', 'value' => 0, 'label' => '<img src="../img/admin/disabled.gif" alt="' . $this->l('Disabled') . '" title="' . $this->l('Disabled') . '" />')), 'desc' => $this->l('Enabled or disabled'))), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'))), array('form' => array('legend' => array('title' => $this->l('Shop URL')), 'input' => array(array('type' => 'text', 'label' => $this->l('Domain:'), 'name' => 'domain', 'size' => 50), array('type' => 'text', 'label' => $this->l('Domain SSL:'), 'name' => 'domain_ssl', 'size' => 50), array('type' => 'text', 'label' => $this->l('Physical URL:'), 'name' => 'physical_uri', 'desc' => $this->l('This is the physical folder for your store on the server. Leave this field empty if your store is installed on the root path (e.g. if your store is available at www.my-prestashop.com/my-store/, you input my-store/ in this field).'), 'size' => 50), array('type' => 'text', 'label' => $this->l('Virtual URL:'), 'name' => 'virtual_uri', 'desc' => $desc_virtual_uri, 'size' => 50, 'hint' => !$update_htaccess ? $this->l('Warning: URL rewriting (e.g. mod_rewrite for Apache) seems to be disabled. If your URL doesn\'t work, please check with your host provider on how to activate URL rewriting.') : ''), array('type' => 'text', 'label' => $this->l('Your final URL will be:'), 'name' => 'final_url', 'size' => 76, 'readonly' => true)))));
if (!($obj = $this->loadObject(true))) {
return;
}
$current_shop = Shop::initialize();
$list_shop_with_url = array();
foreach (Shop::getShops(false, null, true) as $id) {
$list_shop_with_url[$id] = (bool) count(ShopUrl::getShopUrls($id));
}
$this->tpl_form_vars = array('js_shop_url' => Tools::jsonEncode($list_shop_with_url));
$this->fields_value = array('domain' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'domain') : $current_shop->domain, 'domain_ssl' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'domain_ssl') : $current_shop->domain_ssl, 'physical_uri' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'physical_uri') : $current_shop->physical_uri, 'active' => true);
return parent::renderForm();
}
示例6: renderAssoShop
/**
* Render an area to determinate shop association
*
* @return string
*/
public function renderAssoShop($disable_shared = false)
{
if (!Shop::isFeatureActive()) {
return;
}
$assos = array();
if ((int) $this->id) {
$sql = 'SELECT `id_shop`, `' . bqSQL($this->identifier) . '`
FROM `' . _DB_PREFIX_ . bqSQL($this->table) . '_shop`
WHERE `' . bqSQL($this->identifier) . '` = ' . (int) $this->id;
foreach (Db::getInstance()->executeS($sql) as $row) {
$assos[$row['id_shop']] = $row['id_shop'];
}
} else {
switch (Shop::getContext()) {
case Shop::CONTEXT_SHOP:
$assos[Shop::getContextShopID()] = Shop::getContextShopID();
break;
case Shop::CONTEXT_GROUP:
foreach (Shop::getShops(false, Shop::getContextShopGroupID(), true) as $id_shop) {
$assos[$id_shop] = $id_shop;
}
break;
default:
foreach (Shop::getShops(false, null, true) as $id_shop) {
$assos[$id_shop] = $id_shop;
}
break;
}
}
$tpl = $this->createTemplate('assoshop.tpl');
$tree = Shop::getTree();
$nb_shop = 0;
foreach ($tree as &$value) {
$value['disable_shops'] = isset($value[$disable_shared]) && $value[$disable_shared];
$nb_shop += count($value['shops']);
}
$tpl->assign(array('input' => array('type' => 'shop', 'values' => $tree), 'fields_value' => array('shop' => $assos), 'form_id' => $this->id, 'table' => $this->table, 'nb_shop' => $nb_shop));
return $tpl->fetch();
}
示例7: renderFormAttributes
public function renderFormAttributes()
{
$attributes_groups = AttributeGroup::getAttributesGroups($this->context->language->id);
$this->table = 'attribute';
$this->identifier = 'id_attribute';
$this->fields_form = array('legend' => array('title' => $this->l('Values'), 'image' => '../img/admin/asterisk.gif'), 'input' => array(array('type' => 'select', 'label' => $this->l('Attribute type:'), 'name' => 'id_attribute_group', 'required' => true, 'options' => array('query' => $attributes_groups, 'id' => 'id_attribute_group', 'name' => 'name'), 'desc' => $this->l('Choose the type of the attribute')), array('type' => 'text', 'label' => $this->l('Value:'), 'name' => 'name', 'lang' => true, 'size' => 33, 'required' => true, 'hint' => $this->l('Invalid characters:') . ' <>;=#{}')));
if (Shop::isFeatureActive()) {
// We get all associated shops for all attribute groups, because we will disable group shops
// for attributes that the selected attribute group don't support
$sql = 'SELECT id_attribute_group, id_shop FROM ' . _DB_PREFIX_ . 'attribute_group_shop';
$associations = array();
foreach (Db::getInstance()->executeS($sql) as $row) {
$associations[$row['id_attribute_group']][] = $row['id_shop'];
}
$this->fields_form['input'][] = array('type' => 'shop', 'label' => $this->l('Shop association:'), 'name' => 'checkBoxShopAsso', 'values' => Shop::getTree());
} else {
$associations = array();
}
$this->fields_form['shop_associations'] = Tools::jsonEncode($associations);
$this->fields_form['input'][] = array('type' => 'color', 'label' => $this->l('Color:'), 'name' => 'color', 'size' => 33, 'desc' => $this->l('Choose a color with the color picker, or enter an HTML color (e.g. "lightblue", "#CC6600")'));
$this->fields_form['input'][] = array('type' => 'file', 'label' => $this->l('Texture:'), 'name' => 'texture', 'desc' => array($this->l('Upload color texture from your computer'), $this->l('This will override the HTML color!')));
$this->fields_form['input'][] = array('type' => 'current_texture', 'label' => $this->l('Current texture:'), 'name' => 'current_texture');
$this->fields_form['input'][] = array('type' => 'closediv', 'name' => '');
$this->fields_form['submit'] = array('title' => $this->l('Save '), 'class' => 'button');
// Override var of Controller
$this->table = 'attribute';
$this->className = 'Attribute';
$this->identifier = 'id_attribute';
$this->lang = true;
$this->tpl_folder = 'attributes/';
// Create object Attribute
if (!($obj = new Attribute((int) Tools::getValue($this->identifier)))) {
return;
}
$str_attributes_groups = '';
foreach ($attributes_groups as $attribute_group) {
$str_attributes_groups .= '"' . $attribute_group['id_attribute_group'] . '" : ' . ($attribute_group['group_type'] == 'color' ? '1' : '0') . ', ';
}
$image = '../img/' . $this->fieldImageSettings['dir'] . '/' . (int) $obj->id . '.jpg';
$this->tpl_form_vars = array('strAttributesGroups' => $str_attributes_groups, 'colorAttributeProperties' => Validate::isLoadedObject($obj) && $obj->isColorAttribute(), 'imageTextureExists' => file_exists(_PS_IMG_DIR_ . $this->fieldImageSettings['dir'] . '/' . (int) $obj->id . '.jpg'), 'imageTexture' => $image, 'imageTextureUrl' => Tools::safeOutput($_SERVER['REQUEST_URI']) . '&deleteImage=1');
return parent::renderForm();
}
示例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: displayAssoShop
protected function displayAssoShop()
{
if (!Shop::isFeatureActive() || !$this->_object && Shop::getContext() != Shop::CONTEXT_ALL) {
return;
}
$assos = array();
$sql = 'SELECT id_shop, `' . bqSQL($this->identifier) . '`
FROM `' . _DB_PREFIX_ . bqSQL($this->table) . '_shop`';
foreach (Db::getInstance()->executeS($sql) as $row) {
$assos[$row['id_shop']][] = $row[$this->identifier];
}
$html = <<<EOF
\t\t\t<script type="text/javascript">
\t\t\t\$().ready(function()
\t\t\t{
\t\t\t\t// Click on "all shop"
\t\t\t\t\$('.input_all_shop').click(function()
\t\t\t\t{
\t\t\t\t\tvar checked = \$(this).prop('checked');
\t\t\t\t\t\$('.input_shop_group').attr('checked', checked);
\t\t\t\t\t\$('.input_shop').attr('checked', checked);
\t\t\t\t});
\t\t\t\t// Click on a group shop
\t\t\t\t\$('.input_shop_group').click(function()
\t\t\t\t{
\t\t\t\t\t\$('.input_shop[value='+\$(this).val()+']').attr('checked', \$(this).prop('checked'));
\t\t\t\t\tcheck_all_shop();
\t\t\t\t});
\t\t\t\t// Click on a shop
\t\t\t\t\$('.input_shop').click(function()
\t\t\t\t{
\t\t\t\t\tcheck_shop_group_status(\$(this).val());
\t\t\t\t\tcheck_all_shop();
\t\t\t\t});
\t\t\t\t// Initialize checkbox
\t\t\t\t\$('.input_shop').each(function(k, v)
\t\t\t\t{
\t\t\t\t\tcheck_shop_group_status(\$(v).val());
\t\t\t\t\tcheck_all_shop();
\t\t\t\t});
\t\t\t});
\t\t\tfunction check_shop_group_status(id_group)
\t\t\t{
\t\t\t\tvar groupChecked = true;
\t\t\t\t\$('.input_shop[value='+id_group+']').each(function(k, v)
\t\t\t\t{
\t\t\t\t\tif (!\$(v).prop('checked'))
\t\t\t\t\t\tgroupChecked = false;
\t\t\t\t});
\t\t\t\t\$('.input_shop_group[value='+id_group+']').attr('checked', groupChecked);
\t\t\t}
\t\t\tfunction check_all_shop()
\t\t\t{
\t\t\t\tvar allChecked = true;
\t\t\t\t\$('.input_shop_group').each(function(k, v)
\t\t\t\t{
\t\t\t\t\tif (!\$(v).prop('checked'))
\t\t\t\t\t\tallChecked = false;
\t\t\t\t});
\t\t\t\t\$('.input_all_shop').attr('checked', allChecked);
\t\t\t}
\t\t\t</script>
EOF;
$html .= '<div class="assoShop">';
$html .= '<table class="table" cellpadding="0" cellspacing="0" width="100%">
<tr><th>' . $this->l('Shop') . '</th></tr>';
$html .= '<tr><td><label class="t"><input class="input_all_shop" type="checkbox" /> ' . $this->l('All shops') . '</label></td></tr>';
foreach (Shop::getTree() as $groupID => $groupData) {
$html .= '<tr class="alt_row">';
$html .= '<td><img style="vertical-align: middle;" alt="" src="../img/admin/lv2_b.gif" /><label class="t"><input class="input_shop_group" type="checkbox" name="checkBoxShopGroupAsso_' . $this->table . '_' . $this->_object->id . '_' . $groupID . '" value="' . $groupID . '" ' . ($groupChecked ? 'checked="checked"' : '') . ' /> ' . $groupData['name'] . '</label></td>';
$html .= '</tr>';
$total = count($groupData['shops']);
$j = 0;
foreach ($groupData['shops'] as $shopID => $shopData) {
$checked = isset($assos[$shopID]) && in_array($this->_object->id, $assos[$shopID]) || !$this->_object->id;
$html .= '<tr>';
$html .= '<td><img style="vertical-align: middle;" alt="" src="../img/admin/lv3_' . ($j < $total - 1 ? 'b' : 'f') . '.png" /><label class="child">';
$html .= '<input class="input_shop" type="checkbox" value="' . $groupID . '" name="checkBoxShopAsso_' . $this->table . '_' . $this->_object->id . '_' . $shopID . '" id="checkedBox_' . $shopID . '" ' . ($checked ? 'checked="checked"' : '') . ' /> ';
$html .= $shopData['name'] . '</label></td>';
$html .= '</tr>';
$j++;
}
}
$html .= '</table></div>';
echo $html;
}
示例10: getStores
private function getStores()
{
$shop_group_ret = array();
$shop_groups_tree = Shop::getTree();
foreach ($shop_groups_tree as $shop_group_tree) {
$shop_group_ret_shops = array();
foreach ($shop_group_tree['shops'] as $shop) {
$shop_group_ret_shops[] = array('id_shop' => $shop['id_shop'], 'id_shop_group' => $shop['id_shop_group'], 'name' => $shop['name']);
}
$shop_group_ret[] = array('group_id' => $shop_group_tree['id'], 'name' => $shop_group_tree['name'], 'shops' => $shop_group_ret_shops);
}
return $shop_group_ret;
}
示例11: print_shop_list_tree
public static function print_shop_list_tree()
{
$shopList = Shop::getTree();
print_r($shopList);
}