clean up code, first pass

This commit is contained in:
Jean-Christian Denis 2021-09-10 21:18:51 +02:00
parent 7ed1ad5b03
commit c9e185a68c
16 changed files with 1014 additions and 692 deletions

View file

@ -1,95 +1,94 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of postWidgetText, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
/**
* @brief postWidgetText, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
return null;
}
require dirname(__FILE__).'/_widgets.php';
# Admin menu
if ($core->blog->settings->postwidgettext->postwidgettext_active) {
$_menu['Plugins']->addItem(
__('Post widget text'),
'plugin.php?p=postWidgetText',
'index.php?pf=postWidgetText/icon.png',
preg_match(
'/plugin.php\?p=postWidgetText(&.*)?$/',
$_SERVER['REQUEST_URI']),
$core->auth->check('contentadmin', $core->blog->id)
);
$_menu['Plugins']->addItem(
__('Post widget text'),
'plugin.php?p=postWidgetText',
'index.php?pf=postWidgetText/icon.png',
preg_match(
'/plugin.php\?p=postWidgetText(&.*)?$/',
$_SERVER['REQUEST_URI']),
$core->auth->check('contentadmin', $core->blog->id)
);
$core->addBehavior(
'adminDashboardFavorites',
array('postWidgetTextDashboard', 'favorites')
);
$core->addBehavior(
'adminDashboardFavorites',
array('postWidgetTextDashboard', 'favorites')
);
}
# Post
$core->addBehavior(
'adminPostHeaders',
array('postWidgetTextAdmin', 'headers'));
'adminPostHeaders',
array('postWidgetTextAdmin', 'headers'));
$core->addBehavior(
'adminPostFormItems',
array('postWidgetTextAdmin', 'form'));
'adminPostFormItems',
array('postWidgetTextAdmin', 'form'));
$core->addBehavior(
'adminAfterPostUpdate',
array('postWidgetTextAdmin', 'save'));
'adminAfterPostUpdate',
array('postWidgetTextAdmin', 'save'));
$core->addBehavior(
'adminAfterPostCreate',
array('postWidgetTextAdmin', 'save'));
'adminAfterPostCreate',
array('postWidgetTextAdmin', 'save'));
$core->addBehavior(
'adminBeforePostDelete',
array('postWidgetTextAdmin', 'delete'));
'adminBeforePostDelete',
array('postWidgetTextAdmin', 'delete'));
# Plugin "pages"
$core->addBehavior(
'adminPageHeaders',
array('postWidgetTextAdmin', 'headers'));
'adminPageHeaders',
array('postWidgetTextAdmin', 'headers'));
$core->addBehavior(
'adminPageFormItems',
array('postWidgetTextAdmin', 'form'));
'adminPageFormItems',
array('postWidgetTextAdmin', 'form'));
$core->addBehavior(
'adminAfterPageUpdate',
array('postWidgetTextAdmin', 'save'));
'adminAfterPageUpdate',
array('postWidgetTextAdmin', 'save'));
$core->addBehavior(
'adminAfterPageCreate',
array('postWidgetTextAdmin', 'save'));
'adminAfterPageCreate',
array('postWidgetTextAdmin', 'save'));
$core->addBehavior(
'adminBeforePageDelete',
array('postWidgetTextAdmin', 'delete'));
'adminBeforePageDelete',
array('postWidgetTextAdmin', 'delete'));
# Plugin "importExport"
if ($core->blog->settings->postwidgettext->postwidgettext_importexport_active) {
$core->addBehavior(
'exportFull',
array('postWidgetTextBackup', 'exportFull')
);
$core->addBehavior(
'exportSingle',
array('postWidgetTextBackup', 'exportSingle')
);
$core->addBehavior(
'importInit',
array('postWidgetTextBackup', 'importInit')
);
$core->addBehavior(
'importSingle',
array('postWidgetTextBackup', 'importSingle')
);
$core->addBehavior(
'importFull',
array('postWidgetTextBackup', 'importFull')
);
}
$core->addBehavior(
'exportFull',
array('postWidgetTextBackup', 'exportFull')
);
$core->addBehavior(
'exportSingle',
array('postWidgetTextBackup', 'exportSingle')
);
$core->addBehavior(
'importInit',
array('postWidgetTextBackup', 'importInit')
);
$core->addBehavior(
'importSingle',
array('postWidgetTextBackup', 'importSingle')
);
$core->addBehavior(
'importFull',
array('postWidgetTextBackup', 'importFull')
);
}

View file

@ -1,24 +1,23 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of postWidgetText, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
/**
* @brief postWidgetText, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_MODULE')) {
return null;
return null;
}
$redir = empty($_REQUEST['redir']) ?
$list->getURL().'#plugins' : $_REQUEST['redir'];
$list->getURL().'#plugins' : $_REQUEST['redir'];
# -- Get settings --
$core->blog->settings->addNamespace('postwidgettext');
@ -30,26 +29,26 @@ $importexport_active = (boolean) $s->postwidgettext_importexport_active;
# -- Set settings --
if (!empty($_POST['save'])) {
try {
$active = !empty($_POST['active']);
$importexport_active = !empty($_POST['importexport_active']);
try {
$active = !empty($_POST['active']);
$importexport_active = !empty($_POST['importexport_active']);
$s->put('postwidgettext_active', $active);
$s->put('postwidgettext_importexport_active', $importexport_active);
$s->put('postwidgettext_active', $active);
$s->put('postwidgettext_importexport_active', $importexport_active);
$core->blog->triggerBlog();
$core->blog->triggerBlog();
dcPage::addSuccessNotice(
__('Configuration has been successfully updated.')
);
http::redirect(
$list->getURL('module=postWidgetText&conf=1&redir='.
$list->getRedir())
);
}
catch (Exception $e) {
$core->error->add($e->getMessage());
}
dcPage::addSuccessNotice(
__('Configuration has been successfully updated.')
);
http::redirect(
$list->getURL('module=postWidgetText&conf=1&redir='.
$list->getRedir())
);
}
catch (Exception $e) {
$core->error->add($e->getMessage());
}
}
# -- Display form --

View file

@ -1,17 +1,15 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of postWidgetText, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
/**
* @brief postWidgetText, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;

View file

@ -1,87 +1,86 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of postWidgetText, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
/**
* @brief postWidgetText, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
return null;
}
try {
# Check module version
if (version_compare(
$core->getVersion('postWidgetText'),
$core->plugins->moduleInfo('postWidgetText', 'version'),
'>='
)) {
# Check module version
if (version_compare(
$core->getVersion('postWidgetText'),
$core->plugins->moduleInfo('postWidgetText', 'version'),
'>='
)) {
return null;
}
return null;
}
# Check Dotclear version
if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, '2.6', '<', false)) {
throw new Exception(sprintf(
'%s requires Dotclear %s', 'postWidgetText', '2.6'
));
}
# Check Dotclear version
if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, '2.6', '<', false)) {
throw new Exception(sprintf(
'%s requires Dotclear %s', 'postWidgetText', '2.6'
));
}
# Table is the same for plugins
# pollsFactory, postTask, postWidgetText
$s = new dbStruct($core->con,$core->prefix);
$s->post_option
->option_id ('bigint',0,false)
->post_id ('bigint',0,false)
->option_creadt ('timestamp',0,false,'now()')
->option_upddt ('timestamp',0,false,'now()')
->option_type ('varchar',32,false,"''")
->option_format ('varchar',32,false,"'xhtml'")
->option_lang ('varchar',5,true,null)
->option_title ('varchar',255,true,null)
->option_content ('text',0,true,null)
->option_content_xhtml ('text',0,false)
# Table is the same for plugins
# pollsFactory, postTask, postWidgetText
$s = new dbStruct($core->con,$core->prefix);
$s->post_option
->option_id ('bigint',0,false)
->post_id ('bigint',0,false)
->option_creadt ('timestamp',0,false,'now()')
->option_upddt ('timestamp',0,false,'now()')
->option_type ('varchar',32,false,"''")
->option_format ('varchar',32,false,"'xhtml'")
->option_lang ('varchar',5,true,null)
->option_title ('varchar',255,true,null)
->option_content ('text',0,true,null)
->option_content_xhtml ('text',0,false)
->index('idx_post_option_option','btree','option_id')
->index('idx_post_option_post','btree','post_id')
->index('idx_post_option_type','btree','option_type');
->index('idx_post_option_option','btree','option_id')
->index('idx_post_option_post','btree','post_id')
->index('idx_post_option_type','btree','option_type');
$si = new dbStruct($core->con,$core->prefix);
$changes = $si->synchronize($s);
$si = new dbStruct($core->con,$core->prefix);
$changes = $si->synchronize($s);
# 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);
# 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);
# Transfert records from old table to the new one
if ($core->getVersion('postWidgetText') !== null
&& version_compare($core->getVersion('postWidgetText'), '0.5', '<')
) {
require_once dirname(__FILE__).'/inc/patch.0.5.php';
}
# Transfert records from old table to the new one
if ($core->getVersion('postWidgetText') !== null
&& version_compare($core->getVersion('postWidgetText'), '0.5', '<')
) {
require_once dirname(__FILE__).'/inc/patch.0.5.php';
}
# Set module version
$core->setVersion(
'postWidgetText',
$core->plugins->moduleInfo('postWidgetText', 'version')
);
# Set module version
$core->setVersion(
'postWidgetText',
$core->plugins->moduleInfo('postWidgetText', 'version')
);
return true;
return true;
}
catch (Exception $e) {
$core->error->add($e->getMessage());
$core->error->add($e->getMessage());
return false;
}
return false;
}

View file

@ -1,29 +1,28 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of postWidgetText, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
/**
* @brief postWidgetText, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
return null;
}
$__autoload['postWidgetText'] =
dirname(__FILE__).'/inc/class.postwidgettext.php';
dirname(__FILE__).'/inc/class.postwidgettext.php';
$__autoload['postWidgetTextDashboard'] =
dirname(__FILE__).'/inc/lib.pwt.dashboard.php';
dirname(__FILE__).'/inc/lib.pwt.dashboard.php';
$__autoload['postWidgetTextAdmin'] =
dirname(__FILE__).'/inc/lib.pwt.admin.php';
dirname(__FILE__).'/inc/lib.pwt.admin.php';
$__autoload['postWidgetTextBackup'] =
dirname(__FILE__).'/inc/lib.pwt.backup.php';
dirname(__FILE__).'/inc/lib.pwt.backup.php';
$__autoload['postWidgetTextList'] =
dirname(__FILE__).'/inc/lib.pwt.list.php';
dirname(__FILE__).'/inc/lib.pwt.list.php';

View file

@ -1,15 +1,19 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of postWidgetText, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { return null; } require dirname(__FILE__).'/_widgets.php';
<?php
/**
* @brief postWidgetText, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
require dirname(__FILE__).'/_widgets.php';

View file

@ -1,15 +1,111 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of postWidgetText, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { return null; } $core->blog->settings->addNamespace('postwidgettext'); $core->addBehavior( 'initWidgets', array('postWidgetTextWidget', 'init') ); /** * @ingroup DC_PLUGIN_POSTWIDGETTEXT * @brief postWidgetText - admin and public widget methods. * @since 2.6 */ class postWidgetTextWidget { public static function init($w) { global $core; $w->create( 'postwidgettext', __('Post widget text'), array('postWidgetTextWidget', 'display'), null, __('Add a widget with a text related to an entry') ); $w->postwidgettext->setting( 'title', __('Title:'), __('More about this entry'), 'text' ); $w->postwidgettext->setting( 'excerpt', __('Use excerpt if no content'), 0, 'check' ); $w->postwidgettext->setting( 'show', __('Show widget even if empty'), 0, 'check' ); $w->postwidgettext->setting( 'content_only', __('Content only'), 0, 'check' ); $w->postwidgettext->setting( 'class', __('CSS class:'), '' ); } public static function display($w) { global $core, $_ctx; if (!$core->blog->settings->postwidgettext->postwidgettext_active || !$_ctx->exists('posts') || !$_ctx->posts->post_id ) { return null; } $title = (strlen($w->title) > 0) ? '<h2>'.html::escapeHTML($w->title).'</h2>' : null; $content = ''; $pwt = new postWidgetText($core); $rs = $pwt->getWidgets(array('post_id'=>$_ctx->posts->post_id)); if ('' != $rs->option_title) { $title = '<h2>'.$rs->option_title.'</h2>'; } if ('' != $rs->option_content_xhtml) { $content = $rs->option_content_xhtml; } if ('' == $content && $w->excerpt) { $content = $_ctx->posts->post_excerpt_xhtml; } return '' == $content && !$w->show ? null : ($w->content_only ? '' : '<div class="postwidgettext'. ($w->class ? ' '.html::escapeHTML($w->class) : '').'">'). $title. $content. ($w->content_only ? '' : '</div>'); } }
<?php
/**
* @brief postWidgetText, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_RC_PATH')) {
return null;
}
$core->blog->settings->addNamespace('postwidgettext');
$core->addBehavior(
'initWidgets',
array('postWidgetTextWidget', 'init')
);
/**
* @ingroup DC_PLUGIN_POSTWIDGETTEXT
* @brief postWidgetText - admin and public widget methods.
* @since 2.6
*/
class postWidgetTextWidget
{
public static function init($w)
{
global $core;
$w->create(
'postwidgettext',
__('Post widget text'),
array('postWidgetTextWidget', 'display'),
null,
__('Add a widget with a text related to an entry')
);
$w->postwidgettext->setting(
'title',
__('Title:'),
__('More about this entry'),
'text'
);
$w->postwidgettext->setting(
'excerpt',
__('Use excerpt if no content'),
0,
'check'
);
$w->postwidgettext->setting(
'show',
__('Show widget even if empty'),
0,
'check'
);
$w->postwidgettext->setting(
'content_only',
__('Content only'),
0,
'check'
);
$w->postwidgettext->setting(
'class',
__('CSS class:'),
''
);
}
public static function display($w)
{
global $core, $_ctx;
if (!$core->blog->settings->postwidgettext->postwidgettext_active
|| !$_ctx->exists('posts')
|| !$_ctx->posts->post_id
) {
return null;
}
$title = (strlen($w->title) > 0) ?
'<h2>'.html::escapeHTML($w->title).'</h2>' : null;
$content = '';
$pwt = new postWidgetText($core);
$rs = $pwt->getWidgets(array('post_id'=>$_ctx->posts->post_id));
if ('' != $rs->option_title) {
$title = '<h2>'.$rs->option_title.'</h2>';
}
if ('' != $rs->option_content_xhtml) {
$content = $rs->option_content_xhtml;
}
if ('' == $content && $w->excerpt) {
$content = $_ctx->posts->post_excerpt_xhtml;
}
return '' == $content && !$w->show ?
null :
($w->content_only ? '' : '<div class="postwidgettext'.
($w->class ? ' '.html::escapeHTML($w->class) : '').'">').
$title.
$content.
($w->content_only ? '' : '</div>');
}
}

