PSR2 and license

This commit is contained in:
Jean-Christian Paul Denis 2021-08-20 18:39:12 +02:00
parent b38ca38b09
commit a5d4f0d467
10 changed files with 1008 additions and 1069 deletions

View File

@ -1,41 +1,36 @@
fac 0.8 - 2021-08-19
* update license
* fixed PSR2 coding style
fac 0.7 - 2013-11-11 fac 0.7 - 2013-11-11
===========================================================
* Switch to Dotclear 2.6 * Switch to Dotclear 2.6
* Fix missing feed description * Fix missing feed description
fac 0.6.1 - 2010-11-12 fac 0.6.1 - 2010-11-12
===========================================================
* Fixed install on nightly build * Fixed install on nightly build
fac 0.6 - 2010-08-16 fac 0.6 - 2010-08-16
===========================================================
* Added compatibility with plugin muppet * Added compatibility with plugin muppet
fac 0.5 - 2010-06-05 fac 0.5 - 2010-06-05
===========================================================
* Switched to DC 2.2 * Switched to DC 2.2
* Added predefined format (thx to Jean-Michel) (closes #459) * Added predefined format (thx to Jean-Michel) (closes #459)
fac 0.4.1 - 2010-04-10 fac 0.4.1 - 2010-04-10
===========================================================
* Fixed typo (thx to Jean-Michel) (closes #458) * Fixed typo (thx to Jean-Michel) (closes #458)
fac 0.4 - 2010-05-25 fac 0.4 - 2010-05-25
===========================================================
* Fixed Timeout error * Fixed Timeout error
* Fixed DC 2.1.7 * Fixed DC 2.1.7
fac 0.3 - 2010-04-10 fac 0.3 - 2010-04-10
===========================================================
* Added options to format feed * Added options to format feed
* Added DC 2.2 compatibility * Added DC 2.2 compatibility
* Removed class and used metadata * Removed class and used metadata
* Changed admin page design * Changed admin page design
fac 0.2 - 2010-02-17 fac 0.2 - 2010-02-17
===========================================================
* Fixed some fields in admin * Fixed some fields in admin
fac 0.1 - 2010-02-16 fac 0.1 - 2010-02-16
===========================================================
* First lab release * First lab release

View File

@ -3,8 +3,7 @@
# #
# This file is part of fac, a plugin for Dotclear 2. # This file is part of fac, a plugin for Dotclear 2.
# #
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# #
# Licensed under the GPL version 2.0 license. # Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at # A copy of this license is available in LICENSE file or at
@ -13,43 +12,23 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null;
return null;
} }
$core->blog->settings->addNamespace('fac'); $core->blog->settings->addNamespace('fac');
# Not active # Not active
if (!$core->blog->settings->fac->fac_active) { if (!$core->blog->settings->fac->fac_active) {
return null;
return null;
} }
# Admin behaviors # Admin behaviors
$core->addBehavior( $core->addBehavior('adminPostHeaders', ['facAdmin', 'adminPostHeaders']);
'adminPostHeaders', $core->addBehavior('adminPostFormItems', ['facAdmin', 'adminPostFormItems']);
array('facAdmin', 'adminPostHeaders') $core->addBehavior('adminAfterPostCreate', ['facAdmin', 'adminAfterPostSave']);
); $core->addBehavior('adminAfterPostUpdate', ['facAdmin', 'adminAfterPostSave']);
$core->addBehavior( $core->addBehavior('adminBeforePostDelete', ['facAdmin', 'adminBeforePostDelete']);
'adminPostFormItems', $core->addBehavior('adminPostsActionsPage', ['facAdmin', 'adminPostsActionsPage']);
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')
);
/** /**
* @ingroup DC_PLUGIN_FAC * @ingroup DC_PLUGIN_FAC
@ -58,294 +37,288 @@ $core->addBehavior(
*/ */
class facAdmin class facAdmin
{ {
/** /**
* Add javascript (toggle) * Add javascript (toggle)
* *
* @return string HTML head * @return string HTML head
*/ */
public static function adminPostHeaders() public static function adminPostHeaders()
{ {
return dcPage::jsLoad('index.php?pf=fac/js/admin.js'); return dcPage::jsLoad('index.php?pf=fac/js/admin.js');
} }
/** /**
* Add form to post sidebar * Add form to post sidebar
* *
* @param ArrayObject $main_items Main items * @param ArrayObject $main_items Main items
* @param ArrayObject $sidebar_items Sidebar items * @param ArrayObject $sidebar_items Sidebar items
* @param record $post Post record or null * @param record $post Post record or null
*/ */
public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post) public static function adminPostFormItems(ArrayObject $main_items, ArrayObject $sidebar_items, $post)
{ {
global $core; global $core;
# Get existing linked feed # Get existing linked feed
$fac_url = $fac_format = ''; $fac_url = $fac_format = '';
if ($post) { if ($post) {
$rs = $core->meta->getMetadata(array( $rs = $core->meta->getMetadata(array(
'meta_type' => 'fac', 'meta_type' => 'fac',
'post_id' => $post->post_id, 'post_id' => $post->post_id,
'limit' => 1 'limit' => 1
)); ));
$fac_url = $rs->isEmpty() ? '' : $rs->meta_id; $fac_url = $rs->isEmpty() ? '' : $rs->meta_id;
$rs = $core->meta->getMetadata(array( $rs = $core->meta->getMetadata(array(
'meta_type' => 'facformat', 'meta_type' => 'facformat',
'post_id' => $post->post_id, 'post_id' => $post->post_id,
'limit' => 1 'limit' => 1
)); ));
$fac_format = $rs->isEmpty() ? '' : $rs->meta_id; $fac_format = $rs->isEmpty() ? '' : $rs->meta_id;
} }
# Set linked feed form items # Set linked feed form items
$sidebar_items['options-box']['items']['fac'] = $sidebar_items['options-box']['items']['fac'] =
self::formFeed($core, $fac_url, $fac_format); self::formFeed($core, $fac_url, $fac_format);
} }
/** /**
* Save linked feed * Save linked feed
* *
* @param cursor $cur Current post cursor * @param cursor $cur Current post cursor
* @param integer $post_id Post id * @param integer $post_id Post id
*/ */
public static function adminAfterPostSave(cursor $cur, $post_id) public static function adminAfterPostSave(cursor $cur, $post_id)
{ {
global $core; global $core;
if (!isset($_POST['fac_url']) if (!isset($_POST['fac_url'])
|| !isset($_POST['fac_format']) || !isset($_POST['fac_format'])) {
) { return null;
return null; }
}
# Delete old linked feed # Delete old linked feed
self::delFeed($core, $post_id); self::delFeed($core, $post_id);
# Add new linked feed # Add new linked feed
self::addFeed($core, $post_id, $_POST); self::addFeed($core, $post_id, $_POST);
} }
/** /**
* Delete linked feed on post edition * Delete linked feed on post edition
* *
* @param integer $post_id Post id * @param integer $post_id Post id
*/ */
public static function adminBeforePostDelete($post_id) public static function adminBeforePostDelete($post_id)
{ {
self::delFeed($GLOBALS['core'], $post_id); self::delFeed($GLOBALS['core'], $post_id);
} }
/** /**
* Add actions to posts page combo * Add actions to posts page combo
* *
* @param dcCore $core dcCore instance * @param dcCore $core dcCore instance
* @param dcPostsActionsPage $ap dcPostsActionsPage instance * @param dcPostsActionsPage $ap dcPostsActionsPage instance
*/ */
public static function adminPostsActionsPage(dcCore $core, dcPostsActionsPage $pa) public static function adminPostsActionsPage(dcCore $core, dcPostsActionsPage $pa)
{ {
$pa->addAction( $pa->addAction(
array( array(
__('Linked feed') => array( __('Linked feed') => array(
__('Add feed') => 'fac_add' __('Add feed') => 'fac_add'
) )
), ),
array('facAdmin', 'callbackAdd') 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; /**
} * Posts actions callback to remove linked feed
$pa->addAction( *
array( * @param dcCore $core dcCore instance
__('Linked feed') => array( * @param dcPostsActionsPage $pa dcPostsActionsPage instance
__('Remove feed') => 'fac_remove' * @param ArrayObject $post _POST actions
) */
), public static function callbackRemove(dcCore $core, dcPostsActionsPage $pa, ArrayObject $post)
array('facAdmin', 'callbackRemove') {
); # No entry
} $posts_ids = $pa->getIDs();
if (empty($posts_ids)) {
throw new Exception(__('No entry selected'));
}
/** # No right
* Posts actions callback to remove linked feed if (!$core->auth->check('delete,contentadmin',$core->blog->id)) {
* throw new Exception(__('No enough right'));
* @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 # Delete expired date
if (!$core->auth->check('delete,contentadmin',$core->blog->id)) { foreach($posts_ids as $post_id) {
throw new Exception(__('No enough right')); self::delFeed($core, $post_id);
} }
# Delete expired date dcPage::addSuccessNotice(__('Linked feed deleted.'));
foreach($posts_ids as $post_id) { $pa->redirect(true);
self::delFeed($core, $post_id); }
}
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'));
}
/** # Save action
* Posts actions callback to add linked feed if (!empty($post['fac_url'])
* && !empty($post['fac_format'])) {
* @param dcCore $core dcCore instance foreach($posts_ids as $post_id) {
* @param dcPostsActionsPage $pa dcPostsActionsPage instance self::delFeed($core, $post_id);
* @param ArrayObject $post _POST actions self::addFeed($core, $post_id, $post);
*/ }
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 dcPage::addSuccessNotice(__('Linked feed added.'));
if (!empty($post['fac_url']) $pa->redirect(true);
&& !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.')); # Display form
$pa->redirect(true); } else {
} $pa->beginPage(
dcPage::breadcrumb(array(
html::escapeHTML($core->blog->name) => '',
$pa->getCallerTitle() => $pa->getRedirection(true),
__('Linked feed to this selection') => ''
))
);
# Display form echo
else { '<form action="' . $pa->getURI() . '" method="post">' .
$pa->beginPage( $pa->getCheckboxes() .
dcPage::breadcrumb(array(
html::escapeHTML($core->blog->name) => '',
$pa->getCallerTitle() => $pa->getRedirection(true),
__('Linked feed to this selection') => ''
))
);
echo self::formFeed($core) .
'<form action="'.$pa->getURI().'" method="post">'.
$pa->getCheckboxes().
self::formFeed($core). '<p>' .
$core->formNonce() .
$pa->getHiddenFields() .
form::hidden(array('action'), 'fac_add') .
'<input type="submit" value="' . __('Save') . '" /></p>' .
'</form>';
'<p>'. $pa->endPage();
$core->formNonce(). }
$pa->getHiddenFields(). }
form::hidden(array('action'), 'fac_add').
'<input type="submit" value="'.__('Save').'" /></p>'.
'</form>';
$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
'<div id="fac">' .
'<h5>' . __('Linked feed') . '</h5>' .
'<p><label for="fac_url">' .
__('Feed URL:') . '</label>' .
form::field(
'fac_url',
60,
255,
$url,
'maximal'
) . '</p>' .
'<p><label for="fac_format">' .
__('Format:') . '</label>' .
form::combo(
'fac_format',
self::comboFac($core),
$format,
'maximal'
) . '</p>' .
($url ? '<p><a href="' . $url . '" title="' . $url . '">' . __('view feed') . '</a></p>' : '') .
'</div>';
}
/** /**
* Linked feed form field * List of fac formats
* *
* @param dcCore $core dcCore instance * @param dcCore $core dcCore instance
* @param string $url Feed URL * @return array List of fac formats
* @param string $format Feed format */
* @return string Feed form content protected static function comboFac(dcCore $core)
*/ {
protected static function formFeed(dcCore $core, $url='', $format='') $formats = @unserialize($core->blog->settings->fac->fac_formats);
{ if (!is_array($formats) || empty($formats)) {
return return array();
'<div id="fac">'. }
'<h5>'.__('Linked feed').'</h5>'.
'<p><label for="fac_url">'.
__('Feed URL:').'</label>'.
form::field(
'fac_url',
60,
255,
$url,
'maximal'
).'</p>'.
'<p><label for="fac_format">'.
__('Format:').'</label>'.
form::combo(
'fac_format',
self::comboFac($core),
$format,
'maximal'
).'</p>'.
($url ? '<p><a href="'.$url.'" title="'.$url.'">'.__('view feed').'</a></p>' : '').
'</div>';
}
/** $res = array();
* List of fac formats foreach($formats as $uid => $f) {
* $res[$f['name']] = $uid;
* @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(); return $res;
} }
$res = array(); /**
foreach($formats as $uid => $f) { * Delete linked feed
$res[$f['name']] = $uid; *
} * @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;
}
/** $post_id = (integer) $post_id;
* 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');
}
/** $core->meta->setPostMeta(
* Add linked feed $post_id,
* 'fac',
* @param dcCore $core dcCore instance $options['fac_url']
* @param integer $post_id Post id );
* @param array $options Feed options $core->meta->setPostMeta(
*/ $post_id,
protected static function addFeed($core, $post_id, $options) 'facformat',
{ $options['fac_format']
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']
);
}
}

