From a5d4f0d46713c51cefd3ad96d4c95a3562e04432 Mon Sep 17 00:00:00 2001 From: JcDenis Date: Fri, 20 Aug 2021 18:39:12 +0200 Subject: [PATCH] PSR2 and license --- CHANGELOG => CHANGELOG.md | 13 +- _admin.php | 551 ++++++++------- _config.php | 847 ++++++++++++------------ _define.php | 35 +- _install.php | 186 +++--- _public.php | 425 ++++++------ locales/en/help/{help.html => fac.html} | 0 locales/en/resources.php | 10 +- locales/fr/help/{help.html => fac.html} | 0 locales/fr/resources.php | 10 +- 10 files changed, 1008 insertions(+), 1069 deletions(-) rename CHANGELOG => CHANGELOG.md (55%) rename locales/en/help/{help.html => fac.html} (100%) rename locales/fr/help/{help.html => fac.html} (100%) diff --git a/CHANGELOG b/CHANGELOG.md similarity index 55% rename from CHANGELOG rename to CHANGELOG.md index e2f1794..df2838d 100644 --- a/CHANGELOG +++ b/CHANGELOG.md @@ -1,41 +1,36 @@ +fac 0.8 - 2021-08-19 + * update license + * fixed PSR2 coding style + fac 0.7 - 2013-11-11 -=========================================================== * Switch to Dotclear 2.6 * Fix missing feed description fac 0.6.1 - 2010-11-12 -=========================================================== * Fixed install on nightly build fac 0.6 - 2010-08-16 -=========================================================== * Added compatibility with plugin muppet fac 0.5 - 2010-06-05 -=========================================================== * Switched to DC 2.2 * Added predefined format (thx to Jean-Michel) (closes #459) fac 0.4.1 - 2010-04-10 -=========================================================== * Fixed typo (thx to Jean-Michel) (closes #458) fac 0.4 - 2010-05-25 -=========================================================== * Fixed Timeout error * Fixed DC 2.1.7 fac 0.3 - 2010-04-10 -=========================================================== * Added options to format feed * Added DC 2.2 compatibility * Removed class and used metadata * Changed admin page design fac 0.2 - 2010-02-17 -=========================================================== * Fixed some fields in admin fac 0.1 - 2010-02-16 -=========================================================== * First lab release \ No newline at end of file diff --git a/_admin.php b/_admin.php index dd31f19..9c22eb9 100644 --- a/_admin.php +++ b/_admin.php @@ -3,8 +3,7 @@ # # This file is part of fac, a plugin for Dotclear 2. # -# Copyright (c) 2009-2013 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcd.lv +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -13,43 +12,23 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_CONTEXT_ADMIN')) { - - return null; + return null; } $core->blog->settings->addNamespace('fac'); # Not active if (!$core->blog->settings->fac->fac_active) { - - return null; + return null; } # Admin behaviors -$core->addBehavior( - 'adminPostHeaders', - array('facAdmin', 'adminPostHeaders') -); -$core->addBehavior( - 'adminPostFormItems', - array('facAdmin', 'adminPostFormItems') -); -$core->addBehavior( - 'adminAfterPostCreate', - array('facAdmin', 'adminAfterPostSave') -); -$core->addBehavior( - 'adminAfterPostUpdate', - array('facAdmin', 'adminAfterPostSave') -); -$core->addBehavior( - 'adminBeforePostDelete', - array('facAdmin', 'adminBeforePostDelete') -); -$core->addBehavior( - 'adminPostsActionsPage', - array('facAdmin', 'adminPostsActionsPage') -); +$core->addBehavior('adminPostHeaders', ['facAdmin', 'adminPostHeaders']); +$core->addBehavior('adminPostFormItems', ['facAdmin', 'adminPostFormItems']); +$core->addBehavior('adminAfterPostCreate', ['facAdmin', 'adminAfterPostSave']); +$core->addBehavior('adminAfterPostUpdate', ['facAdmin', 'adminAfterPostSave']); +$core->addBehavior('adminBeforePostDelete', ['facAdmin', 'adminBeforePostDelete']); +$core->addBehavior('adminPostsActionsPage', ['facAdmin', 'adminPostsActionsPage']); /** * @ingroup DC_PLUGIN_FAC @@ -58,294 +37,288 @@ $core->addBehavior( */ class facAdmin { - /** - * Add javascript (toggle) - * - * @return string HTML head - */ - public static function adminPostHeaders() - { - return dcPage::jsLoad('index.php?pf=fac/js/admin.js'); - } + /** + * Add javascript (toggle) + * + * @return string HTML head + */ + public static function adminPostHeaders() + { + return dcPage::jsLoad('index.php?pf=fac/js/admin.js'); + } - /** - * Add form to post sidebar - * - * @param ArrayObject $main_items Main items - * @param ArrayObject $sidebar_items Sidebar items - * @param record $post Post record or null - */ - public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post) - { - global $core; + /** + * Add form to post sidebar + * + * @param ArrayObject $main_items Main items + * @param ArrayObject $sidebar_items Sidebar items + * @param record $post Post record or null + */ + public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post) + { + global $core; - # Get existing linked feed - $fac_url = $fac_format = ''; - if ($post) { + # Get existing linked feed + $fac_url = $fac_format = ''; + if ($post) { - $rs = $core->meta->getMetadata(array( - 'meta_type' => 'fac', - 'post_id' => $post->post_id, - 'limit' => 1 - )); - $fac_url = $rs->isEmpty() ? '' : $rs->meta_id; + $rs = $core->meta->getMetadata(array( + 'meta_type' => 'fac', + 'post_id' => $post->post_id, + 'limit' => 1 + )); + $fac_url = $rs->isEmpty() ? '' : $rs->meta_id; - $rs = $core->meta->getMetadata(array( - 'meta_type' => 'facformat', - 'post_id' => $post->post_id, - 'limit' => 1 - )); - $fac_format = $rs->isEmpty() ? '' : $rs->meta_id; - } + $rs = $core->meta->getMetadata(array( + 'meta_type' => 'facformat', + 'post_id' => $post->post_id, + 'limit' => 1 + )); + $fac_format = $rs->isEmpty() ? '' : $rs->meta_id; + } - # Set linked feed form items - $sidebar_items['options-box']['items']['fac'] = - self::formFeed($core, $fac_url, $fac_format); - } + # Set linked feed form items + $sidebar_items['options-box']['items']['fac'] = + self::formFeed($core, $fac_url, $fac_format); + } - /** - * Save linked feed - * - * @param cursor $cur Current post cursor - * @param integer $post_id Post id - */ - public static function adminAfterPostSave(cursor $cur, $post_id) - { - global $core; + /** + * Save linked feed + * + * @param cursor $cur Current post cursor + * @param integer $post_id Post id + */ + public static function adminAfterPostSave(cursor $cur, $post_id) + { + global $core; - if (!isset($_POST['fac_url']) - || !isset($_POST['fac_format']) - ) { - return null; - } + if (!isset($_POST['fac_url']) + || !isset($_POST['fac_format'])) { + return null; + } - # Delete old linked feed - self::delFeed($core, $post_id); + # Delete old linked feed + self::delFeed($core, $post_id); - # Add new linked feed - self::addFeed($core, $post_id, $_POST); - } + # Add new linked feed + self::addFeed($core, $post_id, $_POST); + } - /** - * Delete linked feed on post edition - * - * @param integer $post_id Post id - */ - public static function adminBeforePostDelete($post_id) - { - self::delFeed($GLOBALS['core'], $post_id); - } + /** + * Delete linked feed on post edition + * + * @param integer $post_id Post id + */ + public static function adminBeforePostDelete($post_id) + { + self::delFeed($GLOBALS['core'], $post_id); + } - /** - * Add actions to posts page combo - * - * @param dcCore $core dcCore instance - * @param dcPostsActionsPage $ap dcPostsActionsPage instance - */ - public static function adminPostsActionsPage(dcCore $core, dcPostsActionsPage $pa) - { - $pa->addAction( - array( - __('Linked feed') => array( - __('Add feed') => 'fac_add' - ) - ), - array('facAdmin', 'callbackAdd') - ); + /** + * Add actions to posts page combo + * + * @param dcCore $core dcCore instance + * @param dcPostsActionsPage $ap dcPostsActionsPage instance + */ + public static function adminPostsActionsPage(dcCore $core, dcPostsActionsPage $pa) + { + $pa->addAction( + array( + __('Linked feed') => array( + __('Add feed') => 'fac_add' + ) + ), + array('facAdmin', 'callbackAdd') + ); - if (!$core->auth->check('delete,contentadmin', $core->blog->id)) { + if (!$core->auth->check('delete,contentadmin', $core->blog->id)) { + return null; + } + $pa->addAction( + array( + __('Linked feed') => array( + __('Remove feed') => 'fac_remove' + ) + ), + array('facAdmin', 'callbackRemove') + ); + } - return null; - } - $pa->addAction( - array( - __('Linked feed') => array( - __('Remove feed') => 'fac_remove' - ) - ), - array('facAdmin', 'callbackRemove') - ); - } + /** + * Posts actions callback to remove linked feed + * + * @param dcCore $core dcCore instance + * @param dcPostsActionsPage $pa dcPostsActionsPage instance + * @param ArrayObject $post _POST actions + */ + public static function callbackRemove(dcCore $core, dcPostsActionsPage $pa, ArrayObject $post) + { + # No entry + $posts_ids = $pa->getIDs(); + if (empty($posts_ids)) { + throw new Exception(__('No entry selected')); + } - /** - * Posts actions callback to remove linked feed - * - * @param dcCore $core dcCore instance - * @param dcPostsActionsPage $pa dcPostsActionsPage instance - * @param ArrayObject $post _POST actions - */ - public static function callbackRemove(dcCore $core, dcPostsActionsPage $pa, ArrayObject $post) - { - # No entry - $posts_ids = $pa->getIDs(); - if (empty($posts_ids)) { - throw new Exception(__('No entry selected')); - } + # No right + if (!$core->auth->check('delete,contentadmin',$core->blog->id)) { + throw new Exception(__('No enough right')); + } - # No right - if (!$core->auth->check('delete,contentadmin',$core->blog->id)) { - throw new Exception(__('No enough right')); - } + # Delete expired date + foreach($posts_ids as $post_id) { + self::delFeed($core, $post_id); + } - # Delete expired date - foreach($posts_ids as $post_id) { - self::delFeed($core, $post_id); - } + dcPage::addSuccessNotice(__('Linked feed deleted.')); + $pa->redirect(true); + } - dcPage::addSuccessNotice(__('Linked feed deleted.')); - $pa->redirect(true); - } + /** + * Posts actions callback to add linked feed + * + * @param dcCore $core dcCore instance + * @param dcPostsActionsPage $pa dcPostsActionsPage instance + * @param ArrayObject $post _POST actions + */ + public static function callbackAdd(dcCore $core, dcPostsActionsPage $pa, ArrayObject $post) + { + # No entry + $posts_ids = $pa->getIDs(); + if (empty($posts_ids)) { + throw new Exception(__('No entry selected')); + } - /** - * Posts actions callback to add linked feed - * - * @param dcCore $core dcCore instance - * @param dcPostsActionsPage $pa dcPostsActionsPage instance - * @param ArrayObject $post _POST actions - */ - public static function callbackAdd(dcCore $core, dcPostsActionsPage $pa, ArrayObject $post) - { - # No entry - $posts_ids = $pa->getIDs(); - if (empty($posts_ids)) { - throw new Exception(__('No entry selected')); - } + # Save action + if (!empty($post['fac_url']) + && !empty($post['fac_format'])) { + foreach($posts_ids as $post_id) { + self::delFeed($core, $post_id); + self::addFeed($core, $post_id, $post); + } - # Save action - if (!empty($post['fac_url']) - && !empty($post['fac_format']) - ) { - foreach($posts_ids as $post_id) { - self::delFeed($core, $post_id); - self::addFeed($core, $post_id, $post); - } + dcPage::addSuccessNotice(__('Linked feed added.')); + $pa->redirect(true); - dcPage::addSuccessNotice(__('Linked feed added.')); - $pa->redirect(true); - } + # Display form + } else { + $pa->beginPage( + dcPage::breadcrumb(array( + html::escapeHTML($core->blog->name) => '', + $pa->getCallerTitle() => $pa->getRedirection(true), + __('Linked feed to this selection') => '' + )) + ); - # Display form - else { - $pa->beginPage( - dcPage::breadcrumb(array( - html::escapeHTML($core->blog->name) => '', - $pa->getCallerTitle() => $pa->getRedirection(true), - __('Linked feed to this selection') => '' - )) - ); + echo + '
' . + $pa->getCheckboxes() . - echo - ''. - $pa->getCheckboxes(). + self::formFeed($core) . - self::formFeed($core). + '

' . + $core->formNonce() . + $pa->getHiddenFields() . + form::hidden(array('action'), 'fac_add') . + '

' . + '
'; - '

'. - $core->formNonce(). - $pa->getHiddenFields(). - form::hidden(array('action'), 'fac_add'). - '

'. - ''; + $pa->endPage(); + } + } - $pa->endPage(); - } - } + /** + * Linked feed form field + * + * @param dcCore $core dcCore instance + * @param string $url Feed URL + * @param string $format Feed format + * @return string Feed form content + */ + protected static function formFeed(dcCore $core, $url = '', $format = '') + { + return + '
' . + '
' . __('Linked feed') . '
' . + '

' . + form::field( + 'fac_url', + 60, + 255, + $url, + 'maximal' + ) . '

' . + '

' . + form::combo( + 'fac_format', + self::comboFac($core), + $format, + 'maximal' + ) . '

' . + ($url ? '

' . __('view feed') . '

' : '') . + '
'; + } - /** - * Linked feed form field - * - * @param dcCore $core dcCore instance - * @param string $url Feed URL - * @param string $format Feed format - * @return string Feed form content - */ - protected static function formFeed(dcCore $core, $url='', $format='') - { - return - '
'. - '
'.__('Linked feed').'
'. - '

'. - form::field( - 'fac_url', - 60, - 255, - $url, - 'maximal' - ).'

'. - '

'. - form::combo( - 'fac_format', - self::comboFac($core), - $format, - 'maximal' - ).'

'. - ($url ? '

'.__('view feed').'

' : ''). - '
'; - } + /** + * List of fac formats + * + * @param dcCore $core dcCore instance + * @return array List of fac formats + */ + protected static function comboFac(dcCore $core) + { + $formats = @unserialize($core->blog->settings->fac->fac_formats); + if (!is_array($formats) || empty($formats)) { + return array(); + } - /** - * List of fac formats - * - * @param dcCore $core dcCore instance - * @return array List of fac formats - */ - protected static function comboFac(dcCore $core) - { - $formats = @unserialize($core->blog->settings->fac->fac_formats); - if (!is_array($formats) || empty($formats)) { + $res = array(); + foreach($formats as $uid => $f) { + $res[$f['name']] = $uid; + } - return array(); - } + return $res; + } - $res = array(); - foreach($formats as $uid => $f) { - $res[$f['name']] = $uid; - } + /** + * Delete linked feed + * + * @param dcCore $core dcCore instance + * @param integer $post_id Post id + */ + protected static function delFeed(dcCore $core, $post_id) + { + $post_id = (integer) $post_id; + $core->meta->delPostMeta($post_id, 'fac'); + $core->meta->delPostMeta($post_id, 'facformat'); + } - return $res; - } + /** + * Add linked feed + * + * @param dcCore $core dcCore instance + * @param integer $post_id Post id + * @param array $options Feed options + */ + protected static function addFeed($core, $post_id, $options) + { + if (empty($options['fac_url']) + || empty($options['fac_format'])) { + return null; + } - /** - * Delete linked feed - * - * @param dcCore $core dcCore instance - * @param integer $post_id Post id - */ - protected static function delFeed(dcCore $core, $post_id) - { - $post_id = (integer) $post_id; - $core->meta->delPostMeta($post_id, 'fac'); - $core->meta->delPostMeta($post_id, 'facformat'); - } + $post_id = (integer) $post_id; - /** - * Add linked feed - * - * @param dcCore $core dcCore instance - * @param integer $post_id Post id - * @param array $options Feed options - */ - protected static function addFeed($core, $post_id, $options) - { - if (empty($options['fac_url']) - || empty($options['fac_format']) - ) { - return null; - } - - $post_id = (integer) $post_id; - - $core->meta->setPostMeta( - $post_id, - 'fac', - $options['fac_url'] - ); - $core->meta->setPostMeta( - $post_id, - 'facformat', - $options['fac_format'] - ); - } -} + $core->meta->setPostMeta( + $post_id, + 'fac', + $options['fac_url'] + ); + $core->meta->setPostMeta( + $post_id, + 'facformat', + $options['fac_format'] + ); + } +} \ No newline at end of file diff --git a/_config.php b/_config.php index 35bec29..8254d19 100644 --- a/_config.php +++ b/_config.php @@ -3,8 +3,7 @@ # # This file is part of fac, a plugin for Dotclear 2. # -# Copyright (c) 2009-2013 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcd.lv +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -13,524 +12,518 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_CONTEXT_MODULE')) { - - return null; + return null; } $redir = empty($_REQUEST['redir']) ? - $list->getURL().'#plugins' : $_REQUEST['redir']; + $list->getURL() . '#plugins' : $_REQUEST['redir']; # -- Combos of types of supported public pages -- -$types = array( - __('home page') => 'default', - __('post pages') => 'post', - __('tags pages') => 'tag', - __('archives pages') => 'archive', - __('category pages') => 'category', - __('entries feed') => 'feed' -); +$types = [ + __('home page') => 'default', + __('post pages') => 'post', + __('tags pages') => 'tag', + __('archives pages') => 'archive', + __('category pages') => 'category', + __('entries feed') => 'feed' +]; if ($core->plugins->moduleExists('muppet')) { - foreach(muppet::getPostTypes() as $k => $v) { - $types[sprintf( - __('"%s" pages from extension muppet'), - $v['name'] - )] = $k; - } + foreach(muppet::getPostTypes() as $k => $v) { + $types[sprintf( + __('"%s" pages from extension muppet'), + $v['name'] + )] = $k; + } } # -- Get settings -- $core->blog->settings->addNamespace('fac'); $s = $core->blog->settings->fac; -$fac_active = (boolean) $s->fac_active; -$fac_defaultfeedtitle = (string) $s->fac_defaultfeedtitle; -$fac_showfeeddesc = (boolean) $s->fac_showfeeddesc; -$fac_public_tpltypes = @unserialize($s->fac_public_tpltypes); -$fac_formats = @unserialize($s->fac_formats); +$fac_active = (boolean) $s->fac_active; +$fac_defaultfeedtitle = (string) $s->fac_defaultfeedtitle; +$fac_showfeeddesc = (boolean) $s->fac_showfeeddesc; +$fac_public_tpltypes = @unserialize($s->fac_public_tpltypes); +$fac_formats = @unserialize($s->fac_formats); if (!is_array($fac_public_tpltypes)) { - $fac_public_tpltypes = array(); + $fac_public_tpltypes = array(); } if (!is_array($fac_formats)) { - $fac_formats = array(); + $fac_formats = array(); } # -- Set settings -- if (!empty($_POST['save'])) { + try { + $fac_active = !empty($_POST['fac_active']); + $fac_defaultfeedtitle = (string) $_POST['fac_defaultfeedtitle']; + $fac_showfeeddesc = !empty($_POST['fac_showfeeddesc']); + $fac_public_tpltypes = $_POST['fac_public_tpltypes']; + $fac_formats = array(); - try { - $fac_active = !empty($_POST['fac_active']); - $fac_defaultfeedtitle = (string) $_POST['fac_defaultfeedtitle']; - $fac_showfeeddesc = !empty($_POST['fac_showfeeddesc']); - $fac_public_tpltypes = $_POST['fac_public_tpltypes']; - $fac_formats = array(); + foreach($_POST['fac_formats'] as $uid => $f) { + if (!empty($f['name'])) { + $fac_formats[$uid] = $f; + } + } - foreach($_POST['fac_formats'] as $uid => $f) { - if (!empty($f['name'])) { - $fac_formats[$uid] = $f; - } - } + $s->put('fac_active', $fac_active); + $s->put('fac_defaultfeedtitle', $fac_defaultfeedtitle); + $s->put('fac_showfeeddesc', $fac_showfeeddesc); + $s->put('fac_public_tpltypes', serialize($fac_public_tpltypes)); + $s->put('fac_formats', serialize($fac_formats)); - $s->put('fac_active', $fac_active); - $s->put('fac_defaultfeedtitle', $fac_defaultfeedtitle); - $s->put('fac_showfeeddesc', $fac_showfeeddesc); - $s->put('fac_public_tpltypes', serialize($fac_public_tpltypes)); - $s->put('fac_formats', serialize($fac_formats)); + $core->blog->triggerBlog(); - $core->blog->triggerBlog(); - - dcPage::addSuccessNotice( - __('Configuration has been successfully updated.') - ); - http::redirect( - $list->getURL('module=fac&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=fac&conf=1&redir=' . $list->getRedir()) + ); + } + catch (Exception $e) { + $core->error->add($e->getMessage()); + } } # -- Display form -- echo ' -
-

