Skip to content

Commit

Permalink
OkayCMS 2.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
OkayCMS committed Feb 26, 2019
1 parent 0df6943 commit 8c793ea
Show file tree
Hide file tree
Showing 78 changed files with 3,548 additions and 2,315 deletions.
15 changes: 5 additions & 10 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -66,20 +66,15 @@ RewriteRule ^([a-z]{2}/)?products/([^/]+)/?$ index.php?module=ProductView&produc
RewriteRule ^([a-z]{2}/)?all-products/?$ index.php?module=ProductsView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?all-products/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=all-products [L,QSA]

RewriteRule ^([a-z]{2}/)?discounted/?$ index.php?module=ProductsView&lang_label=$1&mode=discounted [L,QSA]
RewriteRule ^([a-z]{2}/)?discounted/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=discounted&mode=discounted [L,QSA]
RewriteRule ^([a-z]{2}/)?bestsellers/?$ index.php?module=ProductsView&lang_label=$1&mode=bestsellers [L,QSA]
RewriteRule ^([a-z]{2}/)?bestsellers/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=bestsellers&mode=bestsellers [L,QSA]
RewriteRule ^([a-z]{2}/)?(discounted|bestsellers)/?$ index.php?module=ProductsView&lang_label=$1&mode=$2 [L,QSA]
RewriteRule ^([a-z]{2}/)?(discounted|bestsellers)/([^/]+) index.php?module=ProductsView&lang_label=$1&page_url=$2&mode=$2 [L,QSA]

RewriteRule ^([a-z]{2}/)?brands/?$ index.php?module=BrandsView&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?brands/([^/]+) index.php?module=ProductsView&brand=$2&lang_label=$1 [L,QSA]

# Блог
RewriteRule ^([a-z]{2}/)?blog/([^/]+)/?$ index.php?module=BlogView&url=$2&lang_label=$1&type_post=blog [L,QSA]
RewriteRule ^([a-z]{2}/)?blog/?$ index.php?module=BlogView&lang_label=$1&type_post=blog [L,QSA]
# Новости
RewriteRule ^([a-z]{2}/)?news/([^/]+)/?$ index.php?module=BlogView&url=$2&lang_label=$1&type_post=news [L,QSA]
RewriteRule ^([a-z]{2}/)?news/?$ index.php?module=BlogView&lang_label=$1&type_post=news [L,QSA]
# Блог или новости
RewriteRule ^([a-z]{2}/)?(blog|news)/([^/]+)/?$ index.php?module=BlogView&url=$3&lang_label=$1 [L,QSA]
RewriteRule ^([a-z]{2}/)?(blog|news)/?$ index.php?module=BlogView&lang_label=$1 [L,QSA]

# Избранное
RewriteRule ^([a-z]{2}/)?wishlist/?$ index.php?module=WishlistView&lang_label=$1 [L,QSA]
Expand Down
710 changes: 356 additions & 354 deletions 1DB_changes/okay_clean.sql

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions 1DB_changes/update_2.3.1.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
ALTER TABLE `ok_settings` CHANGE `name` `param` varchar(255) COLLATE 'utf8_general_ci' NOT NULL DEFAULT '' AFTER `setting_id`;
ALTER TABLE `ok_settings_lang` CHANGE `name` `param` varchar(128) COLLATE 'utf8_general_ci' NOT NULL FIRST;
/*Где-то пошел сбой, и у некоторых пользователей нет такой колонки, запрос выполнять если её нет*/
ALTER TABLE `ok_support_info` ADD COLUMN `accesses` VARCHAR(2048) NULL DEFAULT '';
INSERT INTO `ok_settings` (`param`, `value`) VALUES ('products_image_sizes ', '200x200|50x50|1800x1200w|600x340|75x75|330x300|800x600|55x55|300x120|35x35');
2 changes: 1 addition & 1 deletion api/BackendTranslations.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

require_once('Okay.php');

