cosmetics
parent
d2a2b18308
commit
ebfc5f0710
10
_define.php
10
_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'
|
||||
]
|
||||
);
|
18
_prepend.php
18
_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';
|
||||
$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';
|
|
@ -12,7 +12,6 @@
|
|||
*/
|
||||
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
));
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -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'] =
|
||||
'<div id="post-wtext-form">'.
|
||||
'<h4>'.__('Additional widget').'</h4>'.
|
||||
'<div id="post-wtext-form">' .
|
||||
'<h4>' . __('Additional widget') . '</h4>' .
|
||||
|
||||
'<p class="col">'.
|
||||
'<label class="bold" for="post_wtitle">'.__('Widget title:').'</label>'.
|
||||
form::field('post_wtitle',20,255,html::escapeHTML($title),'maximal').
|
||||
'</p>'.
|
||||
'<p class="col">'
|
||||
'<label class="bold" for="post_wtitle">' . __('Widget title:') . '</label>' .
|
||||
form::field('post_wtitle', 20, 255, html::escapeHTML($title), 'maximal') .
|
||||
'</p>' .
|
||||
|
||||
'<p class="area" id="post-wtext">'.
|
||||
'<label class="bold" for="post_wtext">'.__('Wigdet text:').'</label>'.
|
||||
form::textarea('post_wtext',50,5,html::escapeHTML($content)).
|
||||
'</p>'.
|
||||
'<p class="area" id="post-wtext">' .
|
||||
'<label class="bold" for="post_wtext">' .__('Wigdet text:') . '</label>' .
|
||||
form::textarea('post_wtext', 50, 5, html::escapeHTML($content)) .
|
||||
'</p>' .
|
||||
|
||||
'</div>';
|
||||
}
|
||||
|
@ -91,16 +90,14 @@ class postWidgetTextAdmin
|
|||
$post_id = (integer) $post_id;
|
||||
|
||||
# _POST fields
|
||||
$title = isset($_POST['post_wtitle']) && !empty($_POST['post_wtitle']) ?
|
||||
$_POST['post_wtitle'] : '';
|
||||
$content = isset($_POST['post_wtext']) && !empty($_POST['post_wtext']) ?
|
||||
$_POST['post_wtext'] : '';
|
||||
$title = $_POST['post_wtitle'] ?? '';
|
||||
$content = $_POST['post_wtext'] ?? '';
|
||||
|
||||
# Object
|
||||
$pwt = new postWidgetText($GLOBALS['core']);
|
||||
|
||||
# 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 (empty($title) && empty($content) && !$w->isEmpty()) {
|
||||
|
@ -111,11 +108,11 @@ class postWidgetTextAdmin
|
|||
if (!empty($title) || !empty($content)) {
|
||||
$wcur = $pwt->openCursor();
|
||||
$wcur->post_id = $post_id;
|
||||
$wcur->option_type = 'postwidgettext';
|
||||
$wcur->option_lang = $cur->post_lang;
|
||||
$wcur->option_format = $cur->post_format;
|
||||
$wcur->option_title = $title;
|
||||
$wcur->option_content = $content;
|
||||
$wcur->option_type = 'postwidgettext';
|
||||
$wcur->option_lang = $cur->post_lang;
|
||||
$wcur->option_format = $cur->post_format;
|
||||
$wcur->option_title = $title;
|
||||
$wcur->option_content = $content;
|
||||
|
||||
# Create widget
|
||||
if ($w->isEmpty()) {
|
||||
|
@ -123,7 +120,7 @@ class postWidgetTextAdmin
|
|||
}
|
||||
# Upddate widget
|
||||
else {
|
||||
$pwt->updWidget($w->option_id,$wcur);
|
||||
$pwt->updWidget($w->option_id, $wcur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +133,7 @@ class postWidgetTextAdmin
|
|||
$pwt = new postWidgetText($GLOBALS['core']);
|
||||
|
||||
# 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 (!$w->isEmpty()) {
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
*/
|
||||
|
||||
if (!defined('DC_CONTEXT_ADMIN')) {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -26,12 +25,12 @@ class postWidgetTextBackup
|
|||
public static function exportSingle(dcCore $core, $exp, $blog_id)
|
||||
{
|
||||
$exp->export('postwidgettext',
|
||||
'SELECT option_type, option_content, '.
|
||||
'option_content_xhtml, W.post_id '.
|
||||
'FROM '.$core->prefix.'post_option W '.
|
||||
'LEFT JOIN '.$core->prefix.'post P '.
|
||||
'ON P.post_id = W.post_id '.
|
||||
"WHERE P.blog_id = '".$blog_id."' ".
|
||||
'SELECT option_type, option_content, ' .
|
||||
'option_content_xhtml, W.post_id ' .
|
||||
'FROM ' . $core->prefix . 'post_option W ' .
|
||||
'LEFT JOIN ' . $core->prefix . 'post P ' .
|
||||
'ON P.post_id = W.post_id ' .
|
||||
"WHERE P.blog_id = '" . $blog_id . "' " .
|
||||
"AND W.option_type = 'postwidgettext' "
|
||||
);
|
||||
}
|
||||
|
@ -39,11 +38,11 @@ class postWidgetTextBackup
|
|||
public static function exportFull(dcCore $core, $exp)
|
||||
{
|
||||
$exp->export('postwidgettext',
|
||||
'SELECT option_type, option_content, '.
|
||||
'SELECT option_type, option_content, ' .
|
||||
'option_content_xhtml, W.post_id '.
|
||||
'FROM '.$core->prefix.'post_option W '.
|
||||
'LEFT JOIN '.$core->prefix.'post P '.
|
||||
'ON P.post_id = W.post_id '.
|
||||
'FROM ' . $core->prefix . 'post_option W ' .
|
||||
'LEFT JOIN ' . $core->prefix . 'post P ' .
|
||||
'ON P.post_id = W.post_id ' .
|
||||
"WHERE W.option_type = 'postwidgettext' "
|
||||
);
|
||||
}
|
||||
|
@ -51,7 +50,7 @@ class postWidgetTextBackup
|
|||
public static function importInit($bk, dcCore $core)
|
||||
{
|
||||
$bk->cur_postwidgettext = $core->con->openCursor(
|
||||
$core->prefix.'post_option'
|
||||
$core->prefix . 'post_option'
|
||||
);
|
||||
$bk->postwidgettext = new postWidgetText($core);
|
||||
}
|
||||
|
@ -63,9 +62,9 @@ class postWidgetTextBackup
|
|||
) {
|
||||
$line->post_id = $bk->old_ids['post'][(integer) $line->post_id];
|
||||
|
||||
$exists = $bk->postwidgettext->getWidgets(array(
|
||||
'post_id' => $line->post_id)
|
||||
);
|
||||
$exists = $bk->postwidgettext->getWidgets([
|
||||
'post_id' => $line->post_id
|
||||
]);
|
||||
|
||||
if ($exists->isEmpty()) {
|
||||
$bk->cur_postwidgettext->clean();
|
||||
|
@ -90,12 +89,12 @@ class postWidgetTextBackup
|
|||
}
|
||||
}
|
||||
|
||||
public static function importFull($line ,$bk, dcCore $core)
|
||||
public static function importFull($line, $bk, dcCore $core)
|
||||
{
|
||||
if ($line->__name == 'postwidgettext') {
|
||||
$exists = $bk->postwidgettext->getWidgets(array(
|
||||
'post_id' => $line->post_id)
|
||||
);
|
||||
$exists = $bk->postwidgettext->getWidgets([
|
||||
'post_id' => $line->post_id
|
||||
]);
|
||||
|
||||
if ($exists->isEmpty()) {
|
||||
$bk->cur_postwidgettext->clean();
|
||||
|
|
|
@ -31,20 +31,14 @@ class postWidgetTextDashboard
|
|||
*/
|
||||
public static function favorites(dcCore $core, $favs)
|
||||
{
|
||||
$favs->register('postWidgetText', array(
|
||||
'title' => __('Post widget text'),
|
||||
'url' => 'plugin.php?p=postWidgetText',
|
||||
'small-icon' => 'index.php?pf=postWidgetText/icon.png',
|
||||
'large-icon' => 'index.php?pf=postWidgetText/icon-big.png',
|
||||
'permissions' => $core->auth->check(
|
||||
'usage,contentadmin',
|
||||
$core->blog->id
|
||||
),
|
||||
'active_cb' => array(
|
||||
'postWidgetTextDashboard',
|
||||
'active'
|
||||
)
|
||||
));
|
||||
$favs->register('postWidgetText', [
|
||||
'title' => __('Post widget text'),
|
||||
'url' => $core->adminurl->get('admin.plugin.postWidgetText'),
|
||||
'small-icon' => dcPage::getPF('postWidgetText/icon.png'),
|
||||
'large-icon' => dcPage::getPF('postWidgetText/icon-big.png'),
|
||||
'permissions' => $core->auth->check('usage,contentadmin', $core->blog->id),
|
||||
'active_cb' => ['postWidgetTextDashboard', 'active']
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,56 +36,56 @@ class postWidgetTextList extends adminGenericList
|
|||
$pager->var_page = 'page';
|
||||
|
||||
$content =
|
||||
'<div class="table-outer">'.
|
||||
'<table class="clear">'.
|
||||
'<thead>'.
|
||||
'<tr>'.
|
||||
'<th colspan="2" class="nowrap">'.__('Post title').'</th>'.
|
||||
'<th class="nowrap">'.__('Post date').'</th>'.
|
||||
'<th class="nowrap">'.__('Widget title').'</th>'.
|
||||
'<th class="nowrap">'.__('Widget date').'</th>'.
|
||||
'<th class="nowrap">'.__('Author').'</th>'.
|
||||
'<th class="nowrap">'.__('Type').'</th>'.
|
||||
'<div class="table-outer">' .
|
||||
'<table class="clear">' .
|
||||
'<thead>' .
|
||||
'<tr>' .
|
||||
'<th colspan="2" class="nowrap">' . __('Post title') . '</th>' .
|
||||
'<th class="nowrap">' . __('Post date') . '</th>' .
|
||||
'<th class="nowrap">' . __('Widget title') . '</th>' .
|
||||
'<th class="nowrap">' . __('Widget date') . '</th>' .
|
||||
'<th class="nowrap">' . __('Author') . '</th>' .
|
||||
'<th class="nowrap">' . __('Type') . '</th>' .
|
||||
'</tr></thead><tbody>';
|
||||
|
||||
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_filter(
|
||||
$this->rs->option_content, 1, 1, 80, 0, 0
|
||||
).'</em>';
|
||||
) . '</em>';
|
||||
}
|
||||
|
||||
$content .=
|
||||
'<tr class="line'.($this->rs->post_status != 1 ?
|
||||
'<tr class="line' . ($this->rs->post_status != 1 ?
|
||||
' offline' : ''
|
||||
).'" id="p'.$this->rs->post_id.'">'.
|
||||
'<td class="nowrap">'.
|
||||
) . '" id="p' . $this->rs->post_id . '">' .
|
||||
'<td class="nowrap">' .
|
||||
form::checkbox(
|
||||
array('widgets[]'),
|
||||
$this->rs->option_id,
|
||||
'', '', '',
|
||||
!$this->rs->isEditable()
|
||||
).'</td>'.
|
||||
'<td class="maximal"><a href="'.
|
||||
) . '</td>' .
|
||||
'<td class="maximal"><a href="' .
|
||||
$this->core->getPostAdminURL(
|
||||
$this->rs->post_type,
|
||||
$this->rs->post_id
|
||||
).'#post-wtext-form">'.
|
||||
html::escapeHTML($this->rs->post_title).
|
||||
'</a></td>'.
|
||||
'<td class="nowrap">'.dt::dt2str(
|
||||
) . '#post-wtext-form">' .
|
||||
html::escapeHTML($this->rs->post_title) .
|
||||
'</a></td>' .
|
||||
'<td class="nowrap">' . dt::dt2str(
|
||||
__('%Y-%m-%d %H:%M'),
|
||||
$this->rs->post_dt
|
||||
).'</td>'.
|
||||
'<td class="nowrap">'.$w_title.'</td>'.
|
||||
'<td class="nowrap">'.dt::dt2str(
|
||||
) . '</td>' .
|
||||
'<td class="nowrap">' . $w_title . '</td>' .
|
||||
'<td class="nowrap">' . dt::dt2str(
|
||||
__('%Y-%m-%d %H:%M'),
|
||||
$this->rs->option_upddt
|
||||
).'</td>'.
|
||||
'<td class="nowrap">'.$this->rs->user_id.'</td>'.
|
||||
'<td class="nowrap">'.$this->rs->post_type.'</td>'.
|
||||
) . '</td>' .
|
||||
'<td class="nowrap">' . $this->rs->user_id . '</td>' .
|
||||
'<td class="nowrap">' . $this->rs->post_type . '</td>' .
|
||||
'</tr>';
|
||||
}
|
||||
|
||||
|
@ -93,8 +93,8 @@ class postWidgetTextList extends adminGenericList
|
|||
'</tbody></table></div>';
|
||||
|
||||
echo
|
||||
$pager->getLinks().
|
||||
sprintf($enclose, $content).
|
||||
$pager->getLinks() .
|
||||
sprintf($enclose, $content) .
|
||||
$pager->getLinks();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue