cosmetics

master
Jean-Christian Paul Denis 2021-10-30 01:12:43 +02:00
parent d2a2b18308
commit ebfc5f0710
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
8 changed files with 108 additions and 124 deletions

View File

@ -12,17 +12,13 @@
*/ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
$__autoload['postWidgetText'] = $d = dirname(__FILE__) . '/inc/';
dirname(__FILE__).'/inc/class.postwidgettext.php';
$__autoload['postWidgetTextDashboard'] = $__autoload['postWidgetText'] = $d . 'class.postwidgettext.php';
dirname(__FILE__).'/inc/lib.pwt.dashboard.php'; $__autoload['postWidgetTextDashboard'] = $d . 'lib.pwt.dashboard.php';
$__autoload['postWidgetTextAdmin'] = $__autoload['postWidgetTextAdmin'] = $d . 'lib.pwt.admin.php';
dirname(__FILE__).'/inc/lib.pwt.admin.php'; $__autoload['postWidgetTextBackup'] = $d . 'lib.pwt.backup.php';
$__autoload['postWidgetTextBackup'] = $__autoload['postWidgetTextList'] = $d . 'lib.pwt.list.php';
dirname(__FILE__).'/inc/lib.pwt.backup.php';
$__autoload['postWidgetTextList'] =
dirname(__FILE__).'/inc/lib.pwt.list.php';

View File

@ -12,7 +12,6 @@
*/ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }

View File

@ -12,7 +12,6 @@
*/ */
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null; return null;
} }
@ -58,7 +57,7 @@ class postWidgetText
public function getWidgets($params, $count_only = false) public function getWidgets($params, $count_only = false)
{ {
if (!isset($params['columns'])) $params['columns'] = array(); if (!isset($params['columns'])) $params['columns'] = [];
$params['columns'][] = 'option_id'; $params['columns'][] = 'option_id';
$params['columns'][] = 'option_creadt'; $params['columns'][] = 'option_creadt';
$params['columns'][] = 'option_upddt'; $params['columns'][] = 'option_upddt';
@ -230,11 +229,11 @@ class postWidgetText
$excerpt = $excerpt_xhtml = ''; $excerpt = $excerpt_xhtml = '';
# --BEHAVIOR-- coreAfterPostContentFormat # --BEHAVIOR-- coreAfterPostContentFormat
$this->core->callBehavior('coreAfterPostContentFormat',array( $this->core->callBehavior('coreAfterPostContentFormat', [
'excerpt' => &$excerpt, 'excerpt' => &$excerpt,
'content' => &$content, 'content' => &$content,
'excerpt_xhtml' => &$excerpt_xhtml, 'excerpt_xhtml' => &$excerpt_xhtml,
'content_xhtml' => &$content_xhtml 'content_xhtml' => &$content_xhtml
)); ]);
} }
} }

View File

