Skip to content

Commit

Permalink
Merge pull request #162 from dle-modules/5.1.5
Browse files Browse the repository at this point in the history
5.1.5
  • Loading branch information
pafnuty authored Dec 1, 2019
2 parents 5fcb7d5 + 8a513a9 commit dad276a
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 5.1.5
- Исправлена ошибка `Error: Syntax error, unrecognized expression: Deprecated: Array and string offset access syntax with curly braces is deprecated` (#159)
- Добавлен модификатор jsonDecode для более удобного перобразования кода в JSON (Используйте его, если не работает json_decode)

# 5.1.4
- Исправлена работа постраничной навигации при `catId=this` (#144)
- Исправлена логика отбора похожих новостей после релиза 5.1.2 (#155)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# DLE-BlockPro — тот самый модуль для вывода новостей!
![version](https://img.shields.io/badge/version-5.1.4-red.svg?style=flat-square "Version")
![version](https://img.shields.io/badge/version-5.1.5-red.svg?style=flat-square "Version")
![DLE](https://img.shields.io/badge/DLE-10.x-green.svg?style=flat-square "DLE Version")
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/dle-modules/DLE-BlockPro/blob/master/LICENSE)

Expand Down
4 changes: 2 additions & 2 deletions blockpro_install.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
// Описание модуля, для установщика и админки.
'moduleDescr' => 'Модуль вывода новостей для DLE',
// Версия модуля, для установщика
'moduleVersion' => '5.1.4',
'moduleVersion' => '5.1.5',
// Дата выпуска модуля, для установщика
'moduleDate' => '17.05.2019',
'moduleDate' => '01.12.2019',
// Версии DLE, поддержваемые модулем, для установщика
'dleVersion' => '10.x',
// ID групп, для которых доступно управление модулем в админке.
Expand Down
2 changes: 1 addition & 1 deletion engine/inc/blockpro.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
define('MODULE_DIR', ENGINE_DIR . '/modules/base/admin/blockpro/');

$moduleName = 'blockpro';
$moduleVersion = '5.1.4';
$moduleVersion = '5.1.5';

$moderate = $_REQUEST['moderate'];
$moderate_checked = ($moderate) ? 'checked' : '';
Expand Down
20 changes: 18 additions & 2 deletions engine/modules/base/blockpro.php
Original file line number Diff line number Diff line change
Expand Up @@ -551,11 +551,27 @@ classic: << Первая < 1 [2] 3 > Последняя >>
// Фильтрация КАТЕГОРИЙ по их ID
if ($base->cfg['catId'] == 'this' && $category_id) {
$isCatIdThis = true;
$base->cfg['catId'] = ($base->cfg['subcats']) ? get_sub_cats($category_id) : ($base->cfg['thisCatOnly']) ? (int)$category_id : $category_id;
/**
* @see https://github.com/dle-modules/DLE-BlockPro/issues/159
*/
$base->cfg['catId'] = $category_id;
if($base->cfg['subcats']) {
$base->cfg['catId'] = get_sub_cats($category_id);
} elseif ($base->cfg['thisCatOnly']) {
$base->cfg['catId'] = (int)$category_id;
}
}
if ($base->cfg['notCatId'] == 'this' && $category_id) {
$isNotCatIdThis = true;
$base->cfg['notCatId'] = ($base->cfg['notSubcats']) ? get_sub_cats($category_id) : ($base->cfg['thisCatOnly']) ? (int)$category_id : $category_id;
/**
* @see https://github.com/dle-modules/DLE-BlockPro/issues/159
*/
$base->cfg['notCatId'] = $category_id;
if ($base->cfg['notSubcats']) {
$base->cfg['notCatId'] = get_sub_cats($category_id);
} elseif($base->cfg['thisCatOnly']) {
$base->cfg['notCatId'] = (int)$category_id;
}
}
// Дублирование кода вызвано необходимостью сочетания параметра notCatId и catId
// Например: catId=this&notCatId=3
Expand Down
6 changes: 6 additions & 0 deletions engine/modules/base/core/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@ public function addModifiers() {
return bpModifiers::timeAgo($data, $precision);
}
);

// Добавляем свой модификатор в шаблонизатор для конвертации текста в json.
$this->tpl->addModifier(
'jsonDecode', function ($data) {
return bpModifiers::jsonDecode($data);
});
}

/**
Expand Down
11 changes: 11 additions & 0 deletions engine/modules/base/core/bpModifiers.php
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,17 @@ public static function timeAgo($date, $precision = 2) {
return $output . ' назад';
}

/**
* Функция для конфертации строки в json на случай, если не работает модификатор json_decode
* @param string $var "{"one":"val"}"
*
* @return array json-массив
*/
public static function jsonDecode($var) {
$decoded = html_entity_decode($var, ENT_COMPAT);
return json_decode($decoded, true);
}


} // bpModifiers

0 comments on commit dad276a

Please sign in to comment.