'.__('Activation').'

+

' . __('Activation') . '

-

+

-
'.__('Show feed after content on:').'
'; +
' . __('Show feed after content on:') . '
'; foreach($types as $k => $v) { - echo ' -

'; + echo ' +

'; } echo ' -
-

'.__('Feed').'

+

' . __('Feed') . '

-

'. -form::field('fac_defaultfeedtitle', 65, 255, $fac_defaultfeedtitle).'

-

'.__('Use %T to insert title of feed.').'

+

' . +form::field('fac_defaultfeedtitle', 65, 255, $fac_defaultfeedtitle) . '

+

' . __('Use %T to insert title of feed.') . '

-

+

'; $i = 1; foreach($fac_formats as $uid => $f) { + if (empty($f['name'])) { + continue; + } - if (empty($f['name'])) { - continue; - } + echo ' +
+

' . sprintf(__('Format %s'), $i) . '

- echo ' -
-

'.sprintf(__('Format %s'), $i).'

+
' . __('General') . '
-
'.__('General').'
+

' . + form::field( + array( + 'fac_formats[' . $uid . '][name]', + 'fac_formats_' . $uid . '_name' + ), + 20, + 255, + empty($f['name']) ? '' : $f['name'], + 'maximal' + ) . '

+

' . + __('In order to remove a format, leave its name empty.') . + '

