diff --git a/_admin.php b/_admin.php
index 942cd4c..7d5fdce 100644
--- a/_admin.php
+++ b/_admin.php
@@ -1,95 +1,94 @@
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')
+ );
+}
\ No newline at end of file
diff --git a/_config.php b/_config.php
index 1202d36..2d62ae2 100644
--- a/_config.php
+++ b/_config.php
@@ -1,24 +1,23 @@
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 --
diff --git a/_define.php b/_define.php
index d98f9a4..f38af86 100644
--- a/_define.php
+++ b/_define.php
@@ -1,17 +1,15 @@
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;
+}
\ No newline at end of file
diff --git a/_prepend.php b/_prepend.php
index a582942..783e73c 100644
--- a/_prepend.php
+++ b/_prepend.php
@@ -1,29 +1,28 @@
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) ?
'
'.html::escapeHTML($w->title).'
' : null;
$content = '';
$pwt = new postWidgetText($core);
$rs = $pwt->getWidgets(array('post_id'=>$_ctx->posts->post_id));
if ('' != $rs->option_title) {
$title = ''.$rs->option_title.'
';
}
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 ? '' : '').
$title.
$content.
($w->content_only ? '' : '
');
}
}
\ No newline at end of file
+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) ?
+ ''.html::escapeHTML($w->title).'
' : null;
+ $content = '';
+
+ $pwt = new postWidgetText($core);
+ $rs = $pwt->getWidgets(array('post_id'=>$_ctx->posts->post_id));
+
+ if ('' != $rs->option_title) {
+ $title = ''.$rs->option_title.'
';
+ }
+ 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 ? '' : '').
+ $title.
+ $content.
+ ($w->content_only ? '' : '
');
+ }
+}
\ No newline at end of file
diff --git a/dcstore.xml b/dcstore.xml
new file mode 100644
index 0000000..f9dc51c
--- /dev/null
+++ b/dcstore.xml
@@ -0,0 +1,12 @@
+
+
+Widget texte de billet
+2021.00.00.1
+Jean-Christian Denis and Contributors
+Add a widget with a text related to an entry
+https://github.com/JcDenis/postWidgetText/releases/download/v2021.00.00.1/plugin-postWidgetText.zip
+2.19
+https://plugins.dotaddict.org/dc2/details/postWidgetText
+https://github.com/JcDenis/postWidgetText
+
+
\ No newline at end of file
diff --git a/inc/class.postwidgettext.php b/inc/class.postwidgettext.php
index 66aa087..b97d923 100644
--- a/inc/class.postwidgettext.php
+++ b/inc/class.postwidgettext.php
@@ -1,15 +1,240 @@
-core =& $core;
$this->con =& $this->core->con;
$this->table = $this->core->prefix.'post_option';
$this->blog = $core->con->escape($core->blog->id);
}
public function tableName()
{
return $this->table;
}
public function openCursor()
{
return $this->con->openCursor($this->table);
}
public function lockTable()
{
$this->con->writeLock($this->table);
}
public function unlockTable()
{
$this->con->unlock();
}
public function triggerBlog()
{
$this->core->blog->triggerBlog();
}
public function getWidgets($params,$count_only=false)
{
if (!isset($params['columns'])) $params['columns'] = array();
$params['columns'][] = 'option_id';
$params['columns'][] = 'option_creadt';
$params['columns'][] = 'option_upddt';
$params['columns'][] = 'option_type';
$params['columns'][] = 'option_format';
$params['columns'][] = 'option_lang';
$params['columns'][] = 'option_title';
$params['columns'][] = 'option_content';
$params['columns'][] = 'option_content_xhtml';
if (!isset($params['from'])) {
$params['from'] = '';
}
$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'])."' ";
}
else {
$params['sql'] .= "AND W.option_type = 'postwidgettext' ";
}
unset($params['option_type']);
if (!isset($params['post_type'])) {
$params['post_type'] = '';
}
return $this->core->blog->getPosts($params, $count_only);
}
public function addWidget($cur)
{
if (!$this->core->auth->check('usage,contentadmin', $this->blog)) {
throw new Exception(__('You are not allowed to create an entry text widget'));
}
if ($cur->post_id == '') {
throw new Exception('No such entry ID');
return null;
}
$this->lockTable();
try {
$rs = $this->con->select(
'SELECT MAX(option_id) '.
'FROM '.$this->table
);
$cur->option_id = (integer) $rs->f(0) + 1;
$cur->option_creadt = date('Y-m-d H:i:s');
$cur->option_upddt = date('Y-m-d H:i:s');
$this->getWidgetContent($cur, $cur->option_id);
$cur->insert();
$this->unlockTable();
}
catch (Exception $e) {
$this->unlockTable();
throw $e;
}
$this->triggerBlog();
return $cur->option_id;
}
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'));
}
$id = (integer) $id;
if (empty($id)) {
throw new Exception(__('No such ID'));
}
$this->getWidgetContent($cur,$id);
$cur->option_upddt = date('Y-m-d H:i:s');
if (!$this->core->auth->check('contentadmin', $this->blog)) {
$params['option_id'] = $id;
$params['user_id'] = $this->con->escape($this->core->auth->userID());
$params['no_content'] = true;
$params['limit'] = 1;
$rs = $this->getWidgets($params);
if ($rs->isEmpty()) {
throw new Exception(__('You are not allowed to delete this entry text widget'));
}
}
$cur->update('WHERE option_id = '.$id.' ');
$this->triggerBlog();
}
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'));
}
$id = (integer) $id;
if (empty($id)) {
throw new Exception(__('No such ID'));
}
if (!$this->core->auth->check('contentadmin', $this->blog)) {
$params['option_id'] = $id;
$params['user_id'] = $this->con->escape($this->core->auth->userID());
$params['no_content'] = true;
$params['limit'] = 1;
$rs = $this->getWidgets($params);
if ($rs->isEmpty()) {
throw new Exception(__('You are not allowed to delete this entry text widget'));
}
}
$this->con->execute(
'DELETE FROM '.$this->table.' '.
'WHERE option_id = '.$id.' '.
"AND option_type = '".$this->con->escape($type)."' "
);
$this->triggerBlog();
}
private function getWidgetContent(&$cur, $option_id)
{
$option_content = $cur->option_content;
$option_content_xhtml = $cur->option_content_xhtml;
$this->setWidgetContent(
$option_id,$cur->option_format,$cur->option_lang,
$option_content,$option_content_xhtml
);
$cur->option_content = $option_content;
$cur->option_content_xhtml = $option_content_xhtml;
}
public function setWidgetContent($option_id, $format, $lang, &$content, &$content_xhtml)
{
if ($format == 'wiki') {
$this->core->initWikiPost();
$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->HTMLfilter($content_xhtml);
}
else {
$content_xhtml = '';
}
$excerpt = $excerpt_xhtml = '';
# --BEHAVIOR-- coreAfterPostContentFormat
$this->core->callBehavior('coreAfterPostContentFormat',array(
'excerpt' => &$excerpt,
'content' => &$content,
'excerpt_xhtml' => &$excerpt_xhtml,
'content_xhtml' => &$content_xhtml
));
}
}
\ No newline at end of file
+core =& $core;
+ $this->con =& $this->core->con;
+ $this->table = $this->core->prefix.'post_option';
+ $this->blog = $core->con->escape($core->blog->id);
+ }
+
+ public function tableName()
+ {
+ return $this->table;
+ }
+
+ public function openCursor()
+ {
+ return $this->con->openCursor($this->table);
+ }
+
+ public function lockTable()
+ {
+ $this->con->writeLock($this->table);
+ }
+
+ public function unlockTable()
+ {
+ $this->con->unlock();
+ }
+
+ public function triggerBlog()
+ {
+ $this->core->blog->triggerBlog();
+ }
+
+ public function getWidgets($params,$count_only=false)
+ {
+ if (!isset($params['columns'])) $params['columns'] = array();
+ $params['columns'][] = 'option_id';
+ $params['columns'][] = 'option_creadt';
+ $params['columns'][] = 'option_upddt';
+ $params['columns'][] = 'option_type';
+ $params['columns'][] = 'option_format';
+ $params['columns'][] = 'option_lang';
+ $params['columns'][] = 'option_title';
+ $params['columns'][] = 'option_content';
+ $params['columns'][] = 'option_content_xhtml';
+
+ if (!isset($params['from'])) {
+ $params['from'] = '';
+ }
+ $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'])."' ";
+ }
+ else {
+ $params['sql'] .= "AND W.option_type = 'postwidgettext' ";
+ }
+ unset($params['option_type']);
+ if (!isset($params['post_type'])) {
+ $params['post_type'] = '';
+ }
+
+ return $this->core->blog->getPosts($params, $count_only);
+ }
+
+ public function addWidget($cur)
+ {
+ if (!$this->core->auth->check('usage,contentadmin', $this->blog)) {
+ throw new Exception(__('You are not allowed to create an entry text widget'));
+ }
+ if ($cur->post_id == '') {
+ throw new Exception('No such entry ID');
+
+ return null;
+ }
+
+ $this->lockTable();
+ try {
+ $rs = $this->con->select(
+ 'SELECT MAX(option_id) '.
+ 'FROM '.$this->table
+ );
+
+ $cur->option_id = (integer) $rs->f(0) + 1;
+ $cur->option_creadt = date('Y-m-d H:i:s');
+ $cur->option_upddt = date('Y-m-d H:i:s');
+
+ $this->getWidgetContent($cur, $cur->option_id);
+
+ $cur->insert();
+ $this->unlockTable();
+ }
+ catch (Exception $e) {
+ $this->unlockTable();
+ throw $e;
+ }
+
+ $this->triggerBlog();
+
+ return $cur->option_id;
+ }
+
+ 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'));
+ }
+
+ $id = (integer) $id;
+
+ if (empty($id)) {
+ throw new Exception(__('No such ID'));
+ }
+
+ $this->getWidgetContent($cur,$id);
+
+ $cur->option_upddt = date('Y-m-d H:i:s');
+
+ if (!$this->core->auth->check('contentadmin', $this->blog)) {
+ $params['option_id'] = $id;
+ $params['user_id'] = $this->con->escape($this->core->auth->userID());
+ $params['no_content'] = true;
+ $params['limit'] = 1;
+
+ $rs = $this->getWidgets($params);
+
+ if ($rs->isEmpty()) {
+ throw new Exception(__('You are not allowed to delete this entry text widget'));
+ }
+ }
+
+ $cur->update('WHERE option_id = '.$id.' ');
+ $this->triggerBlog();
+ }
+
+ 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'));
+ }
+
+ $id = (integer) $id;
+
+ if (empty($id)) {
+ throw new Exception(__('No such ID'));
+ }
+
+ if (!$this->core->auth->check('contentadmin', $this->blog)) {
+ $params['option_id'] = $id;
+ $params['user_id'] = $this->con->escape($this->core->auth->userID());
+ $params['no_content'] = true;
+ $params['limit'] = 1;
+
+ $rs = $this->getWidgets($params);
+
+ if ($rs->isEmpty()) {
+ throw new Exception(__('You are not allowed to delete this entry text widget'));
+ }
+ }
+
+ $this->con->execute(
+ 'DELETE FROM '.$this->table.' '.
+ 'WHERE option_id = '.$id.' '.
+ "AND option_type = '".$this->con->escape($type)."' "
+ );
+
+ $this->triggerBlog();
+ }
+
+ private function getWidgetContent(&$cur, $option_id)
+ {
+ $option_content = $cur->option_content;
+ $option_content_xhtml = $cur->option_content_xhtml;
+
+ $this->setWidgetContent(
+ $option_id,$cur->option_format,$cur->option_lang,
+ $option_content,$option_content_xhtml
+ );
+
+ $cur->option_content = $option_content;
+ $cur->option_content_xhtml = $option_content_xhtml;
+ }
+
+ public function setWidgetContent($option_id, $format, $lang, &$content, &$content_xhtml)
+ {
+ if ($format == 'wiki') {
+ $this->core->initWikiPost();
+ $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->HTMLfilter($content_xhtml);
+ }
+ else {
+ $content_xhtml = '';
+ }
+
+ $excerpt = $excerpt_xhtml = '';
+
+ # --BEHAVIOR-- coreAfterPostContentFormat
+ $this->core->callBehavior('coreAfterPostContentFormat',array(
+ '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 31cb143..3aa0ca2 100644
--- a/inc/lib.pwt.admin.php
+++ b/inc/lib.pwt.admin.php
@@ -1,20 +1,19 @@
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'] =
- ''.
- '
'.__('Additional widget').'
'.
+ $main['post_widget'] =
+ '
'.
+ '
'.__('Additional 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)).
+ '
'.
- '
';
- }
+ '
';
+ }
- 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);
+ }
+ }
+}
\ No newline at end of file
diff --git a/inc/lib.pwt.backup.php b/inc/lib.pwt.backup.php
index 2f4ec02..32faf26 100644
--- a/inc/lib.pwt.backup.php
+++ b/inc/lib.pwt.backup.php
@@ -1,20 +1,19 @@
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
+ );
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/inc/lib.pwt.dashboard.php b/inc/lib.pwt.dashboard.php
index 7cd5998..b7152a3 100644
--- a/inc/lib.pwt.dashboard.php
+++ b/inc/lib.pwt.dashboard.php
@@ -1,20 +1,19 @@
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';
+ }
}
\ No newline at end of file
diff --git a/inc/lib.pwt.list.php b/inc/lib.pwt.list.php
index ad203e2..dbdb0a7 100644
--- a/inc/lib.pwt.list.php
+++ b/inc/lib.pwt.list.php
@@ -1,20 +1,19 @@
rs->isEmpty()) {
+ public function display($page, $nb_per_page, $enclose='')
+ {
+ if ($this->rs->isEmpty()) {
- return ''.__('No widget').'
';
- }
+ return ''.__('No widget').'
';
+ }
- $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 =
- ''.
- '
'.
- ''.
- ''.
- ''.__('Post title').' | '.
- ''.__('Post date').' | '.
- ''.__('Widget title').' | '.
- ''.__('Widget date').' | '.
- ''.__('Author').' | '.
- ''.__('Type').' | '.
- '
';
-
- while ($this->rs->fetch()) {
+ $content =
+ ''.
+ '
'.
+ ''.
+ ''.
+ ''.__('Post title').' | '.
+ ''.__('Post date').' | '.
+ ''.__('Widget title').' | '.
+ ''.__('Widget date').' | '.
+ ''.__('Author').' | '.
+ ''.__('Type').' | '.
+ '
';
- $w_title = html::escapeHTML($this->rs->option_title);
- if ($w_title == '') {
- $w_title = ''.context::global_filter(
- $this->rs->option_content, 1, 1, 80, 0, 0
- ).'';
- }
+ while ($this->rs->fetch()) {
- $content .=
- ''.
- ''.
- form::checkbox(
- array('widgets[]'),
- $this->rs->option_id,
- '', '', '',
- !$this->rs->isEditable()
- ).' | '.
- ''.
- html::escapeHTML($this->rs->post_title).
- ' | '.
- ''.dt::dt2str(
- __('%Y-%m-%d %H:%M'),
- $this->rs->post_dt
- ).' | '.
- ''.$w_title.' | '.
- ''.dt::dt2str(
- __('%Y-%m-%d %H:%M'),
- $this->rs->option_upddt
- ).' | '.
- ''.$this->rs->user_id.' | '.
- ''.$this->rs->post_type.' | '.
- '
';
- }
-
- $content .=
- '
';
+ $w_title = html::escapeHTML($this->rs->option_title);
+ if ($w_title == '') {
+ $w_title = ''.context::global_filter(
+ $this->rs->option_content, 1, 1, 80, 0, 0
+ ).'';
+ }
- return
- $pager->getLinks().
- sprintf($enclose, $content).
- $pager->getLinks();
- }
-}
+ $content .=
+ ''.
+ ''.
+ form::checkbox(
+ array('widgets[]'),
+ $this->rs->option_id,
+ '', '', '',
+ !$this->rs->isEditable()
+ ).' | '.
+ ''.
+ html::escapeHTML($this->rs->post_title).
+ ' | '.
+ ''.dt::dt2str(
+ __('%Y-%m-%d %H:%M'),
+ $this->rs->post_dt
+ ).' | '.
+ ''.$w_title.' | '.
+ ''.dt::dt2str(
+ __('%Y-%m-%d %H:%M'),
+ $this->rs->option_upddt
+ ).' | '.
+ ''.$this->rs->user_id.' | '.
+ ''.$this->rs->post_type.' | '.
+ '
';
+ }
+
+ $content .=
+ '
';
+
+ return
+ $pager->getLinks().
+ sprintf($enclose, $content).
+ $pager->getLinks();
+ }
+}
\ No newline at end of file
diff --git a/inc/patch.0.5.php b/inc/patch.0.5.php
index 5dfcd78..aa5c107 100644
--- a/inc/patch.0.5.php
+++ b/inc/patch.0.5.php
@@ -1,54 +1,52 @@
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;
- }
- }
-}
-?>
\ No newline at end of file
+ $cur->insert();
+ $core->con->unlock();
+ }
+ catch (Exception $e)
+ {
+ $core->con->unlock();
+ throw $e;
+ }
+ }
+}
\ No newline at end of file
diff --git a/index.php b/index.php
index 24daca6..7dfe0d7 100644
--- a/index.php
+++ b/index.php
@@ -1,20 +1,19 @@
$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 '
'.__('Post widget text').''.
dcPage::jsLoad(
- 'js/filter-controls.js'
+ 'js/filter-controls.js'
).
'\n".'
@@ -119,10 +118,10 @@ dcPage::jsVar(
'.
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').'
'.
$posts_list->display($page, $nb_per_page,
- ''
+ ''
);
# Footer
@@ -178,4 +177,4 @@ urlencode('plugin.php?p=postWidgetText').'">'.__('Configuration').' -
postWidgetText - '.$core->plugins->moduleInfo('postWidgetText', 'version').'
-';
+