Skip to content

Commit

Permalink
Исправление некорректной работы постраничной навигации при &catId=this
Browse files Browse the repository at this point in the history
- fixed #144
  • Loading branch information
pafnuty committed May 26, 2019
1 parent 018a162 commit e12bcd0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 17 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.4
- Исправлена работа постраничной навигации при `catId=this` (#144)
- Исправлена логика отбора похожих новостей после релиза 5.1.2 (#155)

# 5.1.3
- Обновлен шаблонизатор Fenom до актуальной версии.

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.3-red.svg?style=flat-square "Version")
![version](https://img.shields.io/badge/version-5.1.4-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
2 changes: 1 addition & 1 deletion blockpro_install.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// Описание модуля, для установщика и админки.
'moduleDescr' => 'Модуль вывода новостей для DLE',
// Версия модуля, для установщика
'moduleVersion' => '5.1.3',
'moduleVersion' => '5.1.4',
// Дата выпуска модуля, для установщика
'moduleDate' => '17.05.2019',
// Версии DLE, поддержваемые модулем, для установщика
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.3';
$moduleVersion = '5.1.4';

$moderate = $_REQUEST['moderate'];
$moderate_checked = ($moderate) ? 'checked' : '';
Expand Down
39 changes: 25 additions & 14 deletions engine/modules/base/blockpro.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,23 +168,25 @@ classic: << Первая < 1 [2] 3 > Последняя >>
];
}

/**
* var array $bpConfig
*/
include ENGINE_DIR . '/data/blockpro.php';

// Объединяем массивы конфигов
/** @var array $bpConfig */
$cfg = array_merge($cfg, $bpConfig);

// Получаем id текущей категории при AJAX навигации
if ($isAjaxConfig && ($cfg['catId'] == 'this' || $cfg['notCatId'] == 'this')) {
/**
* @var string $thisUrl
* @see engine/ajax/blockpro.php
*/
if (substr($thisUrl, -1, 1) == '/') {
$thisUrl = substr($thisUrl, 0, -1);
}
$thisUrl = explode('/', $thisUrl);
$thisUrl = end($thisUrl);
if (trim($thisUrl) != '') {
$category_id = get_ID($cat_info, $thisUrl);
$arThisUrl = explode('/', $thisUrl);
$thisCatName = end($arThisUrl);
if (trim($thisCatName) != '') {
$category_id = get_ID($cat_info, $thisCatName);
}
}

Expand Down Expand Up @@ -259,6 +261,8 @@ classic: << Первая < 1 [2] 3 > Последняя >>
}

$cfg['cacheNameAddon'] = array_filter($cfg['cacheNameAddon']);
// Удаляем дублирующиеся значения кеша. Может возникать при AJAX вызове с &catId=this
$cfg['cacheNameAddon'] = array_unique($cfg['cacheNameAddon']);
$cfg['cacheNameAddon'] = implode('_', $cfg['cacheNameAddon']);

if ($cfg['cacheLive']) {
Expand All @@ -270,7 +274,7 @@ classic: << Первая < 1 [2] 3 > Последняя >>
// Проверим куку пользователя и наличие параметра skin в реквесте.
$currentSiteSkin = (isset($_COOKIE['dle_skin'])) ? trim(totranslit($_COOKIE['dle_skin'], false, false)) : ((isset($_REQUEST['skin'])) ? trim(totranslit($_REQUEST['skin'], false, false)) : $config['skin']);

// Если итоге пусто — назначим опять шаблон из конфига.
// Если итоге пусто — назначим опять шаблон из конфига.
if ($currentSiteSkin == '') {
$currentSiteSkin = $config['skin'];
}
Expand Down Expand Up @@ -539,13 +543,18 @@ classic: << Первая < 1 [2] 3 > Последняя >>
$base->cfg['catId'] = 'this';
}

// Эти переменные потребуются ниже, что бы корректно сформировать имя кеша, когда переданы
// &catId=this или notCatId=this
$isCatIdThis = false;
$isNotCatIdThis = false;

// Фильтрация КАТЕГОРИЙ по их ID
if ($base->cfg['catId'] == 'this' && $category_id) {
$base->cfg['catIdT'] = 'this';
$isCatIdThis = true;
$base->cfg['catId'] = ($base->cfg['subcats']) ? get_sub_cats($category_id) : ($base->cfg['thisCatOnly']) ? (int)$category_id : $category_id;
}
if ($base->cfg['notCatId'] == 'this' && $category_id) {
$base->cfg['notCatIdT'] = 'this';
$isNotCatIdThis = true;
$base->cfg['notCatId'] = ($base->cfg['notSubcats']) ? get_sub_cats($category_id) : ($base->cfg['thisCatOnly']) ? (int)$category_id : $category_id;
}
// Дублирование кода вызвано необходимостью сочетания параметра notCatId и catId
Expand Down Expand Up @@ -1047,11 +1056,11 @@ classic: << Первая < 1 [2] 3 > Последняя >>
$tplArr['totalCount'] = $totalCount;

// Меняем для кеша id категории на this если параметр catId или notCatId равен this
if ($base->cfg['catIdT'] == 'this') {
$base->cfg['catId'] = $base->cfg['catIdT'];
if ($isCatIdThis) {
$base->cfg['catId'] = 'this';
}
if ($base->cfg['notCatIdT'] == 'this') {
$base->cfg['notCatId'] = $base->cfg['notCatIdT'];
if ($isNotCatIdThis) {
$base->cfg['notCatId'] = 'this';
}

// Формируем имя кеш-файла с конфигом
Expand Down Expand Up @@ -1148,6 +1157,7 @@ classic: << Первая < 1 [2] 3 > Последняя >>

unset($stat);
}

// Создаём кеш, если требуется
if (!$base->cfg['nocache']) {
create_cache($base->cfg['cachePrefix'], $output, $cacheName, $cacheSuffix);
Expand All @@ -1160,6 +1170,7 @@ classic: << Первая < 1 [2] 3 > Последняя >>
/** @var $base */
if ($base->dle_config['files_allow']) {
if (strpos($output, '[attachment=') !== false) {
/** @var array $attachments */
$output = show_attach($output, $attachments);
}
} else {
Expand Down

0 comments on commit e12bcd0

Please sign in to comment.