diff --git a/_define.php b/_define.php index f38af86..8d0e559 100644 --- a/_define.php +++ b/_define.php @@ -21,11 +21,11 @@ $this->registerModule( 'Jean-Christian Denis and Contributors', '2021.00.00.1', [ - 'requires' => [['core', '2.19']], + 'requires' => [['core', '2.19']], 'permissions' => 'usage,contentadmin', - 'type'=> 'plugin', - 'support'=> 'https://github.com/JcDenis/postWidgetText', - 'details'=> 'https://plugins.dotaddict.org/dc2/details/postWidgetText', - 'repository' => 'https://raw.githubusercontent.com/JcDenis/postWidgetText/master/dcstore.xml' + 'type' => 'plugin', + 'support' => 'https://github.com/JcDenis/postWidgetText', + 'details' => 'https://plugins.dotaddict.org/dc2/details/postWidgetText', + 'repository' => 'https://raw.githubusercontent.com/JcDenis/postWidgetText/master/dcstore.xml' ] ); \ No newline at end of file diff --git a/_prepend.php b/_prepend.php index 783e73c..169e4c9 100644 --- a/_prepend.php +++ b/_prepend.php @@ -12,17 +12,13 @@ */ if (!defined('DC_RC_PATH')) { - return null; } -$__autoload['postWidgetText'] = - dirname(__FILE__).'/inc/class.postwidgettext.php'; -$__autoload['postWidgetTextDashboard'] = - dirname(__FILE__).'/inc/lib.pwt.dashboard.php'; -$__autoload['postWidgetTextAdmin'] = - dirname(__FILE__).'/inc/lib.pwt.admin.php'; -$__autoload['postWidgetTextBackup'] = - dirname(__FILE__).'/inc/lib.pwt.backup.php'; -$__autoload['postWidgetTextList'] = - dirname(__FILE__).'/inc/lib.pwt.list.php'; \ No newline at end of file +$d = dirname(__FILE__) . '/inc/'; + +$__autoload['postWidgetText'] = $d . 'class.postwidgettext.php'; +$__autoload['postWidgetTextDashboard'] = $d . 'lib.pwt.dashboard.php'; +$__autoload['postWidgetTextAdmin'] = $d . 'lib.pwt.admin.php'; +$__autoload['postWidgetTextBackup'] = $d . 'lib.pwt.backup.php'; +$__autoload['postWidgetTextList'] = $d . 'lib.pwt.list.php'; \ No newline at end of file diff --git a/_public.php b/_public.php index 8e01a8a..360c9dc 100644 --- a/_public.php +++ b/_public.php @@ -12,7 +12,6 @@ */ if (!defined('DC_RC_PATH')) { - return null; } diff --git a/inc/class.postwidgettext.php b/inc/class.postwidgettext.php index b97d923..e29fc79 100644 --- a/inc/class.postwidgettext.php +++ b/inc/class.postwidgettext.php @@ -12,7 +12,6 @@ */ if (!defined('DC_RC_PATH')) { - return null; } @@ -27,7 +26,7 @@ class postWidgetText { $this->core =& $core; $this->con =& $this->core->con; - $this->table = $this->core->prefix.'post_option'; + $this->table = $this->core->prefix . 'post_option'; $this->blog = $core->con->escape($core->blog->id); } @@ -56,9 +55,9 @@ class postWidgetText $this->core->blog->triggerBlog(); } - 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_creadt'; $params['columns'][] = 'option_upddt'; @@ -72,13 +71,13 @@ class postWidgetText if (!isset($params['from'])) { $params['from'] = ''; } - $params['from'] .= 'LEFT JOIN '.$this->table.' W ON P.post_id=W.post_id '; + $params['from'] .= 'LEFT JOIN ' . $this->table . ' W ON P.post_id=W.post_id '; if (!isset($params['sql'])) { $params['sql'] = ''; } if (isset($params['option_type'])) { - $params['sql'] .= "AND W.option_type = '".$this->con->escape($params['option_type'])."' "; + $params['sql'] .= "AND W.option_type = '" . $this->con->escape($params['option_type']) . "' "; } else { $params['sql'] .= "AND W.option_type = 'postwidgettext' "; @@ -106,7 +105,7 @@ class postWidgetText try { $rs = $this->con->select( 'SELECT MAX(option_id) '. - 'FROM '.$this->table + 'FROM ' . $this->table ); $cur->option_id = (integer) $rs->f(0) + 1; @@ -128,7 +127,7 @@ class postWidgetText return $cur->option_id; } - public function updWidget($id,&$cur) + public function updWidget($id, &$cur) { if (!$this->core->auth->check('usage,contentadmin', $this->blog)) { throw new Exception(__('You are not allowed to update entries text widget')); @@ -140,7 +139,7 @@ class postWidgetText throw new Exception(__('No such ID')); } - $this->getWidgetContent($cur,$id); + $this->getWidgetContent($cur, $id); $cur->option_upddt = date('Y-m-d H:i:s'); @@ -157,11 +156,11 @@ class postWidgetText } } - $cur->update('WHERE option_id = '.$id.' '); + $cur->update('WHERE option_id = ' . $id . ' '); $this->triggerBlog(); } - public function delWidget($id,$type='postwidgettext') + public function delWidget($id, $type = 'postwidgettext') { if (!$this->core->auth->check('delete,contentadmin', $this->blog)) { throw new Exception(__('You are not allowed to delete entries text widget')); @@ -187,9 +186,9 @@ class postWidgetText } $this->con->execute( - 'DELETE FROM '.$this->table.' '. - 'WHERE option_id = '.$id.' '. - "AND option_type = '".$this->con->escape($type)."' " + 'DELETE FROM ' . $this->table . ' ' . + 'WHERE option_id = ' . $id . ' ' . + "AND option_type = '" . $this->con->escape($type) . "' " ); $this->triggerBlog(); @@ -213,14 +212,14 @@ class postWidgetText { if ($format == 'wiki') { $this->core->initWikiPost(); - $this->core->wiki2xhtml->setOpt('note_prefix','wnote-'.$option_id); - if (strpos($lang,'fr') === 0) { + $this->core->wiki2xhtml->setOpt('note_prefix','wnote-' . $option_id); + if (strpos($lang, 'fr') === 0) { $this->core->wiki2xhtml->setOpt('active_fr_syntax', 1); } } if ($content) { - $content_xhtml = $this->core->callFormater($format,$content); + $content_xhtml = $this->core->callFormater($format, $content); $content_xhtml = $this->core->HTMLfilter($content_xhtml); } else { @@ -230,11 +229,11 @@ class postWidgetText $excerpt = $excerpt_xhtml = ''; # --BEHAVIOR-- coreAfterPostContentFormat - $this->core->callBehavior('coreAfterPostContentFormat',array( + $this->core->callBehavior('coreAfterPostContentFormat', [ 'excerpt' => &$excerpt, 'content' => &$content, 'excerpt_xhtml' => &$excerpt_xhtml, 'content_xhtml' => &$content_xhtml - )); + ]); } } \ No newline at end of file diff --git a/inc/lib.pwt.admin.php b/inc/lib.pwt.admin.php index 9697740..0d92fe6 100644 --- a/inc/lib.pwt.admin.php +++ b/inc/lib.pwt.admin.php @@ -12,7 +12,6 @@ */ if (!defined('DC_CONTEXT_ADMIN')) { - return null; } @@ -52,15 +51,15 @@ class postWidgetTextAdmin public static function form($main, $sidebar, $post) { # _POST fields - $title = empty($_POST['post_wtitle']) ? '' : $_POST['post_wtitle']; - $content = empty($_POST['post_wtext']) ? '' : $_POST['post_wtext']; + $title = $_POST['post_wtitle'] ?? ''; + $content = $_POST['post_wtext'] ?? ''; # Existing post if ($post) { $post_id = (integer) $post->post_id; $pwt = new postWidgetText($GLOBALS['core']); - $w = $pwt->getWidgets(array('post_id' => $post_id)); + $w = $pwt->getWidgets(['post_id' => $post_id]); # Existing widget if (!$w->isEmpty()) { @@ -70,18 +69,18 @@ class postWidgetTextAdmin } $main['post_widget'] = - '
'. - ''. - form::field('post_wtitle',20,255,html::escapeHTML($title),'maximal'). - '
'. + '' + '' . + form::field('post_wtitle', 20, 255, html::escapeHTML($title), 'maximal') . + '
' . - ''. - ''. - form::textarea('post_wtext',50,5,html::escapeHTML($content)). - '
'. + '' . + '' . + form::textarea('post_wtext', 50, 5, html::escapeHTML($content)) . + '
' . ''.__('Post title').' | '. - ''.__('Post date').' | '. - ''.__('Widget title').' | '. - ''.__('Widget date').' | '. - ''.__('Author').' | '. - ''.__('Type').' | '. + '
---|
' . __('Post title') . ' | ' . + '' . __('Post date') . ' | ' . + '' . __('Widget title') . ' | ' . + '' . __('Widget date') . ' | ' . + '' . __('Author') . ' | ' . + '' . __('Type') . ' | ' . '|||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
'. + ) . '" id="p' . $this->rs->post_id . '">' . + ' | ' . form::checkbox( array('widgets[]'), $this->rs->option_id, '', '', '', !$this->rs->isEditable() - ).' | '. - ''. - html::escapeHTML($this->rs->post_title). - ' | '. - ''.dt::dt2str( + ) . '#post-wtext-form">' . + html::escapeHTML($this->rs->post_title) . + ' | ' . + '' . dt::dt2str( __('%Y-%m-%d %H:%M'), $this->rs->post_dt - ).' | '. - ''.$w_title.' | '. - ''.dt::dt2str( + ) . ' | ' . + '' . $w_title . ' | ' . + '' . dt::dt2str( __('%Y-%m-%d %H:%M'), $this->rs->option_upddt - ).' | '. - ''.$this->rs->user_id.' | '. - ''.$this->rs->post_type.' | '. + ) . '' . + '' . $this->rs->user_id . ' | ' . + '' . $this->rs->post_type . ' | ' . '