12
dcstore.xml Normal file
View file

@ -0,0 +1,12 @@
<modules xmlns:da="http://dotaddict.org/da/">
<module id="postWidgetText">
<name>Widget texte de billet</name>
<version>2021.00.00.1</version>
<author>Jean-Christian Denis and Contributors</author>
<desc>Add a widget with a text related to an entry</desc>
<file>https://github.com/JcDenis/postWidgetText/releases/download/v2021.00.00.1/plugin-postWidgetText.zip</file>
<da:dcmin>2.19</da:dcmin>
<da:details>https://plugins.dotaddict.org/dc2/details/postWidgetText</da:details>
<da:support>https://github.com/JcDenis/postWidgetText</da:support>
</module>
</modules>

File diff suppressed because one or more lines are too long

View file

@ -1,20 +1,19 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of postWidgetText, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
/**
* @brief postWidgetText, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
return null;
}
/**
@ -24,103 +23,103 @@ if (!defined('DC_CONTEXT_ADMIN')) {
*/
class postWidgetTextAdmin
{
public static function headers()
{
return dcPage::jsLoad('index.php?pf=postWidgetText/js/post.js');
}
public static function headers()
{
return dcPage::jsLoad('index.php?pf=postWidgetText/js/post.js');
}
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'];
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'];
# Existing post
if ($post) {
$post_id = (integer) $post->post_id;
# Existing post
if ($post) {
$post_id = (integer) $post->post_id;
$pwt = new postWidgetText($GLOBALS['core']);
$w = $pwt->getWidgets(array('post_id' => $post_id));
$pwt = new postWidgetText($GLOBALS['core']);
$w = $pwt->getWidgets(array('post_id' => $post_id));
# Existing widget
if (!$w->isEmpty()) {
$title = $w->option_title;
$content = $w->option_content;
}
}
# Existing widget
if (!$w->isEmpty()) {
$title = $w->option_title;
$content = $w->option_content;
}
}
$main['post_widget'] =
'<div id="post-wtext-form">'.
'<h4>'.__('Additional widget').'</h4>'.
$main['post_widget'] =
'<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>';
}
'</div>';
}
public static function save($cur, $post_id)
{
$post_id = (integer) $post_id;
public static function save($cur, $post_id)
{
$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'] : '';
# _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'] : '';
# Object
$pwt = new postWidgetText($GLOBALS['core']);
# Object
$pwt = new postWidgetText($GLOBALS['core']);
# Get existing widget
$w = $pwt->getWidgets(array('post_id'=>$post_id));
# Get existing widget
$w = $pwt->getWidgets(array('post_id'=>$post_id));
# If new content is empty, delete old existing widget
if (empty($title) && empty($content) && !$w->isEmpty()) {
$pwt->delWidget($w->option_id);
}
# If new content is empty, delete old existing widget
if (empty($title) && empty($content) && !$w->isEmpty()) {
$pwt->delWidget($w->option_id);
}
# If new content is not empty
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;
# If new content is not empty
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;
# Create widget
if ($w->isEmpty()) {
$id = $pwt->addWidget($wcur);
}
# Upddate widget
else {
$pwt->updWidget($w->option_id,$wcur);
}
}
}
public static function delete($post_id)
{
$post_id = (integer) $post_id;
# Create widget
if ($w->isEmpty()) {
$id = $pwt->addWidget($wcur);
}
# Upddate widget
else {
$pwt->updWidget($w->option_id,$wcur);
}
}
}
# Object
$pwt = new postWidgetText($GLOBALS['core']);
public static function delete($post_id)
{
$post_id = (integer) $post_id;
# Get existing widget
$w = $pwt->getWidgets(array('post_id'=>$post_id));
# Object
$pwt = new postWidgetText($GLOBALS['core']);
# If new content is empty, delete old existing widget
if (!$w->isEmpty()) {
$pwt->delWidget($w->option_id);
}
}
}
# Get existing widget
$w = $pwt->getWidgets(array('post_id'=>$post_id));
# If new content is empty, delete old existing widget
if (!$w->isEmpty()) {
$pwt->delWidget($w->option_id);
}
}
}

