code review (phpstan, php-cs-fixer)
This commit is contained in:
parent
293432f04c
commit
c459a46749
7 changed files with 56 additions and 52 deletions
|
@ -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()->addBehavior('adminDashboardFavoritesV2', ['adminPostWidgetText', 'adminDashboardFavorites']);
|
||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['adminPostWidgetText', 'adminDashboardFavoritesV2']);
|
||||
}
|
||||
# Pref
|
||||
dcCore::app()->addBehavior('adminFiltersListsV2', ['adminPostWidgetText', 'adminFiltersListsV2']);
|
||||
|
|
|
@ -59,7 +59,7 @@ class postWidgetTextWidget
|
|||
|
||||
if (!dcCore::app()->blog->settings->get(basename(__DIR__))->get('active')
|
||||
|| !dcCore::app()->ctx->exists('posts')
|
||||
|| !dcCore::app()->ctx->posts->post_id
|
||||
|| !dcCore::app()->ctx->__get('posts')->post_id
|
||||
) {
|
||||
return null;
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class postWidgetTextWidget
|
|||
$content = '';
|
||||
|
||||
$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()) {
|
||||
return null;
|
||||
|
@ -81,7 +81,7 @@ class postWidgetTextWidget
|
|||
$content = $rs->option_content_xhtml;
|
||||
}
|
||||
if ('' == $content && $w->excerpt) {
|
||||
$content = dcCore::app()->ctx->posts->post_excerpt_xhtml;
|
||||
$content = dcCore::app()->ctx->__get('posts')->post_excerpt_xhtml;
|
||||
}
|
||||
|
||||
return $w->renderDiv(
|
||||
|
|
|
@ -103,8 +103,6 @@ class postWidgetText
|
|||
}
|
||||
if ($cur->post_id == '') {
|
||||
throw new Exception('No such entry ID');
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
$this->lockTable();
|
||||
|
@ -180,7 +178,7 @@ class postWidgetText
|
|||
}
|
||||
|
||||
$id = (int) $id;
|
||||
$type = $type ?? basename(__DIR__);
|
||||
$type ??= basename(__DIR__);
|
||||
|
||||
if (empty($id)) {
|
||||
throw new Exception(__('No such ID'));
|
||||
|
|
|
@ -17,6 +17,9 @@
|
|||
*/
|
||||
class adminPostWidgetText
|
||||
{
|
||||
private static $ie_cursor;
|
||||
private static $ie_pwt;
|
||||
|
||||
private static function id()
|
||||
{
|
||||
return basename(dirname(__DIR__));
|
||||
|
@ -214,10 +217,10 @@ class adminPostWidgetText
|
|||
|
||||
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
|
||||
);
|
||||
$bk->{self::id()} = new postWidgetText();
|
||||
self::$ie_pwt = new postWidgetText();
|
||||
}
|
||||
|
||||
public static function importSingleV2($line, $bk)
|
||||
|
@ -227,22 +230,22 @@ class adminPostWidgetText
|
|||
) {
|
||||
$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,
|
||||
]);
|
||||
|
||||
if ($exists->isEmpty()) {
|
||||
$bk->cur_postwidgettext->clean();
|
||||
self::$ie_cursor->clean();
|
||||
|
||||
$bk->cur_postwidgettext->post_id = (int) $line->post_id;
|
||||
$bk->cur_postwidgettext->option_type = (string) $line->option_type;
|
||||
$bk->cur_postwidgettext->option_lang = (string) $line->option_lang;
|
||||
$bk->cur_postwidgettext->option_format = (string) $line->option_format;
|
||||
$bk->cur_postwidgettext->option_content = (string) $line->option_content;
|
||||
$bk->cur_postwidgettext->option_content_xhtml = (string) $line->option_content_xhtml;
|
||||
self::$ie_cursor->post_id = (int) $line->post_id;
|
||||
self::$ie_cursor->option_type = (string) $line->option_type;
|
||||
self::$ie_cursor->option_lang = (string) $line->option_lang;
|
||||
self::$ie_cursor->option_format = (string) $line->option_format;
|
||||
self::$ie_cursor->option_content = (string) $line->option_content;
|
||||
self::$ie_cursor->option_content_xhtml = (string) $line->option_content_xhtml;
|
||||
|
||||
$bk->{self::id()}->addWidget(
|
||||
$bk->cur_postwidgettext
|
||||
self::$ie_pwt->addWidget(
|
||||
self::$ie_cursor
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -251,22 +254,22 @@ class adminPostWidgetText
|
|||
public static function importFullV2($line, $bk)
|
||||
{
|
||||
if ($line->__name == self::id()) {
|
||||
$exists = $bk->{self::id()}->getWidgets([
|
||||
$exists = self::$ie_pwt->getWidgets([
|
||||
'post_id' => $line->post_id,
|
||||
]);
|
||||
|
||||
if ($exists->isEmpty()) {
|
||||
$bk->cur_postwidgettext->clean();
|
||||
self::$ie_cursor->clean();
|
||||
|
||||
$bk->cur_postwidgettext->post_id = (int) $line->post_id;
|
||||
$bk->cur_postwidgettext->option_type = (string) $line->option_type;
|
||||
$bk->cur_postwidgettext->option_format = (string) $line->option_format;
|
||||
$bk->cur_postwidgettext->option_content = (string) $line->option_content;
|
||||
$bk->cur_postwidgettext->option_content = (string) $line->option_content;
|
||||
$bk->cur_postwidgettext->option_content_xhtml = (string) $line->option_content_xhtml;
|
||||
self::$ie_cursor->post_id = (int) $line->post_id;
|
||||
self::$ie_cursor->option_type = (string) $line->option_type;
|
||||
self::$ie_cursor->option_format = (string) $line->option_format;
|
||||
self::$ie_cursor->option_content = (string) $line->option_content;
|
||||
self::$ie_cursor->option_content = (string) $line->option_content;
|
||||
self::$ie_cursor->option_content_xhtml = (string) $line->option_content_xhtml;
|
||||
|
||||
$bk->{self::id()}->addWidget(
|
||||
$bk->cur_postwidgettext
|
||||
self::$ie_pwt->addWidget(
|
||||
self::$ie_cursor
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,13 +47,13 @@ class listPostWidgetText extends adminGenericList
|
|||
while ($this->rs->fetch()) {
|
||||
$w_title = html::escapeHTML($this->rs->option_title);
|
||||
if ($w_title == '') {
|
||||
$w_title = '<em>' . context::global_filter(
|
||||
$w_title = '<em>' . context::global_filters(
|
||||
$this->rs->option_content,
|
||||
1,
|
||||
1,
|
||||
80,
|
||||
0,
|
||||
0
|
||||
[
|
||||
'encode_xml',
|
||||
'remove_html',
|
||||
'cut_string' => 80,
|
||||
]
|
||||
) . '</em>';
|
||||
}
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ try {
|
|||
$posts_list = new listPostWidgetText(dcCore::app(), $posts, $counter->f(0));
|
||||
} catch (Exception $e) {
|
||||
dcCore::app()->error->add($e->getMessage());
|
||||
$posts_list = null;
|
||||
}
|
||||
|
||||
# Display
|
||||
|
@ -70,6 +71,7 @@ dcPage::breadcrumb([
|
|||
]) .
|
||||
dcPage::notices();
|
||||
|
||||
if ($posts_list) {
|
||||
$filter->display('admin.plugin.' . basename(__DIR__), form::hidden('p', basename(__DIR__)));
|
||||
|
||||
$posts_list->display(
|
||||
|
@ -86,5 +88,6 @@ $posts_list->display(
|
|||
'</div>' .
|
||||
'</form>'
|
||||
);
|
||||
}
|
||||
|
||||
echo '</body></html>';
|
||||
|
|
Loading…
Reference in a new issue