-

'. - form::field( - array( - 'fac_formats['.$uid.'][name]', - 'fac_formats_'.$uid.'_name' - ), - 20, - 255, - empty($f['name']) ? '' : $f['name'], - 'maximal' - ).'

-

'. - __('In order to remove a format, leave its name empty.'). - '

+

' . + form::field( + array( + 'fac_formats[' . $uid . '][dateformat]', + 'fac_formats_' . $uid . '_dateformat' + ), + 20, + 255, + empty($f['dateformat']) ? '' : $f['dateformat'], + 'maximal' + ) . '

+

' . + __('Use date format of Dotclear or leave empty to use default date format of blog.') . + '

-

'. - form::field( - array( - 'fac_formats['.$uid.'][dateformat]', - 'fac_formats_'.$uid.'_dateformat' - ), - 20, - 255, - empty($f['dateformat']) ? '' : $f['dateformat'], - 'maximal' - ).'

-

'. - __('Use date format of Dotclear or leave empty to use default date format of blog.'). - '

+

' . + form::field( + array( + 'fac_formats[' . $uid . '][lineslimit]', + 'fac_formats_' . $uid . '_lineslimit' + ), + 5, + 4, + empty($f['lineslimit']) ? '' : $f['lineslimit'], + 'maximal' + ) . '

