[+] MO: Add Module controller, Cheque and Bankwire modules use it

This commit is contained in:
rMalie
2011-12-22 16:31:03 +00:00
parent e78adabdb7
commit eefa793840
12 changed files with 311 additions and 165 deletions
+17 -3
View File
@@ -108,10 +108,10 @@ class DispatcherCore
),
'module' => array(
'controller' => 'module',
'rule' => 'module/{module}/{action}',
'rule' => 'module/{module}/{process}',
'keywords' => array(
'module' => array('regexp' => '[a-zA-Z0-9_-]+', 'param' => 'module'),
'action' => array('regexp' => '[a-zA-Z0-9_-]+', 'param' => 'action'),
'process' => array('regexp' => '[a-zA-Z0-9_-]+', 'param' => 'process'),
),
),
);
@@ -149,7 +149,7 @@ class DispatcherCore
/**
* @var string Controller to use if found controller doesn't exist
*/
protected $controller_not_found = 'PageNotFound';
protected $controller_not_found = 'pagenotfound';
/**
* @var array List of controllers where are stored controllers
@@ -286,6 +286,20 @@ class DispatcherCore
if (!isset($controllers[$this->controller]))
$this->controller = strtolower($this->controller_not_found);
$controller_class = $controllers[$this->controller];
// If module controller is called, we have to call the right module controller
if ($controller_class == 'ModuleController')
{
$module_name = Tools::getValue('module');
$module = Module::getInstanceByName($module_name);
if (Validate::isLoadedObject($module) && $module->active && file_exists(_PS_MODULE_DIR_.$module_name.'/'.$module_name.'Controller.php'))
{
include_once(_PS_MODULE_DIR_.$module_name.'/'.$module_name.'Controller.php');
$controller_class = 'Module'.$module_name.'Controller';
}
else
$controller_class = $controllers[$this->controller_not_found];
}
}
// BO dispatch
else
+5 -6
View File
@@ -464,16 +464,11 @@ class FrontControllerCore extends Controller
$this->context->smarty->assign('css_files', $this->css_files);
$this->context->smarty->assign('js_files', array_unique($this->js_files));
$this->context->smarty->assign(array(
'errors' => $this->errors,
'display_header' => $this->display_header,
'display_footer' => $this->display_footer,
'template' => $this->context->smarty->fetch($this->template),
));
if (Tools::isSubmit('live_edit'))
{
@@ -482,14 +477,18 @@ class FrontControllerCore extends Controller
// handle 1.4 theme (with layout.tpl missing)
if (file_exists(_PS_THEME_DIR_.'layout.tpl'))
{
if ($this->template)
$this->context->smarty->assign('template', $this->context->smarty->fetch($this->template));
$this->context->smarty->display(_PS_THEME_DIR_.'layout.tpl');
}
else
{
// BEGIN - 1.4 retrocompatibility - will be removed in 1.6
Tools::displayAsDeprecated('layout.tpl is missing in your theme directory');
if ($this->display_header)
$this->context->smarty->display(_PS_THEME_DIR_.'header.tpl');
if ($this->template)
$this->context->smarty->display($this->template);
+3 -3
View File
@@ -266,11 +266,11 @@ class LinkCore
*
* @since 1.5.0
* @param string $module Module name
* @param string $action Action name
* @param string $process Action name
* @param int $id_lang
* @return string
*/
public function getModuleLink($module, $action, $ssl = false, $id_lang = null)
public function getModuleLink($module, $process, $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);
@@ -280,7 +280,7 @@ class LinkCore
// Set available keywords
$params = array();
$params['module'] = $module;
$params['action'] = $action;
$params['process'] = $process;
return $url.Dispatcher::getInstance()->createUrl('module', $params, $this->allow);
}
+22 -3
View File
@@ -1588,16 +1588,35 @@ abstract class ModuleCore
/**
* Get module errors
*
* @since 1.5.0
* @return array errors
*/
public function getErrors() { return $this->_errors; }
public function getErrors()
{
return $this->_errors;
}
/**
* Get module messages confirmation
* @since 1.5.1
*
* @since 1.5.0
* @return array conf
*/
public function getConfirmations() { return $this->_confirmations; }
public function getConfirmations()
{
return $this->_confirmations;
}
/**
* Get uri path for module
*
* @since 1.5.0
* @return string
*/
public function getPathUri()
{
return $this->_path;
}
}