clean up again

This commit is contained in:
Jean-Christian Denis 2021-09-02 21:25:11 +02:00
parent ef17eb4a52
commit fb42b5b6ae
7 changed files with 118 additions and 120 deletions

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief lastBlogUpdate, a plugin for Dotclear 2
# This file is part of lastBlogUpdate, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis, Pierre Van Glabeke
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief lastBlogUpdate, a plugin for Dotclear 2
# This file is part of lastBlogUpdate, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis, Pierre Van Glabeke
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View file

@ -1,104 +1,104 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief lastBlogUpdate, a plugin for Dotclear 2
# This file is part of lastBlogUpdate, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis, Pierre Van Glabeke
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
require dirname(__FILE__).'/_widgets.php'; require dirname(__FILE__).'/_widgets.php';
function lastBlogUpdateWidgetPublic($w) function lastBlogUpdateWidgetPublic($w)
{ {
global $core; global $core;
if ($w->offline) { if ($w->offline) {
return null; return null;
} }
# Nothing to display # Nothing to display
if ($w->homeonly == 1 && $core->url->type != 'default' if ($w->homeonly == 1 && $core->url->type != 'default'
|| $w->homeonly == 2 && $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_show && !$w->post_show && !$w->comment_show && !$w->media_show
|| !$w->blog_text && !$w->post_text && !$w->comment_text && !$w->media_text) { || !$w->blog_text && !$w->post_text && !$w->comment_text && !$w->media_text) {
return null; return null;
} }
$blog = $post = $comment = $media = $addons = ''; $blog = $post = $comment = $media = $addons = '';
# Blog # Blog
if ($w->blog_show && $w->blog_text) { if ($w->blog_show && $w->blog_text) {
$title = $w->blog_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->blog_title)) : ''; $title = $w->blog_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->blog_title)) : '';
$text = dt::str($w->blog_text, $core->blog->upddt, $core->blog->settings->system->blog_timezone); $text = dt::str($w->blog_text, $core->blog->upddt, $core->blog->settings->system->blog_timezone);
$blog = sprintf('<li>%s%s</li>', $title, $text); $blog = sprintf('<li>%s%s</li>', $title, $text);
} }
# Post # Post
if ($w->post_show && $w->post_text) { if ($w->post_show && $w->post_text) {
$rs = $core->blog->getPosts(['limit' => 1, 'no_content' => true]); $rs = $core->blog->getPosts(['limit' => 1, 'no_content' => true]);
if (!$rs->isEmpty()) { if (!$rs->isEmpty()) {
$title = $w->post_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->post_title)) : ''; $title = $w->post_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->post_title)) : '';
$text = dt::str($w->post_text, strtotime($rs->post_upddt), $core->blog->settings->system->blog_timezone); $text = dt::str($w->post_text, strtotime($rs->post_upddt), $core->blog->settings->system->blog_timezone);
$link = $rs->getURL(); $link = $rs->getURL();
$over = $rs->post_title; $over = $rs->post_title;
$post = sprintf('<li>%s<a href="%s" title="%s">%s</a></li>', $title, $link, $over, $text); $post = sprintf('<li>%s<a href="%s" title="%s">%s</a></li>', $title, $link, $over, $text);
} }
} }
# Comment # Comment
if ($w->comment_show && $w->comment_text) { if ($w->comment_show && $w->comment_text) {
$rs = $core->blog->getComments(['limit' => 1, 'no_content' => true]); $rs = $core->blog->getComments(['limit' => 1, 'no_content' => true]);
if (!$rs->isEmpty()) { if (!$rs->isEmpty()) {
$title = $w->comment_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->comment_title)) : ''; $title = $w->comment_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->comment_title)) : '';
$text = dt::str($w->comment_text, strtotime($rs->comment_upddt), $core->blog->settings->system->blog_timezone); $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; $link = $core->blog->url . $core->getPostPublicURL($rs->post_type, html::sanitizeURL($rs->post_url)) . '#c' . $rs->comment_id;
$over = $rs->post_title; $over = $rs->post_title;
$comment = sprintf('<li>%s<a href="%s" title="%s">%s</a></li>', $title, $link, $over, $text); $comment = sprintf('<li>%s<a href="%s" title="%s">%s</a></li>', $title, $link, $over, $text);
} }
} }
# Media # Media
if ($w->media_show && $w->media_text) { if ($w->media_show && $w->media_text) {
$rs = $core->con->select( $rs = $core->con->select(
'SELECT media_upddt FROM ' . $core->prefix . 'media ' . 'SELECT media_upddt FROM ' . $core->prefix . 'media ' .
"WHERE media_path='" . $core->con->escape($core->blog->settings->system->public_path) . "' " . "WHERE media_path='" . $core->con->escape($core->blog->settings->system->public_path) . "' " .
'ORDER BY media_upddt DESC ' . $core->con->limit(1) 'ORDER BY media_upddt DESC ' . $core->con->limit(1)
); );
if (!$rs->isEmpty()) { if (!$rs->isEmpty()) {
$title = $w->media_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->media_title)) : ''; $title = $w->media_title ? sprintf('<strong>%s</strong>', html::escapeHTML($w->media_title)) : '';
$text = dt::str($w->media_text, strtotime($rs->f('media_upddt')), $core->blog->settings->system->blog_timezone); $text = dt::str($w->media_text, strtotime($rs->f('media_upddt')), $core->blog->settings->system->blog_timezone);
$media = sprintf('<li>%s%s</li>', $title, $text); $media = sprintf('<li>%s%s</li>', $title, $text);
} }
} }
# --BEHAVIOR-- lastBlogUpdateWidgetParse # --BEHAVIOR-- lastBlogUpdateWidgetParse
$addons = $core->callBehavior('lastBlogUpdateWidgetParse', $core, $w); $addons = $core->callBehavior('lastBlogUpdateWidgetParse', $core, $w);
# Nothing to display # Nothing to display
if (!$blog && !$post && !$comment && !$media && !$addons) { if (!$blog && !$post && !$comment && !$media && !$addons) {
return null; return null;
} }
# Display # Display
return $w->renderDiv( return $w->renderDiv(
$w->content_only, $w->content_only,
'lastblogupdate ' . $w->class, 'lastblogupdate ' . $w->class,
'', '',
($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') . ($w->title ? $w->renderTitle(html::escapeHTML($w->title)) : '') .
sprintf('<ul>%s</ul>', $blog . $post . $comment . $media . $addons) sprintf('<ul>%s</ul>', $blog . $post . $comment . $media . $addons)
); );
} }