View File

@ -3,8 +3,7 @@
# #
# This file is part of fac, a plugin for Dotclear 2. # This file is part of fac, a plugin for Dotclear 2.
# #
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# #
# Licensed under the GPL version 2.0 license. # Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at # A copy of this license is available in LICENSE file or at
@ -13,524 +12,518 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_MODULE')) { if (!defined('DC_CONTEXT_MODULE')) {
return null;
return null;
} }
$redir = empty($_REQUEST['redir']) ? $redir = empty($_REQUEST['redir']) ?
$list->getURL().'#plugins' : $_REQUEST['redir']; $list->getURL() . '#plugins' : $_REQUEST['redir'];
# -- Combos of types of supported public pages -- # -- Combos of types of supported public pages --
$types = array( $types = [
__('home page') => 'default', __('home page') => 'default',
__('post pages') => 'post', __('post pages') => 'post',
__('tags pages') => 'tag', __('tags pages') => 'tag',
__('archives pages') => 'archive', __('archives pages') => 'archive',
__('category pages') => 'category', __('category pages') => 'category',
__('entries feed') => 'feed' __('entries feed') => 'feed'
); ];
if ($core->plugins->moduleExists('muppet')) { if ($core->plugins->moduleExists('muppet')) {
foreach(muppet::getPostTypes() as $k => $v) { foreach(muppet::getPostTypes() as $k => $v) {
$types[sprintf( $types[sprintf(
__('"%s" pages from extension muppet'), __('"%s" pages from extension muppet'),
$v['name'] $v['name']
)] = $k; )] = $k;
} }
} }
# -- Get settings -- # -- Get settings --
$core->blog->settings->addNamespace('fac'); $core->blog->settings->addNamespace('fac');
$s = $core->blog->settings->fac; $s = $core->blog->settings->fac;
$fac_active = (boolean) $s->fac_active; $fac_active = (boolean) $s->fac_active;
$fac_defaultfeedtitle = (string) $s->fac_defaultfeedtitle; $fac_defaultfeedtitle = (string) $s->fac_defaultfeedtitle;
$fac_showfeeddesc = (boolean) $s->fac_showfeeddesc; $fac_showfeeddesc = (boolean) $s->fac_showfeeddesc;
$fac_public_tpltypes = @unserialize($s->fac_public_tpltypes); $fac_public_tpltypes = @unserialize($s->fac_public_tpltypes);
$fac_formats = @unserialize($s->fac_formats); $fac_formats = @unserialize($s->fac_formats);
if (!is_array($fac_public_tpltypes)) { if (!is_array($fac_public_tpltypes)) {
$fac_public_tpltypes = array(); $fac_public_tpltypes = array();
} }
if (!is_array($fac_formats)) { if (!is_array($fac_formats)) {
$fac_formats = array(); $fac_formats = array();
} }
# -- Set settings -- # -- Set settings --
if (!empty($_POST['save'])) { 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 { foreach($_POST['fac_formats'] as $uid => $f) {
$fac_active = !empty($_POST['fac_active']); if (!empty($f['name'])) {
$fac_defaultfeedtitle = (string) $_POST['fac_defaultfeedtitle']; $fac_formats[$uid] = $f;
$fac_showfeeddesc = !empty($_POST['fac_showfeeddesc']); }
$fac_public_tpltypes = $_POST['fac_public_tpltypes']; }
$fac_formats = array();
foreach($_POST['fac_formats'] as $uid => $f) { $s->put('fac_active', $fac_active);
if (!empty($f['name'])) { $s->put('fac_defaultfeedtitle', $fac_defaultfeedtitle);
$fac_formats[$uid] = $f; $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); $core->blog->triggerBlog();
$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(); dcPage::addSuccessNotice(
__('Configuration has been successfully updated.')
dcPage::addSuccessNotice( );
__('Configuration has been successfully updated.') http::redirect(
); $list->getURL('module=fac&conf=1&redir=' . $list->getRedir())
http::redirect( );
$list->getURL('module=fac&conf=1&redir='. }
$list->getRedir()) catch (Exception $e) {
); $core->error->add($e->getMessage());
} }
catch (Exception $e) {
$core->error->add($e->getMessage());
}
} }
# -- Display form -- # -- Display form --
echo ' echo '
<div class="fieldset"> <div class="fieldset">
<h4>'.__('Activation').'</h4> <h4>' . __('Activation') . '</h4>
<p><label class="classic" for="fac_active">'. <p><label class="classic" for="fac_active">' .
form::checkbox('fac_active', 1, $fac_active). form::checkbox('fac_active', 1, $fac_active) .
__('Enable plugin').'</label></p> __('Enable plugin') . '</label></p>
<h5>'.__('Show feed after content on:').'</h5>'; <h5>' . __('Show feed after content on:') . '</h5>';
foreach($types as $k => $v) { foreach($types as $k => $v) {
echo ' echo '
<p><label class="classic" for="fac_public_tpltypes'.$k.'">'. <p><label class="classic" for="fac_public_tpltypes' . $k . '">' .
form::checkbox( form::checkbox(
array('fac_public_tpltypes[]', 'fac_public_tpltypes'.$k), array('fac_public_tpltypes[]', 'fac_public_tpltypes' . $k),
$v, $v,
in_array($v,$fac_public_tpltypes) in_array($v, $fac_public_tpltypes)
).__($k).'</label></p>'; ) . __($k) . '</label></p>';
} }
echo ' echo '
</div> </div>
<div class="fieldset"> <div class="fieldset">
<h4>'.__('Feed').'</h4> <h4>' . __('Feed') . '</h4>
<p><label for="fac_defaultfeedtitle">'.__('Default title').'</label>'. <p><label for="fac_defaultfeedtitle">' . __('Default title') . '</label>' .
form::field('fac_defaultfeedtitle', 65, 255, $fac_defaultfeedtitle).'</p> form::field('fac_defaultfeedtitle', 65, 255, $fac_defaultfeedtitle) . '</p>
<p class="form-note">'.__('Use %T to insert title of feed.').'</p> <p class="form-note">' . __('Use %T to insert title of feed.') . '</p>
<p><label class="classic" for="fac_showfeeddesc">'. <p><label class="classic" for="fac_showfeeddesc">' .
form::checkbox('fac_showfeeddesc', 1, $fac_showfeeddesc). form::checkbox('fac_showfeeddesc', 1, $fac_showfeeddesc) .
__('Show description of feed').'</label></p> __('Show description of feed') . '</label></p>
</div>'; </div>';
$i = 1; $i = 1;
foreach($fac_formats as $uid => $f) { foreach($fac_formats as $uid => $f) {
if (empty($f['name'])) {
continue;
}
if (empty($f['name'])) { echo '
continue; <div class="fieldset">
} <h4>' . sprintf(__('Format %s'), $i) . '</h4>
echo ' <div class="two-boxes"><h5>' . __('General') . '</h5>
<div class="fieldset">
<h4>'.sprintf(__('Format %s'), $i).'</h4>
<div class="two-boxes"><h5>'.__('General').'</h5> <p><label for="fac_formats_' . $uid . '_name">' .
__('Name:') . '</label>' .
form::field(
array(
'fac_formats[' . $uid . '][name]',
'fac_formats_' . $uid . '_name'
),
20,
255,
empty($f['name']) ? '' : $f['name'],
'maximal'
) . '</p>
<p class="form-note">' .
__('In order to remove a format, leave its name empty.') .
'</p>
<p><label for="fac_formats_'.$uid.'_name">'. <p><label for="fac_formats_' . $uid . '_dateformat">' .
__('Name:').'</label>'. __('Date format:') . '</label>' .
form::field( form::field(
array( array(
'fac_formats['.$uid.'][name]', 'fac_formats[' . $uid . '][dateformat]',
'fac_formats_'.$uid.'_name' 'fac_formats_' . $uid . '_dateformat'
), ),
20, 20,
255, 255,
empty($f['name']) ? '' : $f['name'], empty($f['dateformat']) ? '' : $f['dateformat'],
'maximal' 'maximal'
).'</p> ) . '</p>
<p class="form-note">'. <p class="form-note">' .
__('In order to remove a format, leave its name empty.'). __('Use date format of Dotclear or leave empty to use default date format of blog.') .
'</p> '</p>
<p><label for="fac_formats_'.$uid.'_dateformat">'. <p><label for="fac_formats_' . $uid . '_lineslimit">' .
__('Date format:').'</label>'. __('Entries limit:') . '</label>' .
form::field( form::field(
array( array(
'fac_formats['.$uid.'][dateformat]', 'fac_formats[' . $uid . '][lineslimit]',
'fac_formats_'.$uid.'_dateformat' 'fac_formats_' . $uid . '_lineslimit'
), ),
20, 5,
255, 4,
empty($f['dateformat']) ? '' : $f['dateformat'], empty($f['lineslimit']) ? '' : $f['lineslimit'],
'maximal' 'maximal'
).'</p> ) . '</p>
<p class="form-note">'. <p class="form-note">' .
__('Use date format of Dotclear or leave empty to use default date format of blog.'). __('Leave lengh empty for no limit.') .
'</p> '</p>
<p><label for="fac_formats_'.$uid.'_lineslimit">'. </div><div class="two-boxes"><h5>' . __('Title') . '</h5>
__('Entries limit:').'</label>'.
form::field(
array(
'fac_formats['.$uid.'][lineslimit]',
'fac_formats_'.$uid.'_lineslimit'
),
5,
4,
empty($f['lineslimit']) ? '' : $f['lineslimit'],
'maximal'
).'</p>
<p class="form-note">'.
__('Leave lengh empty for no limit.').
'</p>
</div><div class="two-boxes"><h5>'.__('Title').'</h5> <p><label for="fac_formats_' . $uid . '_linestitletext">' .
__('Title format:') . '</label>' .
form::field(
array(
'fac_formats[' . $uid . '][linestitletext]',
'fac_formats_' . $uid . '_linestitletext'
),
20,
255,
empty($f['linestitletext']) ? '' : $f['linestitletext'],
'maximal'
) . '</p>
<p class="form-note">' .
__('Format can be:') .
'%D : ' . __('Date') .
', %T : ' . __('Title') .
', %A : ' . __('Author') .
', %E : ' . __('Description') .
', %C : ' . __('Content') .
'</p>
<p><label for="fac_formats_'.$uid.'_linestitletext">'. <p><label for="fac_formats_' . $uid . '_linestitleover">' .
__('Title format:').'</label>'. __('Over title format:') . '</label>' .
form::field( form::field(
array( array(
'fac_formats['.$uid.'][linestitletext]', 'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_'.$uid.'_linestitletext' 'fac_formats_' . $uid . '_linestitleover'
), ),
20, 20,
255, 255,
empty($f['linestitletext']) ? '' : $f['linestitletext'], empty($f['linestitleover']) ? '' : $f['linestitleover'],
'maximal' 'maximal'
).'</p> ) . '</p>
<p class="form-note">'. <p class="form-note">' .
__('Format can be:'). __('Format can be:') .
'%D : '.__('Date'). '%D : ' . __('Date') .
', %T : '.__('Title'). ', %T : ' . __('Title') .
', %A : '.__('Author'). ', %A : ' . __('Author') .
', %E : '.__('Description'). ', %E : ' . __('Description') .
', %C : '.__('Content'). ', %C : ' . __('Content') .
'</p> '</p>
<p><label for="fac_formats_'.$uid.'_linestitleover">'. <p><label for="fac_formats_' . $uid . '_linestitlelength">' .
__('Over title format:').'</label>'. __('Maximum length of title:') . '</label>' .
form::field( form::field(
array( array(
'fac_formats['.$uid.'][linestitleover]', 'fac_formats[' . $uid . '][linestitlelength]',
'fac_formats_'.$uid.'_linestitleover' 'fac_formats_' . $uid . '_linestitlelength'
), ),
20, 5,
255, 4,
empty($f['linestitleover']) ? '' : $f['linestitleover'], empty($f['linestitlelength']) ? '' : $f['linestitlelength'],
'maximal' 'maximal'
).'</p> ) . '</p>
<p class="form-note">'. <p class="form-note">' .
__('Format can be:'). __('Leave lengh empty for no limit.') .
'%D : '.__('Date'). '</p>
', %T : '.__('Title').
', %A : '.__('Author').
', %E : '.__('Description').
', %C : '.__('Content').
'</p>
<p><label for="fac_formats_'.$uid.'_linestitlelength">'. </div><div class="two-boxes"><h5>' . __('Description') . '</h5>
__('Maximum length of title:').'</label>'.
form::field(
array(
'fac_formats['.$uid.'][linestitlelength]',
'fac_formats_'.$uid.'_linestitlelength'
),
5,
4,
empty($f['linestitlelength']) ? '' : $f['linestitlelength'],
'maximal'
).'</p>
<p class="form-note">'.
__('Leave lengh empty for no limit.').
'</p>
</div><div class="two-boxes"><h5>'.__('Description').'</h5> <p><label for="fac_formats_' . $uid . '_showlinesdescription">' .
form::checkbox(
array(
'fac_formats[' . $uid . '][showlinesdescription]',
'fac_formats_' . $uid . '_showlinesdescription'
),
1,
!empty($f['showlinesdescription'])
) .
__('Show description of entries') . '</label></p>
<p><label for="fac_formats_'.$uid.'_showlinesdescription">'. <p><label for="fac_formats_' . $uid . '_linesdescriptionnohtml">' .
form::checkbox( form::checkbox(
array( array(
'fac_formats['.$uid.'][showlinesdescription]', 'fac_formats[' . $uid . '][linesdescriptionnohtml]',
'fac_formats_'.$uid.'_showlinesdescription' 'fac_formats_' . $uid . '_linesdescriptionnohtml'
), ),
1, 1,
!empty($f['showlinesdescription']) !empty($f['linesdescriptionnohtml'])
). ).
__('Show description of entries').'</label></p> __('Remove html of description') . '</label></p>
<p><label for="fac_formats_'.$uid.'_linesdescriptionnohtml">'. <p><label for="fac_formats_' . $uid . '_linesdescriptionlength">' .
form::checkbox( __('Maximum length of description:') . '</label>' .
array( form::field(
'fac_formats['.$uid.'][linesdescriptionnohtml]', array(
'fac_formats_'.$uid.'_linesdescriptionnohtml' 'fac_formats[' . $uid . '][linesdescriptionlength]',
), 'fac_formats_' . $uid . '_linesdescriptionlength'
1, ),
!empty($f['linesdescriptionnohtml']) 5,
). 4,
__('Remove html of description').'</label></p> empty($f['linesdescriptionlength']) ? '' : $f['linesdescriptionlength'],
'maximal'
) . '</p>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
'</p>
<p><label for="fac_formats_'.$uid.'_linesdescriptionlength">'. </div><div class="two-boxes"><h5>' . __('Content') . '</h5>
__('Maximum length of description:').'</label>'.
form::field(
array(
'fac_formats['.$uid.'][linesdescriptionlength]',
'fac_formats_'.$uid.'_linesdescriptionlength'
),
5,
4,
empty($f['linesdescriptionlength']) ? '' : $f['linesdescriptionlength'],
'maximal'
).'</p>
<p class="form-note">'.
__('Leave lengh empty for no limit.').
'</p>
</div><div class="two-boxes"><h5>'.__('Content').'</h5> <p><label for="fac_formats_' . $uid . '_showlinescontent">' .
form::checkbox(
array(
'fac_formats[' . $uid . '][showlinescontent]',
'fac_formats_' . $uid . '_showlinescontent'
),
1,
!empty($f['showlinescontent'])
) .
__('Show content of entries') . '</label></p>
<p><label for="fac_formats_'.$uid.'_showlinescontent">'. <p><label for="fac_formats_' . $uid . '_linescontentnohtml">' .
form::checkbox( form::checkbox(
array( array(
'fac_formats['.$uid.'][showlinescontent]', 'fac_formats[' . $uid . '][linescontentnohtml]',
'fac_formats_'.$uid.'_showlinescontent' 'fac_formats_' . $uid . '_linescontentnohtml'
), ),
1, 1,
!empty($f['showlinescontent']) !empty($f['linescontentnohtml'])
). ) .
__('Show content of entries').'</label></p> __('Remove html of content') . '</label></p>
<p><label for="fac_formats_'.$uid.'_linescontentnohtml">'. <p><label for="fac_formats_' . $uid . '_linescontentlength">' .
form::checkbox( __('Maximum length of content:') . '</label>' .
array( form::field(
'fac_formats['.$uid.'][linescontentnohtml]', array(
'fac_formats_'.$uid.'_linescontentnohtml' 'fac_formats[' . $uid . '][linescontentlength]',
), 'fac_formats_' . $uid . '_linescontentlength'
1, ),
!empty($f['linescontentnohtml']) 5,
). 4,
__('Remove html of content').'</label></p> empty($f['linescontentlength']) ? '' : $f['linescontentlength'],
'maximal'
) . '</p>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
'</p>
<p><label for="fac_formats_'.$uid.'_linescontentlength">'. </div>
__('Maximum length of content:').'</label>'.
form::field(
array(
'fac_formats['.$uid.'][linescontentlength]',
'fac_formats_'.$uid.'_linescontentlength'
),
5,
4,
empty($f['linescontentlength']) ? '' : $f['linescontentlength'],
'maximal'
).'</p>
<p class="form-note">'.
__('Leave lengh empty for no limit.').
'</p>
</div> </div>';
</div>'; $i++;
$i++;
} }
$uid = uniqid(); $uid = uniqid();
echo ' echo '
<div class="fieldset"> <div class="fieldset">
<h4>'.__('New format').'</h4> <h4>' . __('New format') . '</h4>
<div class="two-boxes"><h5>'.__('General').'</h5> <div class="two-boxes"><h5>' . __('General') . '</h5>
<p><label for="fac_formats_'.$uid.'_name">'. <p><label for="fac_formats_' . $uid . '_name">' .
__('Name:').'</label>'. __('Name:') . '</label>' .
form::field( form::field(
array( array(
'fac_formats['.$uid.'][name]', 'fac_formats[' . $uid . '][name]',
'fac_formats_'.$uid.'_name' 'fac_formats_' . $uid . '_name'
), ),
20, 20,
255, 255,
'', '',
'maximal' 'maximal'
).'</p> ) . '</p>
<p class="form-note">'. <p class="form-note">'.
__('In order to remove a format, leave its name empty.'). __('In order to remove a format, leave its name empty.') .
'</p> '</p>
<p><label for="fac_formats_'.$uid.'_dateformat">'. <p><label for="fac_formats_' . $uid . '_dateformat">' .
__('Date format:').'</label>'. __('Date format:') . '</label>' .
form::field( form::field(
array( array(
'fac_formats['.$uid.'][dateformat]', 'fac_formats[' . $uid . '][dateformat]',
'fac_formats_'.$uid.'_dateformat' 'fac_formats_' . $uid . '_dateformat'
), ),
20, 20,
255, 255,
'', '',
'maximal' 'maximal'
).'</p> ) . '</p>
<p class="form-note">'. <p class="form-note">' .
__('Use date format of Dotclear or leave empty to use default date format of blog.'). __('Use date format of Dotclear or leave empty to use default date format of blog.') .
'</p> '</p>
<p><label for="fac_formats_'.$uid.'_lineslimit">'. <p><label for="fac_formats_' . $uid . '_lineslimit">' .
__('Entries limit:').'</label>'. __('Entries limit:') . '</label>' .
form::field( form::field(
array( array(
'fac_formats['.$uid.'][lineslimit]', 'fac_formats[' . $uid . '][lineslimit]',
'fac_formats_'.$uid.'_lineslimit' 'fac_formats_' . $uid . '_lineslimit'
), ),
5, 5,
4, 4,
5, 5,
'maximal' 'maximal'
).'</p> ) . '</p>
<p class="form-note">'. <p class="form-note">' .
__('Leave lengh empty for no limit.'). __('Leave lengh empty for no limit.') .
'</p> '</p>
</div><div class="two-boxes"><h5>'.__('Title').'</h5> </div><div class="two-boxes"><h5>' . __('Title') . '</h5>
<p><label for="fac_formats_'.$uid.'_linestitletext">'. <p><label for="fac_formats_' . $uid . '_linestitletext">' .
__('Title format:').'</label>'. __('Title format:') . '</label>' .
form::field( form::field(
array( array(
'fac_formats['.$uid.'][linestitletext]', 'fac_formats[' . $uid . '][linestitletext]',
'fac_formats_'.$uid.'_linestitletext' 'fac_formats_' . $uid . '_linestitletext'
), ),
20, 20,
255, 255,
'%T', '%T',
'maximal' 'maximal'
).'</p> ) . '</p>
<p class="form-note">'. <p class="form-note">' .
__('Format can be:'). __('Format can be:') .
'%D : '.__('Date'). '%D : ' . __('Date') .
', %T : '.__('Title'). ', %T : ' . __('Title') .
', %A : '.__('Author'). ', %A : ' . __('Author') .
', %E : '.__('Description'). ', %E : ' . __('Description') .
', %C : '.__('Content'). ', %C : ' . __('Content') .
'</p> '</p>
<p><label for="fac_formats_'.$uid.'_linestitleover">'. <p><label for="fac_formats_' . $uid . '_linestitleover">' .
__('Over title format:').'</label>'. __('Over title format:') . '</label>' .
form::field( form::field(
array( array(
'fac_formats['.$uid.'][linestitleover]', 'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_'.$uid.'_linestitleover' 'fac_formats_' . $uid . '_linestitleover'
), ),
20, 20,
255, 255,
'%D', '%D',
'maximal' 'maximal'
).'</p> ) . '</p>
<p class="form-note">'. <p class="form-note">' .
__('Format can be:'). __('Format can be:') .
'%D : '.__('Date'). '%D : ' . __('Date') .
', %T : '.__('Title'). ', %T : ' . __('Title') .
', %A : '.__('Author'). ', %A : ' . __('Author') .
', %E : '.__('Description'). ', %E : ' . __('Description') .
', %C : '.__('Content'). ', %C : ' . __('Content') .
'</p> '</p>
<p><label for="fac_formats_'.$uid.'_linestitlelength">'. <p><label for="fac_formats_' . $uid . '_linestitlelength">' .
__('Maximum length of title:').'</label>'. __('Maximum length of title:') . '</label>' .
form::field( form::field(
array( array(
'fac_formats['.$uid.'][linestitlelength]', 'fac_formats[' . $uid . '][linestitlelength]',
'fac_formats_'.$uid.'_linestitlelength' 'fac_formats_' . $uid . '_linestitlelength'
), ),
5, 5,
4, 4,
150, 150,
'maximal' 'maximal'
).'</p> ) . '</p>
<p class="form-note">'. <p class="form-note">' .
__('Leave lengh empty for no limit.'). __('Leave lengh empty for no limit.') .
'</p> '</p>
</div><div class="two-boxes"><h5>'.__('Description').'</h5> </div><div class="two-boxes"><h5>' . __('Description') . '</h5>
<p><label for="fac_formats_'.$uid.'_showlinesdescription">'. <p><label for="fac_formats_' . $uid . '_showlinesdescription">' .
form::checkbox( form::checkbox(
array( array(
'fac_formats['.$uid.'][showlinesdescription]', 'fac_formats[' . $uid . '][showlinesdescription]',
'fac_formats_'.$uid.'_showlinesdescription' 'fac_formats_' . $uid . '_showlinesdescription'
), ),
1, 1,
0 0
). ) .
__('Show description of entries').'</label></p> __('Show description of entries') . '</label></p>
<p><label for="fac_formats_'.$uid.'_linesdescriptionnohtml">'. <p><label for="fac_formats_' . $uid . '_linesdescriptionnohtml">' .
form::checkbox( form::checkbox(
array( array(
'fac_formats['.$uid.'][linesdescriptionnohtml]', 'fac_formats[' . $uid . '][linesdescriptionnohtml]',
'fac_formats_'.$uid.'_linesdescriptionnohtml' 'fac_formats_' . $uid . '_linesdescriptionnohtml'
), ),
1, 1,
1 1
). ) .
__('Remove html of description').'</label></p> __('Remove html of description') . '</label></p>
<p><label for="fac_formats_'.$uid.'_linesdescriptionlength">'. <p><label for="fac_formats_' . $uid . '_linesdescriptionlength">' .
__('Maximum length of description:').'</label>'. __('Maximum length of description:') . '</label>' .
form::field( form::field(
array( array(
'fac_formats['.$uid.'][linesdescriptionlength]', 'fac_formats[' . $uid . '][linesdescriptionlength]',
'fac_formats_'.$uid.'_linesdescriptionlength' 'fac_formats_' . $uid . '_linesdescriptionlength'
), ),
5, 5,
4, 4,
350, 350,
'maximal' 'maximal'
).'</p> ) . '</p>
<p class="form-note">'. <p class="form-note">' .
__('Leave lengh empty for no limit.'). __('Leave lengh empty for no limit.') .
'</p> '</p>
</div><div class="two-boxes"><h5>'.__('Content').'</h5> </div><div class="two-boxes"><h5>' . __('Content') . '</h5>
<p><label for="fac_formats_'.$uid.'_showlinescontent">'. <p><label for="fac_formats_' . $uid . '_showlinescontent">' .
form::checkbox( form::checkbox(
array( array(
'fac_formats['.$uid.'][showlinescontent]', 'fac_formats[' . $uid . '][showlinescontent]',
'fac_formats_'.$uid.'_showlinescontent' 'fac_formats_' . $uid . '_showlinescontent'
), ),
1, 1,
0 0
). ) .
__('Show content of entries').'</label></p> __('Show content of entries') . '</label></p>
<p><label for="fac_formats_'.$uid.'_linescontentnohtml">'. <p><label for="fac_formats_' . $uid . '_linescontentnohtml">' .
form::checkbox( form::checkbox(
array( array(
'fac_formats['.$uid.'][linescontentnohtml]', 'fac_formats[' . $uid . '][linescontentnohtml]',
'fac_formats_'.$uid.'_linescontentnohtml' 'fac_formats_' . $uid . '_linescontentnohtml'
), ),
1, 1,
1 1
). ) .
__('Remove html of content').'</label></p> __('Remove html of content') . '</label></p>
<p><label for="fac_formats_'.$uid.'_linescontentlength">'. <p><label for="fac_formats_' . $uid . '_linescontentlength">' .
__('Maximum length of content:').'</label>'. __('Maximum length of content:') . '</label>' .
form::field( form::field(
array( array(
'fac_formats['.$uid.'][linescontentlength]', 'fac_formats[' . $uid . '][linescontentlength]',
'fac_formats_'.$uid.'_linescontentlength' 'fac_formats_' . $uid . '_linescontentlength'
), ),
5, 5,
4, 4,
350, 350,
'maximal' 'maximal'
).'</p> ) . '</p>
<p class="form-note">'. <p class="form-note">' .
__('Leave lengh empty for no limit.'). __('Leave lengh empty for no limit.') .
'</p> '</p>
</div> </div>
@ -538,30 +531,30 @@ __('Leave lengh empty for no limit.').
</div> </div>
<div class="fieldset"> <div class="fieldset">
<h4>'.__('Informations').'</h4> <h4>' . __('Informations') . '</h4>
<div class="two-boxes"> <div class="two-boxes">
<h5>'.__('Theme').'</h5> <h5>' . __('Theme') . '</h5>
<p>'. <p>' .
__('Theme must have behavoir publicEntryAfterContent.').' '. __('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.'). __('To add feed to an entry edit this entry and put in sidebar the url of the feed and select a format.') .
'</p> '</p>
</div><div class="two-boxes"> </div><div class="two-boxes">
<h5>'.__('Structure').'</h5> <h5>' . __('Structure') . '</h5>
<pre>'.html::escapeHTML(' <pre>' . html::escapeHTML('
<div class="post-fac"> <div class="post-fac">
<h3>'.__('Title of feed').'</h3> <h3>' . __('Title of feed') . '</h3>
<p>'.__('Description of feed').'</p> <p>' . __('Description of feed') . '</p>
<dl> <dl>
<dt>'.__('Title of entry').'</dt> <dt>' . __('Title of entry') . '</dt>
<dd>'.__('Description of entry').'</dd> <dd>' . __('Description of entry') . '</dd>
</dl> </dl>
</div> </div>
').'</pre> ') . '</pre>
</div> </div>
</div>'; </div>';

View File

@ -3,8 +3,7 @@
# #
# This file is part of fac, a plugin for Dotclear 2. # This file is part of fac, a plugin for Dotclear 2.
# #
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# #
# Licensed under the GPL version 2.0 license. # Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at # A copy of this license is available in LICENSE file or at
@ -13,25 +12,19 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null;
return null;
} }
$this->registerModule( $this->registerModule(
/* Name */ 'fac',
"fac", 'Add RSS/Atom feeds after entries content',
/* Description*/ 'Jean-Christian Denis and Contributors',
"Add RSS/Atom feeds after entries content", '0.8',
/* Author */ [
"Jean-Christian Denis", 'permissions' => 'usage,contentadmin',
/* Version */ 'type' => 'plugin',
'0.7', 'dc_min' => '2.18',
/* Properies */ 'support' => 'https://github.com/JcDenis/fac',
array( 'details' => 'https://plugins.dotaddict.org/dc2/details/fac'
'permissions' => 'usage,contentadmin', ]
'type' => 'plugin', );
'dc_min' => '2.6',
'support' => 'http://jcd.lv/q=fac',
'details' => 'http://plugins.dotaddict.org/dc2/details/fac'
)
);

View File

@ -3,8 +3,7 @@
# #
# This file is part of fac, a plugin for Dotclear 2. # This file is part of fac, a plugin for Dotclear 2.
# #
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# #
# Licensed under the GPL version 2.0 license. # Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at # A copy of this license is available in LICENSE file or at
@ -13,8 +12,7 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) { if (!defined('DC_CONTEXT_ADMIN')) {
return null;
return null;
} }
# -- Module specs -- # -- Module specs --
@ -22,107 +20,107 @@ if (!defined('DC_CONTEXT_ADMIN')) {
$dc_min = '2.6'; $dc_min = '2.6';
$mod_id = 'fac'; $mod_id = 'fac';
$mod_conf = array( $mod_conf = array(
array( array(
'fac_active', 'fac_active',
'Enabled fac plugin', 'Enabled fac plugin',
false, false,
'boolean' 'boolean'
), ),
array( array(
'fac_public_tpltypes', 'fac_public_tpltypes',
'List of templates types which used fac', 'List of templates types which used fac',
serialize(array('post', 'tag', 'archive')), serialize(array('post', 'tag', 'archive')),
'string' 'string'
), ),
array( array(
'fac_formats', 'fac_formats',
'Formats of feeds contents', 'Formats of feeds contents',
serialize(array( serialize(array(
uniqid() => array( uniqid() => array(
'name' => 'default', 'name' => 'default',
'dateformat' => '', 'dateformat' => '',
'lineslimit' => '5', 'lineslimit' => '5',
'linestitletext' => '%T', 'linestitletext' => '%T',
'linestitleover' => '%D', 'linestitleover' => '%D',
'linestitlelength' => '150', 'linestitlelength' => '150',
'showlinesdescription' => '0', 'showlinesdescription' => '0',
'linesdescriptionlength' => '350', 'linesdescriptionlength' => '350',
'linesdescriptionnohtml' => '1', 'linesdescriptionnohtml' => '1',
'showlinescontent' => '0', 'showlinescontent' => '0',
'linescontentlength' => '350', 'linescontentlength' => '350',
'linescontentnohtml' => '1' 'linescontentnohtml' => '1'
), ),
uniqid() => array( uniqid() => array(
'name' => 'full', 'name' => 'full',
'dateformat' => '', 'dateformat' => '',
'lineslimit' => '20', 'lineslimit' => '20',
'linestitletext' => '%T', 'linestitletext' => '%T',
'linestitleover' => '%D - %E', 'linestitleover' => '%D - %E',
'linestitlelength' => '', 'linestitlelength' => '',
'showlinesdescription' => '1', 'showlinesdescription' => '1',
'linesdescriptionlength' => '', 'linesdescriptionlength' => '',
'linesdescriptionnohtml' => '1', 'linesdescriptionnohtml' => '1',
'showlinescontent' => '1', 'showlinescontent' => '1',
'linescontentlength' => '', 'linescontentlength' => '',
'linescontentnohtml' => '1' 'linescontentnohtml' => '1'
) )
)), )),
'string' 'string'
), ),
array( array(
'fac_defaultfeedtitle', 'fac_defaultfeedtitle',
'Default title of feed', 'Default title of feed',
'%T', '%T',
'string' 'string'
), ),
array( array(
'fac_showfeeddesc', 'fac_showfeeddesc',
'Show description of feed', 'Show description of feed',
1, 1,
'boolean' 'boolean'
) )
); );
# -- Nothing to change below -- # -- Nothing to change below --
try { try {
# Check module version # Check module version
if (version_compare( if (version_compare(
$core->getVersion($mod_id), $core->getVersion($mod_id),
$core->plugins->moduleInfo($mod_id, 'version'), $core->plugins->moduleInfo($mod_id, 'version'),
'>=' '>='
)) { )) {
return null; return null;
} }
# Check Dotclear version # Check Dotclear version
if (!method_exists('dcUtils', 'versionsCompare') if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) { || dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
throw new Exception(sprintf( throw new Exception(sprintf(
'%s requires Dotclear %s', $mod_id, $dc_min '%s requires Dotclear %s', $mod_id, $dc_min
)); ));
} }
# Set module settings # Set module settings
$core->blog->settings->addNamespace($mod_id); $core->blog->settings->addNamespace($mod_id);
foreach($mod_conf as $v) { foreach($mod_conf as $v) {
$core->blog->settings->{$mod_id}->put( $core->blog->settings->{$mod_id}->put(
$v[0], $v[2], $v[3], $v[1], false, true $v[0], $v[2], $v[3], $v[1], false, true
); );
} }
# Set module version # Set module version
$core->setVersion( $core->setVersion(
$mod_id, $mod_id,
$core->plugins->moduleInfo($mod_id, 'version') $core->plugins->moduleInfo($mod_id, 'version')
); );
return true; return true;
} }
catch (Exception $e) { catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
return false; return false;
} }

View File

@ -3,8 +3,7 @@
# #
# This file is part of fac, a plugin for Dotclear 2. # This file is part of fac, a plugin for Dotclear 2.
# #
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# #
# Licensed under the GPL version 2.0 license. # Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at # A copy of this license is available in LICENSE file or at
@ -13,13 +12,12 @@
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { if (!defined('DC_RC_PATH')) {
return null;
return null;
} }
$core->addBehavior( $core->addBehavior(
'publicEntryAfterContent', 'publicEntryAfterContent',
array('facPublic', 'publicEntryAfterContent') array('facPublic', 'publicEntryAfterContent')
); );
/** /**
@ -29,237 +27,226 @@ $core->addBehavior(
*/ */
class facPublic class facPublic
{ {
/** /**
* Add feed after entry * Add feed after entry
* *
* @param dcCore $core dcCore instance * @param dcCore $core dcCore instance
* @param context $_ctx context instance * @param context $_ctx context instance
*/ */
public static function publicEntryAfterContent(dcCore $core, context $_ctx) public static function publicEntryAfterContent(dcCore $core, context $_ctx)
{ {
$core->blog->settings->addNamespace('fac'); $core->blog->settings->addNamespace('fac');
# Not active or not a post # Not active or not a post
if (!$core->blog->settings->fac->fac_active if (!$core->blog->settings->fac->fac_active
|| !$_ctx->exists('posts') || !$_ctx->exists('posts')) {
) { return null;
return null; }
}
# Not in page to show # Not in page to show
$types = @unserialize($core->blog->settings->fac->fac_public_tpltypes); $types = @unserialize($core->blog->settings->fac->fac_public_tpltypes);
if (!is_array($types) if (!is_array($types)
|| !in_array($core->url->type,$types) || !in_array($core->url->type,$types)) {
) { return null;
return null; }
}
# Get related feed # Get related feed
$fac_url = $core->meta->getMetadata(array( $fac_url = $core->meta->getMetadata([
'meta_type' => 'fac', 'meta_type' => 'fac',
'post_id' => $_ctx->posts->post_id, 'post_id' => $_ctx->posts->post_id,
'limit' => 1 'limit' => 1
)); ]);
if ($fac_url->isEmpty()) { 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 # Get format info
$fac_format = $core->meta->getMetadata(array( $default_format = array(
'meta_type' => 'facformat', 'name' => 'default',
'post_id' => $_ctx->posts->post_id, 'dateformat' => '',
'limit' => 1 'lineslimit' => '5',
)); 'linestitletext' => '%T',
if ($fac_format->isEmpty()) { '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 # Read feed url
$default_format = array( $cache = is_dir(DC_TPL_CACHE . '/fac') ? DC_TPL_CACHE . '/fac' : null;
'name' => 'default', try {
'dateformat' => '', $feed = feedReader::quickParse($fac_url->meta_id, $cache);
'lineslimit' => '5', } catch (Exception $e) {
'linestitletext' => '%T', $feed = null;
'linestitleover' => '%D', }
'linestitlelength' => '150',
'showlinesdescription' => '0',
'linesdescriptionlength' => '350',
'linesdescriptionnohtml' => '1',
'showlinescontent' => '0',
'linescontentlength' => '350',
'linescontentnohtml' => '1'
);
$formats = @unserialize($core->blog->settings->fac->fac_formats); # No entries
if (empty($formats) if (!$feed) {
|| !is_array($formats) return null;
|| !isset($formats[$fac_format->meta_id]) }
) {
$format = $default_format;
}
else {
$format = array_merge(
$default_format,
$formats[$fac_format->meta_id]
);
}
# Read feed url # Feed title
$cache = is_dir(DC_TPL_CACHE.'/fac') ? DC_TPL_CACHE.'/fac' : null; $feedtitle = '';
try { if ('' != $core->blog->settings->fac->fac_defaultfeedtitle) {
$feed = feedReader::quickParse($fac_url->meta_id,$cache); $feedtitle = '<h3>' . html::escapeHTML(empty($feed->title) ?
} str_replace(
catch (Exception $e) { '%T',
$feed = null; __('a related feed'),
} $core->blog->settings->fac->fac_defaultfeedtitle
) :
str_replace(
'%T',
$feed->title,
$core->blog->settings->fac->fac_defaultfeedtitle
)
) . '</h3>';
}
# No entries # Feed desc
if (!$feed) { $feeddesc = '';
if ($core->blog->settings->fac->fac_showfeeddesc
&& '' != $feed->description) {
$feeddesc =
'<p>' . context::global_filter($feed->description, 1, 1, 0, 0, 0) . '</p>';
}
return null; # Date format
} $dateformat = '' != $format['dateformat'] ?
$format['dateformat'] :
$core->blog->settings->system->date_format . ',' . $core->blog->settings->system->time_format;
# Feed title # Enrties limit
$feedtitle = ''; $entrieslimit = abs((integer) $format['lineslimit']);
if ('' != $core->blog->settings->fac->fac_defaultfeedtitle) { $uselimit = $entrieslimit > 0 ? true : false;
$feedtitle = '<h3>'.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
)
).'</h3>';
}
# Feed desc echo
$feeddesc = ''; '<div class="post-fac">' .
if ($core->blog->settings->fac->fac_showfeeddesc $feedtitle . $feeddesc .
&& '' != $feed->description '<dl>';
) {
$feeddesc =
'<p>'.context::global_filter($feed->description,1,1,0,0,0).'</p>';
}
# Date format $i = 0;
$dateformat = '' != $format['dateformat'] ? foreach ($feed->items as $item) {
$format['dateformat'] :
$core->blog->settings->system->date_format.','.$core->blog->settings->system->time_format;
# Enrties limit # Format date
$entrieslimit = abs((integer) $format['lineslimit']); $date = dt::dt2str($dateformat, $item->pubdate);
$uselimit = $entrieslimit > 0 ? true : false;
echo # Entries title
'<div class="post-fac">'. $title = context::global_filter(
$feedtitle.$feeddesc. str_replace(
'<dl>'; 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; # Entries over title
foreach ($feed->items as $item) { $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 # Entries description
$date = dt::dt2str($dateformat, $item->pubdate); $description = '';
if ($format['showlinesdescription']
&& '' != $item->description) {
$description = '<dd>' .
context::global_filter(
$item->description,
0,
(integer) $format['linesdescriptionnohtml'],
abs((integer) $format['linesdescriptionlength']),
0,0
) . '</dd>';
}
# Entries title # Entries content
$title = context::global_filter( $content = '';
str_replace( if ($format['showlinescontent']
array( && '' != $item->content) {
'%D', $content = '<dd>'.
'%T', context::global_filter(
'%A', $item->content,
'%E', 0,
'%C' (integer) $format['linescontentnohtml'],
), abs((integer) $format['linescontentlength']),
array( 0,
$date, 0
$item->title, ) . '</dd>';
$item->creator, }
$item->description,
$item->content
),
$format['linestitletext']
),
0,
1,
abs((integer) $format['linestitlelength']),
0,
0
);
# Entries over title echo
$overtitle = context::global_filter( '<dt><a href="' . $item->link . '" ' .
str_replace( 'title="' . $overtitle . '">' . $title . '</a></dt>' .
array( $description . $content;
'%D',
'%T',
'%A',
'%E',
'%C'
),
array(
$date,
$item->title,
$item->creator,
$item->description,
$item->content
),
$format['linestitleover']
),
0,
1,
350,
0,
0
);
# Entries description $i++;
$description = ''; if ($uselimit && $i == $entrieslimit) {
if ($format['showlinesdescription'] break;
&& '' != $item->description }
) { }
$description = '<dd>'. echo '</dl></div>';
context::global_filter( }
$item->description, }
0,
(integer) $format['linesdescriptionnohtml'],
abs((integer) $format['linesdescriptionlength']),
0,0
).'</dd>';
}
# Entries content
$content = '';
if ($format['showlinescontent']
&& '' != $item->content
) {
$content = '<dd>'.
context::global_filter(
$item->content,
0,
(integer) $format['linescontentnohtml'],
abs((integer) $format['linescontentlength']),
0,
0
).'</dd>';
}
echo
'<dt><a href="'.$item->link.'" '.
'title="'.$overtitle.'">'.$title.'</a></dt>'.
$description.$content;
$i++;
if ($uselimit && $i == $entrieslimit) {
break;
}
}
echo '</dl></div>';
}
}

View File

@ -3,8 +3,7 @@
# #
# This file is part of fac, a plugin for Dotclear 2. # This file is part of fac, a plugin for Dotclear 2.
# #
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# #
# Licensed under the GPL version 2.0 license. # Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at # A copy of this license is available in LICENSE file or at
@ -12,7 +11,8 @@
# #
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { return; } if (!defined('DC_RC_PATH')) {
return;
}
$__resources['help']['fac'] = dirname(__FILE__).'/help/help.html'; $__resources['help']['fac'] = dirname(__FILE__) . '/help/fac.html';
?>

View File

@ -3,8 +3,7 @@
# #
# This file is part of fac, a plugin for Dotclear 2. # This file is part of fac, a plugin for Dotclear 2.
# #
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors # Copyright (c) 2009-2021 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# #
# Licensed under the GPL version 2.0 license. # Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at # A copy of this license is available in LICENSE file or at
@ -12,7 +11,8 @@
# #
# -- END LICENSE BLOCK ------------------------------------ # -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) { return; } if (!defined('DC_RC_PATH')) {
return;
}
$__resources['help']['fac'] = dirname(__FILE__).'/help/help.html'; $__resources['help']['fac'] = dirname(__FILE__) . '/help/fac.html';
?>