// Rename Module->smartyAssign to Module->templateAssign

[+] Front: Add module controller + url dispatch for modules
This commit is contained in:
rMalie
2011-09-23 13:50:33 +00:00
parent 3c215168ac
commit dc957d3d3a
21 changed files with 190 additions and 120 deletions

View File

@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -59,7 +59,7 @@ class AdminMeta extends AdminTab
'fields' => array(),
),
);
// Display route options only if friendly URL is activated
if (Configuration::get('PS_REWRITING_SETTINGS'))
{
@@ -69,9 +69,10 @@ class AdminMeta extends AdminTab
$this->addFieldRoute('manufacturer_rule', $this->l('Route to manufacturer'));
$this->addFieldRoute('cms_rule', $this->l('Route to CMS page'));
$this->addFieldRoute('cms_category_rule', $this->l('Route to CMS category'));
$this->addFieldRoute('module', $this->l('Route to modules'));
}
}
public function addFieldRoute($routeID, $title)
{
$keywords = array();
@@ -91,7 +92,7 @@ class AdminMeta extends AdminTab
public function displayForm($isMainTab = true)
{
parent::displayForm();
if (!($meta = $this->loadObject(true)))
return;
$files = Meta::getPages(true, ($meta->page ? $meta->page : false));
@@ -174,7 +175,7 @@ class AdminMeta extends AdminTab
</fieldset>
</form>';
}
public function postProcess()
{
if (Tools::isSubmit('submitAddmeta'))
@@ -210,18 +211,18 @@ class AdminMeta extends AdminTab
}
Module::hookExec('afterSaveAdminMeta');
}
return parent::postProcess();
}
public function getList($id_lang, $orderBy = NULL, $orderWay = NULL, $start = 0, $limit = NULL, $id_lang_shop = false)
{
parent::getList($id_lang, $orderBy, $orderWay, $start, $limit, Context::getContext()->shop->getID(true));
}
/**
* Validate route syntax and save it in configuration
*
*
* @param string $routeID
*/
public function checkAndUpdateRoute($routeID)
@@ -229,7 +230,7 @@ class AdminMeta extends AdminTab
$default_routes = Dispatcher::getInstance()->default_routes;
if (!isset($default_routes[$routeID]))
return ;
$rule = Tools::getValue('PS_ROUTE_'.$routeID);
if (!$rule || $rule == $default_routes[$routeID]['rule'])
{
@@ -256,22 +257,22 @@ class AdminMeta extends AdminTab
{
$this->checkAndUpdateRoute('category_rule');
}
public function updateOptionPsRouteSupplierRule()
{
$this->checkAndUpdateRoute('supplier_rule');
}
public function updateOptionPsRouteManufacturerRule()
{
$this->checkAndUpdateRoute('manufacturer_rule');
}
public function updateOptionPsRouteCmsRule()
{
$this->checkAndUpdateRoute('cms_rule');
}
public function updateOptionPsRouteCmsCategoryRule()
{
$this->checkAndUpdateRoute('cms_category_rule');

View File

@@ -315,6 +315,8 @@
'IndexController' => 'override/controllers/front/IndexController.php',
'ManufacturerControllerCore' => 'controllers/front/ManufacturerController.php',
'ManufacturerController' => 'override/controllers/front/ManufacturerController.php',
'ModuleControllerCore' => 'controllers/front/ModuleController.php',
'ModuleController' => 'override/controllers/front/ModuleController.php',
'MyAccountControllerCore' => 'controllers/front/MyAccountController.php',
'MyAccountController' => 'override/controllers/front/MyAccountController.php',
'NewProductsControllerCore' => 'controllers/front/NewProductsController.php',

View File

@@ -108,6 +108,14 @@ class DispatcherCore
'meta_title' => array('regexp' => '[a-zA-Z0-9-]*'),
),
),
'module' => array(
'controller' => 'module',
'rule' => 'module/{name}/{action}',
'keywords' => array(
'name' => array('regexp' => '[a-zA-Z0-9_-]+', 'param' => 'module'),
'action' => array('regexp' => '[a-zA-Z0-9_-]+', 'param' => 'action'),
),
),
);
/**

View File

@@ -25,7 +25,7 @@
* International Registered Trademark & Property of PrestaShop SA
*/
class FrontControllerCore extends ControllerCore
class FrontControllerCore extends Controller
{
public $errors = array();

View File

@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -31,7 +31,7 @@ class LinkCore
protected $allow;
protected $url;
public static $cache = array('page' => array());
public $protocol_link;
public $protocol_content;
@@ -74,7 +74,7 @@ class LinkCore
{
$dispatcher = Dispatcher::getInstance();
$url = _PS_BASE_URL_.__PS_BASE_URI__;
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
@@ -97,10 +97,10 @@ class LinkCore
if ($dispatcher->hasKeyword('product_rule', 'manufacturer'))
$params['manufacturer'] = Tools::str2url($product->isFullyLoaded ? $product->manufacturer_name : Manufacturer::getNameById($product->id_manufacturer));
if ($dispatcher->hasKeyword('product_rule', 'supplier'))
$params['supplier'] = Tools::str2url($product->isFullyLoaded ? $product->supplier_name : Supplier::getNameById($product->id_supplier));
if ($dispatcher->hasKeyword('product_rule', 'price'))
$params['supplier'] = $product->isFullyLoaded ? $product->price : Product::getPriceStatic($product->id, false, NULL, 6, NULL, false, true, 1, false, NULL, NULL, NULL, $product->specificPrice);
@@ -118,7 +118,7 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getCategoryLink($category, $alias = NULL, $id_lang = NULL)
public function getCategoryLink($category, $alias = null, $id_lang = null)
{
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if (!$id_lang)
@@ -145,7 +145,7 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getCMSCategoryLink($category, $alias = NULL, $id_lang = NULL)
public function getCMSCategoryLink($category, $alias = null, $id_lang = null)
{
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if (!$id_lang)
@@ -173,7 +173,7 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = NULL)
public function getCMSLink($cms, $alias = null, $ssl = false, $id_lang = null)
{
$base = (($ssl AND Configuration::get('PS_SSL_ENABLED')) ? Tools::getShopDomainSsl(true) : Tools::getShopDomain(true));
$url = $base.__PS_BASE_URI__.$this->getLangLink($id_lang);
@@ -201,7 +201,7 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getSupplierLink($supplier, $alias = NULL, $id_lang = NULL)
public function getSupplierLink($supplier, $alias = null, $id_lang = null)
{
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if (!$id_lang)
@@ -228,7 +228,7 @@ class LinkCore
* @param int $id_lang
* @return string
*/
public function getManufacturerLink($manufacturer, $alias = NULL, $id_lang = NULL)
public function getManufacturerLink($manufacturer, $alias = null, $id_lang = null)
{
$url = _PS_BASE_URL_.__PS_BASE_URI__.$this->getLangLink($id_lang);
if (!$id_lang)
@@ -247,18 +247,42 @@ class LinkCore
return $url.Dispatcher::getInstance()->createUrl('manufacturer_rule', $params, $this->allow);
}
/**
* Create a link to a supplier
*
* @since 1.5.0
* @param string $name Module name
* @param string $action Action name
* @param int $id_lang
* @return string
*/
public function getModuleLink($name, $action, $ssl = false, $id_lang = null)
{
$base = (($ssl && Configuration::get('PS_SSL_ENABLED')) ? _PS_BASE_URL_SSL_ : _PS_BASE_URL_);
$url = $base.__PS_BASE_URI__.$this->getLangLink($id_lang);
if (!$id_lang)
$id_lang = Context::getContext()->language->id;
// Set available keywords
$params = array();
$params['name'] = $name;
$params['action'] = $action;
return $url.Dispatcher::getInstance()->createUrl('module', $params, $this->allow);
}
/**
* Returns a link to a product image for display
* Note: the new image filesystem stores product images in subdirectories of img/p/
*
*
* @param string $name rewrite link of the image
* @param string $ids id part of the image filename - can be "id_product-id_image" (legacy support, recommended) or "id_image" (new)
* @param string $type
*/
public function getImageLink($name, $ids, $type = NULL)
public function getImageLink($name, $ids, $type = null)
{
// legacy mode or default image
if ((Configuration::get('PS_LEGACY_IMAGES')
if ((Configuration::get('PS_LEGACY_IMAGES')
&& (file_exists(_PS_PROD_IMG_DIR_.$ids.($type ? '-'.$type : '').'.jpg')))
|| strpos($ids, 'default') !== false)
{
@@ -271,13 +295,13 @@ class LinkCore
// if ids if of the form id_product-id_image, we want to extract the id_image part
$split_ids = explode('-', $ids);
$id_image = (isset($split_ids[1]) ? $split_ids[1] : $split_ids[0]);
if ($this->allow == 1)
$uri_path = __PS_BASE_URI__.$id_image.($type ? '-'.$type : '').'/'.$name.'.jpg';
else
$uri_path = _THEME_PROD_DIR_.Image::getImgFolderStatic($id_image).$id_image.($type ? '-'.$type : '').'.jpg';
}
return $this->protocol_content.Tools::getMediaServer($uri_path).$uri_path;
}
@@ -288,7 +312,7 @@ class LinkCore
/**
* Create a simple link
*
*
* @param string $controller
* @param bool $ssl
* @param int $id_lang
@@ -344,7 +368,7 @@ class LinkCore
parse_str($_SERVER['QUERY_STRING'], $queryTab);
unset($queryTab['isolang'], $queryTab['controller']);
if (!$this->allow)
$queryTab['id_lang'] = $id_lang;
@@ -377,11 +401,11 @@ class LinkCore
{
if (Configuration::get('PS_REWRITING_SETTINGS') AND ($k == 'isolang' OR $k == 'id_lang'))
continue;
$ifNb = (!$nb OR ($nb AND !in_array($k, $varsNb)));
$ifNb = (!$nb || ($nb AND !in_array($k, $varsNb)));
$ifSort = (!$sort OR ($sort AND !in_array($k, $varsSort)));
$ifPagination = (!$pagination OR ($pagination AND !in_array($k, $varsPagination)));
if ($ifNb AND $ifSort AND $ifPagination AND !is_array($value))
!$array ? ($vars .= ((!$n++ AND ($this->allow == 1 OR $url == $this->url)) ? '?' : '&').urlencode($k).'='.urlencode($value)) : ($vars[urlencode($k)] = urlencode($value));
$ifPagination = (!$pagination || ($pagination && !in_array($k, $varsPagination)));
if ($ifNb && $ifSort && $ifPagination AND !is_array($value))
!$array ? ($vars .= ((!$n++ && ($this->allow == 1 || $url == $this->url)) ? '?' : '&').urlencode($k).'='.urlencode($value)) : ($vars[urlencode($k)] = urlencode($value));
}
if (!$array)
return $url.$vars;

View File

@@ -515,7 +515,7 @@ abstract class ModuleCore
* Return an instance of the specified module
*
* @param string $moduleName Module name
* @return Module instance
* @return Module
*/
public static function getInstanceByName($moduleName)
{
@@ -1158,6 +1158,21 @@ abstract class ModuleCore
return $result;
}
/**
* Get realpath of a template of current module (check if template is overriden too)
*
* @since 1.5.0
* @param string $template
* @return string
*/
public function getTemplatePath($template)
{
$overloaded = $this->_isTemplateOverloaded($template);
if (is_null($overloaded))
return null;
return ($overloaded ? _PS_THEME_DIR_.'modules/'.$this->name : _PS_MODULE_DIR_.$this->name).'/'.$template;
}
/**
* Assign a smarty vars (same syntax as smarty->assign) but prefix all keys with module name
*
@@ -1165,7 +1180,7 @@ abstract class ModuleCore
* @param string $key Variable key (can be an array)
* @param mixed $value Variable value
*/
public function smartyAssign($key, $value = null)
public function templateAssign($key, $value = null)
{
if (is_array($key))
{

View File

@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -25,5 +25,10 @@
* International Registered Trademark & Property of PrestaShop SA
*/
$controller = new FrontController();
$controller->init();
if (isset(Context::getContext()->controller))
$controller = Context::getContext()->controller;
else
{
$controller = new FrontController();
$controller->init();
}

View File

@@ -44,7 +44,7 @@ abstract class Module
/** @var string author of the module */
public $author;
/** @var int need_instance */
public $need_instance = 1;
@@ -84,11 +84,11 @@ abstract class Module
*/
protected static $modulesCache;
protected static $_hookModulesCache;
protected static $_INSTANCE = array();
protected static $_generateConfigXmlMode = false;
protected static $l_cache = array();
/**
@@ -168,14 +168,14 @@ abstract class Module
}
/**
* This function enable module $name. If an $name is an array,
* This function enable module $name. If an $name is an array,
* this will enable all of them
*
* @param array|string $name
*
* @param array|string $name
* @return true if succeed
* @since 1.4.1
*/
public static function enableByName($name)
public static function enableByName($name)
{
if (!is_array($name))
$name = array($name);
@@ -198,16 +198,16 @@ abstract class Module
SET `active`= 1
WHERE `name` = \''.pSQL($this->name).'\'');
}
/**
* This function disable module $name. If an $name is an array,
* This function disable module $name. If an $name is an array,
* this will disable all of them
*
* @param array|string $name
*
* @param array|string $name
* @return true if succeed
* @since 1.4.1
*/
public static function disableByName($name)
public static function disableByName($name)
{
if (!is_array($name))
$name = array($name);
@@ -220,11 +220,11 @@ abstract class Module
SET `active`= 0
WHERE `name` IN ('.implode(',',$name).')');
}
/**
* Called when module is set to deactive
*/
public function disable()
public function disable()
{
return Module::disableByName($this->name);
}
@@ -369,11 +369,11 @@ abstract class Module
/**
* This function is used to determine the module name
* This function is used to determine the module name
* of an AdminTab which belongs to a module, in order to keep translation
* related to a module in its directory (instead of $_LANGADM)
*
* @param mixed $currentClass the
*
* @param mixed $currentClass the
* @return boolean|string if the class belongs to a module, will return the module name. Otherwise, return false.
*/
public static function getModuleNameFromClass($currentClass)
@@ -396,7 +396,7 @@ abstract class Module
if (Tools::file_exists_cache($file) AND include_once($file))
$_MODULES = !empty($_MODULES) ? array_merge($_MODULES, $_MODULE) : $_MODULE;
}
else
else
self::$classInModule[$currentClass] = false;
}
// return name of the module, or false
@@ -434,7 +434,7 @@ abstract class Module
if(!isset($preloadedModuleNameFromId)) {
$preloadedModuleNameFromId = array();
}
if(is_array($ids))
{
foreach($ids as $id)
@@ -458,12 +458,12 @@ abstract class Module
else
$preloadedModuleNameFromId[$ids] = false;
}
if(is_array($ids)) {
return $preloadedModuleNameFromId;
} else {
if(!isset($preloadedModuleNameFromId[$ids]))
if(!isset($preloadedModuleNameFromId[$ids]))
return false;
return $preloadedModuleNameFromId[$ids];
}
@@ -674,7 +674,7 @@ abstract class Module
AND m.`active` = 1
ORDER BY hm.`position`', false);
self::$_hookModulesCache = array();
if ($result)
while ($row = $db->nextRow())
{
@@ -711,7 +711,7 @@ abstract class Module
{
$live_edit = true;
$output .= '<script type="text/javascript"> modules_list.push(\''.$moduleInstance->name.'\');</script>
<div id="hook_'.$array['id_hook'].'_module_'.$moduleInstance->id.'_moduleName_'.$moduleInstance->name.'"
<div id="hook_'.$array['id_hook'].'_module_'.$moduleInstance->id.'_moduleName_'.$moduleInstance->name.'"
class="dndModule" style="border: 1px dotted red;'.(!strlen($display) ? 'height:50px;' : '').'">
<span><img src="'.$moduleInstance->_path.'/logo.gif">'
.$moduleInstance->displayName.'<span style="float:right">
@@ -760,7 +760,7 @@ abstract class Module
/**
* find translation from $_MODULES and put it in self::$l_cache if not already exist
* and return it.
*
*
* @param string $name name of the module
* @param string $string term to find
* @param string $source additional param for building translation key
@@ -769,9 +769,9 @@ abstract class Module
public static function findTranslation($name, $string, $source)
{
global $_MODULES;
$cache_key = $name . '|' . $string . '|' . $source;
if (!isset(self::$l_cache[$cache_key]))
{
if (!is_array($_MODULES))
@@ -780,7 +780,7 @@ abstract class Module
$_MODULES = array_change_key_case($_MODULES);
$currentKey = '<{'.strtolower($name).'}'.strtolower(_THEME_NAME_).'>'.strtolower($source).'_'.md5($string);
$defaultKey = '<{'.strtolower($name).'}prestashop>'.strtolower($source).'_'.md5($string);
if (isset($_MODULES[$currentKey]))
$ret = stripslashes($_MODULES[$currentKey]);
elseif (isset($_MODULES[Tools::strtolower($currentKey)]))
@@ -791,16 +791,16 @@ abstract class Module
$ret = stripslashes($_MODULES[Tools::strtolower($defaultKey)]);
else
$ret = stripslashes($string);
self::$l_cache[$cache_key] = str_replace('"', '&quot;', $ret);
}
}
return self::$l_cache[$cache_key];
}
/**
* Get translation for a given module text
*
* Note: $specific parameter is mandatory for library files.
* Otherwise, translation key will not match for Module library
* Otherwise, translation key will not match for Module library
* when module is loaded with eval() Module::getModulesOnDisk()
*
* @param string $string String to translate
@@ -811,14 +811,14 @@ abstract class Module
{
if (self::$_generateConfigXmlMode)
return $string;
global $_MODULES, $_MODULE, $cookie;
$id_lang = (!isset($cookie) OR !is_object($cookie)) ? (int)(Configuration::get('PS_LANG_DEFAULT')) : (int)($cookie->id_lang);
$file = _PS_MODULE_DIR_.$this->name.'/'.Language::getIsoById($id_lang).'.php';
if (Tools::file_exists_cache($file) AND include_once($file))
$_MODULES = !empty($_MODULES) ? array_merge($_MODULES, $_MODULE) : $_MODULE;
$source = $specific ? $specific : $this->name;
$string = str_replace('\'', '\\\'', $string);
$ret = $this->findTranslation($this->name, $string, $source);
@@ -897,7 +897,7 @@ abstract class Module
*/
public function getPosition($id_hook)
{
if(isset(Hook::$preloadModulesFromHooks))
if(isset(Hook::$preloadModulesFromHooks))
if(isset(Hook::$preloadModulesFromHooks[$id_hook]))
if(isset(Hook::$preloadModulesFromHooks[$id_hook]['module_position'][$this->id]))
return Hook::$preloadModulesFromHooks[$id_hook]['module_position'][$this->id];
@@ -1027,7 +1027,7 @@ abstract class Module
return $smarty->clearCache($template ? $this->_getApplicableTemplateDir($template).$template : NULL, $cacheId, $compileId);
}
protected function _generateConfigXml()
{
$xml = '<?xml version="1.0" encoding="UTF-8" ?>
@@ -1044,7 +1044,7 @@ abstract class Module
if (is_writable(_PS_MODULE_DIR_.$this->name.'/'))
file_put_contents(_PS_MODULE_DIR_.$this->name.'/config.xml', utf8_encode($xml));
}
/**
* @param string $hook_name
* @return bool if module can be transplanted on hook

View File

@@ -77,10 +77,10 @@ class BlockCart extends Module
if ($useTax AND Configuration::get('PS_TAX_DISPLAY') == 1)
{
$totalToPayWithoutTaxes = $params['cart']->getOrderTotal(false);
$this->smartyAssign('tax_cost', Tools::displayPrice($totalToPay - $totalToPayWithoutTaxes, $currency));
$this->templateAssign('tax_cost', Tools::displayPrice($totalToPay - $totalToPayWithoutTaxes, $currency));
}
$this->smartyAssign(array(
$this->templateAssign(array(
'products' => $products,
'customizedDatas' => Product::getAllCustomizedDatas((int)($params['cart']->id)),
'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_,
@@ -98,9 +98,9 @@ class BlockCart extends Module
'ajax_allowed' => (int)(Configuration::get('PS_BLOCK_CART_AJAX')) == 1 ? true : false
));
if (sizeof($errors))
$this->smartyAssign('errors', $errors);
$this->templateAssign('errors', $errors);
if(isset($this->context->cookie->ajax_blockcart_display))
$this->smartyAssign('colapseExpandStatus', $this->context->cookie->ajax_blockcart_display);
$this->templateAssign('colapseExpandStatus', $this->context->cookie->ajax_blockcart_display);
}
public function getContent()
@@ -160,7 +160,7 @@ class BlockCart extends Module
return;
// @todo this variable seems not used
$this->smartyAssign('order_page', strpos($_SERVER['PHP_SELF'], 'order') !== false);
$this->templateAssign('order_page', strpos($_SERVER['PHP_SELF'], 'order') !== false);
$this->assignContentVars($params);
return $this->display(__FILE__, 'blockcart.tpl');
}

View File

@@ -773,7 +773,7 @@ class BlockCms extends Module
public function displayBlockCMS($column)
{
$cms_titles = self::getCMStitles($column);
$this->smartyAssign(array(
$this->templateAssign(array(
'block' => 1,
'cms_titles' => $cms_titles,
));
@@ -796,7 +796,7 @@ class BlockCms extends Module
if (Configuration::get('FOOTER_BLOCK_ACTIVATION'))
{
$cms_titles = self::getCMStitlesFooter();
$this->smartyAssign(array(
$this->templateAssign(array(
'block' => 0,
'cmslinks' => $cms_titles,
'display_stores_footer' => Configuration::get('PS_STORES_DISPLAY_FOOTER'),

View File

@@ -92,7 +92,7 @@ class BlockLanguages extends Module
}
}
if (count($default_rewrite))
$this->smartyAssign('lang_rewrite_urls', $default_rewrite);
$this->templateAssign('lang_rewrite_urls', $default_rewrite);
}
return $this->display(__FILE__, 'blocklanguages.tpl');

View File

@@ -54,8 +54,7 @@ class BlockManufacturer extends Module
function hookLeftColumn($params)
{
$this->smartyAssign(array(
$this->templateAssign(array(
'manufacturers' => Manufacturer::getManufacturers(),
'text_list' => Configuration::get('MANUFACTURER_DISPLAY_TEXT'),
'text_list_nb' => Configuration::get('MANUFACTURER_DISPLAY_TEXT_NB'),

View File

@@ -61,7 +61,7 @@ class BlockMyAccount extends Module
if (!$this->context->customer->isLogged())
return false;
$this->smartyAssign(array(
$this->templateAssign(array(
'voucherAllowed' => (int)Configuration::get('PS_VOUCHERS'),
'returnAllowed' => (int)Configuration::get('PS_ORDER_RETURN'),
'HOOK_BLOCK_MY_ACCOUNT' => Module::hookExec('myAccountBlock'),

View File

@@ -100,7 +100,7 @@ class BlockNewProducts extends Module
if (!$newProducts AND !Configuration::get('PS_BLOCK_NEWPRODUCTS_DISPLAY'))
return;
$this->smartyAssign(array(
$this->templateAssign(array(
'new_products' => $newProducts,
'mediumSize' => Image::getSize('medium'),
));

View File

@@ -90,7 +90,7 @@ class BlockSpecials extends Module
if (!$special = Product::getRandomSpecial((int)$params['cookie']->id_lang) AND !Configuration::get('PS_BLOCK_SPECIALS_DISPLAY'))
return;
$this->smartyAssign(array(
$this->templateAssign(array(
'special' => $special,
'priceWithoutReduction_tax_excl' => Tools::ps_round($special['price_without_reduction'], 2),
'mediumSize' => Image::getSize('medium'),

View File

@@ -60,7 +60,7 @@ class BlockUserInfo extends Module
if (!$this->active)
return;
$this->smartyAssign(array(
$this->templateAssign(array(
'cart' => $this->context->cart,
'cart_qties' => $this->context->cart->nbProducts(),
'logged' => $this->context->customer->isLogged(),

View File

@@ -166,7 +166,7 @@ class BlockViewed extends Module
if (!sizeof($productsViewedObj))
return ;
$this->smartyAssign(array(
$this->templateAssign(array(
'productsViewedObj' => $productsViewedObj,
'mediumSize' => Image::getSize('medium')));

View File

@@ -1,6 +1,6 @@
<?php
/*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -42,7 +42,7 @@ class Cheque extends PaymentModule
$this->tab = 'payments_gateways';
$this->version = '2.3';
$this->author = 'PrestaShop';
$this->currencies = true;
$this->currencies_mode = 'checkbox';
@@ -51,13 +51,13 @@ class Cheque extends PaymentModule
$this->chequeName = $config['CHEQUE_NAME'];
if (isset($config['CHEQUE_ADDRESS']))
$this->address = $config['CHEQUE_ADDRESS'];
parent::__construct();
$this->displayName = $this->l('Check');
$this->description = $this->l('Module for accepting payments by check.');
$this->confirmUninstall = $this->l('Are you sure you want to delete your details ?');
if (!isset($this->chequeName) OR !isset($this->address))
$this->warning = $this->l('\'To the order of\' and address must be configured in order to use this module correctly.');
if (!sizeof(Currency::checkPaymentCurrencies($this->id)))
@@ -149,26 +149,7 @@ class Cheque extends PaymentModule
public function execPayment($cart)
{
if (!$this->active)
return ;
if (!$this->_checkCurrency($cart))
Tools::redirect('index.php?controller=order');
$this->context->smarty->assign(array(
'nbProducts' => $cart->nbProducts(),
'cust_currency' => $cart->id_currency,
'currencies' => $this->getCurrency((int)$cart->id_currency),
'total' => $cart->getOrderTotal(true, Cart::BOTH),
'isoCode' => $this->context->language->iso_code,
'chequeName' => $this->chequeName,
'chequeAddress' => Tools::nl2br($this->address),
'this_path' => $this->_path,
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/'
));
return $this->display(__FILE__, 'payment_execution.tpl');
return $this->actionPayment(true);
}
public function hookPayment($params)
@@ -203,7 +184,7 @@ class Cheque extends PaymentModule
$this->context->smarty->assign('status', 'failed');
return $this->display(__FILE__, 'payment_return.tpl');
}
private function _checkCurrency($cart)
{
$currency_order = new Currency((int)($cart->id_currency));
@@ -215,4 +196,32 @@ class Cheque extends PaymentModule
return true;
return false;
}
public function actionPayment($direct_call = false)
{
if (!$this->active)
return ;
$cart = $this->context->cart;
if (!$this->_checkCurrency($cart))
Tools::redirect('index.php?controller=order');
$this->context->smarty->assign(array(
'nbProducts' => $cart->nbProducts(),
'cust_currency' => $cart->id_currency,
'currencies' => $this->getCurrency((int)$cart->id_currency),
'total' => $cart->getOrderTotal(true, Cart::BOTH),
'isoCode' => $this->context->language->iso_code,
'chequeName' => $this->chequeName,
'chequeAddress' => Tools::nl2br($this->address),
'this_path' => $this->_path,
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->name.'/'
));
if (!$direct_call)
return $this->getTemplatePath('payment_execution.tpl');
else
// For retrocompatibility
return $this->display(__FILE__, 'payment_execution.tpl');
}
}

View File

@@ -1,5 +1,5 @@
{*
* 2007-2011 PrestaShop
* 2007-2011 PrestaShop
*
* NOTICE OF LICENSE
*
@@ -25,7 +25,7 @@
*}
<p class="payment_module">
<a href="{$this_path_ssl}payment.php" title="{l s='Pay by cheque' mod='cheque'}">
<a href="{$link->getModuleLink('cheque', 'payment')}" title="{l s='Pay by cheque' mod='cheque'}">
<img src="{$this_path}cheque.jpg" alt="{l s='Pay by cheque' mod='cheque'}" width="86" height="49" />
{l s='Pay by cheque (order process will be longer)' mod='cheque'}
</a>

View File

@@ -96,7 +96,7 @@ class HomeFeatured extends Module
$nb = (int)(Configuration::get('HOME_FEATURED_NBR'));
$products = $category->getProducts($params['cookie']->id_lang, 1, ($nb ? $nb : 10));
$this->smartyAssign(array(
$this->templateAssign(array(
'products' => $products,
'add_prod_display' => Configuration::get('PS_ATTRIBUTE_CATEGORY_DISPLAY'),
'homeSize' => Image::getSize('home'),

View File

@@ -0,0 +1,7 @@
<?php
class ModuleController extends ModuleControllerCore
{
}