[go: nahoru, domu]

Skip to content

Commit

Permalink
more code struture changes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkerr committed Aug 31, 2020
1 parent 6507b7e commit 8afd7a1
Show file tree
Hide file tree
Showing 33 changed files with 804 additions and 388 deletions.
28 changes: 14 additions & 14 deletions upload/admin/controller/marketplace/installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -323,14 +323,15 @@ public function install() {

// admin > extension/{directory}/admin
if (substr($destination, 0, 6) == 'admin/') {
$path = $destination;
$base = DIR_EXTENSION . $extension_install_info['code'] . '/';

$path = $extension_install_info['code'] . '/' . $destination;
$base = DIR_EXTENSION;
}

// catalog > extension/{directory}/catalog
if (substr($destination, 0, 8) == 'catalog/') {
$path = $destination;
$base = DIR_EXTENSION . $extension_install_info['code'] . '/';
$path = $extension_install_info['code'] . '/' . $destination;
$base = DIR_EXTENSION;
}

// image > image
Expand All @@ -340,12 +341,15 @@ public function install() {
}

if (substr($destination, 0, 7) == 'system/') {
$path = $destination;
$base = DIR_EXTENSION . $extension_install_info['code'] . '/';

$path = $extension_install_info['code'] . '/' . $destination;
$base = DIR_EXTENSION;
}

// system/config > system/config
if (substr($destination, 0, 14) == 'system/config/') {


$path = substr($destination, 14);
$base = DIR_CONFIG;
}
Expand Down Expand Up @@ -422,11 +426,7 @@ public function uninstall() {

$extension_install_info = $this->model_setting_extension->getInstall($extension_install_id);

if ($extension_install_info) {
if (!is_dir(DIR_EXTENSION . $extension_install_info['code'] . '/')) {
$json['error'] = sprintf($this->language->get('error_directory'), $extension_install_info['code'] . '/');
}
} else {
if (!$extension_install_info) {
$json['error'] = $this->language->get('error_install');
}

Expand All @@ -440,12 +440,12 @@ public function uninstall() {

// admin > extension/{directory}/admin
if (substr($result['path'], 0, 6) == 'admin/') {
$path = DIR_EXTENSION . $extension_install_info['code'] . '/' . $result['path'];
$path = DIR_EXTENSION . $result['path'];
}

// catalog > extension/{directory}/catalog
if (substr($result['path'], 0, 8) == 'catalog/') {
$path = DIR_EXTENSION . $extension_install_info['code'] . '/' . $result['path'];
$path = DIR_EXTENSION . $result['path'];
}

// Image
Expand All @@ -454,7 +454,7 @@ public function uninstall() {
}

if (substr($result['path'], 0, 7) == 'system/') {
$path = DIR_EXTENSION . $extension_install_info['code'] . '/' . $result['path'];
$path = DIR_EXTENSION . $result['path'];
}

// Config
Expand Down
12 changes: 11 additions & 1 deletion upload/admin/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php
namespace Admin;
// Version
//define('VERSION', '3.1.0.0_b');
define('VERSION', '3.0.3.2');
Expand All @@ -18,4 +17,15 @@
// Startup
require_once(DIR_SYSTEM . 'startup.php');

// Autoloader
$autoloader = new Autoloader();
$autoloader->register('Application', DIR_APPLICATION);
$autoloader->register('Extension', DIR_EXTENSION);
$autoloader->register('Catalog', DIR_CATALOG);
$autoloader->register('Admin', DIR_ADMIN);
$autoloader->register('System', DIR_SYSTEM);
$autoloader->register('Application\Controller\Extension\Opencart', DIR_EXTENSION . 'opencart/admin/controller/');
$autoloader->register('Application\Model\Extension\Opencart', DIR_EXTENSION . 'opencart/admin/model/');
$autoloader->register('System\Extension\Opencart', DIR_EXTENSION . 'opencart/system/');

start('admin');
118 changes: 59 additions & 59 deletions upload/admin/model/localisation/language.php

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions upload/admin/model/localisation/length_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
namespace Application\Model\Localisation;
class LengthClass extends \System\Engine\Model {
public function addLengthClass($data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "length_class SET value = '" . (float)$data['value'] . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "length_class` SET `value` = '" . (float)$data['value'] . "'");

$length_class_id = $this->db->getLastId();

foreach ($data['length_class_description'] as $language_id => $value) {
$this->db->query("INSERT INTO " . DB_PREFIX . "length_class_description SET length_class_id = '" . (int)$length_class_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', unit = '" . $this->db->escape($value['unit']) . "'");
$this->db->query("INSERT INTO " . DB_PREFIX . "length_class_description SET `length_class_id` = '" . (int)$length_class_id . "', `language_id` = '" . (int)$language_id . "', `title` = '" . $this->db->escape($value['title']) . "', `unit` = '" . $this->db->escape($value['unit']) . "'");
}

$this->cache->delete('length_class');
Expand All @@ -16,12 +16,12 @@ public function addLengthClass($data) {
}

public function editLengthClass($length_class_id, $data) {
$this->db->query("UPDATE " . DB_PREFIX . "length_class SET value = '" . (float)$data['value'] . "' WHERE length_class_id = '" . (int)$length_class_id . "'");
$this->db->query("UPDATE " . DB_PREFIX . "length_class SET value = '" . (float)$data['value'] . "' WHERE `length_class_id` = '" . (int)$length_class_id . "'");

$this->db->query("DELETE FROM " . DB_PREFIX . "length_class_description WHERE length_class_id = '" . (int)$length_class_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "length_class_description` WHERE `length_class_id` = '" . (int)$length_class_id . "'");

foreach ($data['length_class_description'] as $language_id => $value) {
$this->db->query("INSERT INTO " . DB_PREFIX . "length_class_description SET length_class_id = '" . (int)$length_class_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($value['title']) . "', unit = '" . $this->db->escape($value['unit']) . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "length_class_description` SET `length_class_id` = '" . (int)$length_class_id . "', `language_id` = '" . (int)$language_id . "', `title` = '" . $this->db->escape($value['title']) . "', `unit` = '" . $this->db->escape($value['unit']) . "'");
}

$this->cache->delete('length_class');
Expand All @@ -36,7 +36,7 @@ public function deleteLengthClass($length_class_id) {

public function getLengthClasses($data = []) {
if ($data) {
$sql = "SELECT * FROM " . DB_PREFIX . "length_class lc LEFT JOIN " . DB_PREFIX . "length_class_description lcd ON (lc.length_class_id = lcd.length_class_id) WHERE lcd.language_id = '" . (int)$this->config->get('config_language_id') . "'";
$sql = "SELECT * FROM `" . DB_PREFIX . "length_class` lc LEFT JOIN` " . DB_PREFIX . "length_class_description` lcd ON (lc.`length_class_id` = lcd.`length_class_id`) WHERE lcd.`language_id` = '" . (int)$this->config->get('config_language_id') . "'";

$sort_data = [
'title',
Expand All @@ -47,7 +47,7 @@ public function getLengthClasses($data = []) {
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
$sql .= " ORDER BY " . $data['sort'];
} else {
$sql .= " ORDER BY title";
$sql .= " ORDER BY `title`";
}

if (isset($data['order']) && ($data['order'] == 'DESC')) {
Expand Down Expand Up @@ -75,7 +75,7 @@ public function getLengthClasses($data = []) {
$length_class_data = $this->cache->get('length_class.' . (int)$this->config->get('config_language_id'));

if (!$length_class_data) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "length_class lc LEFT JOIN " . DB_PREFIX . "length_class_description lcd ON (lc.length_class_id = lcd.length_class_id) WHERE lcd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "length_class lc LEFT JOIN " . DB_PREFIX . "length_class_description lcd ON (lc.`length_class_id` = lcd.`length_class_id`) WHERE lcd.`language_id` = '" . (int)$this->config->get('config_language_id') . "'");

$length_class_data = $query->rows;

Expand Down
4 changes: 2 additions & 2 deletions upload/admin/model/localisation/location.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
namespace Application\Model\Localisation;
class Location extends \System\Engine\Model {
public function addLocation($data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "location SET name = '" . $this->db->escape((string)$data['name']) . "', address = '" . $this->db->escape((string)$data['address']) . "', geocode = '" . $this->db->escape((string)$data['geocode']) . "', telephone = '" . $this->db->escape((string)$data['telephone']) . "', fax = '" . $this->db->escape((string)$data['fax']) . "', image = '" . $this->db->escape((string)$data['image']) . "', open = '" . $this->db->escape((string)$data['open']) . "', comment = '" . $this->db->escape((string)$data['comment']) . "'");
$this->db->query("INSERT INTO " . DB_PREFIX . "location SET `name` = '" . $this->db->escape((string)$data['name']) . "', address = '" . $this->db->escape((string)$data['address']) . "', `geocode` = '" . $this->db->escape((string)$data['geocode']) . "', `telephone` = '" . $this->db->escape((string)$data['telephone']) . "', `fax` = '" . $this->db->escape((string)$data['fax']) . "', `image` = '" . $this->db->escape((string)$data['image']) . "', `open` = '" . $this->db->escape((string)$data['open']) . "', `comment` = '" . $this->db->escape((string)$data['comment']) . "'");

return $this->db->getLastId();
}

public function editLocation($location_id, $data) {
$this->db->query("UPDATE " . DB_PREFIX . "location SET name = '" . $this->db->escape((string)$data['name']) . "', address = '" . $this->db->escape((string)$data['address']) . "', geocode = '" . $this->db->escape((string)$data['geocode']) . "', telephone = '" . $this->db->escape((string)$data['telephone']) . "', fax = '" . $this->db->escape((string)$data['fax']) . "', image = '" . $this->db->escape((string)$data['image']) . "', open = '" . $this->db->escape((string)$data['open']) . "', comment = '" . $this->db->escape((string)$data['comment']) . "' WHERE location_id = '" . (int)$location_id . "'");
$this->db->query("UPDATE " . DB_PREFIX . "location SET `name` = '" . $this->db->escape((string)$data['name']) . "', `address` = '" . $this->db->escape((string)$data['address']) . "', `geocode` = '" . $this->db->escape((string)$data['geocode']) . "', `telephone` = '" . $this->db->escape((string)$data['telephone']) . "', `fax` = '" . $this->db->escape((string)$data['fax']) . "', `image` = '" . $this->db->escape((string)$data['image']) . "', `open` = '" . $this->db->escape((string)$data['open']) . "', `comment` = '" . $this->db->escape((string)$data['comment']) . "' WHERE `location_id` = '" . (int)$location_id . "'");
}

public function deleteLocation($location_id) {
Expand Down
24 changes: 12 additions & 12 deletions upload/admin/model/localisation/return_action.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ class ReturnAction extends \System\Engine\Model {
public function addReturnAction($data) {
foreach ($data['return_action'] as $language_id => $value) {
if (isset($return_action_id)) {
$this->db->query("INSERT INTO " . DB_PREFIX . "return_action SET return_action_id = '" . (int)$return_action_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "return_action` SET `return_action_id` = '" . (int)$return_action_id . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($value['name']) . "'");
} else {
$this->db->query("INSERT INTO " . DB_PREFIX . "return_action SET language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "return_action` SET `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($value['name']) . "'");

$return_action_id = $this->db->getLastId();
}
Expand All @@ -18,32 +18,32 @@ public function addReturnAction($data) {
}

public function editReturnAction($return_action_id, $data) {
$this->db->query("DELETE FROM " . DB_PREFIX . "return_action WHERE return_action_id = '" . (int)$return_action_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "return_action` WHERE `return_action_id` = '" . (int)$return_action_id . "'");

foreach ($data['return_action'] as $language_id => $value) {
$this->db->query("INSERT INTO " . DB_PREFIX . "return_action SET return_action_id = '" . (int)$return_action_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "return_action` SET `return_action_id` = '" . (int)$return_action_id . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($value['name']) . "'");
}

$this->cache->delete('return_action');
}

public function deleteReturnAction($return_action_id) {
$this->db->query("DELETE FROM " . DB_PREFIX . "return_action WHERE return_action_id = '" . (int)$return_action_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "return_action` WHERE `return_action_id` = '" . (int)$return_action_id . "'");

$this->cache->delete('return_action');
}

public function getReturnAction($return_action_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "return_action WHERE return_action_id = '" . (int)$return_action_id . "' AND language_id = '" . (int)$this->config->get('config_language_id') . "'");
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "return_action` WHERE `return_action_id` = '" . (int)$return_action_id . "' AND `language_id` = '" . (int)$this->config->get('config_language_id') . "'");

return $query->row;
}

public function getReturnActions($data = []) {
if ($data) {
$sql = "SELECT * FROM " . DB_PREFIX . "return_action WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'";
$sql = "SELECT * FROM `" . DB_PREFIX . "return_action` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'";

$sql .= " ORDER BY name";
$sql .= " ORDER BY `name`";

if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC";
Expand All @@ -70,7 +70,7 @@ public function getReturnActions($data = []) {
$return_action_data = $this->cache->get('return_action.' . (int)$this->config->get('config_language_id'));

if (!$return_action_data) {
$query = $this->db->query("SELECT return_action_id, name FROM " . DB_PREFIX . "return_action WHERE language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY name");
$query = $this->db->query("SELECT `return_action_id`, `name` FROM `" . DB_PREFIX . "return_action` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "' ORDER BY `name`");

$return_action_data = $query->rows;

Expand All @@ -84,17 +84,17 @@ public function getReturnActions($data = []) {
public function getDescriptions($return_action_id) {
$return_action_data = [];

$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "return_action WHERE return_action_id = '" . (int)$return_action_id . "'");
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "return_action` WHERE `return_action_id` = '" . (int)$return_action_id . "'");

foreach ($query->rows as $result) {
$return_action_data[$result['language_id']] = ['name' => $result['name']);
$return_action_data[$result['language_id']] = ['name' => $result['name']];
}

return $return_action_data;
}

public function getTotalReturnActions() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "return_action WHERE language_id = '" . (int)$this->config->get('config_language_id') . "'");
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "return_action` WHERE `language_id` = '" . (int)$this->config->get('config_language_id') . "'");

return $query->row['total'];
}
Expand Down
Loading

0 comments on commit 8afd7a1

Please sign in to comment.