From 65db1c53dd7eb370cbbb3cc1407e06a5e3bfe411 Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Wed, 7 Dec 2022 21:19:33 +0100 Subject: [PATCH] use common pager settings for availabled and used templates --- _prepend.php | 2 +- inc/class.templator.pager.php | 2 +- index.php | 23 ++++++++++------------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/_prepend.php b/_prepend.php index e80a1a6..28b3ec7 100644 --- a/_prepend.php +++ b/_prepend.php @@ -6,7 +6,7 @@ if (!defined('DC_RC_PATH')) { Clearbricks::lib()->autoload([ 'dcTemplator' => __DIR__ . '/inc/class.templator.php', 'templatorMedia' => __DIR__ . '/inc/class.templator.media.php', - 'pagerTemplator' => __DIR__ . '/inc/admin.pager.templator.php', + 'templatorPager' => __DIR__ . '/inc/class.templator.pager.php', ]); dcCore::app()->templator = new dcTemplator(); diff --git a/inc/class.templator.pager.php b/inc/class.templator.pager.php index 8441c15..315a964 100644 --- a/inc/class.templator.pager.php +++ b/inc/class.templator.pager.php @@ -14,7 +14,7 @@ if (!defined('DC_RC_PATH')) { return; } -class pagerTemplator +class templatorPager { public static function templatorItemLine($f, $i) { diff --git a/index.php b/index.php index c3fc431..1d162f8 100644 --- a/index.php +++ b/index.php @@ -13,15 +13,12 @@ $part = $_REQUEST['part'] ?? ''; ### grab info ### if (in_array($part, ['files', 'delete'])) { - $page = !empty($_GET['page']) ? $_GET['page'] : 1; - $nb_per_page = 20; - + //Extend dcMedia to change settings to allow .html vs media_exclusion $media = new templatorMedia(); $media->chdir(dcCore::app()->templator->template_dir_name); // For users with only templator permission, we use sudo. dcCore::app()->auth->sudo([$media,'getDir']); $dir = $media->dir; - //if files did not appear in this list, check blog->settings->media_exclusion $items = array_values($dir['files']); } @@ -308,23 +305,24 @@ if (!dcCore::app()->templator->canUseRessources(true)) { if (count($items) == 0) { echo '

' . __('No template.') . '

'; } else { - $pager = new pager($page, count($items), $nb_per_page, 10); + // reuse "used templatro template" filter settings + $filter = new adminGenericFilterV2('templator'); + $filter->add(dcAdminFilters::getPageFilter()); + + $pager = new dcPager($filter->page, count($items), $filter->nb, 10); $pager->html_prev = __('«prev.'); $pager->html_next = __('next»'); echo - '
' . - '
' . - '
' . - '

' . __('Page(s)') . ' : ' . $pager->getLinks() . '

'; + $pager->getLinks(); for ($i = $pager->index_start, $j = 0; $i <= $pager->index_end; $i++, $j++) { - echo pagerTemplator::templatorItemLine($items[$i], $j); + echo templatorPager::templatorItemLine($items[$i], $j); } echo - '

' . __('Page(s)') . ' : ' . $pager->getLinks() . '

' . + $pager->getLinks() . '
'; } @@ -413,11 +411,10 @@ if (!dcCore::app()->templator->canUseRessources(true)) { while ($cat_parents->fetch()) { $full_name = $cat_parents->cat_title . ' › '; }; - $full_name = $full_name . dcCore::app()->blog->getCategory($cat_id)->cat_title; $name .= ' (' . $full_name . $category->cat_title . ')'; } } catch (Exception $e) { - $file = $file_default; + $file = ''; throw $e; }