+

' . + __('Leave lengh empty for no limit.') . + '

-

'. - form::field( - array( - 'fac_formats['.$uid.'][lineslimit]', - 'fac_formats_'.$uid.'_lineslimit' - ), - 5, - 4, - empty($f['lineslimit']) ? '' : $f['lineslimit'], - 'maximal' - ).'

-

'. - __('Leave lengh empty for no limit.'). - '

+
' . __('Title') . '
-
'.__('Title').'
+

' . + form::field( + array( + 'fac_formats[' . $uid . '][linestitletext]', + 'fac_formats_' . $uid . '_linestitletext' + ), + 20, + 255, + empty($f['linestitletext']) ? '' : $f['linestitletext'], + 'maximal' + ) . '

+

' . + __('Format can be:') . + '%D : ' . __('Date') . + ', %T : ' . __('Title') . + ', %A : ' . __('Author') . + ', %E : ' . __('Description') . + ', %C : ' . __('Content') . + '

-

'. - form::field( - array( - 'fac_formats['.$uid.'][linestitletext]', - 'fac_formats_'.$uid.'_linestitletext' - ), - 20, - 255, - empty($f['linestitletext']) ? '' : $f['linestitletext'], - 'maximal' - ).'

-

'. - __('Format can be:'). - '%D : '.__('Date'). - ', %T : '.__('Title'). - ', %A : '.__('Author'). - ', %E : '.__('Description'). - ', %C : '.__('Content'). - '

+

' . + form::field( + array( + 'fac_formats[' . $uid . '][linestitleover]', + 'fac_formats_' . $uid . '_linestitleover' + ), + 20, + 255, + empty($f['linestitleover']) ? '' : $f['linestitleover'], + 'maximal' + ) . '

+

' . + __('Format can be:') . + '%D : ' . __('Date') . + ', %T : ' . __('Title') . + ', %A : ' . __('Author') . + ', %E : ' . __('Description') . + ', %C : ' . __('Content') . + '

-

'. - form::field( - array( - 'fac_formats['.$uid.'][linestitleover]', - 'fac_formats_'.$uid.'_linestitleover' - ), - 20, - 255, - empty($f['linestitleover']) ? '' : $f['linestitleover'], - 'maximal' - ).'

-

'. - __('Format can be:'). - '%D : '.__('Date'). - ', %T : '.__('Title'). - ', %A : '.__('Author'). - ', %E : '.__('Description'). - ', %C : '.__('Content'). - '

+

' . + form::field( + array( + 'fac_formats[' . $uid . '][linestitlelength]', + 'fac_formats_' . $uid . '_linestitlelength' + ), + 5, + 4, + empty($f['linestitlelength']) ? '' : $f['linestitlelength'], + 'maximal' + ) . '

+

' . + __('Leave lengh empty for no limit.') . + '

-

'. - form::field( - array( - 'fac_formats['.$uid.'][linestitlelength]', - 'fac_formats_'.$uid.'_linestitlelength' - ), - 5, - 4, - empty($f['linestitlelength']) ? '' : $f['linestitlelength'], - 'maximal' - ).'

-

'. - __('Leave lengh empty for no limit.'). - '

+
' . __('Description') . '
-
'.__('Description').'
+