View file

@ -1,20 +1,19 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of postWidgetText, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
/**
* @brief postWidgetText, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
return null;
}
/**
@ -24,100 +23,100 @@ if (!defined('DC_CONTEXT_ADMIN')) {
*/
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."' ".
"AND W.option_type = 'postwidgettext' "
);
}
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."' ".
"AND W.option_type = 'postwidgettext' "
);
}
public static function exportFull(dcCore $core, $exp)
{
$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 W.option_type = 'postwidgettext' "
);
}
public static function exportFull(dcCore $core, $exp)
{
$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 W.option_type = 'postwidgettext' "
);
}
public static function importInit($bk, dcCore $core)
{
$bk->cur_postwidgettext = $core->con->openCursor(
$core->prefix.'post_option'
);
$bk->postwidgettext = new postWidgetText($core);
}
public static function importInit($bk, dcCore $core)
{
$bk->cur_postwidgettext = $core->con->openCursor(
$core->prefix.'post_option'
);
$bk->postwidgettext = new postWidgetText($core);
}
public static function importSingle($line, $bk, dcCore $core)
{
if ($line->__name == 'postwidgettext'
&& isset($bk->old_ids['post'][(integer) $line->post_id])
) {
$line->post_id = $bk->old_ids['post'][(integer) $line->post_id];
$exists = $bk->postwidgettext->getWidgets(array(
'post_id' => $line->post_id)
);
public static function importSingle($line, $bk, dcCore $core)
{
if ($line->__name == 'postwidgettext'
&& isset($bk->old_ids['post'][(integer) $line->post_id])
) {
$line->post_id = $bk->old_ids['post'][(integer) $line->post_id];
if ($exists->isEmpty()) {
$bk->cur_postwidgettext->clean();
$exists = $bk->postwidgettext->getWidgets(array(
'post_id' => $line->post_id)
);
$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;
if ($exists->isEmpty()) {
$bk->cur_postwidgettext->clean();
$bk->postwidgettext->addWidget(
$bk->cur_postwidgettext
);
}
}
}
$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;
public static function importFull($line ,$bk, dcCore $core)
{
if ($line->__name == 'postwidgettext') {
$exists = $bk->postwidgettext->getWidgets(array(
'post_id' => $line->post_id)
);
$bk->postwidgettext->addWidget(
$bk->cur_postwidgettext
);
}
}
}
if ($exists->isEmpty()) {
$bk->cur_postwidgettext->clean();
public static function importFull($line ,$bk, dcCore $core)
{
if ($line->__name == 'postwidgettext') {
$exists = $bk->postwidgettext->getWidgets(array(
'post_id' => $line->post_id)
);
$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;
if ($exists->isEmpty()) {
$bk->cur_postwidgettext->clean();
$bk->postwidgettext->addWidget(
$bk->cur_postwidgettext
);
}
}
}
}
$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->postwidgettext->addWidget(
$bk->cur_postwidgettext
);
}
}
}
}

