From 50f881d512fb25af2b0a805db35c200a74b3648f Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Thu, 26 Aug 2021 00:51:55 +0200 Subject: [PATCH] cleanup (license, help, dc2.19, PSR2, short array, php7.3+, php8.0.x) --- CHANGELOG => CHANGELOG.md | 18 +- README.md | 6 + _admin.php | 8 +- _define.php | 33 +- _public.php | 8 +- _widgets.php | 909 +++++++++++++++++++------------------- locales/fr/main.lang.php | 41 +- locales/fr/main.po | 41 +- repository.xml | 13 + 9 files changed, 531 insertions(+), 546 deletions(-) rename CHANGELOG => CHANGELOG.md (60%) create mode 100644 repository.xml diff --git a/CHANGELOG b/CHANGELOG.md similarity index 60% rename from CHANGELOG rename to CHANGELOG.md index 53241ac..b66e13e 100644 --- a/CHANGELOG +++ b/CHANGELOG.md @@ -1,71 +1,59 @@ +lastpostsExtend 2021.08.25 + * cleanup (license, help, dc2.19, PSR2, short array, php7.3+, php8.0.x) + lastpostsExtend 2016.10.24 -=========================================================== * oops missed 2015 update lastpostsExtend 2016.10.23 -=========================================================== * Used new widget rendering method * Updated year lastpostsExtend 2015.01.13 Pierre Van Glabeke -=========================================================== * Compatibilité dotclear 2.7 * Ajout options widget et compatibilité currywurst * Modifications locales lastpostsExtend 2013.12.01 -=========================================================== * Fix XHTML validation on widget * Fix category id from wrong table. thx BG lastpostsExtend 2013.11.12 -=========================================================== * Switch to Dotclear 2.6 * Add widget options lastpostsExtend 2013.06.30 -=========================================================== * Used new 'homeonly' style for widgets lastpostsExtend 2011.08.01 -=========================================================== * Added support of plugin muppet (post types) * Try to fix date compare on sql request lastpostsExtend 0.10 - 2010-08-19 -=========================================================== * Sort by comments (annso) lastpostsExtend 0.9 - 2010-06-09 -=========================================================== * Writed now for DC 2.2 or higher lastpostsExtend 0.8.2 - 2010-03-29 -=========================================================== * Fixed getPosts by using sudo * Fixed entryFirstImage on non-pushided post lastpostsExtend 0.8.1 - 2009-12-31 -=========================================================== * Happy new year! * Fixed multiple bugs and crashes lastpostsExtend 0.8 - 2009-12-30 -=========================================================== * Added post words limit * Added post status limit * Added post password limit (closes #385) * Changed blog->getPosts to internal getPosts lastpostsExtend 0.7 2009-12-10 -=========================================================== * Added entryFirstimage * Fixed typo lastpostsExtend 0.6 - 2009-08-23 -=========================================================== * Added ''pluginsPage'' support lastpostsExtend 0.5 - 2009-08-16 -=========================================================== * Fixed php 5.3 compatibility diff --git a/README.md b/README.md index 695d61f..7d0312d 100644 --- a/README.md +++ b/README.md @@ -20,3 +20,9 @@ First install lastpostsExtend, manualy from a zip package or from Dotaddict repository. (See Dotclear's documentation to know how do this) Add and configure "Last entries (Extended)" from widgets manager. + +## MORE + + * License : GNU GPL v2 + * Source & contribution : [GitHub Page](https://github.com/JcDenis/lastpostsExtend) + * Packages & details: [Dotaddict Page](https://plugins.dotaddict.org/dc2/details/lastpostsExtend) \ No newline at end of file diff --git a/_admin.php b/_admin.php index 77cd391..a56563d 100644 --- a/_admin.php +++ b/_admin.php @@ -3,8 +3,7 @@ # # This file is part of lastpostsExtend, a plugin for Dotclear 2. # -# Copyright (c) 2009-2016 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcdenis.net +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -13,8 +12,7 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_CONTEXT_ADMIN')) { - - return null; + return null; } -require dirname(__FILE__).'/_widgets.php'; +require dirname(__FILE__) . '/_widgets.php'; \ No newline at end of file diff --git a/_define.php b/_define.php index 6d78a17..aaea4de 100644 --- a/_define.php +++ b/_define.php @@ -3,8 +3,7 @@ # # This file is part of lastpostsExtend, a plugin for Dotclear 2. # -# Copyright (c) 2009-2016 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcdenis.net +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -13,24 +12,20 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_RC_PATH')) { - - return null; + return null; } $this->registerModule( - /* Name */ - "Last entries (Extended)", - /* Description*/ - "Extended list of entries", - /* Author */ - "Jean-Christian Denis", - /* Version */ - '2016.10.24', - array( - 'permissions' => 'admin', - 'type' => 'plugin', - 'dc_min' => '2.10', - 'support' => 'http://lab.dotclear.org/wiki/plugin/lastpostsExtend', - 'details' => 'http://plugins.dotaddict.org/dc2/details/lastpostsExtend' - ) + 'Last entries (Extended)', + 'Extended list of entries', + 'Jean-Christian Denis and contributors', + '2021.08.25', + [ + 'permissions' => 'admin', + 'type' => 'plugin', + 'dc_min' => '2.19', + 'support' => 'https://github.com/JcDenis/lastpostsExtend', + 'details' => 'http://plugins.dotaddict.org/dc2/details/lastpostsExtend', + 'repository' => 'https://raw.githubusercontent.com/JcDenis/lastpostsExtend/master/repository.xml' + ] ); \ No newline at end of file diff --git a/_public.php b/_public.php index 0070b56..594eb81 100644 --- a/_public.php +++ b/_public.php @@ -3,8 +3,7 @@ # # This file is part of lastpostsExtend, a plugin for Dotclear 2. # -# Copyright (c) 2009-2016 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcdenis.net +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -13,8 +12,7 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_RC_PATH')) { - - return null; + return null; } -require dirname(__FILE__).'/_widgets.php'; +require dirname(__FILE__) . '/_widgets.php'; \ No newline at end of file diff --git a/_widgets.php b/_widgets.php index 167250c..09f8299 100644 --- a/_widgets.php +++ b/_widgets.php @@ -3,8 +3,7 @@ # # This file is part of lastpostsExtend, a plugin for Dotclear 2. # -# Copyright (c) 2009-2016 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcdenis.net +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -13,507 +12,495 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_RC_PATH')) { - - return null; + return null; } $core->addBehavior( - 'initWidgets', - array('lastpostsextendWidget', 'initWidget') + 'initWidgets', + ['lastpostsextendWidget', 'initWidget'] ); class lastpostsextendWidget { - public static function initWidget($w) - { - global $core; + public static function initWidget($w) + { + global $core; - # Create widget - $w->create( - 'lastpostsextend', - __('Last entries (Extended)'), - array('lastpostsextendWidget', 'parseWidget'), - null, - __('Extended list of entries') - ); - # Title - $w->lastpostsextend->setting( - 'title', - __('Title:'), - __('Last entries'), - 'text' - ); - # type - $posttypes = array( - __('Post') => 'post', - __('Page') => 'page', - __('Gallery') => 'galitem' - ); - # plugin muppet types - if ($core->plugins->moduleExists('muppet')) { - $muppet_types = muppet::getPostTypes(); - if(is_array($muppet_types) && !empty($muppet_types)) { - - foreach($muppet_types as $k => $v) { - $posttypes[$v['name']] = $k; - } - } - } - $w->lastpostsextend->setting( - 'posttype', - __('Type:'), - 'post', - 'combo', - $posttypes - ); - # Category (post and page have same category) - $rs = $core->blog->getCategories(array( - 'post_type' => 'post' - )); - $categories = array( - '' => '', - __('Uncategorized') => 'null' - ); - while ($rs->fetch()) { - $categories[str_repeat( - '  ', - $rs->level-1 - ).'• '.html::escapeHTML($rs->cat_title)] = - $rs->cat_id; - } - $w->lastpostsextend->setting( - 'category', - __('Category:'), - '', - 'combo', - $categories - ); - unset($rs,$categories); - # Pasworded - $w->lastpostsextend->setting( - 'passworded', - __('Protection:'), - 'no', - 'combo', - array( - __('all') => 'all', - __('only without password') => 'no', - __('only with password') => 'yes' - ) - ); - # Status - $w->lastpostsextend->setting( - 'status', - __('Status:'), - '1', - 'combo', - array( - __('all') => 'all', - __('pending') => '-2', - __('scheduled') => '-1', - __('unpublished') => '0', - __('published') => '1' - ) - ); - # Selected entries only - $w->lastpostsextend->setting( - 'selectedonly', - __('Selected entries only'), - 0, - 'check' - ); - # Updated entries only - $w->lastpostsextend->setting( - 'updatedonly', - __('Updated entries only'), - 0, - 'check' - ); - # Tag - if ($core->plugins->moduleExists('tags')) - { - $w->lastpostsextend->setting( - 'tag', - __('Limit to tags:'), - '', - 'text' - ); - } - # Search - $w->lastpostsextend->setting( - 'search', - __('Limit to words:'), - '', - 'text' - ); - # Entries limit - $w->lastpostsextend->setting( - 'limit', - __('Entries limit:'), - 10, - 'text' - ); - # Sort type - $w->lastpostsextend->setting( - 'sortby', - __('Order by:'), - 'date', - 'combo', - array( - __('Date') => 'date', - __('Title') => 'post_title', - __('Comments') => 'nb_comment' - ) - ); - # Sort order - $w->lastpostsextend->setting( - 'sort', - __('Sort:'), - 'desc', - 'combo', - array( - __('Ascending') => 'asc', - __('Descending') => 'desc' - ) - ); - # First image - $w->lastpostsextend->setting( - 'firstimage', - __('Show entries first image:'), - '', - 'combo', - array( - __('no') => '', - __('square') => 'sq', - __('thumbnail') => 't', - __('small') => 's', - __('medium') => 'm', - __('original') => 'o' - ) - ); - # With excerpt - $w->lastpostsextend->setting( - 'excerpt', - __('Show entries excerpt'), - 0, - 'check' - ); - # Excerpt length - $w->lastpostsextend->setting( - 'excerptlen', - __('Excerpt length:'), - 100, - 'text' - ); - # Comment count - $w->lastpostsextend->setting( - 'commentscount', - __('Show comments count'), - 0, - 'check' - ); - # Home only - $w->lastpostsextend->setting( - 'homeonly', - __('Display on:'), - 0, - 'combo', - array( - __('All pages') => 0, - __('Home page only') => 1, - __('Except on home page') => 2 - ) - ); - # widget option - content only - $w->lastpostsextend->setting( - 'content_only', - __('Content only'), - 0, - 'check' - ); - # widget option - additionnal CSS - $w->lastpostsextend->setting( - 'class', - __('CSS class:'), - '' - ); - # widget option - put offline - $w->lastpostsextend->setting( - 'offline', - __('Offline'), - 0, - 'check' - ); - } - - public static function parseWidget($w) - { - global $core; - - $params = array( - 'sql' => '', - 'columns' => array(), - 'from' => '' - ); + # Create widget + $w->create( + 'lastpostsextend', + __('Last entries (Extended)'), + ['lastpostsextendWidget', 'parseWidget'], + null, + __('Extended list of entries') + ); + # Title + $w->lastpostsextend->setting( + 'title', + __('Title:'), + __('Last entries'), + 'text' + ); + # type + $posttypes = [ + __('Post') => 'post', + __('Page') => 'page', + __('Gallery') => 'galitem' + ]; + # plugin muppet types + if ($core->plugins->moduleExists('muppet')) { + $muppet_types = muppet::getPostTypes(); + if(is_array($muppet_types) && !empty($muppet_types)) { - # Widget is offline - if ($w->offline) - return; + foreach($muppet_types as $k => $v) { + $posttypes[$v['name']] = $k; + } + } + } + $w->lastpostsextend->setting( + 'posttype', + __('Type:'), + 'post', + 'combo', + $posttypes + ); + # Category (post and page have same category) + $rs = $core->blog->getCategories([ + 'post_type' => 'post' + ]); + $categories = [ + '' => '', + __('Uncategorized') => 'null' + ]; + while ($rs->fetch()) { + $categories[str_repeat( + '  ', + $rs->level-1 + ) . '• ' . html::escapeHTML($rs->cat_title)] = + $rs->cat_id; + } + $w->lastpostsextend->setting( + 'category', + __('Category:'), + '', + 'combo', + $categories + ); + unset($rs, $categories); + # Pasworded + $w->lastpostsextend->setting( + 'passworded', + __('Protection:'), + 'no', + 'combo', + [ + __('all') => 'all', + __('only without password') => 'no', + __('only with password') => 'yes' + ] + ); + # Status + $w->lastpostsextend->setting( + 'status', + __('Status:'), + '1', + 'combo', + [ + __('all') => 'all', + __('pending') => '-2', + __('scheduled') => '-1', + __('unpublished') => '0', + __('published') => '1' + ] + ); + # Selected entries only + $w->lastpostsextend->setting( + 'selectedonly', + __('Selected entries only'), + 0, + 'check' + ); + # Updated entries only + $w->lastpostsextend->setting( + 'updatedonly', + __('Updated entries only'), + 0, + 'check' + ); + # Tag + if ($core->plugins->moduleExists('tags')) { + $w->lastpostsextend->setting( + 'tag', + __('Limit to tags:'), + '', + 'text' + ); + } + # Search + $w->lastpostsextend->setting( + 'search', + __('Limit to words:'), + '', + 'text' + ); + # Entries limit + $w->lastpostsextend->setting( + 'limit', + __('Entries limit:'), + 10, + 'text' + ); + # Sort type + $w->lastpostsextend->setting( + 'sortby', + __('Order by:'), + 'date', + 'combo', + [ + __('Date') => 'date', + __('Title') => 'post_title', + __('Comments') => 'nb_comment' + ] + ); + # Sort order + $w->lastpostsextend->setting( + 'sort', + __('Sort:'), + 'desc', + 'combo', + [ + __('Ascending') => 'asc', + __('Descending') => 'desc' + ] + ); + # First image + $w->lastpostsextend->setting( + 'firstimage', + __('Show entries first image:'), + '', + 'combo', + [ + __('no') => '', + __('square') => 'sq', + __('thumbnail') => 't', + __('small') => 's', + __('medium') => 'm', + __('original') => 'o' + ] + ); + # With excerpt + $w->lastpostsextend->setting( + 'excerpt', + __('Show entries excerpt'), + 0, + 'check' + ); + # Excerpt length + $w->lastpostsextend->setting( + 'excerptlen', + __('Excerpt length:'), + 100, + 'text' + ); + # Comment count + $w->lastpostsextend->setting( + 'commentscount', + __('Show comments count'), + 0, + 'check' + ); + # Home only + $w->lastpostsextend->setting( + 'homeonly', + __('Display on:'), + 0, + 'combo', + [ + __('All pages') => 0, + __('Home page only') => 1, + __('Except on home page') => 2 + ] + ); + # widget option - content only + $w->lastpostsextend->setting( + 'content_only', + __('Content only'), + 0, + 'check' + ); + # widget option - additionnal CSS + $w->lastpostsextend->setting( + 'class', + __('CSS class:'), + '' + ); + # widget option - put offline + $w->lastpostsextend->setting( + 'offline', + __('Offline'), + 0, + 'check' + ); + } + + public static function parseWidget($w) + { + global $core; + + $params = [ + 'sql' => '', + 'columns' => [], + 'from' => '' + ]; - # Home page only - if ($w->homeonly == 1 && $core->url->type != 'default' - || $w->homeonly == 2 && $core->url->type == 'default' - ) { - return null; - } + # Widget is offline + if ($w->offline) { + return; + } - # Need posts excerpt - if ($w->excerpt) { - $params['columns'][] = 'post_excerpt'; - } + # Home page only + if ($w->homeonly == 1 && $core->url->type != 'default' + || $w->homeonly == 2 && $core->url->type == 'default') { + return null; + } - # Passworded - if ($w->passworded == 'yes') { - $params['sql'] .= 'AND post_password IS NOT NULL '; - } - elseif ($w->passworded == 'no') { - $params['sql'] .= 'AND post_password IS NULL '; - } + # Need posts excerpt + if ($w->excerpt) { + $params['columns'][] = 'post_excerpt'; + } - # Status - if ($w->status != 'all') { - $params['post_status'] = $w->status; - } + # Passworded + if ($w->passworded == 'yes') { + $params['sql'] .= 'AND post_password IS NOT NULL '; + } + elseif ($w->passworded == 'no') { + $params['sql'] .= 'AND post_password IS NULL '; + } - # Search words - if ('' != $w->search) { - $params['search'] = $w->search; - } + # Status + if ($w->status != 'all') { + $params['post_status'] = $w->status; + } - # Updated posts only - if ($w->updatedonly) { - $params['sql'] .= - "AND post_creadt < post_upddt ". - "AND post_dt < post_upddt "; + # Search words + if ('' != $w->search) { + $params['search'] = $w->search; + } + + # Updated posts only + if ($w->updatedonly) { + $params['sql'] .= + "AND post_creadt < post_upddt " . + "AND post_dt < post_upddt "; /* - $params['sql'] .= - "AND TIMESTAMP(post_creadt ,'DD-MM-YYYY HH24:MI:SS') < TIMESTAMP(post_upddt ,'DD-MM-YYYY HH24:MI:SS') ". - "AND TIMESTAMP(post_dt ,'DD-MM-YYYY HH24:MI:SS') < TIMESTAMP(post_upddt ,'DD-MM-YYYY HH24:MI:SS') "; + $params['sql'] .= + "AND TIMESTAMP(post_creadt ,'DD-MM-YYYY HH24:MI:SS') < TIMESTAMP(post_upddt ,'DD-MM-YYYY HH24:MI:SS') ". + "AND TIMESTAMP(post_dt ,'DD-MM-YYYY HH24:MI:SS') < TIMESTAMP(post_upddt ,'DD-MM-YYYY HH24:MI:SS') "; //*/ - $params['order'] = $w->sortby == 'date' ? - 'post_upddt ' : $w->sortby.' '; - } - else { - $params['order'] = $w->sortby == 'date' ? - 'post_dt ' : $w->sortby.' '; - } - $params['order'] .= $w->sort == 'asc' ? 'asc' : 'desc'; - $params['limit'] = abs((integer) $w->limit); - $params['no_content'] = true; + $params['order'] = $w->sortby == 'date' ? + 'post_upddt ' : $w->sortby . ' '; + } + else { + $params['order'] = $w->sortby == 'date' ? + 'post_dt ' : $w->sortby . ' '; + } + $params['order'] .= $w->sort == 'asc' ? 'asc' : 'desc'; + $params['limit'] = abs((integer) $w->limit); + $params['no_content'] = true; - # Selected posts only - if ($w->selectedonly) { - $params['post_selected'] = 1; - } + # Selected posts only + if ($w->selectedonly) { + $params['post_selected'] = 1; + } - # Type - $params['post_type'] = $w->posttype; + # Type + $params['post_type'] = $w->posttype; - # Category - if ($w->category) { - if ($w->category == 'null') { - $params['sql'] .= ' AND P.cat_id IS NULL '; - } - elseif (is_numeric($w->category)) { - $params['cat_id'] = (integer) $w->category; - } - else { - $params['cat_url'] = $w->category; - } - } + # Category + if ($w->category) { + if ($w->category == 'null') { + $params['sql'] .= ' AND P.cat_id IS NULL '; + } elseif (is_numeric($w->category)) { + $params['cat_id'] = (integer) $w->category; + } else { + $params['cat_url'] = $w->category; + } + } - # Tags - if ($core->plugins->moduleExists('tags') && $w->tag) { - $tags = explode(',', $w->tag); - foreach($tags as $i => $tag) { - $tags[$i] = trim($tag); - } - $params['from'] .= ', '.$core->prefix.'meta META '; - $params['sql'] .= 'AND META.post_id = P.post_id '; - $params['sql'] .= "AND META.meta_id ".$core->con->in($tags)." "; - $params['sql'] .= "AND META.meta_type = 'tag' "; - } + # Tags + if ($core->plugins->moduleExists('tags') && $w->tag) { + $tags = explode(',', $w->tag); + foreach($tags as $i => $tag) { + $tags[$i] = trim($tag); + } + $params['from'] .= ', ' . $core->prefix . 'meta META '; + $params['sql'] .= 'AND META.post_id = P.post_id '; + $params['sql'] .= "AND META.meta_id " . $core->con->in($tags) . " "; + $params['sql'] .= "AND META.meta_type = 'tag' "; + } - $rs = $core->auth->sudo( - array($core->blog, 'getPosts'), - $params, - false - ); + $rs = $core->auth->sudo( + [$core->blog, 'getPosts'], + $params, + false + ); - # No result - if ($rs->isEmpty()) { + # No result + if ($rs->isEmpty()) { + return null; + } - return null; - } + # Return + $res = $w->title ? $w->renderTitle(html::escapeHTML($w->title)) : ''; - # Return - $res = $w->title ? $w->renderTitle(html::escapeHTML($w->title)) : ''; + while ($rs->fetch()) { + $res .= '
  • ' . + '<' . ($rs->post_status == 1 ? 'a href="' . $rs->getURL() . '"' : 'span') . + ' title="' . + dt::dt2str( + $core->blog->settings->system->date_format, + $rs->post_upddt + ) . ', ' . + dt::dt2str( + $core->blog->settings->system->time_format, + $rs->post_upddt + ) . '">' . + html::escapeHTML($rs->post_title) . + 'post_status == 1 ? 'a' : 'span') . '>'; - while ($rs->fetch()) { - $res .= '
  • '. - '<'.($rs->post_status == 1 ? 'a href="'.$rs->getURL().'"' : 'span'). - ' title="'. - dt::dt2str( - $core->blog->settings->system->date_format, - $rs->post_upddt - ).', '. - dt::dt2str( - $core->blog->settings->system->time_format, - $rs->post_upddt - ).'">'. - html::escapeHTML($rs->post_title). - 'post_status == 1 ? 'a' : 'span').'>'; + # Nb comments + if ($w->commentscount && $rs->post_status == 1) { + $res .= ' (' . $rs->nb_comment . ')'; + } - # Nb comments - if ($w->commentscount && $rs->post_status == 1) { - $res .= ' ('.$rs->nb_comment.')'; - } + # First image + if ($w->firstimage != '') { + $res .= self::entryFirstImage( + $core, + $rs->post_type, + $rs->post_id, + $w->firstimage + ); + } - # First image - if ($w->firstimage != '') { - $res .= self::entryFirstImage( - $core, - $rs->post_type, - $rs->post_id, - $w->firstimage - ); - } + # Excerpt + if ($w->excerpt) { + $excerpt = $rs->post_excerpt; + if ($rs->post_format == 'wiki') { + $core->initWikiComment(); + $excerpt = $core->wikiTransform($excerpt); + $excerpt = $core->HTMLfilter($excerpt); + } + if (strlen($excerpt) > 0) { + $cut = text::cutString( + $excerpt, + abs((integer) $w->excerptlen) + ); + $res .= ' : ' . $cut . (strlen($cut) < strlen($excerpt) ? '...' : ''); - # Excerpt - if ($w->excerpt) { - $excerpt = $rs->post_excerpt; - if ($rs->post_format == 'wiki') { - $core->initWikiComment(); - $excerpt = $core->wikiTransform($excerpt); - $excerpt = $core->HTMLfilter($excerpt); - } - if (strlen($excerpt) > 0) { - $cut = text::cutString( - $excerpt, - abs((integer) $w->excerptlen) - ); - $res .= ' : '.$cut.(strlen($cut) < strlen($excerpt) ? - '...' : ''); + unset($cut); + } + } + $res .= '
  • '; + } - unset($cut); - } - } - $res .= ''; - } + return $w->renderDiv( + $w->content_only, + 'lastpostsextend ' . $w->class, + '', + '' + ); + } + + private static function entryFirstImage($core, $type, $id, $size = 's') + { + if (!in_array($type, ['post', 'page', 'galitem'])) { - return $w->renderDiv( - $w->content_only, - 'lastpostsextend '.$w->class, - '', - '' - ); - } - - private static function entryFirstImage($core, $type, $id, $size='s') - { - if (!in_array($type, array('post', 'page', 'galitem'))) { + return ''; + } - return ''; - } + $rs = $core->auth->sudo( + [$core->blog, 'getPosts'], + ['post_id' => $id, 'post_type' => $type], + false + ); - $rs = $core->auth->sudo( - array($core->blog, 'getPosts'), - array('post_id' => $id, 'post_type' => $type), - false - ); + if ($rs->isEmpty()) { + return ''; + } - if ($rs->isEmpty()) { + if (!preg_match('/^sq|t|s|m|o$/', $size)) { + $size = 's'; + } - return ''; - } + $p_url = $core->blog->settings->system->public_url; + $p_site = preg_replace( + '#^(.+?//.+?)/(.*)$#', + '$1', + $core->blog->url + ); + $p_root = $core->blog->public_path; - if (!preg_match('/^sq|t|s|m|o$/',$size)) { - $size = 's'; - } + $pattern = '(?:' . preg_quote($p_site, '/') . ')?' . preg_quote($p_url, '/'); + $pattern = sprintf('/]+/msu', $pattern); - $p_url = $core->blog->settings->system->public_url; - $p_site = preg_replace( - '#^(.+?//.+?)/(.*)$#', - '$1', - $core->blog->url - ); - $p_root = $core->blog->public_path; + $src = ''; + $alt = ''; - $pattern = '(?:'.preg_quote($p_site, '/').')?'.preg_quote($p_url, '/'); - $pattern = sprintf('/]+/msu', $pattern); + $subject = $rs->post_excerpt_xhtml . $rs->post_content_xhtml . $rs->cat_desc; + if (preg_match_all($pattern, $subject, $m) > 0) { - $src = ''; - $alt = ''; + foreach ($m[1] as $i => $img) { + if (($src = self::ContentFirstImageLookup($p_root, $img, $size)) !== false) { - $subject = $rs->post_excerpt_xhtml.$rs->post_content_xhtml.$rs->cat_desc; - if (preg_match_all($pattern, $subject, $m) > 0) { + $src = $p_url . (dirname($img) != '/' ? dirname($img) : '') . '/' . $src; + if (preg_match('/alt="([^"]+)"/', $m[0][$i], $malt)) { + $alt = $malt[1]; + } + break; + } + } + } - foreach ($m[1] as $i => $img) { - if (($src = self::ContentFirstImageLookup($p_root, $img, $size)) !== false) { + if (!$src) { + return ''; + } - $src = $p_url.(dirname($img) != '/' ? dirname($img) : '').'/'.$src; - if (preg_match('/alt="([^"]+)"/', $m[0][$i], $malt)) { - $alt = $malt[1]; - } - break; - } - } - } + return + '
    ' . + '' . + "
    \n"; + } - if (!$src) { + private static function ContentFirstImageLookup($root, $img, $size) + { + # Get base name and extension + $info = path::info($img); + $base = $info['base']; + + if (preg_match('/^\.(.+)_(sq|t|s|m)$/', $base, $m)) { + $base = $m[1]; + } + + $res = false; + if ($size != 'o' && file_exists($root . '/' . $info['dirname'] . '/.' . $base . '_' . $size . '.jpg')) { + $res = '.' . $base . '_' . $size . '.jpg'; + } else { + $f = $root . '/' . $info['dirname'] . '/' . $base; + if (file_exists($f . '.' . $info['extension'])) { + $res = $base . '.' . $info['extension']; + } elseif (file_exists($f . '.jpg')) { + $res = $base . '.jpg'; + } elseif (file_exists($f . '.png')) { + $res = $base . '.png'; + } elseif (file_exists($f . '.gif')) { + $res = $base . '.gif'; + } + } - return ''; - } - - return - '
    '. - ''. - "
    \n"; - } - - private static function ContentFirstImageLookup($root,$img,$size) - { - # Get base name and extension - $info = path::info($img); - $base = $info['base']; - - if (preg_match('/^\.(.+)_(sq|t|s|m)$/',$base,$m)) { - $base = $m[1]; - } - - $res = false; - if ($size != 'o' && file_exists($root.'/'.$info['dirname'].'/.'.$base.'_'.$size.'.jpg')) { - $res = '.'.$base.'_'.$size.'.jpg'; - } - else { - $f = $root.'/'.$info['dirname'].'/'.$base; - if (file_exists($f.'.'.$info['extension'])) { - $res = $base.'.'.$info['extension']; - } - elseif (file_exists($f.'.jpg')) { - $res = $base.'.jpg'; - } - elseif (file_exists($f.'.png')) { - $res = $base.'.png'; - } - elseif (file_exists($f.'.gif')) { - $res = $base.'.gif'; - } - } - - return $res ? $res : false; - } + return $res ? $res : false; + } } \ No newline at end of file diff --git a/locales/fr/main.lang.php b/locales/fr/main.lang.php index a4c571d..d72f3db 100644 --- a/locales/fr/main.lang.php +++ b/locales/fr/main.lang.php @@ -1,52 +1,51 @@ \ No newline at end of file diff --git a/locales/fr/main.po b/locales/fr/main.po index b1d3f75..fc60aa1 100644 --- a/locales/fr/main.po +++ b/locales/fr/main.po @@ -1,76 +1,77 @@ # Language: Français -# Module: lastpostsExtend - 2013.11.12 -# Date: 2013-11-13 07:22:55 -# Translated with translater 2013.05.11 +# Module: lastpostsExtend - 2021.08.25 +# Date: 2021-08-25 22:43:47 +# Translated with translater 2021.08.18 msgid "" msgstr "" "Content-Type: text/plain; charset=UTF-8\n" -"Project-Id-Version: lastpostsExtend 2013.11.12\n" +"Project-Id-Version: lastpostsExtend 2021.08.25\n" "POT-Creation-Date: \n" -"PO-Revision-Date: 2013-11-13T07:22:55+00:00\n" +"PO-Revision-Date: 2021-08-25T22:43:47+00:00\n" "Last-Translator: Jean-Christian Denis\n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n > 1);\n" -#: _widgets.php:34 +#: _widgets.php:33 msgid "Last entries (Extended)" msgstr "Derniers billets (étendu)" -#: _widgets.php:37 +#: _widgets.php:36 msgid "Extended list of entries" msgstr "Liste étendue de billets" -#: _widgets.php:48 +#: _widgets.php:47 msgid "Post" msgstr "Billet" -#: _widgets.php:50 +#: _widgets.php:49 msgid "Gallery" msgstr "Galerie" -#: _widgets.php:95 +#: _widgets.php:94 msgid "Protection:" msgstr "Protection :" -#: _widgets.php:100 +#: _widgets.php:99 msgid "only without password" msgstr "seulement sans mot de passe" -#: _widgets.php:101 +#: _widgets.php:100 msgid "only with password" msgstr "seulement avec mot de passe" -#: _widgets.php:121 +#: _widgets.php:120 msgid "Selected entries only" msgstr "Billets sélectionnés seulement" -#: _widgets.php:128 +#: _widgets.php:127 msgid "Updated entries only" msgstr "Billets mis à jour seulement" -#: _widgets.php:137 +#: _widgets.php:135 msgid "Limit to tags:" msgstr "Limiter aux mots-clés :" -#: _widgets.php:145 +#: _widgets.php:143 msgid "Limit to words:" msgstr "Limiter aux mots :" -#: _widgets.php:182 +#: _widgets.php:180 msgid "Show entries first image:" msgstr "Afficher la première image du billet :" -#: _widgets.php:197 +#: _widgets.php:195 msgid "Show entries excerpt" msgstr "Afficher l'extrait" -#: _widgets.php:204 +#: _widgets.php:202 msgid "Excerpt length:" msgstr "Taille de l'extrait :" -#: _widgets.php:211 +#: _widgets.php:209 msgid "Show comments count" msgstr "Afficher le nombre de commentaires" diff --git a/repository.xml b/repository.xml new file mode 100644 index 0000000..a31c462 --- /dev/null +++ b/repository.xml @@ -0,0 +1,13 @@ + + +Last entries (Extended) +2021.08.25 +Jean-Christian Denis and contributors +Extended list of entries +https://github.com/JcDenis/lastpostsExtend/releases/download/v2021.08.25/plugin-lastpostsExtend.zip +2.19 +https://plugins.dotaddict.org/dc2/details/lastpostsExtend + +https://github.com/JcDenis/lastpostsExtend + + \ No newline at end of file