From fb42b5b6ae68902a7367146264eb7cc9ad091f0b Mon Sep 17 00:00:00 2001 From: Jean-Christian Denis Date: Thu, 2 Sep 2021 21:25:11 +0200 Subject: [PATCH] clean up again --- README.md | 2 +- _admin.php | 22 +++--- _define.php | 22 +++--- _public.php | 160 +++++++++++++++++++-------------------- _widgets.php | 24 +++--- dcstore.xml | 5 +- locales/fr/main.lang.php | 3 +- 7 files changed, 118 insertions(+), 120 deletions(-) diff --git a/README.md b/README.md index 9969a60..ed40a0e 100644 --- a/README.md +++ b/README.md @@ -30,4 +30,4 @@ Add and configure "Last blog update" from widgets manager. ## CONTRIBUTORS * Jean-Chirstian Denis - * Pierre Van Glabeke + * Pierre Van Glabeke \ No newline at end of file diff --git a/_admin.php b/_admin.php index 92ef251..7408da3 100644 --- a/_admin.php +++ b/_admin.php @@ -1,15 +1,15 @@ offline) { - return null; - } + if ($w->offline) { + return null; + } - # Nothing to display - if ($w->homeonly == 1 && $core->url->type != 'default' - || $w->homeonly == 2 && $core->url->type == 'default' - || !$w->blog_show && !$w->post_show && !$w->comment_show && !$w->media_show - || !$w->blog_text && !$w->post_text && !$w->comment_text && !$w->media_text) { - return null; - } + # Nothing to display + if ($w->homeonly == 1 && $core->url->type != 'default' + || $w->homeonly == 2 && $core->url->type == 'default' + || !$w->blog_show && !$w->post_show && !$w->comment_show && !$w->media_show + || !$w->blog_text && !$w->post_text && !$w->comment_text && !$w->media_text) { + return null; + } - $blog = $post = $comment = $media = $addons = ''; + $blog = $post = $comment = $media = $addons = ''; - # Blog - if ($w->blog_show && $w->blog_text) { - $title = $w->blog_title ? sprintf('%s', html::escapeHTML($w->blog_title)) : ''; - $text = dt::str($w->blog_text, $core->blog->upddt, $core->blog->settings->system->blog_timezone); - $blog = sprintf('
  • %s%s
  • ', $title, $text); - } + # Blog + if ($w->blog_show && $w->blog_text) { + $title = $w->blog_title ? sprintf('%s', html::escapeHTML($w->blog_title)) : ''; + $text = dt::str($w->blog_text, $core->blog->upddt, $core->blog->settings->system->blog_timezone); + $blog = sprintf('
  • %s%s
  • ', $title, $text); + } - # Post - if ($w->post_show && $w->post_text) { - $rs = $core->blog->getPosts(['limit' => 1, 'no_content' => true]); - if (!$rs->isEmpty()) { - $title = $w->post_title ? sprintf('%s', html::escapeHTML($w->post_title)) : ''; - $text = dt::str($w->post_text, strtotime($rs->post_upddt), $core->blog->settings->system->blog_timezone); - $link = $rs->getURL(); - $over = $rs->post_title; + # Post + if ($w->post_show && $w->post_text) { + $rs = $core->blog->getPosts(['limit' => 1, 'no_content' => true]); + if (!$rs->isEmpty()) { + $title = $w->post_title ? sprintf('%s', html::escapeHTML($w->post_title)) : ''; + $text = dt::str($w->post_text, strtotime($rs->post_upddt), $core->blog->settings->system->blog_timezone); + $link = $rs->getURL(); + $over = $rs->post_title; - $post = sprintf('
  • %s%s
  • ', $title, $link, $over, $text); - } - } + $post = sprintf('
  • %s%s
  • ', $title, $link, $over, $text); + } + } - # Comment - if ($w->comment_show && $w->comment_text) { - $rs = $core->blog->getComments(['limit' => 1, 'no_content' => true]); - if (!$rs->isEmpty()) { - $title = $w->comment_title ? sprintf('%s', html::escapeHTML($w->comment_title)) : ''; - $text = dt::str($w->comment_text, strtotime($rs->comment_upddt), $core->blog->settings->system->blog_timezone); - $link = $core->blog->url . $core->getPostPublicURL($rs->post_type, html::sanitizeURL($rs->post_url)) . '#c' . $rs->comment_id; - $over = $rs->post_title; + # Comment + if ($w->comment_show && $w->comment_text) { + $rs = $core->blog->getComments(['limit' => 1, 'no_content' => true]); + if (!$rs->isEmpty()) { + $title = $w->comment_title ? sprintf('%s', html::escapeHTML($w->comment_title)) : ''; + $text = dt::str($w->comment_text, strtotime($rs->comment_upddt), $core->blog->settings->system->blog_timezone); + $link = $core->blog->url . $core->getPostPublicURL($rs->post_type, html::sanitizeURL($rs->post_url)) . '#c' . $rs->comment_id; + $over = $rs->post_title; - $comment = sprintf('
  • %s%s
  • ', $title, $link, $over, $text); - } - } + $comment = sprintf('
  • %s%s
  • ', $title, $link, $over, $text); + } + } - # Media - if ($w->media_show && $w->media_text) { - $rs = $core->con->select( - 'SELECT media_upddt FROM ' . $core->prefix . 'media ' . - "WHERE media_path='" . $core->con->escape($core->blog->settings->system->public_path) . "' " . - 'ORDER BY media_upddt DESC ' . $core->con->limit(1) - ); - - if (!$rs->isEmpty()) { - $title = $w->media_title ? sprintf('%s', html::escapeHTML($w->media_title)) : ''; - $text = dt::str($w->media_text, strtotime($rs->f('media_upddt')), $core->blog->settings->system->blog_timezone); + # Media + if ($w->media_show && $w->media_text) { + $rs = $core->con->select( + 'SELECT media_upddt FROM ' . $core->prefix . 'media ' . + "WHERE media_path='" . $core->con->escape($core->blog->settings->system->public_path) . "' " . + 'ORDER BY media_upddt DESC ' . $core->con->limit(1) + ); - $media = sprintf('
  • %s%s
  • ', $title, $text); - } - } + if (!$rs->isEmpty()) { + $title = $w->media_title ? sprintf('%s', html::escapeHTML($w->media_title)) : ''; + $text = dt::str($w->media_text, strtotime($rs->f('media_upddt')), $core->blog->settings->system->blog_timezone); - # --BEHAVIOR-- lastBlogUpdateWidgetParse - $addons = $core->callBehavior('lastBlogUpdateWidgetParse', $core, $w); + $media = sprintf('
  • %s%s
  • ', $title, $text); + } + } - # Nothing to display - if (!$blog && !$post && !$comment && !$media && !$addons) { - return null; - } + # --BEHAVIOR-- lastBlogUpdateWidgetParse + $addons = $core->callBehavior('lastBlogUpdateWidgetParse', $core, $w); - # Display - return $w->renderDiv( - $w->content_only, - 'lastblogupdate ' . $w->class, - '', - ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . - sprintf('', $blog . $post . $comment . $media . $addons) - ); + # Nothing to display + if (!$blog && !$post && !$comment && !$media && !$addons) { + return null; + } + + # Display + return $w->renderDiv( + $w->content_only, + 'lastblogupdate ' . $w->class, + '', + ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . + sprintf('', $blog . $post . $comment . $media . $addons) + ); } \ No newline at end of file diff --git a/_widgets.php b/_widgets.php index 55065d6..3013ed2 100644 --- a/_widgets.php +++ b/_widgets.php @@ -1,15 +1,15 @@ addBehavior('initWidgets', 'lastBlogUpdateWidgetAdmin'); function lastBlogUpdateWidgetAdmin($w) { global $core; - + $w ->create( 'lastblogupdate', diff --git a/dcstore.xml b/dcstore.xml index 0ecfa30..c4d3bcd 100644 --- a/dcstore.xml +++ b/dcstore.xml @@ -1,13 +1,12 @@ lastBlogUpdate -2021.08.27 +2021.08.27.1 Jean-Christian Denis, Pierre Van Glabeke Show the dates of last updates of your blog in a widget -https://github.com/JcDenis/lastBlogUpdate/releases/download/v2021.08.27/plugin-lastBlogUpdate.zip +https://github.com/JcDenis/lastBlogUpdate/releases/download/v2021.08.27.1/plugin-lastBlogUpdate.zip 2.19 http://plugins.dotaddict.org/dc2/details/lastBlogUpdate - http://forum.dotclear.org/viewtopic.php?pid=332950#p332950 \ No newline at end of file diff --git a/locales/fr/main.lang.php b/locales/fr/main.lang.php index 3e9220e..32a87c9 100644 --- a/locales/fr/main.lang.php +++ b/locales/fr/main.lang.php @@ -57,5 +57,4 @@ $GLOBALS['__l10n']['Text for media update:'] = 'Texte pour la date de mise à jo $GLOBALS['__l10n']['Show the dates of last updates of your blog in a widget'] = 'Afficher les dates des dernières mises à jour de votre blog'; -$GLOBALS['__l10n']['Last blog update'] = 'Dernières mises à jour du blog'; - +$GLOBALS['__l10n']['Last blog update'] = 'Dernières mises à jour du blog'; \ No newline at end of file