opencart核心代码方法
public function __construct($route, $args = array()) {
$path = ”;
$parts = exe(‘../’, ”, (string)$route));
foreach ($parts as $part) { plode(‘/’, str_replac
$path .= $part;
if (is_dir(DIR_APPLICATION . ‘controller/’ . $path)) {
$path .= ‘/’;
array_shift($parts);
continue;
}
if (is_file(DIR_APPLICATION . ‘controller/’ . str_replace(array(‘../’, ‘..\\’, ‘..’), ”, $path) . ‘.php’)) {
$this->file = DIR_APPLICATION . ‘controller/’ . str_replace(array(‘../’, ‘..\\’, ‘..’), ”, $path) . ‘.php’;
$this->class = ‘Controller’ . preg_replace(‘/[^a-zA-Z0-9]/’, ”, $path);
array_shift($parts);
break;
}
}
if ($args) {
$this->args = $args;
}
$method = array_shift($parts);
if ($method) {
$this->method = $method;
} else {
$this->method = ‘index’;
}
}
private function execute($action) {
if (file_exists($action->getFile())) {
require_once($action->getFile());
$class = $action->getClass();
$controller = new $class($this->registry);
if (is_callable(array($controller, $action->getMethod()))) {
分析调用那个controler
$action = call_user_func_array(array($controller, $action->getMethod()), $action->getArgs());
} else {
$action = $this->error;
$this->error = ”;
}
} else {
$action = $this->error;
$this->error = ”;
}
return $action;
}
}
public function dispatch($action, $error) {
$this->error = $error;
foreach ($this->pre_action as $pre_action) {
$result = $this->execute($pre_action);
if ($result) {
$action = $result;
break;
}
}
while ($action) {
$action = $this->execute($action);
}
}
protected function getChild($child, $args = array()) {
$action = new Action($child, $args);
if (file_exists($action->getFile())) {
require_once($action->getFile());
$class = $action->getClass();
$controller = new $class($this->registry);
分析调用那个controler
$controller->{$action->getMethod()}($action->getArgs());
return $controller->output;
} else {
trigger_error(‘Error: Could not load controller ‘ . $child . ‘!’);
exit();
}
}
protected function render() {
foreach ($this->children as $child) {
$this->data[basename($child)] = $this->getChild($child);
}
if (file_exists(DIR_TEMPLATE . $this->template)) {
extract($this->data);
ob_start();
require(DIR_TEMPLATE . $this->template);
$this->output = ob_get_contents();
ob_end_clean();
return $this->output;
} else {
trigger_error(‘Error: Could not load template ‘ . DIR_TEMPLATE . $this->template . ‘!’);
exit();
}
}
相关推荐
opencart_international_3.7
OpenCart 程序结构与业务逻辑一些内部的介绍
OpenCart 1.5 是一款功能强大的电子商务网站,代码修改方便,插件种类多,支持国际化等。。
opencart短信插件_opencart短信接口开发_opencart短信发送设置
opencart3 stripe 支付插件
OpenCart批量上传插件安装及使用详细教程.docx
Opencart主题模板,自定义模板,可以直接上传使用模板
[Packt Publishing] OpenCart 模块开发 入门教程 (英文版) [Packt Publishing] Getting Started with OpenCart Module Development (E-Book) ☆ 图书概要:☆ Master your OpenCart modules and code! Overview ...
opencart 1.4.91 opencart 1.4.91 opencart 1.4.91 opencart 1.4.91
opencart french
opencart2 网银在线chinapay
OpenCart.V.2.0.1.1版本 数据表:oc_country的 国家中英文数据。 直接导入即可。
opencart2.0的数据字典
所以程序代码相当轻巧,执行效率更是超越其它购物程序,这样的架构和程序代码让后 续的程序开发人员在编写时更容易且清楚,程序和视觉设计分离,有利于日后的维护,而 有别于其它的MVC模式,opencart更加入了语言层,能够更...
opencart 开源模板代码,适合初学者
opencart中文手册,内容包含后台网站的搭建,配置,及Opencart测试环境的搭建
opencart教程
opencart多版本2.0 2.2 3.0
opencart language 中文语言包 3.0.3.7
opencart采集导入