update to PSR12
parent
f024b01c85
commit
05a623e4fb
|
@ -1,7 +1,9 @@
|
|||
dev
|
||||
- ...
|
||||
- fix error on empty record on widget
|
||||
- update to PS12
|
||||
|
||||
2021.11.01
|
||||
2021.10.30
|
||||
- clean up code
|
||||
- update license
|
||||
- update translations
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
|
21
_install.php
21
_install.php
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
@ -47,10 +46,22 @@ try {
|
|||
|
||||
# Settings
|
||||
$core->blog->settings->addNamespace('postwidgettext');
|
||||
$core->blog->settings->postwidgettext->put('postwidgettext_active',
|
||||
true, 'boolean', 'post widget text plugin enabled', false, true);
|
||||
$core->blog->settings->postwidgettext->put('postwidgettext_importexport_active',
|
||||
true, 'boolean', 'activate import/export behaviors', false, true);
|
||||
$core->blog->settings->postwidgettext->put(
|
||||
'postwidgettext_active',
|
||||
true,
|
||||
'boolean',
|
||||
'post widget text plugin enabled',
|
||||
false,
|
||||
true
|
||||
);
|
||||
$core->blog->settings->postwidgettext->put(
|
||||
'postwidgettext_importexport_active',
|
||||
true,
|
||||
'boolean',
|
||||
'activate import/export behaviors',
|
||||
false,
|
||||
true
|
||||
);
|
||||
|
||||
# Transfert records from old table to the new one
|
||||
if ($core->getVersion('postWidgetText') !== null
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return null;
|
||||
}
|
||||
|
@ -62,7 +61,9 @@ class postWidgetText
|
|||
|
||||
public function getWidgets($params, $count_only = false)
|
||||
{
|
||||
if (!isset($params['columns'])) $params['columns'] = [];
|
||||
if (!isset($params['columns'])) {
|
||||
$params['columns'] = [];
|
||||
}
|
||||
$params['columns'][] = 'option_id';
|
||||
$params['columns'][] = 'option_creadt';
|
||||
$params['columns'][] = 'option_upddt';
|
||||
|
@ -83,8 +84,7 @@ class postWidgetText
|
|||
}
|
||||
if (isset($params['option_type'])) {
|
||||
$params['sql'] .= "AND W.option_type = '" . $this->con->escape($params['option_type']) . "' ";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$params['sql'] .= "AND W.option_type = 'postwidgettext' ";
|
||||
}
|
||||
unset($params['option_type']);
|
||||
|
@ -107,13 +107,14 @@ class postWidgetText
|
|||
}
|
||||
|
||||
$this->lockTable();
|
||||
|
||||
try {
|
||||
$rs = $this->con->select(
|
||||
'SELECT MAX(option_id) ' .
|
||||
'FROM ' . $this->table
|
||||
);
|
||||
|
||||
$cur->option_id = (integer) $rs->f(0) + 1;
|
||||
$cur->option_id = (int) $rs->f(0) + 1;
|
||||
$cur->option_creadt = date('Y-m-d H:i:s');
|
||||
$cur->option_upddt = date('Y-m-d H:i:s');
|
||||
|
||||
|
@ -121,9 +122,9 @@ class postWidgetText
|
|||
|
||||
$cur->insert();
|
||||
$this->unlockTable();
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$this->unlockTable();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
||||
|
@ -138,7 +139,7 @@ class postWidgetText
|
|||
throw new Exception(__('You are not allowed to update entries text widget'));
|
||||
}
|
||||
|
||||
$id = (integer) $id;
|
||||
$id = (int) $id;
|
||||
|
||||
if (empty($id)) {
|
||||
throw new Exception(__('No such ID'));
|
||||
|
@ -171,7 +172,7 @@ class postWidgetText
|
|||
throw new Exception(__('You are not allowed to delete entries text widget'));
|
||||
}
|
||||
|
||||
$id = (integer) $id;
|
||||
$id = (int) $id;
|
||||
|
||||
if (empty($id)) {
|
||||
throw new Exception(__('No such ID'));
|
||||
|
@ -205,8 +206,11 @@ class postWidgetText
|
|||
$option_content_xhtml = $cur->option_content_xhtml;
|
||||
|
||||
$this->setWidgetContent(
|
||||
$option_id,$cur->option_format,$cur->option_lang,
|
||||
$option_content,$option_content_xhtml
|
||||
$option_id,
|
||||
$cur->option_format,
|
||||
$cur->option_lang,
|
||||
$option_content,
|
||||
$option_content_xhtml
|
||||
);
|
||||
|
||||
$cur->option_content = $option_content;
|
||||
|
@ -226,8 +230,7 @@ class postWidgetText
|
|||
if ($content) {
|
||||
$content_xhtml = $this->core->callFormater($format, $content);
|
||||
$content_xhtml = $this->core->HTMLfilter($content_xhtml);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$content_xhtml = '';
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ingroup DC_PLUGIN_POSTWIDGETTEXT
|
||||
* @brief postWidgetText - admin methods.
|
||||
|
@ -47,12 +46,12 @@ class adminPostWidgetText
|
|||
<div class="two-cols">
|
||||
<div class="col">
|
||||
<p><label for="active">' .
|
||||
form::checkbox('active', 1, (boolean) $blog_settings->postwidgettext->postwidgettext_active).
|
||||
form::checkbox('active', 1, (bool) $blog_settings->postwidgettext->postwidgettext_active) .
|
||||
__('Enable post widget text on this blog') . '</label></p>
|
||||
</div>
|
||||
<div class="col">
|
||||
<p><label for="importexport_active">' .
|
||||
form::checkbox('importexport_active', 1, (boolean) $blog_settings->postwidgettext->postwidgettext_importexport_active).
|
||||
form::checkbox('importexport_active', 1, (bool) $blog_settings->postwidgettext->postwidgettext_importexport_active) .
|
||||
__('Enable import/export behaviors') . '</label></p>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -109,7 +108,7 @@ class adminPostWidgetText
|
|||
|
||||
# Existing post
|
||||
if ($post) {
|
||||
$post_id = (integer) $post->post_id;
|
||||
$post_id = (int) $post->post_id;
|
||||
|
||||
$pwt = new postWidgetText($GLOBALS['core']);
|
||||
$w = $pwt->getWidgets(['post_id' => $post_id]);
|
||||
|
@ -121,8 +120,7 @@ class adminPostWidgetText
|
|||
}
|
||||
}
|
||||
|
||||
$main['post_widget'] =
|
||||
'<div id="post-wtext-form">' .
|
||||
$main['post_widget'] = '<div id="post-wtext-form">' .
|
||||
'<h4>' . __('Additional widget') . '</h4>' .
|
||||
|
||||
'<p class="col">' .
|
||||
|
@ -140,7 +138,7 @@ class adminPostWidgetText
|
|||
|
||||
public static function adminAfterPostSave($cur, $post_id)
|
||||
{
|
||||
$post_id = (integer) $post_id;
|
||||
$post_id = (int) $post_id;
|
||||
|
||||
# _POST fields
|
||||
$title = $_POST['post_wtitle'] ?? '';
|
||||
|
@ -180,7 +178,7 @@ class adminPostWidgetText
|
|||
|
||||
public static function adminBeforePostDelete($post_id)
|
||||
{
|
||||
$post_id = (integer) $post_id;
|
||||
$post_id = (int) $post_id;
|
||||
|
||||
# Object
|
||||
$pwt = new postWidgetText($GLOBALS['core']);
|
||||
|
@ -196,7 +194,8 @@ class adminPostWidgetText
|
|||
|
||||
public static function exportSingle(dcCore $core, $exp, $blog_id)
|
||||
{
|
||||
$exp->export('postwidgettext',
|
||||
$exp->export(
|
||||
'postwidgettext',
|
||||
'SELECT option_type, option_content, ' .
|
||||
'option_content_xhtml, W.post_id ' .
|
||||
'FROM ' . $core->prefix . 'post_option W ' .
|
||||
|
@ -209,7 +208,8 @@ class adminPostWidgetText
|
|||
|
||||
public static function exportFull(dcCore $core, $exp)
|
||||
{
|
||||
$exp->export('postwidgettext',
|
||||
$exp->export(
|
||||
'postwidgettext',
|
||||
'SELECT option_type, option_content, ' .
|
||||
'option_content_xhtml, W.post_id ' .
|
||||
'FROM ' . $core->prefix . 'post_option W ' .
|
||||
|
@ -230,9 +230,9 @@ class adminPostWidgetText
|
|||
public static function importSingle($line, $bk, dcCore $core)
|
||||
{
|
||||
if ($line->__name == 'postwidgettext'
|
||||
&& isset($bk->old_ids['post'][(integer) $line->post_id])
|
||||
&& isset($bk->old_ids['post'][(int) $line->post_id])
|
||||
) {
|
||||
$line->post_id = $bk->old_ids['post'][(integer) $line->post_id];
|
||||
$line->post_id = $bk->old_ids['post'][(int) $line->post_id];
|
||||
|
||||
$exists = $bk->postwidgettext->getWidgets([
|
||||
'post_id' => $line->post_id
|
||||
|
@ -241,18 +241,12 @@ class adminPostWidgetText
|
|||
if ($exists->isEmpty()) {
|
||||
$bk->cur_postwidgettext->clean();
|
||||
|
||||
$bk->cur_postwidgettext->post_id =
|
||||
(integer) $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;
|
||||
$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;
|
||||
|
||||
$bk->postwidgettext->addWidget(
|
||||
$bk->cur_postwidgettext
|
||||
|
@ -271,18 +265,12 @@ class adminPostWidgetText
|
|||
if ($exists->isEmpty()) {
|
||||
$bk->cur_postwidgettext->clean();
|
||||
|
||||
$bk->cur_postwidgettext->post_id =
|
||||
(integer) $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;
|
||||
$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;
|
||||
|
||||
$bk->postwidgettext->addWidget(
|
||||
$bk->cur_postwidgettext
|
||||
|
|
|
@ -10,9 +10,7 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -26,7 +24,6 @@ class listPostWidgetText extends adminGenericList
|
|||
public function display($page, $nb_per_page, $enclose = '')
|
||||
{
|
||||
if ($this->rs->isEmpty()) {
|
||||
|
||||
return '<p><strong>' . __('No widget') . '</strong></p>';
|
||||
}
|
||||
|
||||
|
@ -35,8 +32,7 @@ class listPostWidgetText extends adminGenericList
|
|||
$pager->html_next = $this->html_next;
|
||||
$pager->var_page = 'page';
|
||||
|
||||
$content =
|
||||
'<div class="table-outer">' .
|
||||
$content = '<div class="table-outer">' .
|
||||
'<table class="clear">' .
|
||||
'<thead>' .
|
||||
'<tr>' .
|
||||
|
@ -49,23 +45,29 @@ class listPostWidgetText extends adminGenericList
|
|||
'</tr></thead><tbody>';
|
||||
|
||||
while ($this->rs->fetch()) {
|
||||
|
||||
$w_title = html::escapeHTML($this->rs->option_title);
|
||||
if ($w_title == '') {
|
||||
$w_title = '<em>' . context::global_filter(
|
||||
$this->rs->option_content, 1, 1, 80, 0, 0
|
||||
$this->rs->option_content,
|
||||
1,
|
||||
1,
|
||||
80,
|
||||
0,
|
||||
0
|
||||
) . '</em>';
|
||||
}
|
||||
|
||||
$content .=
|
||||
'<tr class="line' . ($this->rs->post_status != 1 ?
|
||||
$content .= '<tr class="line' . (
|
||||
$this->rs->post_status != 1 ?
|
||||
' offline' : ''
|
||||
) . '" id="p' . $this->rs->post_id . '">' .
|
||||
'<td class="nowrap">' .
|
||||
form::checkbox(
|
||||
array('widgets[]'),
|
||||
['widgets[]'],
|
||||
$this->rs->option_id,
|
||||
'', '', '',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
!$this->rs->isEditable()
|
||||
) . '</td>' .
|
||||
'<td class="maximal"><a href="' .
|
||||
|
@ -89,8 +91,7 @@ class listPostWidgetText extends adminGenericList
|
|||
'</tr>';
|
||||
}
|
||||
|
||||
$content .=
|
||||
'</tbody></table></div>';
|
||||
$content .= '</tbody></table></div>';
|
||||
|
||||
echo
|
||||
$pager->getLinks() .
|
||||
|
|
|
@ -10,19 +10,16 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
$records = $core->con->select(
|
||||
'SELECT W.*, P.post_lang, P.post_format FROM ' . $core->prefix . 'post_wtext W ' .
|
||||
'LEFT JOIN ' . $core->prefix . 'post P ON P.post_id=W.post_id '
|
||||
);
|
||||
if (!$records->isEmpty())
|
||||
{
|
||||
if (!$records->isEmpty()) {
|
||||
$cur = $core->con->openCursor($core->prefix . 'post_option');
|
||||
while ($records->fetch())
|
||||
{
|
||||
while ($records->fetch()) {
|
||||
$core->con->writeLock($core->prefix . 'post_option');
|
||||
try {
|
||||
|
||||
try {
|
||||
$id = $core->con->select(
|
||||
'SELECT MAX(option_id) FROM ' . $core->prefix . 'post_option'
|
||||
)->f(0) + 1;
|
||||
|
@ -42,10 +39,9 @@ if (!$records->isEmpty())
|
|||
|
||||
$cur->insert();
|
||||
$core->con->unlock();
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
} catch (Exception $e) {
|
||||
$core->con->unlock();
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
|
13
index.php
13
index.php
|
@ -10,7 +10,6 @@
|
|||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
return null;
|
||||
}
|
||||
|
@ -23,7 +22,7 @@ $pwt = new postWidgetText($core);
|
|||
if (!empty($_POST['save']) && !empty($_POST['widgets'])) {
|
||||
try {
|
||||
foreach ($_POST['widgets'] as $k => $id) {
|
||||
$id = (integer) $id;
|
||||
$id = (int) $id;
|
||||
$pwt->delWidget($id);
|
||||
}
|
||||
|
||||
|
@ -35,8 +34,7 @@ if (!empty($_POST['save']) && !empty($_POST['widgets'])) {
|
|||
} else {
|
||||
$core->adminurl->redirect('admin.plugin.postWidgetText');
|
||||
}
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
@ -51,8 +49,7 @@ try {
|
|||
$posts = $pwt->getWidgets($params);
|
||||
$counter = $pwt->getWidgets($params, true);
|
||||
$posts_list = new listPostWidgetText($core, $posts, $counter->f(0));
|
||||
}
|
||||
catch (Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
$core->error->add($e->getMessage());
|
||||
}
|
||||
|
||||
|
@ -72,7 +69,9 @@ dcPage::notices();
|
|||
|
||||
$filter->display('admin.plugin.postWidgetText', form::hidden('p', 'postWidgetText'));
|
||||
|
||||
$posts_list->display($filter->page, $filter->nb,
|
||||
$posts_list->display(
|
||||
$filter->page,
|
||||
$filter->nb,
|
||||
'<form action="' . $core->adminurl->get('admin.plugin.postWidgetText') . '" method="post" id="form-entries">' .
|
||||
'%s' .
|
||||
'<div class="two-cols">' .
|
||||
|
|
Loading…
Reference in New Issue