-

+

-

+

' . + form::field( + array( + 'fac_formats[' . $uid . '][linesdescriptionlength]', + 'fac_formats_' . $uid . '_linesdescriptionlength' + ), + 5, + 4, + empty($f['linesdescriptionlength']) ? '' : $f['linesdescriptionlength'], + 'maximal' + ) . '

+

' . + __('Leave lengh empty for no limit.') . + '

-

'. - form::field( - array( - 'fac_formats['.$uid.'][linesdescriptionlength]', - 'fac_formats_'.$uid.'_linesdescriptionlength' - ), - 5, - 4, - empty($f['linesdescriptionlength']) ? '' : $f['linesdescriptionlength'], - 'maximal' - ).'

-

'. - __('Leave lengh empty for no limit.'). - '

+
' . __('Content') . '
-
'.__('Content').'
+

-

+

-

+

' . + form::field( + array( + 'fac_formats[' . $uid . '][linescontentlength]', + 'fac_formats_' . $uid . '_linescontentlength' + ), + 5, + 4, + empty($f['linescontentlength']) ? '' : $f['linescontentlength'], + 'maximal' + ) . '

+

' . + __('Leave lengh empty for no limit.') . + '

-

'. - form::field( - array( - 'fac_formats['.$uid.'][linescontentlength]', - 'fac_formats_'.$uid.'_linescontentlength' - ), - 5, - 4, - empty($f['linescontentlength']) ? '' : $f['linescontentlength'], - 'maximal' - ).'

-

'. - __('Leave lengh empty for no limit.'). - '

+
-
+
'; -
'; - - $i++; + $i++; } $uid = uniqid(); echo '
-

'.__('New format').'

+

' . __('New format') . '

-
'.__('General').'
+
' . __('General') . '
-

'. +

' . form::field( - array( - 'fac_formats['.$uid.'][name]', - 'fac_formats_'.$uid.'_name' - ), - 20, - 255, - '', - 'maximal' -).'

+ array( + 'fac_formats[' . $uid . '][name]', + 'fac_formats_' . $uid . '_name' + ), + 20, + 255, + '', + 'maximal' +) . '

'. -__('In order to remove a format, leave its name empty.'). +__('In order to remove a format, leave its name empty.') . '

-

'. +

' . form::field( - array( - 'fac_formats['.$uid.'][dateformat]', - 'fac_formats_'.$uid.'_dateformat' - ), - 20, - 255, - '', - 'maximal' -).'

-

'. -__('Use date format of Dotclear or leave empty to use default date format of blog.'). + array( + 'fac_formats[' . $uid . '][dateformat]', + 'fac_formats_' . $uid . '_dateformat' + ), + 20, + 255, + '', + 'maximal' +) . '

+

' . +__('Use date format of Dotclear or leave empty to use default date format of blog.') . '

-

'. +

' . form::field( - array( - 'fac_formats['.$uid.'][lineslimit]', - 'fac_formats_'.$uid.'_lineslimit' - ), - 5, - 4, - 5, - 'maximal' -).'

-

'. -__('Leave lengh empty for no limit.'). + array( + 'fac_formats[' . $uid . '][lineslimit]', + 'fac_formats_' . $uid . '_lineslimit' + ), + 5, + 4, + 5, + 'maximal' +) . '

+

' . +__('Leave lengh empty for no limit.') . '

-
'.__('Title').'
+
' . __('Title') . '
-

'. +

' . form::field( - array( - 'fac_formats['.$uid.'][linestitletext]', - 'fac_formats_'.$uid.'_linestitletext' - ), - 20, - 255, - '%T', - 'maximal' -).'

-

'. -__('Format can be:'). -'%D : '.__('Date'). -', %T : '.__('Title'). -', %A : '.__('Author'). -', %E : '.__('Description'). -', %C : '.__('Content'). + array( + 'fac_formats[' . $uid . '][linestitletext]', + 'fac_formats_' . $uid . '_linestitletext' + ), + 20, + 255, + '%T', + 'maximal' +) . '

+

' . +__('Format can be:') . +'%D : ' . __('Date') . +', %T : ' . __('Title') . +', %A : ' . __('Author') . +', %E : ' . __('Description') . +', %C : ' . __('Content') . '

-

'. +

' . form::field( - array( - 'fac_formats['.$uid.'][linestitleover]', - 'fac_formats_'.$uid.'_linestitleover' - ), - 20, - 255, - '%D', - 'maximal' -).'

-

'. -__('Format can be:'). -'%D : '.__('Date'). -', %T : '.__('Title'). -', %A : '.__('Author'). -', %E : '.__('Description'). -', %C : '.__('Content'). + array( + 'fac_formats[' . $uid . '][linestitleover]', + 'fac_formats_' . $uid . '_linestitleover' + ), + 20, + 255, + '%D', + 'maximal' +) . '

+

' . +__('Format can be:') . +'%D : ' . __('Date') . +', %T : ' . __('Title') . +', %A : ' . __('Author') . +', %E : ' . __('Description') . +', %C : ' . __('Content') . '

-

'. +

' . form::field( - array( - 'fac_formats['.$uid.'][linestitlelength]', - 'fac_formats_'.$uid.'_linestitlelength' - ), - 5, - 4, - 150, - 'maximal' -).'

-

'. -__('Leave lengh empty for no limit.'). + array( + 'fac_formats[' . $uid . '][linestitlelength]', + 'fac_formats_' . $uid . '_linestitlelength' + ), + 5, + 4, + 150, + 'maximal' +) . '

+

' . +__('Leave lengh empty for no limit.') . '

-
'.__('Description').'
+
' . __('Description') . '
-

+ array( + 'fac_formats[' . $uid . '][showlinesdescription]', + 'fac_formats_' . $uid . '_showlinesdescription' + ), + 1, + 0 +) . +__('Show description of entries') . '

-

+ array( + 'fac_formats[' . $uid . '][linesdescriptionnohtml]', + 'fac_formats_' . $uid . '_linesdescriptionnohtml' + ), + 1, + 1 +) . +__('Remove html of description') . '

-

'. +

' . form::field( - array( - 'fac_formats['.$uid.'][linesdescriptionlength]', - 'fac_formats_'.$uid.'_linesdescriptionlength' - ), - 5, - 4, - 350, - 'maximal' -).'

-

'. -__('Leave lengh empty for no limit.'). + array( + 'fac_formats[' . $uid . '][linesdescriptionlength]', + 'fac_formats_' . $uid . '_linesdescriptionlength' + ), + 5, + 4, + 350, + 'maximal' +) . '

+

' . +__('Leave lengh empty for no limit.') . '

-
'.__('Content').'
+
' . __('Content') . '
-

+ array( + 'fac_formats[' . $uid . '][showlinescontent]', + 'fac_formats_' . $uid . '_showlinescontent' + ), + 1, + 0 +) . +__('Show content of entries') . '