@ -12,7 +12,6 @@
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -52,15 +51,15 @@ class postWidgetTextAdmin
public static function form($main, $sidebar, $post) public static function form($main, $sidebar, $post)
{ {
# _POST fields # _POST fields
$title = empty($_POST['post_wtitle']) ? '' : $_POST['post_wtitle']; $title = $_POST['post_wtitle'] ?? '';
$content = empty($_POST['post_wtext']) ? '' : $_POST['post_wtext']; $content = $_POST['post_wtext'] ?? '';
# Existing post # Existing post
if ($post) { if ($post) {
$post_id = (integer) $post->post_id; $post_id = (integer) $post->post_id;
$pwt = new postWidgetText($GLOBALS['core']); $pwt = new postWidgetText($GLOBALS['core']);
$w = $pwt->getWidgets(array('post_id' => $post_id)); $w = $pwt->getWidgets(['post_id' => $post_id]);
# Existing widget # Existing widget
if (!$w->isEmpty()) { if (!$w->isEmpty()) {
@ -73,7 +72,7 @@ class postWidgetTextAdmin
'<div id="post-wtext-form">' . '<div id="post-wtext-form">' .
'<h4>' . __('Additional widget') . '</h4>' . '<h4>' . __('Additional widget') . '</h4>' .
'<p class="col">'. '<p class="col">'
'<label class="bold" for="post_wtitle">' . __('Widget title:') . '</label>' . '<label class="bold" for="post_wtitle">' . __('Widget title:') . '</label>' .
form::field('post_wtitle', 20, 255, html::escapeHTML($title), 'maximal') . form::field('post_wtitle', 20, 255, html::escapeHTML($title), 'maximal') .
'</p>' . '</p>' .
@ -91,16 +90,14 @@ class postWidgetTextAdmin
$post_id = (integer) $post_id; $post_id = (integer) $post_id;
# _POST fields # _POST fields
$title = isset($_POST['post_wtitle']) && !empty($_POST['post_wtitle']) ? $title = $_POST['post_wtitle'] ?? '';
$_POST['post_wtitle'] : ''; $content = $_POST['post_wtext'] ?? '';
$content = isset($_POST['post_wtext']) && !empty($_POST['post_wtext']) ?
$_POST['post_wtext'] : '';
# Object # Object
$pwt = new postWidgetText($GLOBALS['core']); $pwt = new postWidgetText($GLOBALS['core']);
# Get existing widget # Get existing widget
$w = $pwt->getWidgets(array('post_id'=>$post_id)); $w = $pwt->getWidgets(['post_id' => $post_id]);
# If new content is empty, delete old existing widget # If new content is empty, delete old existing widget
if (empty($title) && empty($content) && !$w->isEmpty()) { if (empty($title) && empty($content) && !$w->isEmpty()) {
@ -136,7 +133,7 @@ class postWidgetTextAdmin
$pwt = new postWidgetText($GLOBALS['core']); $pwt = new postWidgetText($GLOBALS['core']);
# Get existing widget # Get existing widget
$w = $pwt->getWidgets(array('post_id'=>$post_id)); $w = $pwt->getWidgets(['post_id' => $post_id]);
# If new content is empty, delete old existing widget # If new content is empty, delete old existing widget
if (!$w->isEmpty()) { if (!$w->isEmpty()) {

View File

@ -12,7 +12,6 @@
*/ */
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null; return null;
} }
@ -63,9 +62,9 @@ class postWidgetTextBackup
) { ) {
$line->post_id = $bk->old_ids['post'][(integer) $line->post_id]; $line->post_id = $bk->old_ids['post'][(integer) $line->post_id];
$exists = $bk->postwidgettext->getWidgets(array( $exists = $bk->postwidgettext->getWidgets([
'post_id' => $line->post_id) 'post_id' => $line->post_id
); ]);
if ($exists->isEmpty()) { if ($exists->isEmpty()) {
$bk->cur_postwidgettext->clean(); $bk->cur_postwidgettext->clean();
@ -93,9 +92,9 @@ class postWidgetTextBackup
public static function importFull($line, $bk, dcCore $core) public static function importFull($line, $bk, dcCore $core)
{ {
if ($line->__name == 'postwidgettext') { if ($line->__name == 'postwidgettext') {
$exists = $bk->postwidgettext->getWidgets(array( $exists = $bk->postwidgettext->getWidgets([
'post_id' => $line->post_id) 'post_id' => $line->post_id
); ]);
if ($exists->isEmpty()) { if ($exists->isEmpty()) {
$bk->cur_postwidgettext->clean(); $bk->cur_postwidgettext->clean();

View File

@ -31,20 +31,14 @@ class postWidgetTextDashboard
*/ */
public static function favorites(dcCore $core, $favs) public static function favorites(dcCore $core, $favs)
{ {
$favs->register('postWidgetText', array( $favs->register('postWidgetText', [
'title' => __('Post widget text'), 'title' => __('Post widget text'),
'url' => 'plugin.php?p=postWidgetText', 'url' => $core->adminurl->get('admin.plugin.postWidgetText'),
'small-icon' => 'index.php?pf=postWidgetText/icon.png', 'small-icon' => dcPage::getPF('postWidgetText/icon.png'),
'large-icon' => 'index.php?pf=postWidgetText/icon-big.png', 'large-icon' => dcPage::getPF('postWidgetText/icon-big.png'),
'permissions' => $core->auth->check( 'permissions' => $core->auth->check('usage,contentadmin', $core->blog->id),
'usage,contentadmin', 'active_cb' => ['postWidgetTextDashboard', 'active']
$core->blog->id ]);
),
'active_cb' => array(
'postWidgetTextDashboard',
'active'
)
));
} }
/** /**