diff --git a/classes/AdminController.php b/classes/AdminController.php index 931a94eb9..29bbe5066 100644 --- a/classes/AdminController.php +++ b/classes/AdminController.php @@ -65,8 +65,6 @@ class AdminControllerCore extends Controller /** @var string Security token */ public $token; - protected $_object; - /** @var string shop | group_shop */ public $shopLinkType; @@ -756,21 +754,22 @@ class AdminControllerCore extends Controller $id = (int)Tools::getValue($this->identifier); if ($id && Validate::isUnsignedId($id)) { - if (!$this->_object) - $this->_object = new $this->className($id); - if (Validate::isLoadedObject($this->_object)) - return $this->_object; + if (!$this->object) + $this->object = new $this->className($id); + if (Validate::isLoadedObject($this->object)) + return $this->object; $this->_errors[] = Tools::displayError('Object cannot be loaded (not found)'); } else if ($opt) { - $this->_object = new $this->className(); - return $this->_object; + $this->object = new $this->className(); + return $this->object; } else $this->_errors[] = Tools::displayError('Object cannot be loaded (identifier missing or invalid)'); $this->content = $this->displayErrors(); + return $this->object; } /** @@ -1084,14 +1083,15 @@ class AdminControllerCore extends Controller $this->initToolbar(); if ($this->display == 'edit' || $this->display == 'add') { - if (!($this->object = $this->loadObject(true))) + if (!$this->loadObject(true)) return; $this->content .= $this->initForm(); } elseif ($this->display == 'view') { - if (!($this->object = $this->loadObject(true))) - return; + // Some controllers use the view action without an object + if ($this->className) + $this->loadObject(true); $this->content .= $this->initView(); } elseif (!$this->ajax) @@ -1104,7 +1104,7 @@ class AdminControllerCore extends Controller 'content' => $this->content, 'url_post' => self::$currentIndex.'&token='.$this->token, )); - } + } /** * initialize the invalid doom page of death @@ -1210,7 +1210,7 @@ class AdminControllerCore extends Controller // For each action, try to add the corresponding skip elements list $helper->list_skip_actions = $this->list_skip_actions; - + } /** @@ -2025,7 +2025,7 @@ class AdminControllerCore extends Controller */ protected function displayAssoShop($type = 'shop') { - if (!Shop::isFeatureActive() || (!$this->_object && $this->context->shop->getContextType() != Shop::CONTEXT_ALL)) + if (!Shop::isFeatureActive() || (!$this->object && $this->context->shop->getContextType() != Shop::CONTEXT_ALL)) return; if ($type != 'shop' && $type != 'group_shop') @@ -2101,9 +2101,9 @@ EOF; $html .= '


 ? 'b' : 'f').'.png)