-

+ array( + 'fac_formats[' . $uid . '][linescontentnohtml]', + 'fac_formats_' . $uid . '_linescontentnohtml' + ), + 1, + 1 +) . +__('Remove html of content') . '

-

'. +

' . form::field( - array( - 'fac_formats['.$uid.'][linescontentlength]', - 'fac_formats_'.$uid.'_linescontentlength' - ), - 5, - 4, - 350, - 'maximal' -).'

-

'. -__('Leave lengh empty for no limit.'). + array( + 'fac_formats[' . $uid . '][linescontentlength]', + 'fac_formats_' . $uid . '_linescontentlength' + ), + 5, + 4, + 350, + 'maximal' +) . '

+

' . +__('Leave lengh empty for no limit.') . '

@@ -538,30 +531,30 @@ __('Leave lengh empty for no limit.').
-

'.__('Informations').'

+

' . __('Informations') . '

-
'.__('Theme').'
-

'. -__('Theme must have behavoir publicEntryAfterContent.').' '. -__('To add feed to an entry edit this entry and put in sidebar the url of the feed and select a format.'). +

' . __('Theme') . '
+

' . +__('Theme must have behavoir publicEntryAfterContent.') . ' ' . +__('To add feed to an entry edit this entry and put in sidebar the url of the feed and select a format.') . '

-
'.__('Structure').'
-
'.html::escapeHTML('
+
' . __('Structure') . '
+
' . html::escapeHTML('
 
-

'.__('Title of feed').'

-

'.__('Description of feed').'

+

' . __('Title of feed') . '

+

' . __('Description of feed') . '

