[go: nahoru, domu]

Skip to content

Commit

Permalink
more code structure changes
Browse files Browse the repository at this point in the history
  • Loading branch information
danielkerr committed Aug 24, 2020
1 parent ff959db commit 6d470c6
Show file tree
Hide file tree
Showing 27 changed files with 2,588 additions and 2,549 deletions.
22 changes: 11 additions & 11 deletions upload/admin/model/localisation/order_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ class OrderStatus extends \System\Engine\Model {
public function addOrderStatus($data) {
foreach ($data['order_status'] as $language_id => $value) {
if (isset($order_status_id)) {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_status SET order_status_id = '" . (int)$order_status_id . "', language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "order_status` SET `order_status_id` = '" . (int)$order_status_id . "', `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($value['name']) . "'");
} else {
$this->db->query("INSERT INTO " . DB_PREFIX . "order_status SET language_id = '" . (int)$language_id . "', name = '" . $this->db->escape($value['name']) . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "order_status` SET `language_id` = '" . (int)$language_id . "', `name` = '" . $this->db->escape($value['name']) . "'");

$order_status_id = $this->db->getLastId();
}
Expand All @@ -18,30 +18,30 @@ public function addOrderStatus($data) {
}

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

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

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

public function deleteOrderStatus($order_status_id) {
$this->db->query("DELETE FROM " . DB_PREFIX . "order_status WHERE order_status_id = '" . (int)$order_status_id . "'");
$this->db->query("DELETE FROM `" . DB_PREFIX . "order_status` WHERE `order_status_id` = '" . (int)$order_status_id . "'");

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

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

return $query->row;
}

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

$sql .= " ORDER BY name";

Expand Down Expand Up @@ -70,7 +70,7 @@ public function getOrderStatuses($data = []) {
$order_status_data = $this->cache->get('order_status.' . (int)$this->config->get('config_language_id'));

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

$order_status_data = $query->rows;

Expand All @@ -84,17 +84,17 @@ public function getOrderStatuses($data = []) {
public function getDescriptions($order_status_id) {
$order_status_data = [];

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

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

return $order_status_data;
}

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

return $query->row['total'];
}
Expand Down
18 changes: 9 additions & 9 deletions upload/admin/model/sale/voucher_theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ public function addVoucherTheme($data) {
}

public function editVoucherTheme($voucher_theme_id, $data) {
$this->db->query("UPDATE " . DB_PREFIX . "voucher_theme SET image = '" . $this->db->escape((string)$data['image']) . "' WHERE voucher_theme_id = '" . (int)$voucher_theme_id . "'");
$this->db->query("UPDATE " . DB_PREFIX . "voucher_theme SET image = '" . $this->db->escape((string)$data['image']) . "' WHERE `voucher_theme_id` = '" . (int)$voucher_theme_id . "'");

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

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

$this->cache->delete('voucher_theme');
Expand All @@ -35,14 +35,14 @@ public function deleteVoucherTheme($voucher_theme_id) {
}

public function getVoucherTheme($voucher_theme_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "voucher_theme vt LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) WHERE vt.voucher_theme_id = '" . (int)$voucher_theme_id . "' AND vtd.language_id = '" . (int)$this->config->get('config_language_id') . "'");
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "voucher_theme` vt LEFT JOIN `" . DB_PREFIX . "voucher_theme_description` vtd ON (vt.`voucher_theme_id` = vtd.`voucher_theme_id`) WHERE vt.`voucher_theme_id` = '" . (int)$voucher_theme_id . "' AND vtd.`language_id` = '" . (int)$this->config->get('config_language_id') . "'");

return $query->row;
}

public function getVoucherThemes($data = []) {
if ($data) {
$sql = "SELECT * FROM " . DB_PREFIX . "voucher_theme vt LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) WHERE vtd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY vtd.name";
$sql = "SELECT * FROM `" . DB_PREFIX . "voucher_theme` vt LEFT JOIN `" . DB_PREFIX . "voucher_theme_description` vtd ON (vt.`voucher_theme_id` = vtd.`voucher_theme_id`) WHERE vtd.`language_id` = '" . (int)$this->config->get('config_language_id') . "' ORDER BY vtd.`name`";

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

if (!$voucher_theme_data) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "voucher_theme vt LEFT JOIN " . DB_PREFIX . "voucher_theme_description vtd ON (vt.voucher_theme_id = vtd.voucher_theme_id) WHERE vtd.language_id = '" . (int)$this->config->get('config_language_id') . "' ORDER BY vtd.name");
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "voucher_theme` vt LEFT JOIN `" . DB_PREFIX . "voucher_theme_description` vtd ON (vt.`voucher_theme_id` = vtd.`voucher_theme_id`) WHERE vtd.`language_id` = '" . (int)$this->config->get('config_language_id') . "' ORDER BY vtd.`name`");

$voucher_theme_data = $query->rows;

Expand All @@ -83,17 +83,17 @@ public function getVoucherThemes($data = []) {
public function getDescriptions($voucher_theme_id) {
$voucher_theme_data = [];

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

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

return $voucher_theme_data;
}

public function getTotalVoucherThemes() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "voucher_theme");
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "voucher_theme`");

return $query->row['total'];
}
Expand Down
4 changes: 2 additions & 2 deletions upload/admin/model/setting/cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ public function deleteCronByCode($code) {
}

public function editCron($cron_id) {
$this->db->query("UPDATE `" . DB_PREFIX . "cron` SET `date_modified` = NOW() WHERE cron_id = '" . (int)$cron_id . "'");
$this->db->query("UPDATE `" . DB_PREFIX . "cron` SET `date_modified` = NOW() WHERE `cron_id` = '" . (int)$cron_id . "'");
}

public function editStatus($cron_id, $status) {
$this->db->query("UPDATE `" . DB_PREFIX . "cron` SET `status` = '" . (int)$status . "' WHERE cron_id = '" . (int)$cron_id . "'");
$this->db->query("UPDATE `" . DB_PREFIX . "cron` SET `status` = '" . (int)$status . "' WHERE `cron_id` = '" . (int)$cron_id . "'");
}

public function getCron($cron_id) {
Expand Down
32 changes: 16 additions & 16 deletions upload/admin/model/setting/store.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
namespace Application\Model\Setting;
class Store extends \System\Engine\Model {
public function addStore($data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "store SET name = '" . $this->db->escape((string)$data['config_name']) . "', `url` = '" . $this->db->escape((string)$data['config_url']) . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "store` SET `name` = '" . $this->db->escape((string)$data['config_name']) . "', `url` = '" . $this->db->escape((string)$data['config_url']) . "'");

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

// Layout Route
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "layout_route WHERE store_id = '0'");
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "layout_route` WHERE `store_id` = '0'");

foreach ($query->rows as $layout_route) {
$this->db->query("INSERT INTO " . DB_PREFIX . "layout_route SET layout_id = '" . (int)$layout_route['layout_id'] . "', route = '" . $this->db->escape($layout_route['route']) . "', store_id = '" . (int)$store_id . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "layout_route` SET `layout_id` = '" . (int)$layout_route['layout_id'] . "', `route` = '" . $this->db->escape($layout_route['route']) . "', `store_id` = '" . (int)$store_id . "'");
}

$this->cache->delete('store');
Expand All @@ -19,7 +19,7 @@ public function addStore($data) {
}

public function editStore($store_id, $data) {
$this->db->query("UPDATE " . DB_PREFIX . "store SET name = '" . $this->db->escape((string)$data['config_name']) . "', `url` = '" . $this->db->escape((string)$data['config_url']) . "' WHERE store_id = '" . (int)$store_id . "'");
$this->db->query("UPDATE " . DB_PREFIX . "store SET `name` = '" . $this->db->escape((string)$data['config_name']) . "', `url` = '" . $this->db->escape((string)$data['config_url']) . "' WHERE `store_id` = '" . (int)$store_id . "'");

$this->cache->delete('store');
}
Expand All @@ -34,7 +34,7 @@ public function deleteStore($store_id) {
}

public function getStore($store_id) {
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "store WHERE store_id = '" . (int)$store_id . "'");
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "store` WHERE `store_id` = '" . (int)$store_id . "'");

