fix nullsafe warnings and remove magic
This commit is contained in:
parent
0b45344ae0
commit
60e5abd9f4
@ -10,7 +10,7 @@
|
|||||||
* @copyright Jean-Christian Denis
|
* @copyright Jean-Christian Denis
|
||||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||||
*/
|
*/
|
||||||
if (!defined('DC_RC_PATH')) {
|
if (!defined('DC_RC_PATH') || is_null(dcCore::app()->auth)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,7 +22,7 @@ $this->registerModule(
|
|||||||
[
|
[
|
||||||
'requires' => [['core', '2.26']],
|
'requires' => [['core', '2.26']],
|
||||||
'permissions' => dcCore::app()->auth->makePermissions([
|
'permissions' => dcCore::app()->auth->makePermissions([
|
||||||
dcAuth::PERMISSION_ADMIN,
|
dcCore::app()->auth::PERMISSION_ADMIN,
|
||||||
]),
|
]),
|
||||||
'type' => 'plugin',
|
'type' => 'plugin',
|
||||||
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=321044#p321044',
|
'support' => 'http://forum.dotclear.org/viewtopic.php?pid=321044#p321044',
|
||||||
|
@ -43,7 +43,12 @@ class Widgets
|
|||||||
|
|
||||||
public static function parseWidget(WidgetsElement $w): string
|
public static function parseWidget(WidgetsElement $w): string
|
||||||
{
|
{
|
||||||
if ($w->offline || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|
// nullsafe
|
||||||
|
if (is_null(dcCore::app()->blog)) {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($w->__get('offline') || !$w->checkHomeOnly(dcCore::app()->url->type)) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +65,7 @@ class Widgets
|
|||||||
$posts = [];
|
$posts = [];
|
||||||
while ($rs->fetch()) {
|
while ($rs->fetch()) {
|
||||||
$posts[Date::dt2str(__('%Y'), $rs->f('dt'))][] = [
|
$posts[Date::dt2str(__('%Y'), $rs->f('dt'))][] = [
|
||||||
'url' => $rs->url(),
|
'url' => $rs->__call('url', []),
|
||||||
'date' => Html::escapeHTML(Date::dt2str(__('%B'), $rs->f('dt'))),
|
'date' => Html::escapeHTML(Date::dt2str(__('%B'), $rs->f('dt'))),
|
||||||
'nbpost' => $rs->f('nb_post'),
|
'nbpost' => $rs->f('nb_post'),
|
||||||
];
|
];
|
||||||
@ -77,23 +82,23 @@ class Widgets
|
|||||||
$res .= '<span>' . $annee . '</span><ul class="arch-months">';
|
$res .= '<span>' . $annee . '</span><ul class="arch-months">';
|
||||||
for ($i = 0; $i < sizeof($post); $i++) {
|
for ($i = 0; $i < sizeof($post); $i++) {
|
||||||
$res .= '<li><a href="' . $post[$i]['url'] . '">' . $post[$i]['date'] . '</a>' .
|
$res .= '<li><a href="' . $post[$i]['url'] . '">' . $post[$i]['date'] . '</a>' .
|
||||||
($w->postcount ? ' (' . $post[$i]['nbpost'] . ')' : '') .
|
($w->__get('postcount') ? ' (' . $post[$i]['nbpost'] . ')' : '') .
|
||||||
'</li>';
|
'</li>';
|
||||||
}
|
}
|
||||||
$res .= '</ul></li>';
|
$res .= '</ul></li>';
|
||||||
}
|
}
|
||||||
$res .= '</ul>';
|
$res .= '</ul>';
|
||||||
|
|
||||||
if (dcCore::app()->url->getBase('archive') && !is_null($w->allarchivesslinktitle) && $w->allarchivesslinktitle !== '') {
|
if (dcCore::app()->url->getBase('archive') && !is_null($w->__get('allarchivesslinktitle')) && $w->__get('allarchivesslinktitle') !== '') {
|
||||||
$res .= '<p><strong><a href="' . dcCore::app()->blog->url . dcCore::app()->url->getURLFor('archive') . '">' .
|
$res .= '<p><strong><a href="' . dcCore::app()->blog->url . dcCore::app()->url->getURLFor('archive') . '">' .
|
||||||
Html::escapeHTML($w->allarchivesslinktitle) . '</a></strong></p>';
|
Html::escapeHTML($w->__get('allarchivesslinktitle')) . '</a></strong></p>';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $w->renderDiv(
|
return $w->renderDiv(
|
||||||
(bool) $w->content_only,
|
(bool) $w->__get('content_only'),
|
||||||
My::id() . ' ' . $w->class,
|
My::id() . ' ' . $w->__get('class'),
|
||||||
'',
|
'',
|
||||||
($w->title ? $w->renderTitle(Html::escapeHTML($w->title)) : '') . $res
|
($w->__get('title') ? $w->renderTitle(Html::escapeHTML($w->__get('title'))) : '') . $res
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user