';
+ $this->context->smarty->assign(array(
+ 'enabled' => (bool)$value,
+ 'url_enable' => $this->currentIndex.'&'.$this->identifier.'='.$id.'&'.$active.$this->table.
+ ((int)$id_category && (int)$id_product ? '&id_category='.$id_category : '').'&token='.($token != null ? $token : $this->token)
+ ));
+ return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/helper/list/list_action_enable.tpl');
}
public function displayListContent($token = null)
@@ -406,7 +408,7 @@ class HelperListCore extends Helper
$tpl = $this->context->smarty->template_dir[0].'/helper/list/list_action_edit.tpl';
return $this->context->smarty->fetch($tpl);
-
+
}
/**
@@ -426,8 +428,7 @@ class HelperListCore extends Helper
'action' => self::$cache_lang['Delete'],
));
- return $this->context->smarty->fetch(_PS_ADMIN_DIR_.'/themes/template/helper/list/list_action_delete.tpl');
-
+ return $this->context->smarty->fetch('helper/list/list_action_delete.tpl');
}
/**
@@ -512,7 +513,7 @@ class HelperListCore extends Helper
$this->context->controller->addJqueryUI('ui.datepicker');
break;
case 'select':
- foreach ($params['select'] as $option_value => $option_display)
+ foreach ($params['list'] as $option_value => $option_display)
{
if (isset($_POST[$this->table.'Filter_'.$params['filter_key']])
&& Tools::getValue($this->table.'Filter_'.$params['filter_key']) == $option_value
diff --git a/controllers/admin/AdminAddressesController.php b/controllers/admin/AdminAddressesController.php
index aaacbf10c..ef3d68c29 100644
--- a/controllers/admin/AdminAddressesController.php
+++ b/controllers/admin/AdminAddressesController.php
@@ -56,7 +56,7 @@ class AdminAddressesControllerCore extends AdminController
'address1' => array('title' => $this->l('Address'), 'width' => 200),
'postcode' => array('title' => $this->l('Postcode/ Zip Code'), 'align' => 'right', 'width' => 50),
'city' => array('title' => $this->l('City'), 'width' => 150),
- 'country' => array('title' => $this->l('Country'), 'width' => 100, 'type' => 'select', 'select' => $this->countriesArray, 'filter_key' => 'cl!id_country'));
+ 'country' => array('title' => $this->l('Country'), 'width' => 100, 'type' => 'select', 'list' => $this->countriesArray, 'filter_key' => 'cl!id_country'));
parent::__construct();
}
diff --git a/controllers/admin/AdminCustomersController.php b/controllers/admin/AdminCustomersController.php
index 4946667f0..0a3c39ef8 100644
--- a/controllers/admin/AdminCustomersController.php
+++ b/controllers/admin/AdminCustomersController.php
@@ -67,7 +67,7 @@ class AdminCustomersControllerCore extends AdminController
'icon' => $genders_icon,
'orderby' => false,
'type' => 'select',
- 'select' => $genders,
+ 'list' => $genders,
'filter_key' => 'a!id_gender',
),
'lastname' => array(
diff --git a/controllers/admin/AdminEmployeesController.php b/controllers/admin/AdminEmployeesController.php
index 73ebd0b92..bf7da3f21 100644
--- a/controllers/admin/AdminEmployeesController.php
+++ b/controllers/admin/AdminEmployeesController.php
@@ -60,7 +60,7 @@ class AdminEmployeesControllerCore extends AdminController
'lastname' => array('title' => $this->l('Last name'), 'width' => 130),
'firstname' => array('title' => $this->l('First name'), 'width' => 130),
'email' => array('title' => $this->l('E-mail address'), 'width' => 180),
- 'profile' => array('title' => $this->l('Profile'), 'width' => 90, 'type' => 'select', 'select' => $this->profiles_array, 'filter_key' => 'pl!name'),
+ 'profile' => array('title' => $this->l('Profile'), 'width' => 90, 'type' => 'select', 'list' => $this->profiles_array, 'filter_key' => 'pl!name'),
'active' => array('title' => $this->l('Can log in'), 'align' => 'center', 'active' => 'status', 'type' => 'bool'),
);
diff --git a/controllers/admin/AdminGendersController.php b/controllers/admin/AdminGendersController.php
index 7fdd9247c..772aed3cd 100644
--- a/controllers/admin/AdminGendersController.php
+++ b/controllers/admin/AdminGendersController.php
@@ -68,7 +68,7 @@ class AdminGendersController extends AdminController
'width' => 100,
'orderby' => false,
'type' => 'select',
- 'select' => array(
+ 'list' => array(
0 => $this->l('Male'),
1 => $this->l('Female'),
2 => $this->l('Neutral')
diff --git a/controllers/admin/AdminGroupShopController.php b/controllers/admin/AdminGroupShopController.php
index cb3f41ba8..bcd1e8071 100644
--- a/controllers/admin/AdminGroupShopController.php
+++ b/controllers/admin/AdminGroupShopController.php
@@ -175,7 +175,7 @@ class AdminGroupShopControllerCore extends AdminController
'name' => 'useImportData',
'value' => 1
),
- 'select' => array(
+ 'list' => array(
'type' => 'select',
'name' => 'importFromShop',
'options' => array(
diff --git a/controllers/admin/AdminManufacturersController.php b/controllers/admin/AdminManufacturersController.php
index 3c56912f4..93139ea0c 100644
--- a/controllers/admin/AdminManufacturersController.php
+++ b/controllers/admin/AdminManufacturersController.php
@@ -171,7 +171,7 @@ class AdminManufacturersControllerCore extends AdminController
'title' => $this->l('Country'),
'width' => 100,
'type' => 'select',
- 'select' => $this->countries_array,
+ 'list' => $this->countries_array,
'filter_key' => 'cl!id_country'
)
);
diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php
index eb08bf3ef..0ea95440d 100755
--- a/controllers/admin/AdminOrdersController.php
+++ b/controllers/admin/AdminOrdersController.php
@@ -66,7 +66,7 @@ class AdminOrdersControllerCore extends AdminController
'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 160, 'width' => 140, 'filter_key' => 'customer', 'tmpTableFilter' => true),
'total_paid' => array('title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '', 'suffix' => '', 'price' => true, 'currency' => true),
'payment' => array('title' => $this->l('Payment'), 'width' => 100),
- 'osname' => array('title' => $this->l('Status'), 'widthColumn' => 230, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200),
+ 'osname' => array('title' => $this->l('Status'), 'widthColumn' => 230, 'type' => 'select', 'list' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200),
'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'),
'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false));
$this->shopLinkType = 'shop';
@@ -74,7 +74,7 @@ class AdminOrdersControllerCore extends AdminController
parent::__construct();
}
-
+
public function initForm()
{
parent::initForm();
@@ -438,18 +438,18 @@ class AdminOrdersControllerCore extends AdminController
{
$order = new Order((int)(Tools::getValue('id_order')));
$pcc = new PaymentCC((int)Tools::getValue('id_payment_cc'));
-
+
$pcc->id_order = $order->id;
$pcc->transaction_id = (string)Tools::getValue('transaction_id');
$pcc->id_currency = $order->id_currency;
$pcc->amount = $order->total_paid;
$pcc->save();
-
+
unset($order, $pcc);
}
elseif (Tools::isSubmit('submitAddOrder') == 1 && ($id_cart = Tools::getValue('id_cart')) && ($module_name = pSQL(Tools::getValue('payment_module_name'))) && ($id_order_state = Tools::getValue('id_order_state')))
{
-
+
if ($this->tabAccess['edit'] === '1')
{
$payment_module = Module::getInstanceByName($module_name);
@@ -511,7 +511,7 @@ class AdminOrdersControllerCore extends AdminController
if (Validate::isLoadedObject($addressDelivery) AND $addressDelivery->id_state)
$deliveryState = new State((int)($addressDelivery->id_state));
}
-
+
// Smarty assign
$this->context->smarty->assign(array(
'order' => $order,
@@ -562,7 +562,7 @@ class AdminOrdersControllerCore extends AdminController
$this->content = Tools::jsonEncode($to_return);
}
-
+
public function ajaxProcessSearchProducts()
{
$currency = new Currency((int)Tools::getValue('id_currency'));
@@ -584,10 +584,10 @@ class AdminOrdersControllerCore extends AdminController
$combinations[$attribute['id_product_attribute']]['default_on'] = $attribute['default_on'];
if (!isset($combinations[$attribute['id_product_attribute']]['price']))
$combinations[$attribute['id_product_attribute']]['price'] = Tools::displayPrice(Tools::convertPrice(Product::getPriceStatic((int)$product['id_product'], true, $attribute['id_product_attribute']), $currency), $currency);
- if (!isset($combinations[$attribute['id_product_attribute']]['qty_in_stock']))
+ if (!isset($combinations[$attribute['id_product_attribute']]['qty_in_stock']))
$combinations[$attribute['id_product_attribute']]['qty_in_stock']= StockAvailable::getStockAvailableForProduct((int)$product['id_product'], $attribute['id_product_attribute'], (int)$this->context->shop->getID());
}
-
+
foreach ($combinations AS &$combination)
$combination['attributes'] = rtrim($combination['attributes'], ' - ');
$product['combinations'] = $combinations;
@@ -597,13 +597,13 @@ class AdminOrdersControllerCore extends AdminController
}
else
$to_return = array('found' => false);
-
+
$this->content = Tools::jsonEncode($to_return);
}
-
+
public function ajaxProcessSendMailValidateOrder()
{
- $errors = array();
+ $errors = array();
$cart = new Cart((int)Tools::getValue('id_cart'));
if (Validate::isLoadedObject($cart))
{
diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php
index fbf278307..e659774a3 100644
--- a/controllers/admin/AdminProductsController.php
+++ b/controllers/admin/AdminProductsController.php
@@ -1712,42 +1712,42 @@ if (false)
if($this->tabAccess['delete'])
$this->toolbar_btn['delete'] = array(
'short' => 'Delete',
- 'href' => $this->context->link->getAdminLink('AdminProducts').'&id_product='.$product->id.'&deleteproduct',
+ 'href' => $this->context->link->getAdminLink('AdminProducts').'&id_product='.$product->id.'&deleteproduct',
'desc' => $this->l('Delete this product'),
'confirm' => 1);
if($this->tabAccess['add'])
$this->toolbar_btn['duplicate'] = array(
'short' => 'Duplicate',
- 'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&id_product='.$product->id, 'desc' => $this->l('Duplicate'),
+ 'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&id_product='.$product->id, 'desc' => $this->l('Duplicate'),
'confirm' => 1
);
// @TODO navigation
$this->toolbar_btn['preview'] = array(
- 'short' => 'Preview',
- 'href' => '', 'desc' => 'prevdesc',
+ 'short' => 'Preview',
+ 'href' => '', 'desc' => 'prevdesc',
'class' => 'previewUrl',
);
if (file_exists(_PS_MODULE_DIR_.'statsproduct/statsproduct.php'))
$this->toolbar_btn['stats'] = array(
'short' => 'Statistics',
- 'href' => $this->context->link->getAdminLink('AdminStats').'&module=statsproduct&id_product='.$product->id,
- 'desc' => $this->l('View product sales'),
+ 'href' => $this->context->link->getAdminLink('AdminStats').'&module=statsproduct&id_product='.$product->id,
+ 'desc' => $this->l('View product sales'),
);
-
+
$this->toolbar_btn['cancel'] = array(
'short' => 'Close',
- 'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&id_product='.$product->id, 'desc' => $this->l('Cancel'),
+ 'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&id_product='.$product->id, 'desc' => $this->l('Cancel'),
'confirm' => 1);
if($this->tabAccess['add'])
$this->toolbar_btn['new'] = array(
'short' => 'Create',
- 'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&id_product='.$product->id, 'desc' => $this->l('Create'),
+ 'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&id_product='.$product->id, 'desc' => $this->l('Create'),
);
if($this->tabAccess['edit'])
$this->toolbar_btn['save'] = array(
'short' => 'Save',
- 'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&id_product='.$product->id, 'desc' => $this->l('Save'),
+ 'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&id_product='.$product->id, 'desc' => $this->l('Save'),
);
}
parent::initToolbar();
@@ -2378,7 +2378,7 @@ switch ($this->action)
'uploadable_files', 'text_fields'
);
// prices
- array_push($product_props,
+ array_push($product_props,
'price', 'wholesale_price', 'id_tax_rules_group', 'unit_price_ratio', 'on_sale',
'unity'
);
@@ -3795,21 +3795,22 @@ $product->supplier_name = Supplier::getNameById($product->id_supplier);
{
if ($id = (int)(Tools::getValue($this->identifier)) AND Validate::isUnsignedId($id))
{
- if (!$this->_object)
- $this->_object = new $this->className($id);
- if (Validate::isLoadedObject($this->_object))
- return $this->_object;
+ if (!$this->object)
+ $this->object = new $this->className($id);
+ if (Validate::isLoadedObject($this->object))
+ return $this->object;
$this->_errors[] = Tools::displayError('Object cannot be loaded (not found)');
}
else if ($opt)
{
- $this->_object = new $this->className();
- return $this->_object;
+ $this->object = new $this->className();
+ return $this->object;
}
else
$this->_errors[] = Tools::displayError('Object cannot be loaded (identifier missing or invalid)');
$this->displayErrors();
+ return $this->object;
}
public function displayInitInformationAndAttachment()
diff --git a/controllers/admin/AdminStockMvtController.php b/controllers/admin/AdminStockMvtController.php
index a0d7c5a3a..a4ac96164 100644
--- a/controllers/admin/AdminStockMvtController.php
+++ b/controllers/admin/AdminStockMvtController.php
@@ -52,7 +52,7 @@ class AdminStockMvtControllerCore extends AdminController
'align' => 'center',
'type' => 'select',
'filter_key' => 'a!sign',
- 'select' => array(
+ 'list' => array(
'1' => $this->l('Increment'),
'-1' => $this->l('Decrement'),
),