return $query->row;
}
Expand All @@ -43,7 +43,7 @@ public function getStores($data = []) {
$store_data = $this->cache->get('store');

if (!$store_data) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "store ORDER BY url");
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "store` ORDER BY `url`");

$store_data = $query->rows;

Expand All @@ -54,57 +54,57 @@ public function getStores($data = []) {
}

public function getTotalStores() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "store");
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "store`");

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

public function getTotalStoresByLayoutId($layout_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_layout_id' AND `value` = '" . (int)$layout_id . "' AND store_id != '0'");
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_layout_id' AND `value` = '" . (int)$layout_id . "' AND `store_id` != '0'");

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

public function getTotalStoresByLanguage($language) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_language' AND `value` = '" . $this->db->escape($language) . "' AND store_id != '0'");
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_language' AND `value` = '" . $this->db->escape($language) . "' AND `store_id` != '0'");

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

public function getTotalStoresByCurrency($currency) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_currency' AND `value` = '" . $this->db->escape($currency) . "' AND store_id != '0'");
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_currency' AND `value` = '" . $this->db->escape($currency) . "' AND `store_id` != '0'");

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

public function getTotalStoresByCountryId($country_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_country_id' AND `value` = '" . (int)$country_id . "' AND store_id != '0'");
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_country_id' AND `value` = '" . (int)$country_id . "' AND `store_id` != '0'");

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

public function getTotalStoresByZoneId($zone_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_zone_id' AND `value` = '" . (int)$zone_id . "' AND store_id != '0'");
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_zone_id' AND `value` = '" . (int)$zone_id . "' AND `store_id` != '0'");

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

public function getTotalStoresByCustomerGroupId($customer_group_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_customer_group_id' AND `value` = '" . (int)$customer_group_id . "' AND store_id != '0'");
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_customer_group_id' AND `value` = '" . (int)$customer_group_id . "' AND `store_id` != '0'");

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

public function getTotalStoresByInformationId($information_id) {
$account_query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_account_id' AND `value` = '" . (int)$information_id . "' AND store_id != '0'");
$account_query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_account_id' AND `value` = '" . (int)$information_id . "' AND `store_id` != '0'");

$checkout_query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_checkout_id' AND `value` = '" . (int)$information_id . "' AND store_id != '0'");
$checkout_query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_checkout_id' AND `value` = '" . (int)$information_id . "' AND `store_id` != '0'");

return ($account_query->row['total'] + $checkout_query->row['total']);
}

public function getTotalStoresByOrderStatusId($order_status_id) {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "setting WHERE `key` = 'config_order_status_id' AND `value` = '" . (int)$order_status_id . "' AND store_id != '0'");
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "setting` WHERE `key` = 'config_order_status_id' AND `value` = '" . (int)$order_status_id . "' AND `store_id` != '0'");

return $query->row['total'];
}
Expand Down
4 changes: 2 additions & 2 deletions upload/admin/model/tool/s3.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public function addFile($file, $path) {
'version' => 'latest',
'region' => 'us-west-2',
'credentials' => false
);
];

$s3 = new Aws\S3\S3Client($option);
$s3->completeMultipartUpload($option);
Expand All @@ -29,7 +29,7 @@ public function getFile($file, $file) {
'version' => 'latest',
'region' => 'us-west-2',
'credentials' => false
);
];