View file

@ -1,20 +1,19 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of postWidgetText, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
/**
* @brief postWidgetText, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
return null;
}
/**
@ -24,40 +23,40 @@ if (!defined('DC_CONTEXT_ADMIN')) {
*/
class postWidgetTextDashboard
{
/**
* Favorites.
*
* @param dcCore $core dcCore instance
* @param arrayObject $favs Array of favorites
*/
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'
)
));
}
/**
* Favorites.
*
* @param dcCore $core dcCore instance
* @param arrayObject $favs Array of favorites
*/
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'
)
));
}
/**
* Favorites selection.
*
* @param string $request Requested page
* @param array $params Requested parameters
*/
public static function active($request, $params)
{
return $request == 'plugin.php'
&& isset($params['p'])
&& $params['p'] == 'postWidgetText';
}
/**
* Favorites selection.
*
* @param string $request Requested page
* @param array $params Requested parameters
*/
public static function active($request, $params)
{
return $request == 'plugin.php'
&& isset($params['p'])
&& $params['p'] == 'postWidgetText';
}
}

View file

@ -1,20 +1,19 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of postWidgetText, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
/**
* @brief postWidgetText, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
return null;
}
/**
@ -24,78 +23,78 @@ if (!defined('DC_CONTEXT_ADMIN')) {
*/
class postWidgetTextList extends adminGenericList
{
public function display($page, $nb_per_page, $enclose='')
{
if ($this->rs->isEmpty()) {
public function display($page, $nb_per_page, $enclose='')
{
if ($this->rs->isEmpty()) {
return '<p><strong>'.__('No widget').'</strong></p>';
}
return '<p><strong>'.__('No widget').'</strong></p>';
}
$pager = new dcPager($page, $this->rs_count, $nb_per_page,10);
$pager->html_prev = $this->html_prev;
$pager->html_next = $this->html_next;
$pager->var_page = 'page';
$pager = new dcPager($page, $this->rs_count, $nb_per_page,10);
$pager->html_prev = $this->html_prev;
$pager->html_next = $this->html_next;
$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>'.
'</tr></thead><tbody>';
while ($this->rs->fetch()) {
$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>'.
'</tr></thead><tbody>';
$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
).'</em>';
}
while ($this->rs->fetch()) {
$content .=
'<tr class="line'.($this->rs->post_status != 1 ?
' offline' : ''
).'" 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="'.
$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(
__('%Y-%m-%d %H:%M'),
$this->rs->post_dt
).'</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>'.
'</tr>';
}
$content .=
'</tbody></table></div>';
$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
).'</em>';
}
return
$pager->getLinks().
sprintf($enclose, $content).
$pager->getLinks();
}
}
$content .=
'<tr class="line'.($this->rs->post_status != 1 ?
' offline' : ''
).'" 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="'.
$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(
__('%Y-%m-%d %H:%M'),
$this->rs->post_dt
).'</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>'.
'</tr>';
}
$content .=
'</tbody></table></div>';
return
$pager->getLinks().
sprintf($enclose, $content).
$pager->getLinks();
}
}