-
'.__('Title of entry').'
-
'.__('Description of entry').'
+
' . __('Title of entry') . '
+
' . __('Description of entry') . '
-').'
+') . '
-
'; +
'; \ No newline at end of file diff --git a/_define.php b/_define.php index b3e2c95..bc9ca90 100644 --- a/_define.php +++ b/_define.php @@ -3,8 +3,7 @@ # # This file is part of fac, a plugin for Dotclear 2. # -# Copyright (c) 2009-2013 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcd.lv +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -13,25 +12,19 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_RC_PATH')) { - - return null; + return null; } $this->registerModule( - /* Name */ - "fac", - /* Description*/ - "Add RSS/Atom feeds after entries content", - /* Author */ - "Jean-Christian Denis", - /* Version */ - '0.7', - /* Properies */ - array( - 'permissions' => 'usage,contentadmin', - 'type' => 'plugin', - 'dc_min' => '2.6', - 'support' => 'http://jcd.lv/q=fac', - 'details' => 'http://plugins.dotaddict.org/dc2/details/fac' - ) -); + 'fac', + 'Add RSS/Atom feeds after entries content', + 'Jean-Christian Denis and Contributors', + '0.8', + [ + 'permissions' => 'usage,contentadmin', + 'type' => 'plugin', + 'dc_min' => '2.18', + 'support' => 'https://github.com/JcDenis/fac', + 'details' => 'https://plugins.dotaddict.org/dc2/details/fac' + ] +); \ No newline at end of file diff --git a/_install.php b/_install.php index 19ffd8a..dcccebb 100644 --- a/_install.php +++ b/_install.php @@ -3,8 +3,7 @@ # # This file is part of fac, a plugin for Dotclear 2. # -# Copyright (c) 2009-2013 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcd.lv +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -13,8 +12,7 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_CONTEXT_ADMIN')) { - - return null; + return null; } # -- Module specs -- @@ -22,107 +20,107 @@ if (!defined('DC_CONTEXT_ADMIN')) { $dc_min = '2.6'; $mod_id = 'fac'; $mod_conf = array( - array( - 'fac_active', - 'Enabled fac plugin', - false, - 'boolean' - ), - array( - 'fac_public_tpltypes', - 'List of templates types which used fac', - serialize(array('post', 'tag', 'archive')), - 'string' - ), - array( - 'fac_formats', - 'Formats of feeds contents', - serialize(array( - uniqid() => array( - 'name' => 'default', - 'dateformat' => '', - 'lineslimit' => '5', - 'linestitletext' => '%T', - 'linestitleover' => '%D', - 'linestitlelength' => '150', - 'showlinesdescription' => '0', - 'linesdescriptionlength' => '350', - 'linesdescriptionnohtml' => '1', - 'showlinescontent' => '0', - 'linescontentlength' => '350', - 'linescontentnohtml' => '1' - ), - uniqid() => array( - 'name' => 'full', - 'dateformat' => '', - 'lineslimit' => '20', - 'linestitletext' => '%T', - 'linestitleover' => '%D - %E', - 'linestitlelength' => '', - 'showlinesdescription' => '1', - 'linesdescriptionlength' => '', - 'linesdescriptionnohtml' => '1', - 'showlinescontent' => '1', - 'linescontentlength' => '', - 'linescontentnohtml' => '1' - ) - )), - 'string' - ), - array( - 'fac_defaultfeedtitle', - 'Default title of feed', - '%T', - 'string' - ), - array( - 'fac_showfeeddesc', - 'Show description of feed', - 1, - 'boolean' - ) + array( + 'fac_active', + 'Enabled fac plugin', + false, + 'boolean' + ), + array( + 'fac_public_tpltypes', + 'List of templates types which used fac', + serialize(array('post', 'tag', 'archive')), + 'string' + ), + array( + 'fac_formats', + 'Formats of feeds contents', + serialize(array( + uniqid() => array( + 'name' => 'default', + 'dateformat' => '', + 'lineslimit' => '5', + 'linestitletext' => '%T', + 'linestitleover' => '%D', + 'linestitlelength' => '150', + 'showlinesdescription' => '0', + 'linesdescriptionlength' => '350', + 'linesdescriptionnohtml' => '1', + 'showlinescontent' => '0', + 'linescontentlength' => '350', + 'linescontentnohtml' => '1' + ), + uniqid() => array( + 'name' => 'full', + 'dateformat' => '', + 'lineslimit' => '20', + 'linestitletext' => '%T', + 'linestitleover' => '%D - %E', + 'linestitlelength' => '', + 'showlinesdescription' => '1', + 'linesdescriptionlength' => '', + 'linesdescriptionnohtml' => '1', + 'showlinescontent' => '1', + 'linescontentlength' => '', + 'linescontentnohtml' => '1' + ) + )), + 'string' + ), + array( + 'fac_defaultfeedtitle', + 'Default title of feed', + '%T', + 'string' + ), + array( + 'fac_showfeeddesc', + 'Show description of feed', + 1, + 'boolean' + ) ); # -- Nothing to change below -- try { - # Check module version - if (version_compare( - $core->getVersion($mod_id), - $core->plugins->moduleInfo($mod_id, 'version'), - '>=' - )) { + # Check module version + if (version_compare( + $core->getVersion($mod_id), + $core->plugins->moduleInfo($mod_id, 'version'), + '>=' + )) { - return null; - } + return null; + } - # Check Dotclear version - if (!method_exists('dcUtils', 'versionsCompare') - || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) { - throw new Exception(sprintf( - '%s requires Dotclear %s', $mod_id, $dc_min - )); - } + # Check Dotclear version + if (!method_exists('dcUtils', 'versionsCompare') + || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) { + throw new Exception(sprintf( + '%s requires Dotclear %s', $mod_id, $dc_min + )); + } - # Set module settings - $core->blog->settings->addNamespace($mod_id); - foreach($mod_conf as $v) { - $core->blog->settings->{$mod_id}->put( - $v[0], $v[2], $v[3], $v[1], false, true - ); - } + # Set module settings + $core->blog->settings->addNamespace($mod_id); + foreach($mod_conf as $v) { + $core->blog->settings->{$mod_id}->put( + $v[0], $v[2], $v[3], $v[1], false, true + ); + } - # Set module version - $core->setVersion( - $mod_id, - $core->plugins->moduleInfo($mod_id, 'version') - ); + # Set module version + $core->setVersion( + $mod_id, + $core->plugins->moduleInfo($mod_id, '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/_public.php b/_public.php index 80f10db..2b535f4 100644 --- a/_public.php +++ b/_public.php @@ -3,8 +3,7 @@ # # This file is part of fac, a plugin for Dotclear 2. # -# Copyright (c) 2009-2013 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcd.lv +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -13,13 +12,12 @@ # -- END LICENSE BLOCK ------------------------------------ if (!defined('DC_RC_PATH')) { - - return null; + return null; } $core->addBehavior( - 'publicEntryAfterContent', - array('facPublic', 'publicEntryAfterContent') + 'publicEntryAfterContent', + array('facPublic', 'publicEntryAfterContent') ); /** @@ -29,237 +27,226 @@ $core->addBehavior( */ class facPublic { - /** - * Add feed after entry - * - * @param dcCore $core dcCore instance - * @param context $_ctx context instance - */ - public static function publicEntryAfterContent(dcCore $core, context $_ctx) - { - $core->blog->settings->addNamespace('fac'); + /** + * Add feed after entry + * + * @param dcCore $core dcCore instance + * @param context $_ctx context instance + */ + public static function publicEntryAfterContent(dcCore $core, context $_ctx) + { + $core->blog->settings->addNamespace('fac'); - # Not active or not a post - if (!$core->blog->settings->fac->fac_active - || !$_ctx->exists('posts') - ) { - return null; - } + # Not active or not a post + if (!$core->blog->settings->fac->fac_active + || !$_ctx->exists('posts')) { + return null; + } - # Not in page to show - $types = @unserialize($core->blog->settings->fac->fac_public_tpltypes); - if (!is_array($types) - || !in_array($core->url->type,$types) - ) { - return null; - } + # Not in page to show + $types = @unserialize($core->blog->settings->fac->fac_public_tpltypes); + if (!is_array($types) + || !in_array($core->url->type,$types)) { + return null; + } - # Get related feed - $fac_url = $core->meta->getMetadata(array( - 'meta_type' => 'fac', - 'post_id' => $_ctx->posts->post_id, - 'limit' => 1 - )); - if ($fac_url->isEmpty()) { + # Get related feed + $fac_url = $core->meta->getMetadata([ + 'meta_type' => 'fac', + 'post_id' => $_ctx->posts->post_id, + 'limit' => 1 + ]); + if ($fac_url->isEmpty()) { + return null; + } - return null; - } + # Get related format + $fac_format = $core->meta->getMetadata([ + 'meta_type' => 'facformat', + 'post_id' => $_ctx->posts->post_id, + 'limit' => 1 + ]); + if ($fac_format->isEmpty()) { + return null; + } - # Get related format - $fac_format = $core->meta->getMetadata(array( - 'meta_type' => 'facformat', - 'post_id' => $_ctx->posts->post_id, - 'limit' => 1 - )); - if ($fac_format->isEmpty()) { + # Get format info + $default_format = array( + 'name' => 'default', + 'dateformat' => '', + 'lineslimit' => '5', + 'linestitletext' => '%T', + 'linestitleover' => '%D', + 'linestitlelength' => '150', + 'showlinesdescription' => '0', + 'linesdescriptionlength' => '350', + 'linesdescriptionnohtml' => '1', + 'showlinescontent' => '0', + 'linescontentlength' => '350', + 'linescontentnohtml' => '1' + ); - return null; - } + $formats = @unserialize($core->blog->settings->fac->fac_formats); + if (empty($formats) + || !is_array($formats) + || !isset($formats[$fac_format->meta_id])) { + $format = $default_format; + } else { + $format = array_merge( + $default_format, + $formats[$fac_format->meta_id] + ); + } - # Get format info - $default_format = array( - 'name' => 'default', - 'dateformat' => '', - 'lineslimit' => '5', - 'linestitletext' => '%T', - 'linestitleover' => '%D', - 'linestitlelength' => '150', - 'showlinesdescription' => '0', - 'linesdescriptionlength' => '350', - 'linesdescriptionnohtml' => '1', - 'showlinescontent' => '0', - 'linescontentlength' => '350', - 'linescontentnohtml' => '1' - ); + # Read feed url + $cache = is_dir(DC_TPL_CACHE . '/fac') ? DC_TPL_CACHE . '/fac' : null; + try { + $feed = feedReader::quickParse($fac_url->meta_id, $cache); + } catch (Exception $e) { + $feed = null; + } - $formats = @unserialize($core->blog->settings->fac->fac_formats); - if (empty($formats) - || !is_array($formats) - || !isset($formats[$fac_format->meta_id]) - ) { - $format = $default_format; - } - else { - $format = array_merge( - $default_format, - $formats[$fac_format->meta_id] - ); - } + # No entries + if (!$feed) { + return null; + } - # Read feed url - $cache = is_dir(DC_TPL_CACHE.'/fac') ? DC_TPL_CACHE.'/fac' : null; - try { - $feed = feedReader::quickParse($fac_url->meta_id,$cache); - } - catch (Exception $e) { - $feed = null; - } + # Feed title + $feedtitle = ''; + if ('' != $core->blog->settings->fac->fac_defaultfeedtitle) { + $feedtitle = '

' . html::escapeHTML(empty($feed->title) ? + str_replace( + '%T', + __('a related feed'), + $core->blog->settings->fac->fac_defaultfeedtitle + ) : + str_replace( + '%T', + $feed->title, + $core->blog->settings->fac->fac_defaultfeedtitle + ) + ) . '

'; + } - # No entries - if (!$feed) { + # Feed desc + $feeddesc = ''; + if ($core->blog->settings->fac->fac_showfeeddesc + && '' != $feed->description) { + $feeddesc = + '