$s3 = new Aws\S3\S3Client($option);
$s3->completeMultipartUpload($option);
Expand Down
2 changes: 1 addition & 1 deletion upload/catalog/controller/common/column_right.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
namespace Application\Controller\Common;
class ColumnRight extends \System\Engine\Controller
class ColumnRight extends \System\Engine\Controller {
public function index() {
$this->load->model('design/layout');

Expand Down
36 changes: 36 additions & 0 deletions upload/config-dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
// HTTP
define('HTTP_SERVER', 'http://localhost/opencart-master/upload/');

// HTTPS
define('HTTPS_SERVER', 'http://localhost/opencart-master/upload/');

// DIR
define('DIR_APPLICATION', 'C:/xampp/htdocs/opencart-master/upload/catalog/');
define('DIR_CATALOG', 'C:/xampp/htdocs/opencart-master/upload/catalog/');
define('DIR_ADMIN', 'C:/xampp/htdocs/opencart-master/upload/admin/');

define('DIR_EXTENSION', 'C:/xampp/htdocs/opencart-master/upload/extension/');
define('DIR_IMAGE', 'C:/xampp/htdocs/opencart-master/upload/image/');
define('DIR_SYSTEM', 'C:/xampp/htdocs/opencart-master/upload/system/');

define('DIR_STORAGE', DIR_SYSTEM . 'storage/');

define('DIR_LANGUAGE', DIR_APPLICATION . 'language/');
define('DIR_TEMPLATE', DIR_APPLICATION . 'view/theme/');

define('DIR_CONFIG', DIR_SYSTEM . 'config/');
define('DIR_CACHE', DIR_STORAGE . 'cache/');
define('DIR_DOWNLOAD', DIR_STORAGE . 'download/');
define('DIR_LOGS', DIR_STORAGE . 'logs/');
define('DIR_SESSION', DIR_STORAGE . 'session/');
define('DIR_UPLOAD', DIR_STORAGE . 'upload/');

// DB
define('DB_DRIVER', 'mysqli');
define('DB_HOSTNAME', 'localhost');
define('DB_USERNAME', 'root');
define('DB_PASSWORD', '');
define('DB_DATABASE', 'opencart-master');
define('DB_PORT', '3306');
define('DB_PREFIX', 'oc_');
2 changes: 1 addition & 1 deletion upload/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Catalog;
//namespace Catalog;

// Version
define('VERSION', '3.1.0.0_b');
Expand Down
4 changes: 2 additions & 2 deletions upload/install/controller/common/column_left.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Install\Controller\Common;
namespace Application\Controller\Common;
class ColumnLeft extends \System\Engine\Controller {
public function index() {
$this->load->language('common/column_left');
Expand Down Expand Up @@ -40,7 +40,7 @@ public function index() {
$data['languages'][] = [
'text' => $language->get('text_name'),
'value' => $code
);
];
}

if (!isset($this->request->get['route'])) {
Expand Down
Loading

0 comments on commit 6d470c6

Please sign in to comment.