code review (phpstan, php-cs-fixer)
parent
293432f04c
commit
c459a46749
|
@ -26,7 +26,7 @@ if (dcCore::app()->blog->settings->get(basename(__DIR__))->get('active')) {
|
||||||
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id)
|
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id)
|
||||||
);
|
);
|
||||||
|
|
||||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['adminPostWidgetText', 'adminDashboardFavorites']);
|
dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['adminPostWidgetText', 'adminDashboardFavoritesV2']);
|
||||||
}
|
}
|
||||||
# Pref
|
# Pref
|
||||||
dcCore::app()->addBehavior('adminFiltersListsV2', ['adminPostWidgetText', 'adminFiltersListsV2']);
|
dcCore::app()->addBehavior('adminFiltersListsV2', ['adminPostWidgetText', 'adminFiltersListsV2']);
|
||||||
|
|
|
@ -59,7 +59,7 @@ class postWidgetTextWidget
|
||||||
|
|
||||||
if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('active')
|
if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('active')
|
||||||
|| !dcCore::app()->ctx->exists('posts')
|
|| !dcCore::app()->ctx->exists('posts')
|
||||||
|| !dcCore::app()->ctx->posts->post_id
|
|| !dcCore::app()->ctx->__get('posts')->post_id
|
||||||
) {
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ class postWidgetTextWidget
|
||||||
$content = '';
|
$content = '';
|
||||||
|
|
||||||
$pwt = new postWidgetText();
|
$pwt = new postWidgetText();
|
||||||
$rs = $pwt->getWidgets(['post_id' => dcCore::app()->ctx->posts->post_id]);
|
$rs = $pwt->getWidgets(['post_id' => dcCore::app()->ctx->__get('posts')->post_id]);
|
||||||
|
|
||||||
if ($rs->isEmpty()) {
|
if ($rs->isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -81,7 +81,7 @@ class postWidgetTextWidget
|
||||||
$content = $rs->option_content_xhtml;
|
$content = $rs->option_content_xhtml;
|
||||||
}
|
}
|
||||||
if ('' == $content && $w->excerpt) {
|
if ('' == $content && $w->excerpt) {
|
||||||
$content = dcCore::app()->ctx->posts->post_excerpt_xhtml;
|
$content = dcCore::app()->ctx->__get('posts')->post_excerpt_xhtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $w->renderDiv(
|
return $w->renderDiv(
|
||||||
|
|
|
@ -103,8 +103,6 @@ class postWidgetText
|
||||||
}
|
}
|
||||||
if ($cur->post_id == '') {
|
if ($cur->post_id == '') {
|
||||||
throw new Exception('No such entry ID');
|
throw new Exception('No such entry ID');
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->lockTable();
|
$this->lockTable();
|
||||||
|
@ -179,8 +177,8 @@ class postWidgetText
|
||||||
throw new Exception(__('You are not allowed to delete entries text widget'));
|
throw new Exception(__('You are not allowed to delete entries text widget'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = (int) $id;
|
$id = (int) $id;
|
||||||
$type = $type ?? basename(__DIR__);
|
$type ??= basename(__DIR__);
|
||||||
|
|
||||||
if (empty($id)) {
|
if (empty($id)) {
|
||||||
throw new Exception(__('No such ID'));
|
throw new Exception(__('No such ID'));
|
||||||
|
|
|
@ -17,6 +17,9 @@
|
||||||
*/
|
*/
|
||||||
class adminPostWidgetText
|
class adminPostWidgetText
|
||||||
{
|
{
|
||||||
|
private static $ie_cursor;
|
||||||
|
private static $ie_pwt;
|
||||||
|
|
||||||
private static function id()
|
private static function id()
|
||||||
{
|
{
|
||||||
return basename(dirname(__DIR__));
|
return basename(dirname(__DIR__));
|
||||||
|
@ -214,10 +217,10 @@ class adminPostWidgetText
|
||||||
|
|
||||||
public static function importInitV2($bk)
|
public static function importInitV2($bk)
|
||||||
{
|
{
|
||||||
$bk->cur_postwidgettext = dcCore::app()->con->openCursor(
|
self::$ie_cursor = dcCore::app()->con->openCursor(
|
||||||
dcCore::app()->prefix . initPostWidgetText::PWT_TABLE_NAME
|
dcCore::app()->prefix . initPostWidgetText::PWT_TABLE_NAME
|
||||||
);
|
);
|
||||||
$bk->{self::id()} = new postWidgetText();
|
self::$ie_pwt = new postWidgetText();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function importSingleV2($line, $bk)
|
public static function importSingleV2($line, $bk)
|
||||||
|
@ -227,22 +230,22 @@ class adminPostWidgetText
|
||||||
) {
|
) {
|
||||||
$line->post_id = $bk->old_ids['post'][(int) $line->post_id];
|
$line->post_id = $bk->old_ids['post'][(int) $line->post_id];
|
||||||
|
|
||||||
$exists = $bk->{self::id()}->getWidgets([
|
$exists = self::$ie_pwt->getWidgets([
|
||||||
'post_id' => $line->post_id,
|
'post_id' => $line->post_id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($exists->isEmpty()) {
|
if ($exists->isEmpty()) {
|
||||||
$bk->cur_postwidgettext->clean();
|
self::$ie_cursor->clean();
|
||||||
|
|
||||||
$bk->cur_postwidgettext->post_id = (int) $line->post_id;
|
self::$ie_cursor->post_id = (int) $line->post_id;
|
||||||
$bk->cur_postwidgettext->option_type = (string) $line->option_type;
|
self::$ie_cursor->option_type = (string) $line->option_type;
|
||||||
$bk->cur_postwidgettext->option_lang = (string) $line->option_lang;
|
self::$ie_cursor->option_lang = (string) $line->option_lang;
|
||||||
$bk->cur_postwidgettext->option_format = (string) $line->option_format;
|
self::$ie_cursor->option_format = (string) $line->option_format;
|
||||||
$bk->cur_postwidgettext->option_content = (string) $line->option_content;
|
self::$ie_cursor->option_content = (string) $line->option_content;
|
||||||
$bk->cur_postwidgettext->option_content_xhtml = (string) $line->option_content_xhtml;
|
self::$ie_cursor->option_content_xhtml = (string) $line->option_content_xhtml;
|
||||||
|
|
||||||
$bk->{self::id()}->addWidget(
|
self::$ie_pwt->addWidget(
|
||||||
$bk->cur_postwidgettext
|
self::$ie_cursor
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -251,22 +254,22 @@ class adminPostWidgetText
|
||||||
public static function importFullV2($line, $bk)
|
public static function importFullV2($line, $bk)
|
||||||
{
|
{
|
||||||
if ($line->__name == self::id()) {
|
if ($line->__name == self::id()) {
|
||||||
$exists = $bk->{self::id()}->getWidgets([
|
$exists = self::$ie_pwt->getWidgets([
|
||||||
'post_id' => $line->post_id,
|
'post_id' => $line->post_id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if ($exists->isEmpty()) {
|
if ($exists->isEmpty()) {
|
||||||
$bk->cur_postwidgettext->clean();
|
self::$ie_cursor->clean();
|
||||||
|
|
||||||
$bk->cur_postwidgettext->post_id = (int) $line->post_id;
|
self::$ie_cursor->post_id = (int) $line->post_id;
|
||||||
$bk->cur_postwidgettext->option_type = (string) $line->option_type;
|
self::$ie_cursor->option_type = (string) $line->option_type;
|
||||||
$bk->cur_postwidgettext->option_format = (string) $line->option_format;
|
self::$ie_cursor->option_format = (string) $line->option_format;
|
||||||
$bk->cur_postwidgettext->option_content = (string) $line->option_content;
|
self::$ie_cursor->option_content = (string) $line->option_content;
|
||||||
$bk->cur_postwidgettext->option_content = (string) $line->option_content;
|
self::$ie_cursor->option_content = (string) $line->option_content;
|
||||||
$bk->cur_postwidgettext->option_content_xhtml = (string) $line->option_content_xhtml;
|
self::$ie_cursor->option_content_xhtml = (string) $line->option_content_xhtml;
|
||||||
|
|
||||||
$bk->{self::id()}->addWidget(
|
self::$ie_pwt->addWidget(
|
||||||
$bk->cur_postwidgettext
|
self::$ie_cursor
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,13 +47,13 @@ class listPostWidgetText extends adminGenericList
|
||||||
while ($this->rs->fetch()) {
|
while ($this->rs->fetch()) {
|
||||||
$w_title = html::escapeHTML($this->rs->option_title);
|
$w_title = html::escapeHTML($this->rs->option_title);
|
||||||
if ($w_title == '') {
|
if ($w_title == '') {
|
||||||
$w_title = '<em>' . context::global_filter(
|
$w_title = '<em>' . context::global_filters(
|
||||||
$this->rs->option_content,
|
$this->rs->option_content,
|
||||||
1,
|
[
|
||||||
1,
|
'encode_xml',
|
||||||
80,
|
'remove_html',
|
||||||
0,
|
'cut_string' => 80,
|
||||||
0
|
]
|
||||||
) . '</em>';
|
) . '</em>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
33
index.php
33
index.php
|
@ -54,6 +54,7 @@ try {
|
||||||
$posts_list = new listPostWidgetText(dcCore::app(), $posts, $counter->f(0));
|
$posts_list = new listPostWidgetText(dcCore::app(), $posts, $counter->f(0));
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
dcCore::app()->error->add($e->getMessage());
|
dcCore::app()->error->add($e->getMessage());
|
||||||
|
$posts_list = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Display
|
# Display
|
||||||
|
@ -70,21 +71,23 @@ dcPage::breadcrumb([
|
||||||
]) .
|
]) .
|
||||||
dcPage::notices();
|
dcPage::notices();
|
||||||
|
|
||||||
$filter->display('admin.plugin.' . basename(__DIR__), form::hidden('p', basename(__DIR__)));
|
if ($posts_list) {
|
||||||
|
$filter->display('admin.plugin.' . basename(__DIR__), form::hidden('p', basename(__DIR__)));
|
||||||
|
|
||||||
$posts_list->display(
|
$posts_list->display(
|
||||||
$filter->page,
|
$filter->page,
|
||||||
$filter->nb,
|
$filter->nb,
|
||||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '" method="post" id="form-entries">' .
|
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '" method="post" id="form-entries">' .
|
||||||
'%s' .
|
'%s' .
|
||||||
'<div class="two-cols">' .
|
'<div class="two-cols">' .
|
||||||
'<p class="col checkboxes-helpers"></p>' .
|
'<p class="col checkboxes-helpers"></p>' .
|
||||||
'<p class="col right">' .
|
'<p class="col right">' .
|
||||||
'<input id="do-action" type="submit" name="save" value="' . __('Delete selected widgets') . '" /></p>' .
|
'<input id="do-action" type="submit" name="save" value="' . __('Delete selected widgets') . '" /></p>' .
|
||||||
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . basename(__DIR__), array_merge(['p' => basename(__DIR__)], $filter->values(true))) .
|
dcCore::app()->adminurl->getHiddenFormFields('admin.plugin.' . basename(__DIR__), array_merge(['p' => basename(__DIR__)], $filter->values(true))) .
|
||||||
dcCore::app()->formNonce() .
|
dcCore::app()->formNonce() .
|
||||||
'</div>' .
|
'</div>' .
|
||||||
'</form>'
|
'</form>'
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
echo '</body></html>';
|
echo '</body></html>';
|
||||||
|
|
Loading…
Reference in New Issue