' . context::global_filter($feed->description, 1, 1, 0, 0, 0) . '

'; + } - return null; - } + # Date format + $dateformat = '' != $format['dateformat'] ? + $format['dateformat'] : + $core->blog->settings->system->date_format . ',' . $core->blog->settings->system->time_format; - # Feed title - $feedtitle = ''; - if ('' != $core->blog->settings->fac->fac_defaultfeedtitle) { - $feedtitle = '

'.html::escapeHTML(empty($feed->title) ? - str_replace( - '%T', - __('a related feed'), - $core->blog->settings->fac->fac_defaultfeedtitle - ) : - str_replace( - '%T', - $feed->title, - $core->blog->settings->fac->fac_defaultfeedtitle - ) - ).'

'; - } + # Enrties limit + $entrieslimit = abs((integer) $format['lineslimit']); + $uselimit = $entrieslimit > 0 ? true : false; - # Feed desc - $feeddesc = ''; - if ($core->blog->settings->fac->fac_showfeeddesc - && '' != $feed->description - ) { - $feeddesc = - '

'.context::global_filter($feed->description,1,1,0,0,0).'

'; - } + echo + '
' . + $feedtitle . $feeddesc . + '
'; - # Date format - $dateformat = '' != $format['dateformat'] ? - $format['dateformat'] : - $core->blog->settings->system->date_format.','.$core->blog->settings->system->time_format; + $i = 0; + foreach ($feed->items as $item) { - # Enrties limit - $entrieslimit = abs((integer) $format['lineslimit']); - $uselimit = $entrieslimit > 0 ? true : false; + # Format date + $date = dt::dt2str($dateformat, $item->pubdate); - echo - '
'. - $feedtitle.$feeddesc. - '
'; + # Entries title + $title = context::global_filter( + str_replace( + array( + '%D', + '%T', + '%A', + '%E', + '%C' + ), + array( + $date, + $item->title, + $item->creator, + $item->description, + $item->content + ), + $format['linestitletext'] + ), + 0, + 1, + abs((integer) $format['linestitlelength']), + 0, + 0 + ); - $i = 0; - foreach ($feed->items as $item) { + # Entries over title + $overtitle = context::global_filter( + str_replace( + array( + '%D', + '%T', + '%A', + '%E', + '%C' + ), + array( + $date, + $item->title, + $item->creator, + $item->description, + $item->content + ), + $format['linestitleover'] + ), + 0, + 1, + 350, + 0, + 0 + ); - # Format date - $date = dt::dt2str($dateformat, $item->pubdate); + # Entries description + $description = ''; + if ($format['showlinesdescription'] + && '' != $item->description) { + $description = '
' . + context::global_filter( + $item->description, + 0, + (integer) $format['linesdescriptionnohtml'], + abs((integer) $format['linesdescriptionlength']), + 0,0 + ) . '
'; + } - # Entries title - $title = context::global_filter( - str_replace( - array( - '%D', - '%T', - '%A', - '%E', - '%C' - ), - array( - $date, - $item->title, - $item->creator, - $item->description, - $item->content - ), - $format['linestitletext'] - ), - 0, - 1, - abs((integer) $format['linestitlelength']), - 0, - 0 - ); + # Entries content + $content = ''; + if ($format['showlinescontent'] + && '' != $item->content) { + $content = '
'. + context::global_filter( + $item->content, + 0, + (integer) $format['linescontentnohtml'], + abs((integer) $format['linescontentlength']), + 0, + 0 + ) . '
'; + } - # Entries over title - $overtitle = context::global_filter( - str_replace( - array( - '%D', - '%T', - '%A', - '%E', - '%C' - ), - array( - $date, - $item->title, - $item->creator, - $item->description, - $item->content - ), - $format['linestitleover'] - ), - 0, - 1, - 350, - 0, - 0 - ); + echo + '
' . $title . '
' . + $description . $content; - # Entries description - $description = ''; - if ($format['showlinesdescription'] - && '' != $item->description - ) { - $description = '
'. - context::global_filter( - $item->description, - 0, - (integer) $format['linesdescriptionnohtml'], - abs((integer) $format['linesdescriptionlength']), - 0,0 - ).'
'; - } - - # Entries content - $content = ''; - if ($format['showlinescontent'] - && '' != $item->content - ) { - $content = '
'. - context::global_filter( - $item->content, - 0, - (integer) $format['linescontentnohtml'], - abs((integer) $format['linescontentlength']), - 0, - 0 - ).'
'; - } - - echo - '
'.$title.'
'. - $description.$content; - - $i++; - if ($uselimit && $i == $entrieslimit) { - break; - } - } - echo '
'; - } -} + $i++; + if ($uselimit && $i == $entrieslimit) { + break; + } + } + echo '
'; + } +} \ No newline at end of file diff --git a/locales/en/help/help.html b/locales/en/help/fac.html similarity index 100% rename from locales/en/help/help.html rename to locales/en/help/fac.html diff --git a/locales/en/resources.php b/locales/en/resources.php index 93f65d7..549b317 100644 --- a/locales/en/resources.php +++ b/locales/en/resources.php @@ -3,8 +3,7 @@ # # This file is part of fac, a plugin for Dotclear 2. # -# Copyright (c) 2009-2013 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcd.lv +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -12,7 +11,8 @@ # # -- END LICENSE BLOCK ------------------------------------ -if (!defined('DC_RC_PATH')) { return; } +if (!defined('DC_RC_PATH')) { + return; +} -$__resources['help']['fac'] = dirname(__FILE__).'/help/help.html'; -?> \ No newline at end of file +$__resources['help']['fac'] = dirname(__FILE__) . '/help/fac.html'; \ No newline at end of file diff --git a/locales/fr/help/help.html b/locales/fr/help/fac.html similarity index 100% rename from locales/fr/help/help.html rename to locales/fr/help/fac.html diff --git a/locales/fr/resources.php b/locales/fr/resources.php index 93f65d7..549b317 100644 --- a/locales/fr/resources.php +++ b/locales/fr/resources.php @@ -3,8 +3,7 @@ # # This file is part of fac, a plugin for Dotclear 2. # -# Copyright (c) 2009-2013 Jean-Christian Denis and contributors -# contact@jcdenis.fr http://jcd.lv +# Copyright (c) 2009-2021 Jean-Christian Denis and contributors # # Licensed under the GPL version 2.0 license. # A copy of this license is available in LICENSE file or at @@ -12,7 +11,8 @@ # # -- END LICENSE BLOCK ------------------------------------ -if (!defined('DC_RC_PATH')) { return; } +if (!defined('DC_RC_PATH')) { + return; +} -$__resources['help']['fac'] = dirname(__FILE__).'/help/help.html'; -?> \ No newline at end of file +$__resources['help']['fac'] = dirname(__FILE__) . '/help/fac.html'; \ No newline at end of file