first commit

This commit is contained in:
Konstantin
2026-05-30 09:27:58 +03:00
commit de0344d218
2371 changed files with 661486 additions and 0 deletions
+106
View File
@@ -0,0 +1,106 @@
<?php
class ModelDesignBanner extends Model {
public function addBanner($data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "banner SET name = '" . $this->db->escape($data['name']) . "', status = '" . (int)$data['status'] . "'");
$banner_id = $this->db->getLastId();
if (isset($data['banner_image'])) {
foreach ($data['banner_image'] as $language_id => $value) {
foreach ($value as $banner_image) {
$this->db->query("INSERT INTO " . DB_PREFIX . "banner_image SET banner_id = '" . (int)$banner_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($banner_image['title']) . "', link = '" . $this->db->escape($banner_image['link']) . "', description = '" . $this->db->escape($banner_image['description']) . "', button_text = '" . $this->db->escape($banner_image['button_text']) . "', image = '" . $this->db->escape($banner_image['image']) . "', image_mobile = '" . $this->db->escape($banner_image['image_mobile']) . "', sort_order = '" . (int)$banner_image['sort_order'] . "'");
}
}
}
return $banner_id;
}
public function editBanner($banner_id, $data) {
$this->db->query("UPDATE " . DB_PREFIX . "banner SET name = '" . $this->db->escape($data['name']) . "', status = '" . (int)$data['status'] . "' WHERE banner_id = '" . (int)$banner_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "banner_image WHERE banner_id = '" . (int)$banner_id . "'");
if (isset($data['banner_image'])) {
foreach ($data['banner_image'] as $language_id => $value) {
foreach ($value as $banner_image) {
$this->db->query("INSERT INTO " . DB_PREFIX . "banner_image SET banner_id = '" . (int)$banner_id . "', language_id = '" . (int)$language_id . "', title = '" . $this->db->escape($banner_image['title']) . "', link = '" . $this->db->escape($banner_image['link']) . "', description = '" . $this->db->escape($banner_image['description']) . "', button_text = '" . $this->db->escape($banner_image['button_text']) . "', image = '" . $this->db->escape($banner_image['image']) . "', image_mobile = '" . $this->db->escape($banner_image['image_mobile']) . "', sort_order = '" . (int)$banner_image['sort_order'] . "'");
}
}
}
}
public function deleteBanner($banner_id) {
$this->db->query("DELETE FROM " . DB_PREFIX . "banner WHERE banner_id = '" . (int)$banner_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "banner_image WHERE banner_id = '" . (int)$banner_id . "'");
}
public function getBanner($banner_id) {
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "banner WHERE banner_id = '" . (int)$banner_id . "'");
return $query->row;
}
public function getBanners($data = array()) {
$sql = "SELECT * FROM " . DB_PREFIX . "banner";
$sort_data = array(
'name',
'status'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
$sql .= " ORDER BY " . $data['sort'];
} else {
$sql .= " ORDER BY name";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
}
public function getBannerImages($banner_id) {
$banner_image_data = array();
$banner_image_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "banner_image WHERE banner_id = '" . (int)$banner_id . "' ORDER BY sort_order ASC");
foreach ($banner_image_query->rows as $banner_image) {
$banner_image_data[$banner_image['language_id']][] = array(
'title' => $banner_image['title'],
'link' => $banner_image['link'],
'description' => $banner_image['description'],
'button_text' => $banner_image['button_text'],
'image' => $banner_image['image'],
'image_mobile' => $banner_image['image_mobile'],
'sort_order' => $banner_image['sort_order']
);
}
return $banner_image_data;
}
public function getTotalBanners() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "banner");
return $query->row['total'];
}
}
+109
View File
@@ -0,0 +1,109 @@
<?php
class ModelDesignLayout extends Model {
public function addLayout($data) {
$this->db->query("INSERT INTO " . DB_PREFIX . "layout SET name = '" . $this->db->escape($data['name']) . "'");
$layout_id = $this->db->getLastId();
if (isset($data['layout_route'])) {
foreach ($data['layout_route'] as $layout_route) {
$this->db->query("INSERT INTO " . DB_PREFIX . "layout_route SET layout_id = '" . (int)$layout_id . "', store_id = '" . (int)$layout_route['store_id'] . "', route = '" . $this->db->escape($layout_route['route']) . "'");
}
}
if (isset($data['layout_module'])) {
foreach ($data['layout_module'] as $layout_module) {
$this->db->query("INSERT INTO " . DB_PREFIX . "layout_module SET layout_id = '" . (int)$layout_id . "', code = '" . $this->db->escape($layout_module['code']) . "', position = '" . $this->db->escape($layout_module['position']) . "', sort_order = '" . (int)$layout_module['sort_order'] . "'");
}
}
return $layout_id;
}
public function editLayout($layout_id, $data) {
$this->db->query("UPDATE " . DB_PREFIX . "layout SET name = '" . $this->db->escape($data['name']) . "' WHERE layout_id = '" . (int)$layout_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "layout_route WHERE layout_id = '" . (int)$layout_id . "'");
if (isset($data['layout_route'])) {
foreach ($data['layout_route'] as $layout_route) {
$this->db->query("INSERT INTO " . DB_PREFIX . "layout_route SET layout_id = '" . (int)$layout_id . "', store_id = '" . (int)$layout_route['store_id'] . "', route = '" . $this->db->escape($layout_route['route']) . "'");
}
}
$this->db->query("DELETE FROM " . DB_PREFIX . "layout_module WHERE layout_id = '" . (int)$layout_id . "'");
if (isset($data['layout_module'])) {
foreach ($data['layout_module'] as $layout_module) {
$this->db->query("INSERT INTO " . DB_PREFIX . "layout_module SET layout_id = '" . (int)$layout_id . "', code = '" . $this->db->escape($layout_module['code']) . "', position = '" . $this->db->escape($layout_module['position']) . "', sort_order = '" . (int)$layout_module['sort_order'] . "'");
}
}
}
public function deleteLayout($layout_id) {
$this->db->query("DELETE FROM " . DB_PREFIX . "layout WHERE layout_id = '" . (int)$layout_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "layout_route WHERE layout_id = '" . (int)$layout_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "layout_module WHERE layout_id = '" . (int)$layout_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "category_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "product_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
$this->db->query("DELETE FROM " . DB_PREFIX . "information_to_layout WHERE layout_id = '" . (int)$layout_id . "'");
}
public function getLayout($layout_id) {
$query = $this->db->query("SELECT DISTINCT * FROM " . DB_PREFIX . "layout WHERE layout_id = '" . (int)$layout_id . "'");
return $query->row;
}
public function getLayouts($data = array()) {
$sql = "SELECT * FROM " . DB_PREFIX . "layout";
$sort_data = array('name');
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
$sql .= " ORDER BY " . $data['sort'];
} else {
$sql .= " ORDER BY name";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
}
public function getLayoutRoutes($layout_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "layout_route WHERE layout_id = '" . (int)$layout_id . "'");
return $query->rows;
}
public function getLayoutModules($layout_id) {
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "layout_module WHERE layout_id = '" . (int)$layout_id . "' ORDER BY position ASC, sort_order ASC");
return $query->rows;
}
public function getTotalLayouts() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM " . DB_PREFIX . "layout");
return $query->row['total'];
}
}
+123
View File
@@ -0,0 +1,123 @@
<?php
class ModelDesignSeoUrl extends Model {
public function addSeoUrl($data) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "seo_url` SET store_id = '" . (int)$data['store_id'] . "', language_id = '" . (int)$data['language_id'] . "', query = '" . $this->db->escape($data['query']) . "', keyword = '" . $this->db->escape($data['keyword']) . "'");
}
public function editSeoUrl($seo_url_id, $data) {
$this->db->query("UPDATE `" . DB_PREFIX . "seo_url` SET store_id = '" . (int)$data['store_id'] . "', language_id = '" . (int)$data['language_id'] . "', query = '" . $this->db->escape($data['query']) . "', keyword = '" . $this->db->escape($data['keyword']) . "' WHERE seo_url_id = '" . (int)$seo_url_id . "'");
}
public function deleteSeoUrl($seo_url_id) {
$this->db->query("DELETE FROM `" . DB_PREFIX . "seo_url` WHERE seo_url_id = '" . (int)$seo_url_id . "'");
}
public function getSeoUrl($seo_url_id) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "seo_url` WHERE seo_url_id = '" . (int)$seo_url_id . "'");
return $query->row;
}
public function getSeoUrls($data = array()) {
$sql = "SELECT *, (SELECT `name` FROM `" . DB_PREFIX . "store` s WHERE s.store_id = su.store_id) AS store, (SELECT `name` FROM `" . DB_PREFIX . "language` l WHERE l.language_id = su.language_id) AS language FROM `" . DB_PREFIX . "seo_url` su";
$implode = array();
if (!empty($data['filter_query'])) {
$implode[] = "`query` LIKE '" . $this->db->escape($data['filter_query']) . "'";
}
if (!empty($data['filter_keyword'])) {
$implode[] = "`keyword` LIKE '" . $this->db->escape($data['filter_keyword']) . "'";
}
if (isset($data['filter_store_id']) && $data['filter_store_id'] !== '') {
$implode[] = "`store_id` = '" . (int)$data['filter_store_id'] . "'";
}
if (!empty($data['filter_language_id']) && $data['filter_language_id'] !== '') {
$implode[] = "`language_id` = '" . (int)$data['filter_language_id'] . "'";
}
if ($implode) {
$sql .= " WHERE " . implode(" AND ", $implode);
}
$sort_data = array(
'query',
'keyword',
'language_id',
'store_id'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
$sql .= " ORDER BY " . $data['sort'];
} else {
$sql .= " ORDER BY query";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
}
public function getTotalSeoUrls($data = array()) {
$sql = "SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "seo_url`";
$implode = array();
if (!empty($data['filter_query'])) {
$implode[] = "query LIKE '" . $this->db->escape($data['filter_query']) . "'";
}
if (!empty($data['filter_keyword'])) {
$implode[] = "keyword LIKE '" . $this->db->escape($data['filter_keyword']) . "'";
}
if (!empty($data['filter_store_id']) && $data['filter_store_id'] !== '') {
$implode[] = "store_id = '" . (int)$data['filter_store_id'] . "'";
}
if (!empty($data['filter_language_id']) && $data['filter_language_id'] !== '') {
$implode[] = "language_id = '" . (int)$data['filter_language_id'] . "'";
}
if ($implode) {
$sql .= " WHERE " . implode(" AND ", $implode);
}
$query = $this->db->query($sql);
return $query->row['total'];
}
public function getSeoUrlsByKeyword($keyword) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "seo_url` WHERE keyword = '" . $this->db->escape(trim($keyword)) . "'");
return $query->rows;
}
public function getSeoUrlsByQuery($keyword) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "seo_url` WHERE keyword = '" . $this->db->escape(trim($keyword)) . "'");
return $query->rows;
}
}
+38
View File
@@ -0,0 +1,38 @@
<?php
class ModelDesignTheme extends Model {
public function editTheme($store_id, $theme, $route, $code) {
$this->db->query("DELETE FROM `" . DB_PREFIX . "theme` WHERE store_id = '" . (int)$store_id . "' AND theme = '" . $this->db->escape($theme) . "' AND route = '" . $this->db->escape($route) . "'");
$this->db->query("INSERT INTO `" . DB_PREFIX . "theme` SET store_id = '" . (int)$store_id . "', theme = '" . $this->db->escape($theme) . "', route = '" . $this->db->escape($route) . "', code = '" . $this->db->escape($code) . "', date_added = NOW()");
}
public function deleteTheme($theme_id) {
$this->db->query("DELETE FROM `" . DB_PREFIX . "theme` WHERE theme_id = '" . (int)$theme_id . "'");
}
public function getTheme($store_id, $theme, $route) {
$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "theme` WHERE store_id = '" . (int)$store_id . "' AND theme = '" . $this->db->escape($theme) . "' AND route = '" . $this->db->escape($route) . "'");
return $query->row;
}
public function getThemes($start = 0, $limit = 10) {
if ($start < 0) {
$start = 0;
}
if ($limit < 1) {
$limit = 10;
}
$query = $this->db->query("SELECT *, (SELECT name FROM `" . DB_PREFIX . "store` s WHERE s.store_id = t.store_id) AS store FROM `" . DB_PREFIX . "theme` t ORDER BY t.date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
return $query->rows;
}
public function getTotalThemes() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "theme`");
return $query->row['total'];
}
}
+66
View File
@@ -0,0 +1,66 @@
<?php
class ModelDesignTranslation extends Model {
public function addTranslation($data) {
$this->db->query("INSERT INTO `" . DB_PREFIX . "translation` SET `store_id` = '" . (int)$data['store_id'] . "', `language_id` = '" . (int)$data['language_id'] . "', `route` = '" . $this->db->escape($data['route']) . "', `key` = '" . $this->db->escape($data['key']) . "', `value` = '" . $this->db->escape($data['value']) . "', `date_added` = NOW()");
}
public function editTranslation($translation_id, $data) {
$this->db->query("UPDATE `" . DB_PREFIX . "translation` SET `store_id` = '" . (int)$data['store_id'] . "', `language_id` = '" . (int)$data['language_id'] . "', `route` = '" . $this->db->escape($data['route']) . "', `key` = '" . $this->db->escape($data['key']) . "', `value` = '" . $this->db->escape($data['value']) . "' WHERE `translation_id` = '" . (int)$translation_id . "'");
}
public function deleteTranslation($translation_id) {
$this->db->query("DELETE FROM `" . DB_PREFIX . "translation` WHERE `translation_id` = '" . (int)$translation_id . "'");
}
public function getTranslation($translation_id) {
$query = $this->db->query("SELECT DISTINCT * FROM `" . DB_PREFIX . "translation` WHERE `translation_id` = '" . (int)$translation_id . "'");
return $query->row;
}
public function getTranslations($data = array()) {
$sql = "SELECT *, (SELECT s.name FROM `" . DB_PREFIX . "store` s WHERE s.store_id = t.store_id) AS store, (SELECT l.name FROM `" . DB_PREFIX . "language` l WHERE l.language_id = t.language_id) AS language FROM `" . DB_PREFIX . "translation` t";
$sort_data = array(
'store',
'language',
'route',
'key',
'value'
);
if (isset($data['sort']) && in_array($data['sort'], $sort_data)) {
$sql .= " ORDER BY `" . $data['sort'] . "`";
} else {
$sql .= " ORDER BY store";
}
if (isset($data['order']) && ($data['order'] == 'DESC')) {
$sql .= " DESC";
} else {
$sql .= " ASC";
}
if (isset($data['start']) || isset($data['limit'])) {
if ($data['start'] < 0) {
$data['start'] = 0;
}
if ($data['limit'] < 1) {
$data['limit'] = 20;
}
$sql .= " LIMIT " . (int)$data['start'] . "," . (int)$data['limit'];
}
$query = $this->db->query($sql);
return $query->rows;
}
public function getTotalTranslations() {
$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "translation`");
return $query->row['total'];
}
}