Skip to content

Commit

Permalink
Merge pull request #2 from opencart/master
Browse files Browse the repository at this point in the history
master branche updates #2
  • Loading branch information
alexander-mart committed Nov 8, 2015
2 parents ce12b5c + 4b79aa0 commit 13999a5
Show file tree
Hide file tree
Showing 20 changed files with 183 additions and 130 deletions.
4 changes: 1 addition & 3 deletions upload/admin/controller/payment/securetrading_pp.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,7 @@ public function order() {
$data['order_id'] = $this->request->get['order_id'];
$data['token'] = $this->request->get['token'];

$this->template = 'payment/securetrading_pp_order.tpl';

$this->response->setOutput($this->render());
return $this->load->view('payment/securetrading_pp_order.tpl', $data);
}
}
}
Expand Down
4 changes: 1 addition & 3 deletions upload/admin/controller/payment/securetrading_ws.php
Original file line number Diff line number Diff line change
Expand Up @@ -399,9 +399,7 @@ public function showTransactions() {
}
}

$this->template = 'payment/securetrading_ws_transactions.tpl';

$this->response->setOutput($this->render());
return $this->load->view('payment/securetrading_ws_transactions.tpl', $data);
}

public function order() {
Expand Down
2 changes: 1 addition & 1 deletion upload/admin/controller/sale/recurring.php
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ public function info() {
$data['entry_status'] = $this->language->get('entry_status');
$data['entry_type'] = $this->language->get('entry_type');
$data['entry_email'] = $this->language->get('entry_email');
$data['entry_recurring_description'] = $this->language->get('entry_recurring_description');
$data['entry_description'] = $this->language->get('entry_description');
$data['entry_product'] = $this->language->get('entry_product');
$data['entry_quantity'] = $this->language->get('entry_quantity');
$data['entry_amount'] = $this->language->get('entry_amount');
Expand Down
2 changes: 1 addition & 1 deletion upload/admin/language/english/catalog/product.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
$_['help_filter'] = '(Autocomplete)';
$_['help_download'] = '(Autocomplete)';
$_['help_related'] = '(Autocomplete)';
$_['help_tag'] = 'comma separated';
$_['help_tag'] = 'Comma separated';

// Error
$_['error_warning'] = 'Warning: Please check the form carefully for errors!';
Expand Down
2 changes: 1 addition & 1 deletion upload/admin/model/catalog/attribute.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
class ModelCatalogAttribute extends Model {
public function addAttribute($data) {
$this->event->trigger('pre.admin.attribute.add', $data);
$this->event->trigger('admin/attribute/addAttribute/before', $data);

$this->db->query("INSERT INTO " . DB_PREFIX . "attribute SET attribute_group_id = '" . (int)$data['attribute_group_id'] . "', sort_order = '" . (int)$data['sort_order'] . "'");

Expand Down
2 changes: 1 addition & 1 deletion upload/admin/view/template/sale/recurring_info.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
<?php } ?></td>
</tr>
<tr>
<td><?php echo $entry_recurring_description; ?></td>
<td><?php echo $entry_description; ?></td>
<td><?php echo $recurring_description; ?></td>
</tr>
<tr>
Expand Down
15 changes: 8 additions & 7 deletions upload/catalog/controller/account/account.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
class ControllerAccountAccount extends Controller {
public function index() {
$this->event->trigger('controller/account/account/after');

if (!$this->customer->isLogged()) {
$this->session->data['redirect'] = $this->url->link('account/account', '', true);

Expand Down Expand Up @@ -70,13 +72,12 @@ public function index() {
$data['content_top'] = $this->load->controller('common/content_top');
$data['content_bottom'] = $this->load->controller('common/content_bottom');
$data['footer'] = $this->load->controller('common/footer');
$data['header'] = $this->load->controller('common/header');

if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/account/account.tpl')) {
$this->response->setOutput($this->load->view($this->config->get('config_template') . '/template/account/account.tpl', $data));
} else {
$this->response->setOutput($this->load->view('default/template/account/account.tpl', $data));
}

$output = $this->load->view('account/account.tpl', $data);

$this->event->trigger('controller/account/account/after', $output);

$this->response->setOutput($output);
}

public function country() {
Expand Down
4 changes: 1 addition & 3 deletions upload/catalog/controller/account/address.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function add() {

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
$this->model_account_address->addAddress($this->request->post);

$this->session->data['success'] = $this->language->get('text_add');

// Add to activity log
Expand Down Expand Up @@ -71,8 +71,6 @@ public function edit() {
$this->document->addScript('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.js');
$this->document->addStyle('catalog/view/javascript/jquery/datetimepicker/bootstrap-datetimepicker.min.css');

$this->load->model('account/address');

if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validateForm()) {
$this->model_account_address->editAddress($this->request->get['address_id'], $this->request->post);

Expand Down
6 changes: 3 additions & 3 deletions upload/catalog/controller/api/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@ public function index() {
if ($api_info) {
$json['success'] = $this->language->get('text_success');

$sesion_name = 'temp_session_' . uniqid();
$session_name = 'temp_session_' . uniqid();

$session = new Session();
$session->start($this->session->getId(), $sesion_name);
$session->start($this->session->getId(), $session_name);

// Set API ID
$session->data['api_id'] = $api_info['api_id'];

// Create Token
$json['token'] = $this->model_account_api->addApiSession($api_info['api_id'], $sesion_name, $session->getId(), $this->request->server['REMOTE_ADDR']);
$json['token'] = $this->model_account_api->addApiSession($api_info['api_id'], $session_name, $session->getId(), $this->request->server['REMOTE_ADDR']);
} else {
$json['error']['key'] = $this->language->get('error_key');
}
Expand Down
2 changes: 1 addition & 1 deletion upload/catalog/controller/api/order.php
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,7 @@ public function history() {
$keys = array(
'order_status_id',
'notify',
'append',
'override',
'comment'
);

Expand Down
4 changes: 2 additions & 2 deletions upload/catalog/model/account/address.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
class ModelAccountAddress extends Model {
public function addAddress($data) {
$this->event->trigger('pre.customer.add.address', $data);
$this->event->trigger('model/customer/address/addAddress/before', $data);

$this->db->query("INSERT INTO " . DB_PREFIX . "address SET customer_id = '" . (int)$this->customer->getId() . "', firstname = '" . $this->db->escape($data['firstname']) . "', lastname = '" . $this->db->escape($data['lastname']) . "', company = '" . $this->db->escape($data['company']) . "', address_1 = '" . $this->db->escape($data['address_1']) . "', address_2 = '" . $this->db->escape($data['address_2']) . "', postcode = '" . $this->db->escape($data['postcode']) . "', city = '" . $this->db->escape($data['city']) . "', zone_id = '" . (int)$data['zone_id'] . "', country_id = '" . (int)$data['country_id'] . "', custom_field = '" . $this->db->escape(isset($data['custom_field']) ? json_encode($data['custom_field']) : '') . "'");

Expand All @@ -11,7 +11,7 @@ public function addAddress($data) {
$this->db->query("UPDATE " . DB_PREFIX . "customer SET address_id = '" . (int)$address_id . "' WHERE customer_id = '" . (int)$this->customer->getId() . "'");
}

$this->event->trigger('post.customer.add.address', $address_id);
$this->event->trigger('model/customer/address/addAddress/after', $address_id);

return $address_id;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,8 @@ $(document).delegate('#button-payment-method', 'click', function() {
if (json['error']['warning']) {
$('#collapse-payment-method .panel-body').prepend('<div class="alert alert-warning">' + json['error']['warning'] + '<button type="button" class="close" data-dismiss="alert">&times;</button></div>');
}
$('#button-payment-method').button('reset');
} else {
$.ajax({
url: 'index.php?route=checkout/confirm',
Expand All @@ -795,4 +797,4 @@ $(document).delegate('#button-payment-method', 'click', function() {
});
});
//--></script>
<?php echo $footer; ?>
<?php echo $footer; ?>
74 changes: 74 additions & 0 deletions upload/system/engine/aspect.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
/*
*/
class Aspect {
private $registry;
private $data = array();

public function __construct($registry) {
$this->registry = $registry;
}

public function factory($object, $args = array()) {
$code = 'Class Aspect' . get_class($object) . ' extends ' . get_parent_class($object) . ' {' . "\n";

foreach (get_class_methods($object) as $method) {
if (substr($method, 0, 2) != '__') {
$code .= ' public function ' . $method . '() {' . "\n";
$code .= ' $this->event->trigger($route, $data);' . "\n";
$code .= ' $this->object->method();' . "\n";
$code .= ' $this->event->trigger($data);' . "\n";
$code .= ' }' . "\n\n";
}
}

$code .= '}' . "\n";

echo $code;

eval($code);

$class = 'Aspect' . get_class($object);

return new $class($this->registry);
}

public function __call($method, $args = array()) {
echo __METHOD__;

return call_user_func_array($this->{$method}, $args);
}
}

class Interceptor {
private $object;
private $pre_action = array();
private $post_action = array();

public function __construct($object) {
$this->object = $object;
}

public function addPreAction($method, $action) {
$this->pre_action[$method][] = $action;
}

public function addPostAction($method, $action) {
$this->post_action[$method][] = $action;
}

public function &__call($method, $args = array()) {
foreach ($this->pre_action[$method] as $pre_action) {
$pre_action->execute($data);
}

$output = call_user_func_array(array($this->object, $method), $args);

foreach ($this->post_action[$method] as $post_action) {
$post_action->execute($output);
}

return $output;
}
}
6 changes: 5 additions & 1 deletion upload/system/engine/front.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ public function __construct($registry) {
public function addPreAction($pre_action) {
$this->pre_action[] = $pre_action;
}


public function addPostAction($pre_action) {
$this->pre_action[] = $pre_action;
}

public function dispatch($action, $error) {
$this->error = $error;

Expand Down
66 changes: 36 additions & 30 deletions upload/system/engine/loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ final class Loader {
public function __construct($registry) {
$this->registry = $registry;
}

public function controller($route, $data = array()) {
// $this->event->trigger('pre.controller.' . $route, $data);
//$this->registry->get('event')->trigger('controller/' . $route . '/before', $route, $data);

$parts = explode('/', str_replace('../', '', (string)$route));

Expand All @@ -25,8 +25,6 @@ public function controller($route, $data = array()) {
}
}

$controller = new $class($this->registry);

if (!isset($method)) {
$method = 'index';
}
Expand All @@ -36,19 +34,21 @@ public function controller($route, $data = array()) {
return false;
}

$output = '';
$controller = new $class($this->registry);

if (is_callable(array($controller, $method))) {
$output = call_user_func(array($controller, $method), $data);
} else {
$output = null;
}

// $this->event->trigger('post.controller.' . $route, $output);

//$this->registry->get('event')->trigger('controller/' . $route . '/after', $output);
return $output;
}

public function model($model, $data = array()) {
// $this->event->trigger('pre/model/' . str_replace('/', '.', (string)$model), $data);
//$this->registry->get('event')->trigger('model/' . $model . '/before', $model, $data);

$model = str_replace('../', '', (string)$model);

Expand All @@ -57,37 +57,35 @@ public function model($model, $data = array()) {

if (file_exists($file)) {
include_once($file);

$this->registry->set('model_' . str_replace('/', '_', $model), new $class($this->registry));

$object = new $class($this->registry);

//$aspect = new Aspect($this->registry);
//$test = $aspect->factory($object);

//$aspect->addListener('addOrderHistory', $this->registry->get('event'));

$this->registry->set('model_' . str_replace('/', '_', $model), $object);
} else {
trigger_error('Error: Could not load model ' . $file . '!');
exit();
}

// $this->event->trigger('post/model/' . str_replace('/', '.', (string)$model), $output);
//$this->registry->get('event')->trigger('model/' . $model . '/after', $output);
}

public function view($template, $data = array()) {
$this->event->beforeTrigger('view/' . str_replace('/', '.', $template) . '/before/', $data);

$file = DIR_TEMPLATE . $template;
public function view($view, $data = array()) {
//$this->registry->get('event')->trigger('view/' . $view . '/before', $view, $data);

if (file_exists($file)) {
extract($data);

ob_start();

require($file);

$output = ob_get_contents();

ob_end_clean();
} else {
trigger_error('Error: Could not load template ' . $file . '!');
exit();
$template = new Template('basic');

foreach ($data as $key => $value) {
$template->set($key, $value);
}

$output = $template->render($view);

$this->event->afterTrigger('view/' . $template, $output);
//$this->registry->get('event')->trigger('view/' . $view . '/after', $output);

return $output;
}
Expand All @@ -104,10 +102,18 @@ public function helper($helper) {
}

public function config($config) {
//$this->registry->get('event')->trigger('config/' . $config . '/before', $config);

$this->registry->get('config')->load($config);

//$this->registry->get('event')->trigger('config/' . $config . '/after');
}

public function language($language) {
return $this->registry->get('language')->load($language);
//$this->registry->get('event')->trigger('language/' . $language . '/before', $language);

$this->registry->get('language')->load($language);

//$this->registry->get('event')->trigger('language/' . $language . '/after');
}
}
12 changes: 0 additions & 12 deletions upload/system/engine/observer.php

This file was deleted.

Loading

0 comments on commit 13999a5

Please sign in to comment.