View file

@ -1,54 +1,52 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of postWidgetText, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
/**
* @brief postWidgetText, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @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 '
'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())
{
$cur = $core->con->openCursor($core->prefix.'post_option');
while ($records->fetch())
{
$core->con->writeLock($core->prefix.'post_option');
try {
$cur = $core->con->openCursor($core->prefix.'post_option');
while ($records->fetch())
{
$core->con->writeLock($core->prefix.'post_option');
try {
$id = $core->con->select(
'SELECT MAX(option_id) FROM '.$core->prefix.'post_option'
)->f(0) + 1;
$id = $core->con->select(
'SELECT MAX(option_id) FROM '.$core->prefix.'post_option'
)->f(0) + 1;
$cur->clean();
$cur->option_creadt = date('Y-m-d H:i:s');
$cur->option_upddt = date('Y-m-d H:i:s');
$cur->clean();
$cur->option_creadt = date('Y-m-d H:i:s');
$cur->option_upddt = date('Y-m-d H:i:s');
$cur->option_id = $id;
$cur->post_id = $records->post_id;
$cur->option_type = $records->wtext_type;
$cur->option_lang = $records->post_lang;
$cur->option_format = $records->post_format;
$cur->option_title = $records->wtext_title;
$cur->option_content = $records->wtext_content;
$cur->option_content_xhtml = $records->wtext_content_xhtml;
$cur->option_id = $id;
$cur->post_id = $records->post_id;
$cur->option_type = $records->wtext_type;
$cur->option_lang = $records->post_lang;
$cur->option_format = $records->post_format;
$cur->option_title = $records->wtext_title;
$cur->option_content = $records->wtext_content;
$cur->option_content_xhtml = $records->wtext_content_xhtml;
$cur->insert();
$core->con->unlock();
}
catch (Exception $e)
{
$core->con->unlock();
throw $e;
}
}
}
?>
$cur->insert();
$core->con->unlock();
}
catch (Exception $e)
{
$core->con->unlock();
throw $e;
}
}
}

155
index.php
View file

@ -1,20 +1,19 @@
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
#
# This file is part of postWidgetText, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
#
# -- END LICENSE BLOCK ------------------------------------
/**
* @brief postWidgetText, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
return null;
}
dcPage::check('usage,contentadmin');
@ -23,35 +22,35 @@ $pwt = new postWidgetText($core);
# Delete widgets
if (!empty($_POST['save']) && !empty($_POST['widgets'])) {
try {
foreach($_POST['widgets'] as $k => $id) {
$id = (integer) $id;
$pwt->delWidget($id);
}
try {
foreach($_POST['widgets'] as $k => $id) {
$id = (integer) $id;
$pwt->delWidget($id);
}
dcPage::addSuccessNotice(
__('Posts widgets successfully delete.')
);
http::redirect(
$p_url
);
}
catch (Exception $e) {
$core->error->add($e->getMessage());
}
dcPage::addSuccessNotice(
__('Posts widgets successfully delete.')
);
http::redirect(
$p_url
);
}
catch (Exception $e) {
$core->error->add($e->getMessage());
}
}
# Combos
$sortby_combo = array(
__('Post title') => 'post_title',
__('Post date') => 'post_dt',
__('Widget title') => 'option_title',
__('Widget date') => 'option_upddt',
__('Post title') => 'post_title',
__('Post date') => 'post_dt',
__('Widget title') => 'option_title',
__('Widget date') => 'option_upddt',
);
$order_combo = array(
__('Descending') => 'desc',
__('Ascending') => 'asc'
__('Descending') => 'desc',
__('Ascending') => 'asc'
);
# Filters
@ -63,55 +62,55 @@ $order = !empty($_GET['order']) ? $_GET['order'] : 'desc';
$page = !empty($_GET['page']) ? (integer) $_GET['page'] : 1;
if (!empty($_GET['nb']) && (integer) $_GET['nb'] > 0) {
if ($nb_per_page != $_GET['nb']) {
$show_filters = true;
}
$nb_per_page = (integer) $_GET['nb'];
if ($nb_per_page != $_GET['nb']) {
$show_filters = true;
}
$nb_per_page = (integer) $_GET['nb'];
}
$params['limit'] = array((($page-1)*$nb_per_page), $nb_per_page);
if ($sortby !== '' && in_array($sortby,$sortby_combo)) {
if ($order !== '' && in_array($order,$order_combo)) {
$params['order'] = $sortby.' '.$order;
}
if ($sortby != 'post_dt' || $order != 'desc') {
$show_filters = true;
}
if ($order !== '' && in_array($order,$order_combo)) {
$params['order'] = $sortby.' '.$order;
}
if ($sortby != 'post_dt' || $order != 'desc') {
$show_filters = true;
}
}
# Get posts with text widget
try {
$posts = $pwt->getWidgets($params);
$counter = $pwt->getWidgets($params, true);
$posts_list = new postWidgetTextList(
$core,
$posts,
$counter->f(0)
);
$posts = $pwt->getWidgets($params);
$counter = $pwt->getWidgets($params, true);
$posts_list = new postWidgetTextList(
$core,
$posts,
$counter->f(0)
);
}
catch (Exception $e) {
$core->error->add($e->getMessage());
$core->error->add($e->getMessage());
}
# Display
echo '
<html><head><title>'.__('Post widget text').'</title>'.
dcPage::jsLoad(
'js/filter-controls.js'
'js/filter-controls.js'
).
'<script type="text/javascript">'."\n".
"//<![CDATA["."\n".
dcPage::jsVar(
'dotclear.msg.show_filters',
$show_filters ? 'true':'false'
'dotclear.msg.show_filters',
$show_filters ? 'true':'false'
)."\n".
dcPage::jsVar(
'dotclear.msg.filter_posts_list',
__('Show filters and display options')
'dotclear.msg.filter_posts_list',
__('Show filters and display options')
)."\n".
dcPage::jsVar(
'dotclear.msg.cancel_the_filter',
__('Cancel filters and display options')
'dotclear.msg.cancel_the_filter',
__('Cancel filters and display options')
)."\n".
"//]]>\n".
"</script>\n".'
@ -119,10 +118,10 @@ dcPage::jsVar(
<body>'.
dcPage::breadcrumb(
array(
html::escapeHTML($core->blog->name) => '',
__('Posts widgets') => ''
)
array(
html::escapeHTML($core->blog->name) => '',
__('Posts widgets') => ''
)
).
dcPage::notices().'
@ -151,20 +150,20 @@ form::hidden(array('p'), 'postWidgetText').'
</form>'.
$posts_list->display($page, $nb_per_page,
'<form action="'.$p_url.'" method="post" id="form-periods">'.
'%s'.
'<div class="two-cols">'.
'<p class="col checkboxes-helpers"></p>'.
'<p class="col right">'.
'<input type="submit" name="save" value="'.__('Delete selected widgets').'" /></p>'.
form::hidden(array('sortby'), $sortby).
form::hidden(array('order'), $order).
form::hidden(array('page'), $page).
form::hidden(array('nb'), $nb_per_page).
form::hidden(array('p'), 'postWidgetText').
$core->formNonce().
'</div>'.
'</form>'
'<form action="'.$p_url.'" method="post" id="form-periods">'.
'%s'.
'<div class="two-cols">'.
'<p class="col checkboxes-helpers"></p>'.
'<p class="col right">'.
'<input type="submit" name="save" value="'.__('Delete selected widgets').'" /></p>'.
form::hidden(array('sortby'), $sortby).
form::hidden(array('order'), $order).
form::hidden(array('page'), $page).
form::hidden(array('nb'), $nb_per_page).
form::hidden(array('p'), 'postWidgetText').
$core->formNonce().
'</div>'.
'</form>'
);
# Footer
@ -178,4 +177,4 @@ urlencode('plugin.php?p=postWidgetText').'">'.__('Configuration').'</a> -
postWidgetText - '.$core->plugins->moduleInfo('postWidgetText', 'version').'&nbsp;
<img alt="'.__('postWidgetText').'" src="index.php?pf=postWidgetText/icon.png" />
</p>
</body></html>';
</body></html>';

View file

@ -76,6 +76,4 @@ $GLOBALS['__l10n']['Posts widgets successfully delete.'] = 'Widgets de billets e
$GLOBALS['__l10n']['Posts widgets'] = 'Widgets de billets';
#index.php:157
$GLOBALS['__l10n']['Delete selected widgets'] = 'Effacer les widgets texte selectionnés';
?>
$GLOBALS['__l10n']['Delete selected widgets'] = 'Effacer les widgets texte selectionnés';