use sql statement

This commit is contained in:
Jean-Christian Denis 2023-04-24 16:32:19 +02:00
parent 0b9849f4ed
commit a175e88d66
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951

View file

@ -16,6 +16,7 @@ namespace Dotclear\Plugin\lastBlogUpdate;
use dcCore; use dcCore;
use dcMedia; use dcMedia;
use Dotclear\Database\Statement\SelectStatement;
use Dotclear\Helper\Date; use Dotclear\Helper\Date;
use Dotclear\Helper\Html\Html; use Dotclear\Helper\Html\Html;
use Dotclear\Plugin\widgets\WidgetsStack; use Dotclear\Plugin\widgets\WidgetsStack;
@ -167,13 +168,15 @@ class Widgets
# Media # Media
if ($w->media_show && $w->media_text) { if ($w->media_show && $w->media_text) {
$rs = dcCore::app()->con->select( $sql = new SelectStatement();
'SELECT media_upddt FROM ' . dcCore::app()->prefix . dcMedia::MEDIA_TABLE_NAME . ' ' . $rs = $sql->from(dcCore::app()->prefix . dcMedia::MEDIA_TABLE_NAME)
"WHERE media_path='" . dcCore::app()->con->escapeStr(dcCore::app()->blog->settings->get('system')->get('public_path')) . "' " . ->column('media_upddt')
'ORDER BY media_upddt DESC ' . dcCore::app()->con->limit(1) ->where('media_path = ' . $sql->quote((string) dcCore::app()->blog->settings->get('system')->get('public_path')))
); ->order('media_upddt DESC')
->limit(1)
->select();
if (!$rs->isEmpty()) { if (!is_null($rs) && !$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 = Date::str($w->media_text, (int) strtotime($rs->f('media_upddt')), dcCore::app()->blog->settings->get('system')->get('blog_timezone')); $text = Date::str($w->media_text, (int) strtotime($rs->f('media_upddt')), dcCore::app()->blog->settings->get('system')->get('blog_timezone'));