class BackendTranslations extends Okay {
class BackendTranslations {

public function get_translation($var)
{
Expand Down
92 changes: 41 additions & 51 deletions api/Banners.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@
class Banners extends Okay {

/*Выбираем все слайды*/
public function get_banners_images($filter = array()) {
public function get_banners_images($filter = array(), $count = false) {
$limit = 100; // По умолчанию
$page = 1;
$banner_id_filter = '';
$banners_images_id_filter = '';
$visible_filter = '';
$joins = '';
$where = '1';
$group_by = '';
$order = 'bi.position DESC';
$lang_sql = $this->languages->get_query(array('object'=>'banner_image', 'px'=>'bi'));
$select = "bi.id,
bi.banner_id,
bi.image,
bi.position,
bi.visible,
$lang_sql->fields ";

if ($count === true) {
$select = "COUNT(DISTINCT bi.id) as count";
}

if(isset($filter['limit'])) {
$limit = max(1, intval($filter['limit']));
Expand All @@ -25,15 +35,15 @@ public function get_banners_images($filter = array()) {
$sql_limit = $this->db->placehold(' LIMIT ?, ? ', ($page-1)*$limit, $limit);

if(!empty($filter['id'])) {
$banners_images_id_filter = $this->db->placehold('AND bi.id in(?@)', (array)$filter['id']);
$where .= $this->db->placehold(' AND bi.id in(?@)', (array)$filter['id']);
}

if(!empty($filter['banner_id'])) {
$banner_id_filter = $this->db->placehold('AND bi.banner_id in(?@)', (array)$filter['banner_id']);
$where .= $this->db->placehold(' AND bi.banner_id in(?@)', (array)$filter['banner_id']);
}

if(isset($filter['visible'])) {
$visible_filter = $this->db->placehold('AND bi.visible=?', intval($filter['visible']));
$where .= $this->db->placehold(' AND bi.visible=?', intval($filter['visible']));
}

if(!empty($filter['sort'])) {
Expand All @@ -43,60 +53,40 @@ public function get_banners_images($filter = array()) {
break;
}
}

if (!empty($order)) {
$order = "ORDER BY $order";
}

// При подсчете нам эти переменные не нужны
if ($count === true) {
$order = '';
$group_by = '';
$sql_limit = '';
}

$lang_sql = $this->languages->get_query(array('object'=>'banner_image', 'px'=>'bi'));
$query = "SELECT
bi.id,
bi.banner_id,
bi.image,
bi.position,
bi.visible,
$lang_sql->fields
$query = $this->db->placehold("SELECT $select
FROM __banners_images bi
$lang_sql->join
$joins
WHERE
1
$banners_images_id_filter
$banner_id_filter
$visible_filter
$group_by
ORDER BY $order
$sql_limit
";
$where
$group_by
$order
$sql_limit
");

$this->db->query($query);
return $this->db->results();
if ($count === true) {
return $this->db->result('count');
} else {
return $this->db->results();
}
}

/*Подсчитываем количество найденных слайдов*/
public function count_banners_images($filter = array()) {
$banner_id_filter = '';
$banners_images_id_filter = '';
$visible_filter = '';

if(!empty($filter['banner_id'])) {
$banner_id_filter = $this->db->placehold('AND bi.banner_id in(?@)', (array)$filter['banner_id']);
}

if(!empty($filter['id'])) {
$banners_images_id_filter = $this->db->placehold('AND bi.id in(?@)', (array)$filter['id']);
}

if(isset($filter['visible'])) {
$visible_filter = $this->db->placehold('AND bi.visible=?', intval($filter['visible']));
}

$query = "SELECT count(distinct bi.id) as count
FROM __banners_images AS bi
WHERE
1
$banner_id_filter
$banners_images_id_filter
$visible_filter
";

$this->db->query($query);
return $this->db->result('count');
return $this->get_banners_images($filter, true);
}

/*Выбираем конкретный слайд*/
Expand Down
115 changes: 45 additions & 70 deletions api/Blog.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,25 @@ public function get_post($id,$type_post = null) {
}

/*Выбираем все записи*/
public function get_posts($filter = array()) {
public function get_posts($filter = array(), $count = false) {
$limit = 1000; // По умолчанию
$page = 1;
$post_id_filter = '';
$visible_filter = '';
$keyword_filter = '';
$type_filter = '';
$posts = array();
$where = '1';
$order = 'b.date DESC, b.id DESC ';
$lang_sql = $this->languages->get_query(array('object'=>'blog'));
$select = "b.id,
b.url,
b.visible,
b.date,
b.image,
b.type_post,
b.last_modify,
$lang_sql->fields";

if ($count === true) {
$select = "COUNT(DISTINCT b.id) as count";
}

$lang_id = $this->languages->lang_id();
$px = ($lang_id ? 'l' : 'b');

Expand All @@ -62,96 +73,60 @@ public function get_posts($filter = array()) {
if(isset($filter['page'])) {
$page = max(1, intval($filter['page']));
}

$sql_limit = $this->db->placehold(' LIMIT ?, ? ', ($page-1)*$limit, $limit);

if(!empty($filter['id'])) {
$post_id_filter = $this->db->placehold('AND b.id in(?@)', (array)$filter['id']);
$where .= $this->db->placehold(' AND b.id in(?@)', (array)$filter['id']);
}

if(!empty($filter['type_post'])) {
$type_filter = $this->db->placehold('AND b.type_post = ?', $filter['type_post']);
$where .= $this->db->placehold(' AND b.type_post = ?', $filter['type_post']);
}

if(isset($filter['visible'])) {
$visible_filter = $this->db->placehold('AND b.visible = ?', intval($filter['visible']));
$where .= $this->db->placehold(' AND b.visible = ?', intval($filter['visible']));
}
if(isset($filter['keyword'])) {
$keyword_filter = ' ';
$keywords = explode(' ', $filter['keyword']);
foreach($keywords as $keyword) {
$keyword_filter .= $this->db->placehold('AND ('.$px.'.name LIKE "%'.$this->db->escape(trim($keyword)).'%" OR '.$px.'.meta_keywords LIKE "%'.$this->db->escape(trim($keyword)).'%") ');
}
$where .= $keyword_filter;
}

if (!empty($order)) {
$order = "ORDER BY $order";
}

// При подсчете нам эти переменные не нужны
if ($count === true) {
$order = '';
$sql_limit = '';
}

$sql_limit = $this->db->placehold(' LIMIT ?, ? ', ($page-1)*$limit, $limit);
$lang_sql = $this->languages->get_query(array('object'=>'blog'));
$query = $this->db->placehold("SELECT
b.id,
b.url,
b.visible,
b.date,
b.image,
b.type_post,
b.last_modify,
$lang_sql->fields
$query = $this->db->placehold("SELECT $select
FROM __blog b
$lang_sql->join
WHERE
1
$post_id_filter
$visible_filter
$keyword_filter
$type_filter
ORDER BY date DESC, id DESC
$sql_limit
$where
$order
$sql_limit
");
$this->db->query($query);
return $this->db->results();
}

/*Подсчитываем количество найденных записей*/
public function count_posts($filter = array()) {
$post_id_filter = '';
$visible_filter = '';
$keyword_filter = '';
$type_filter = '';
$lang_id = $this->languages->lang_id();
$px = ($lang_id ? 'l' : 'b');

if(!empty($filter['id'])) {
$post_id_filter = $this->db->placehold('AND b.id in(?@)', (array)$filter['id']);
}

if(!empty($filter['type_post'])) {
$type_filter = $this->db->placehold('AND b.type_post = ?', $filter['type_post']);
}

if(isset($filter['visible'])) {
$visible_filter = $this->db->placehold('AND b.visible = ?', intval($filter['visible']));
}

if(isset($filter['keyword'])) {
$keywords = explode(' ', $filter['keyword']);
foreach($keywords as $keyword) {
$keyword_filter .= $this->db->placehold('AND ('.$px.'.name LIKE "%'.$this->db->escape(trim($keyword)).'%" OR '.$px.'.meta_keywords LIKE "%'.$this->db->escape(trim($keyword)).'%") ');
}
}
$lang_sql = $this->languages->get_query(array('object'=>'blog'));
$query = "SELECT COUNT(distinct b.id) as count
FROM __blog b
$lang_sql->join
WHERE 1
$post_id_filter
$visible_filter
$keyword_filter
$type_filter
";

if($this->db->query($query)) {
if ($count === true) {
return $this->db->result('count');
} else {
return false;
return $this->db->results();
}
}

/*Подсчитываем количество найденных записей*/
public function count_posts($filter = array()) {
return $this->get_posts($filter, true);
}

/*Добавляем запись*/
public function add_post($post) {
$post = (object)$post;
Expand Down
Loading

0 comments on commit 8c793ea

Please sign in to comment.