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()->addBehavior('adminDashboardFavoritesV2', ['adminPostWidgetText', 'adminDashboardFavorites']);
|
||||
dcCore::app()->addBehavior('adminDashboardFavoritesV2', ['adminPostWidgetText', 'adminDashboardFavoritesV2']);
|
||||
}
|
||||
# Pref
|
||||
dcCore::app()->addBehavior('adminFiltersListsV2', ['adminPostWidgetText', 'adminFiltersListsV2']);
|
||||
|
|
|
@ -17,7 +17,7 @@ if (!defined('DC_CONTEXT_ADMIN')) {
|
|||
try {
|
||||
// check installed version
|
||||
if (!dcCore::app()->newVersion(
|
||||
basename(__DIR__),
|
||||
basename(__DIR__),
|
||||
dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version')
|
||||
)) {
|
||||
return null;
|
||||
|
|
|
@ -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();
|
||||
|
@ -179,8 +177,8 @@ class postWidgetText
|
|||
throw new Exception(__('You are not allowed to delete entries text widget'));
|
||||
}
|
||||
|
||||
$id = (int) $id;
|
||||
$type = $type ?? basename(__DIR__);
|
||||
$id = (int) $id;
|
||||
$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>';
|
||||
}
|
||||
|
||||
|
|
33
index.php
33
index.php
|
@ -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,21 +71,23 @@ dcPage::breadcrumb([
|
|||
]) .
|
||||
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(
|
||||
$filter->page,
|
||||
$filter->nb,
|
||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '" method="post" id="form-entries">' .
|
||||
'%s' .
|
||||
'<div class="two-cols">' .
|
||||
'<p class="col checkboxes-helpers"></p>' .
|
||||
'<p class="col right">' .
|
||||
'<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()->formNonce() .
|
||||
'</div>' .
|
||||
'</form>'
|
||||
);
|
||||
$posts_list->display(
|
||||
$filter->page,
|
||||
$filter->nb,
|
||||
'<form action="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '" method="post" id="form-entries">' .
|
||||
'%s' .
|
||||
'<div class="two-cols">' .
|
||||
'<p class="col checkboxes-helpers"></p>' .
|
||||
'<p class="col right">' .
|
||||
'<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()->formNonce() .
|
||||
'</div>' .
|
||||
'</form>'
|
||||
);
|
||||
}
|
||||
|
||||
echo '</body></html>';
|
||||
|
|
Loading…
Reference in New Issue