View file

@ -1,15 +1,15 @@
<?php <?php
# -- BEGIN LICENSE BLOCK ---------------------------------- /**
# * @brief lastBlogUpdate, a plugin for Dotclear 2
# This file is part of lastBlogUpdate, a plugin for Dotclear 2. *
# * @package Dotclear
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors * @subpackage Plugin
# *
# Licensed under the GPL version 2.0 license. * @author Jean-Christian Denis, Pierre Van Glabeke
# A copy of this license is available in LICENSE file or at *
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html * @copyright Jean-Christian Denis
# * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;

View file

@ -1,13 +1,12 @@
<modules xmlns:da="http://dotaddict.org/da/"> <modules xmlns:da="http://dotaddict.org/da/">
<module id="lastBlogUpdate"> <module id="lastBlogUpdate">
<name>lastBlogUpdate</name> <name>lastBlogUpdate</name>
<version>2021.08.27</version> <version>2021.08.27.1</version>
<author>Jean-Christian Denis, Pierre Van Glabeke</author> <author>Jean-Christian Denis, Pierre Van Glabeke</author>
<desc>Show the dates of last updates of your blog in a widget</desc> <desc>Show the dates of last updates of your blog in a widget</desc>
<file>https://github.com/JcDenis/lastBlogUpdate/releases/download/v2021.08.27/plugin-lastBlogUpdate.zip</file> <file>https://github.com/JcDenis/lastBlogUpdate/releases/download/v2021.08.27.1/plugin-lastBlogUpdate.zip</file>
<da:dcmin>2.19</da:dcmin> <da:dcmin>2.19</da:dcmin>
<da:details>http://plugins.dotaddict.org/dc2/details/lastBlogUpdate</da:details> <da:details>http://plugins.dotaddict.org/dc2/details/lastBlogUpdate</da:details>
<da:section></da:section>
<da:support>http://forum.dotclear.org/viewtopic.php?pid=332950#p332950</da:support> <da:support>http://forum.dotclear.org/viewtopic.php?pid=332950#p332950</da:support>
</module> </module>
</modules> </modules>

View file

@ -58,4 +58,3 @@ $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']['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';