[*] PROJECT : New Module API (part 1)

git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9790 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
fSerny
2011-11-02 10:49:01 +00:00
parent 953cb8b872
commit 0ba4fe9c7e
53 changed files with 640 additions and 339 deletions
+7 -7
View File
@@ -118,8 +118,8 @@ class AuthControllerCore extends FrontController
// Call a hook to display more information on form
$this->context->smarty->assign(array(
'HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'),
'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop')
'HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('createAccountForm'),
'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('createAccountTop')
));
$this->setTemplate(_PS_THEME_DIR_.'authentication.tpl');
}
@@ -235,7 +235,7 @@ class AuthControllerCore extends FrontController
*/
protected function processSubmitLogin()
{
Module::hookExec('beforeAuthentication');
Hook::exec('beforeAuthentication');
$passwd = trim(Tools::getValue('passwd'));
$email = trim(Tools::getValue('email'));
if (empty($email))
@@ -275,7 +275,7 @@ class AuthControllerCore extends FrontController
$this->context->cart->id_address_delivery = Address::getFirstCustomerAddressId((int)($customer->id));
$this->context->cart->id_address_invoice = Address::getFirstCustomerAddressId((int)($customer->id));
$this->context->cart->update();
Module::hookExec('authentication');
Hook::exec('authentication');
// Login information have changed, so we check if the cart rules still apply
CartRule::autoRemoveFromCart();
@@ -352,7 +352,7 @@ class AuthControllerCore extends FrontController
$this->updateContext($customer);
$this->context->cart->update();
Module::hookExec('createAccount', array(
Hook::exec('createAccount', array(
'_POST' => $_POST,
'newCustomer' => $customer
));
@@ -472,7 +472,7 @@ class AuthControllerCore extends FrontController
// If a logged guest logs in as a customer, the cart secure key was already set and needs to be updated
$this->context->cart->update();
Module::hookExec('createAccount', array(
Hook::exec('createAccount', array(
'_POST' => $_POST,
'newCustomer' => $customer
));
@@ -581,4 +581,4 @@ class AuthControllerCore extends FrontController
$customer->firstname.' '.$customer->lastname
);
}
}
}
+2 -2
View File
@@ -213,8 +213,8 @@ class CartControllerCore extends FrontController
}
$result['summary'] = $this->context->cart->getSummaryDetails();
$result['customizedDatas'] = Product::getAllCustomizedDatas($this->context->cart->id, null, true);
$result['HOOK_SHOPPING_CART'] = Module::hookExec('shoppingCart', $result['summary']);
$result['HOOK_SHOPPING_CART_EXTRA'] = Module::hookExec('shoppingCartExtra', $result['summary']);
$result['HOOK_SHOPPING_CART'] = Hook::exec('shoppingCart', $result['summary']);
$result['HOOK_SHOPPING_CART_EXTRA'] = Hook::exec('shoppingCartExtra', $result['summary']);
// Display reduced price (or not) without quantity discount
if (Tools::getIsset('getproductprice'))
+1 -1
View File
@@ -162,7 +162,7 @@ class CategoryControllerCore extends FrontController
public function assignProductList()
{
$hookExecuted = false;
Module::hookExec('productListAssign', array(
Hook::exec('productListAssign', array(
'nbProducts' => &$this->nbProducts,
'catProducts' => &$this->cat_products,
'hookExecuted' => &$hookExecuted,
+1 -1
View File
@@ -159,7 +159,7 @@ class CompareControllerCore extends FrontController
'width' => $width,
'homeSize' => Image::getSize('home')
));
$this->context->smarty->assign('HOOK_EXTRA_PRODUCT_COMPARISON', Module::hookExec('extraProductComparison', array('list_ids_product' => $ids)));
$this->context->smarty->assign('HOOK_EXTRA_PRODUCT_COMPARISON', Hook::exec('extraProductComparison', array('list_ids_product' => $ids)));
}
}
}
@@ -156,8 +156,8 @@ class GuestTrackingControllerCore extends FrontController
'deliveryAddressFormatedValues' => $deliveryAddressFormatedValues));
if ($carrier->url && $order->shipping_number)
$this->context->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
$this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order)));
Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order));
$this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Hook::exec('orderDetailDisplayed', array('order' => $order)));
Hook::exec('OrderDetail', array('carrier' => $carrier, 'order' => $order));
}
public function setMedia()
+1 -1
View File
@@ -35,7 +35,7 @@ class IndexControllerCore extends FrontController
*/
public function initContent()
{
$this->context->smarty->assign('HOOK_HOME', Module::hookExec('home'));
$this->context->smarty->assign('HOOK_HOME', Hook::exec('home'));
$this->setTemplate(_PS_THEME_DIR_.'index.tpl');
}
}
+1 -1
View File
@@ -48,7 +48,7 @@ class MyAccountControllerCore extends FrontController
'voucherAllowed' => (int)(Configuration::get('PS_VOUCHERS')),
'returnAllowed' => (int)(Configuration::get('PS_ORDER_RETURN'))
));
$this->context->smarty->assign('HOOK_CUSTOMER_ACCOUNT', Module::hookExec('customerAccount'));
$this->context->smarty->assign('HOOK_CUSTOMER_ACCOUNT', Hook::exec('customerAccount'));
$this->setTemplate(_PS_THEME_DIR_.'my-account.tpl');
}
+2 -2
View File
@@ -192,8 +192,8 @@ class OrderDetailControllerCore extends FrontController
));
if ($carrier->url && $order->shipping_number)
$this->context->smarty->assign('followup', str_replace('@', $order->shipping_number, $carrier->url));
$this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Module::hookExec('orderDetailDisplayed', array('order' => $order)));
Module::hookExec('OrderDetail', array('carrier' => $carrier, 'order' => $order));
$this->context->smarty->assign('HOOK_ORDERDETAILDISPLAYED', Hook::exec('orderDetailDisplayed', array('order' => $order)));
Hook::exec('OrderDetail', array('carrier' => $carrier, 'order' => $order));
unset($carrier, $addressInvoice, $addressDelivery);
}
+1 -1
View File
@@ -67,7 +67,7 @@ class OrderFollowControllerCore extends FrontController
$orderReturn->state = 1;
$orderReturn->add();
$orderReturn->addReturnDetail($ids_order_detail, $order_qte_input, $customizationIds, $customizationQtyInput);
Module::hookExec('orderReturn', array('orderReturn' => $orderReturn));
Hook::exec('orderReturn', array('orderReturn' => $orderReturn));
Tools::redirect('index.php?controller=order-follow');
}
}
+11 -11
View File
@@ -67,7 +67,7 @@ class OrderOpcControllerCore extends ParentOrderController
{
$return = array(
'summary' => $this->context->cart->getSummaryDetails(),
'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'),
'HOOK_TOP_PAYMENT' => Hook::exec('paymentTop'),
'HOOK_PAYMENT' => $this->_getPaymentMethods()
);
die(Tools::jsonEncode($return));
@@ -84,7 +84,7 @@ class OrderOpcControllerCore extends ParentOrderController
{
$this->context->cookie->checkedTOS = (int)(Tools::getValue('checked'));
die(Tools::jsonEncode(array(
'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'),
'HOOK_TOP_PAYMENT' => Hook::exec('paymentTop'),
'HOOK_PAYMENT' => $this->_getPaymentMethods()
)));
}
@@ -137,7 +137,7 @@ class OrderOpcControllerCore extends ParentOrderController
'order_opc_adress' => $this->context->smarty->fetch(_PS_THEME_DIR_.'order-address.tpl'),
'block_user_info' => (isset($blockUserInfo) ? $blockUserInfo->hookTop(array()) : ''),
'carrier_list' => $this->_getCarrierList(),
'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'),
'HOOK_TOP_PAYMENT' => Hook::exec('paymentTop'),
'HOOK_PAYMENT' => $this->_getPaymentMethods(),
'no_address' => 0,
'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int)($this->context->cookie->id_currency))))
@@ -190,7 +190,7 @@ class OrderOpcControllerCore extends ParentOrderController
$wrapping_fees_tax_inc = $wrapping_fees * (1 + (((float)($wrapping_fees_tax->rate) / 100)));
$result = array_merge($result, array(
'summary' => $this->context->cart->getSummaryDetails(),
'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'),
'HOOK_TOP_PAYMENT' => Hook::exec('paymentTop'),
'HOOK_PAYMENT' => $this->_getPaymentMethods(),
'gift_price' => Tools::displayPrice(Tools::convertPrice(Product::getTaxCalculationMethod() == 1 ? $wrapping_fees : $wrapping_fees_tax_inc, new Currency((int)($this->context->cookie->id_currency))))
));
@@ -256,8 +256,8 @@ class OrderOpcControllerCore extends ParentOrderController
));
/* Call a hook to display more information on form */
self::$smarty->assign(array(
'HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'),
'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop')
'HOOK_CREATE_ACCOUNT_FORM' => Hook::exec('createAccountForm'),
'HOOK_CREATE_ACCOUNT_TOP' => Hook::exec('createAccountTop')
));
$years = Tools::dateYears();
$months = Tools::dateMonths();
@@ -333,7 +333,7 @@ class OrderOpcControllerCore extends ParentOrderController
'carriers' => $carriers,
'default_carrier' => (int)(Configuration::get('PS_CARRIER_DEFAULT')),
'HOOK_EXTRACARRIER' => NULL,
'HOOK_BEFORECARRIER' => Module::hookExec('beforeCarrier', array('carriers' => $carriers))
'HOOK_BEFORECARRIER' => Hook::exec('beforeCarrier', array('carriers' => $carriers))
));
}
else
@@ -343,7 +343,7 @@ class OrderOpcControllerCore extends ParentOrderController
protected function _assignPayment()
{
$this->context->smarty->assign(array(
'HOOK_TOP_PAYMENT' => ($this->isLogged ? Module::hookExec('paymentTop') : ''),
'HOOK_TOP_PAYMENT' => ($this->isLogged ? Hook::exec('paymentTop') : ''),
'HOOK_PAYMENT' => $this->_getPaymentMethods()
));
}
@@ -389,7 +389,7 @@ class OrderOpcControllerCore extends ParentOrderController
if ($this->context->cart->getOrderTotal() <= 0)
return '<p class="center"><input type="button" class="exclusive_large" name="confirmOrder" id="confirmOrder" value="'.Tools::displayError('I confirm my order').'" onclick="confirmFreeOrder();" /></p>';
$return = Module::hookExecPayment();
$return = Hook::exec('payment');
if (!$return)
return '<p class="warning">'.Tools::displayError('No payment method is available').'</p>';
return $return;
@@ -412,8 +412,8 @@ class OrderOpcControllerCore extends ParentOrderController
$result = array(
'checked' => $this->_setDefaultCarrierSelection($carriers),
'carriers' => $carriers,
'HOOK_BEFORECARRIER' => Module::hookExec('beforeCarrier', array('carriers' => $carriers)),
'HOOK_EXTRACARRIER' => Module::hookExec('extraCarrier', array('address' => $address_delivery))
'HOOK_BEFORECARRIER' => Hook::exec('beforeCarrier', array('carriers' => $carriers)),
'HOOK_EXTRACARRIER' => Hook::exec('extraCarrier', array('address' => $address_delivery))
);
return $result;
}
+7 -7
View File
@@ -222,7 +222,7 @@ class ParentOrderControllerCore extends FrontController
else if (!$this->context->cart->isVirtualCart() && (int)(Tools::getValue('id_carrier')) == 0)
$this->errors[] = Tools::displayError('Invalid carrier or no carrier selected');
Module::hookExec('processCarrier', array('cart' => $this->context->cart));
Hook::exec('processCarrier', array('cart' => $this->context->cart));
if (!$this->context->cart->update())
return false;
@@ -293,8 +293,8 @@ class ParentOrderControllerCore extends FrontController
'currencyFormat' => $this->context->currency->format,
'currencyBlank' => $this->context->currency->blank));
$this->context->smarty->assign(array(
'HOOK_SHOPPING_CART' => Module::hookExec('shoppingCart', $summary),
'HOOK_SHOPPING_CART_EXTRA' => Module::hookExec('shoppingCartExtra', $summary)
'HOOK_SHOPPING_CART' => Hook::exec('shoppingCart', $summary),
'HOOK_SHOPPING_CART_EXTRA' => Hook::exec('shoppingCartExtra', $summary)
));
}
@@ -383,8 +383,8 @@ class ParentOrderControllerCore extends FrontController
'default_carrier' => (int)(Configuration::get('PS_CARRIER_DEFAULT'))
));
$this->context->smarty->assign(array(
'HOOK_EXTRACARRIER' => Module::hookExec('extraCarrier', array('address' => $address)),
'HOOK_BEFORECARRIER' => Module::hookExec('beforeCarrier', array('carriers' => $carriers))
'HOOK_EXTRACARRIER' => Hook::exec('extraCarrier', array('address' => $address)),
'HOOK_BEFORECARRIER' => Hook::exec('beforeCarrier', array('carriers' => $carriers))
));
}
@@ -419,8 +419,8 @@ class ParentOrderControllerCore extends FrontController
protected function _assignPayment()
{
$this->context->smarty->assign(array(
'HOOK_TOP_PAYMENT' => Module::hookExec('paymentTop'),
'HOOK_PAYMENT' => Module::hookExecPayment()
'HOOK_TOP_PAYMENT' => Hook::exec('paymentTop'),
'HOOK_PAYMENT' => Hook::exec('payment'),
));
}
+7 -7
View File
@@ -178,12 +178,12 @@ class ProductControllerCore extends FrontController
'attachments' => (($this->product->cache_has_attachments) ? $this->product->getAttachments($this->context->language->id) : array()),
'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int)$this->product->out_of_stock),
'last_qties' => (int)Configuration::get('PS_LAST_QTIES'),
'HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'),
'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'),
'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($this->product),
'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'),
'HOOK_PRODUCT_TAB' => Module::hookExec('productTab'),
'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent'),
'HOOK_EXTRA_LEFT' => Hook::exec('extraLeft'),
'HOOK_EXTRA_RIGHT' => Hook::exec('extraRight'),
'HOOK_PRODUCT_OOS' => Hook::exec('productOutOfStock', array('product' => $this->product)),
'HOOK_PRODUCT_ACTIONS' => Hook::exec('productActions'),
'HOOK_PRODUCT_TAB' => Hook::exec('productTab'),
'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('productTabContent'),
'display_qties' => (int)Configuration::get('PS_DISPLAY_QTIES'),
'display_ht' => !Tax::excludeTaxeOption(),
'currencySign' => $this->context->currency->sign,
@@ -499,7 +499,7 @@ class ProductControllerCore extends FrontController
$this->context->smarty->assign('path', Tools::getPath((int)$this->product->id_category_default, $this->product->name));
$this->context->smarty->assign('categories', Category::getHomeCategories($this->context->language->id));
$this->context->smarty->assign(array('HOOK_PRODUCT_FOOTER' => Hook::productFooter($this->product, $category)));
$this->context->smarty->assign(array('HOOK_PRODUCT_FOOTER' => Hook::exec('productFooter', array('product' => $this->product, 'category' => $category))));
}
public function transformDescriptionWithImg($desc)
+4 -4
View File
@@ -64,7 +64,7 @@ class SearchControllerCore extends FrontController
$this->n = abs((int)(Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'))));
$this->p = abs((int)(Tools::getValue('p', 1)));
$search = Search::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
Module::hookExec('search', array('expr' => $query, 'total' => $search['total']));
Hook::exec('search', array('expr' => $query, 'total' => $search['total']));
$nbProducts = $search['total'];
$this->pagination($nbProducts);
$this->context->smarty->assign(array(
@@ -81,7 +81,7 @@ class SearchControllerCore extends FrontController
$this->n = abs((int)(Tools::getValue('n', Configuration::get('PS_PRODUCTS_PER_PAGE'))));
$this->p = abs((int)(Tools::getValue('p', 1)));
$search = Search::find($this->context->language->id, $query, $this->p, $this->n, $this->orderBy, $this->orderWay);
Module::hookExec('search', array('expr' => $query, 'total' => $search['total']));
Hook::exec('search', array('expr' => $query, 'total' => $search['total']));
$nbProducts = $search['total'];
$this->pagination($nbProducts);
$this->context->smarty->assign(array(
@@ -96,7 +96,7 @@ class SearchControllerCore extends FrontController
$nbProducts = (int)(Search::searchTag($this->context->language->id, $tag, true));
$this->pagination($nbProducts);
$result = Search::searchTag($this->context->language->id, $tag, false, $this->p, $this->n, $this->orderBy, $this->orderWay);
Module::hookExec('search', array('expr' => $tag, 'total' => count($result)));
Hook::exec('search', array('expr' => $tag, 'total' => count($result)));
$this->context->smarty->assign(array(
'search_tag' => $tag,
'products' => $result, // DEPRECATED (since to 1.4), not use this: conflict with block_cart module
@@ -138,4 +138,4 @@ class SearchControllerCore extends FrontController
if (!$this->instant_search && !$this->ajax_search)
$this->addCSS(_THEME_CSS_DIR_.'product_list.css');
}
}
}