From 0c86069956d323af701430e3b5c9fb1ad3d147df Mon Sep 17 00:00:00 2001 From: Phil Wareham Date: Fri, 21 Jul 2017 14:37:23 +0100 Subject: [PATCH] Add a message when no cached items exist --- etc_cache.php | 124 +++++++++++++++++++++++++++----------------------- manifest.json | 2 +- 2 files changed, 68 insertions(+), 58 deletions(-) diff --git a/etc_cache.php b/etc_cache.php index c9d14d0..88a8315 100644 --- a/etc_cache.php +++ b/etc_cache.php @@ -17,7 +17,7 @@ // 1 = Plugin help is in raw HTML. Not recommended. # $plugin['allow_html_help'] = 1; -$plugin['version'] = '0.2.6-beta2'; +$plugin['version'] = '0.2.6'; $plugin['author'] = 'Oleg Loukianov'; $plugin['author_uri'] = 'www.iut-fbleau.fr/projet/etc/'; $plugin['description'] = 'Events-driven cache'; @@ -56,10 +56,11 @@ $plugin['textpack'] = << Cache -etc_cache_heading => Cached items etc_cache_cached_at => Cached at etc_cache_filter => Filter +etc_cache_heading => Cached items +etc_cache_no_cached_items => No cached items recorded. +etc_cache_tab => Cache EOT; // End of textpack @@ -261,60 +262,69 @@ public function tab($event, $step) { echo n.tag_start('div', array( 'class' => 'txp-layout-1col', 'id' => $event.'_container', - )). - n.tag_start('div', array('class' => 'txp-listtables')). - n.tag_start('table', array('class' => 'txp-list--no-options')). - n.tag_start('thead'). - tr( - n.''.dLink('etc_cache', 'save', 'save', 'Delete').n.''. - n.'ID'. - n.''.gTxt('etc_cache_cached_at').''. - n.'URL'. - n.''.gTxt('reset').''. - n.''.gTxt('etc_cache_filter').''. - n.'Actions' - ). - n.tag_end('thead'). - n.tag_start('tbody'); - - foreach($rs as $row) { - extract($row); - $class = 'date'.($reset == '%' && $time < $prefs['lastmod'] ? ' warning' : ''); - $datetime = date_create($time); - $diff = $datetime->diff($now); - $days = $diff->format('%d'); - $diff = (!$days ? '' : "$days day".($days == 1 ? '' : 's'). ' ').$diff->format('%H:%I hours old'); - - echo n.'
'. - n.''. - n.''. - n.tag( - span(gTxt('delete'), array('class' => 'ui-icon ui-icon-close')), - 'button', - array( - 'name' => 'save', - 'value' => 'Delete', - 'class' => 'destroy', - 'type' => 'submit', - 'title' => gTxt('delete'), - 'aria-label' => gTxt('delete'), - ) - ).''. - n.''.doSpecial($id).''. - n.''.doSpecial($time).' ('.$diff.')'. - n.''.fInput('text', 'url', $url, '', '', '', INPUT_REGULAR).n.''. - n.''.fInput('text', 'reset', $reset, '', '', '', INPUT_REGULAR).n.''. - n.''.fInput('text', 'filter', $filter, '', '', '', INPUT_REGULAR).n.''. - n.''.fInput('submit', 'save', gTxt('update')).fInput('submit', 'save', gTxt('save')).n.''. - sInput('save'). - hInput('id', $id). - tInput(). - n.''.n.'
'; - } - - echo n.tag_end('tbody'). - n.tag_end('table'). - n.tag_end('div'); + )); + + if ($rs) { + echo n.tag_start('div', array('class' => 'txp-listtables')). + n.tag_start('table', array('class' => 'txp-list--no-options')). + n.tag_start('thead'). + tr( + n.''.dLink('etc_cache', 'save', 'save', 'Delete').n.''. + n.'ID'. + n.''.gTxt('etc_cache_cached_at').''. + n.'URL'. + n.''.gTxt('reset').''. + n.''.gTxt('etc_cache_filter').''. + n.'Actions' + ). + n.tag_end('thead'). + n.tag_start('tbody'); + + foreach($rs as $row) { + extract($row); + $class = 'date'.($reset == '%' && $time < $prefs['lastmod'] ? ' warning' : ''); + $datetime = date_create($time); + $diff = $datetime->diff($now); + $days = $diff->format('%d'); + $diff = (!$days ? '' : "$days day".($days == 1 ? '' : 's'). ' ').$diff->format('%H:%I hours old'); + + echo n.'
'. + n.''. + n.''. + n.tag( + span(gTxt('delete'), array('class' => 'ui-icon ui-icon-close')), + 'button', + array( + 'name' => 'save', + 'value' => 'Delete', + 'class' => 'destroy', + 'type' => 'submit', + 'title' => gTxt('delete'), + 'aria-label' => gTxt('delete'), + ) + ).''. + n.''.doSpecial($id).''. + n.''.doSpecial($time).' ('.$diff.')'. + n.''.fInput('text', 'url', $url, '', '', '', INPUT_MEDIUM).n.''. + n.''.fInput('text', 'reset', $reset, '', '', '', INPUT_MEDIUM).n.''. + n.''.fInput('text', 'filter', $filter, '', '', '', INPUT_MEDIUM).n.''. + n.''.fInput('submit', 'save', gTxt('update')).fInput('submit', 'save', gTxt('save')).n.''. + sInput('save'). + hInput('id', $id). + tInput(). + n.''.n.'
'; + } + + echo n.tag_end('tbody'). + n.tag_end('table'). + n.tag_end('div'); + } else { + echo graf( + span(null, array('class' => 'ui-icon ui-icon-info')).' '. + gTxt('etc_cache_no_cached_items'), + array('class' => 'alert-block information') + ); + } echo n.tag_end('div'). // End of .txp-layout-1col. n.''; // End of .txp-layout. diff --git a/manifest.json b/manifest.json index ec57e67..3ff9b07 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "etc_cache", "description": "Events-driven cache solution for Textpattern CMS.", - "version": "0.2.6-beta2", + "version": "0.2.6", "type": 5, "author": "Oleg Loukianov", "author_uri": "http://www.iut-fbleau.fr/projet/etc/",