split super vs admin configs

This commit is contained in:
Jean-Christian Denis 2021-08-23 22:47:08 +02:00
parent 59583a33d0
commit f75c3c88ba
8 changed files with 230 additions and 192 deletions

View file

@ -1,3 +1,9 @@
fac 0.9
* split superadmin and admin config
* move blog settings from plugin config to blog pref
* fix help
* use php short array code
fac 0.8.1 fac 0.8.1
* fix context filters * fix context filters

View file

@ -12,9 +12,10 @@ to link en extenal feed to the bottom of an entry.
fac requires: fac requires:
* superadmin to configure feeds formats
* admin permissions to configure plugin * admin permissions to configure plugin
* usage,contentadmin permissions to link feeds * usage,contentadmin permissions to link feeds
* Dotclear 2.6 * Dotclear 2.19
* A theme that contents behavior publicEntryAfterContent * A theme that contents behavior publicEntryAfterContent
## USAGE ## USAGE
@ -22,6 +23,9 @@ to link en extenal feed to the bottom of an entry.
First install fac, manualy from a zip package or from First install fac, manualy from a zip package or from
Dotaddict repository. (See Dotclear's documentation to know how do this) Dotaddict repository. (See Dotclear's documentation to know how do this)
Superadmin can configure, add, remove feeds formats on plugins configuration.
Admin can configure fac activation et selected page where to display feeds.
When you edit a post you have a new sidebar menu called "Linked feed" When you edit a post you have a new sidebar menu called "Linked feed"
to link a feed to this post. to link a feed to this post.

View file

@ -17,12 +17,9 @@ if (!defined('DC_CONTEXT_ADMIN')) {
$core->blog->settings->addNamespace('fac'); $core->blog->settings->addNamespace('fac');
# Not active
if (!$core->blog->settings->fac->fac_active) {
return null;
}
# Admin behaviors # Admin behaviors
$core->addBehavior('adminBlogPreferencesForm', ['facAdmin', 'adminBlogPreferencesForm']);
$core->addBehavior('adminBeforeBlogSettingsUpdate', ['facAdmin', 'adminBeforeBlogSettingsUpdate']);
$core->addBehavior('adminPostHeaders', ['facAdmin', 'adminPostHeaders']); $core->addBehavior('adminPostHeaders', ['facAdmin', 'adminPostHeaders']);
$core->addBehavior('adminPostFormItems', ['facAdmin', 'adminPostFormItems']); $core->addBehavior('adminPostFormItems', ['facAdmin', 'adminPostFormItems']);
$core->addBehavior('adminAfterPostCreate', ['facAdmin', 'adminAfterPostSave']); $core->addBehavior('adminAfterPostCreate', ['facAdmin', 'adminAfterPostSave']);
@ -37,6 +34,101 @@ $core->addBehavior('adminPostsActionsPage', ['facAdmin', 'adminPostsActionsPage'
*/ */
class facAdmin class facAdmin
{ {
/**
* Get combos of types of supported public pages
*
* @param dcCore $core dcCore instance
* @return array List of post type and name
*/
public static function getPostsTypes(dcCore $core)
{
$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;
}
}
return $types;
}
/**
* Add settings to blog preference
*
* @param dcCore $core dcCore instance
* @param dcSettings $blog_settings dcSettings instance
*/
public static function adminBlogPreferencesForm(dcCore $core, dcSettings $blog_settings)
{
echo
'<div class="fieldset"><h4 id="fac_params">Feed after content</h4>' .
'<p class="form-note">' .
__('To add feed to an entry edit this entry and put in sidebar the url of the feed and select a format.') .
'</p>' .
'<div class="two-cols">' .
'<div class="col">' .
'<h5>' . __('Activation') . '</h5>' .
'<p><label class="classic">' .
form::checkbox('fac_active', '1', (boolean) $blog_settings->fac->fac_active) .
__('Enable "fac" extension') . '</label></p>' .
'<p class="form-note">' .
__("You can manage related feed to display for each post with a predefined format.") .
'</p>' .
'<h5>' . __('Feed') . '</h5>' .
'<p><label for="fac_defaultfeedtitle">' . __('Default title') . '</label>' .
form::field('fac_defaultfeedtitle', 65, 255, (string) $blog_settings->fac->fac_defaultfeedtitle) . '</p>' .
'<p class="form-note">' . __('Use %T to insert title of feed.') . '</p>' .
'<p><label class="classic" for="fac_showfeeddesc">' .
form::checkbox('fac_showfeeddesc', 1, (boolean) $blog_settings->fac->fac_showfeeddesc) .
__('Show description of feed') . '</label></p>' .
'</div>' .
'<div class="col">' .
'<h5>' . __('Show feed after content on:') . '</h5>';
$fac_public_tpltypes = @unserialize($blog_settings->fac->fac_public_tpltypes);
if (!is_array($fac_public_tpltypes)) {
$fac_public_tpltypes = [];
}
foreach(self::getPostsTypes($core) as $k => $v) {
echo '
<p><label class="classic" for="fac_public_tpltypes' . $k . '">' .
form::checkbox(
['fac_public_tpltypes[]', 'fac_public_tpltypes' . $k],
$v,
in_array($v, $fac_public_tpltypes)
) . __($k) . '</label></p>';
}
echo
'</div>' .
'</div>' .
'<br class="clear" />' .
'</div>';
}
/**
* Save blog settings
*
* @param dcSettings $blog_settings dcSettings instance
*/
public static function adminBeforeBlogSettingsUpdate(dcSettings $blog_settings)
{
$blog_settings->fac->put('fac_active', !empty($_POST['fac_active']));
$blog_settings->fac->put('fac_public_tpltypes', serialize($_POST['fac_public_tpltypes']));
$blog_settings->fac->put('fac_defaultfeedtitle', (string) $_POST['fac_defaultfeedtitle']);
$blog_settings->fac->put('fac_showfeeddesc', !empty($_POST['fac_showfeeddesc']));
}
/** /**
* Add javascript (toggle) * Add javascript (toggle)
* *
@ -58,22 +150,26 @@ class facAdmin
{ {
global $core; global $core;
if (!$core->blog->settings->fac->fac_active) {
return null;
}
# 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([
'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([
'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;
} }
@ -122,25 +218,21 @@ class facAdmin
*/ */
public static function adminPostsActionsPage(dcCore $core, dcPostsActionsPage $pa) public static function adminPostsActionsPage(dcCore $core, dcPostsActionsPage $pa)
{ {
if (!$core->blog->settings->fac->fac_active) {
return null;
}
$pa->addAction( $pa->addAction(
array( [__('Linked feed') => [__('Add feed') => 'fac_add']],
__('Linked feed') => array( ['facAdmin', 'callbackAdd']
__('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; return null;
} }
$pa->addAction( $pa->addAction(
array( [__('Linked feed') => [__('Remove feed') => 'fac_remove']],
__('Linked feed') => array( ['facAdmin', 'callbackRemove']
__('Remove feed') => 'fac_remove'
)
),
array('facAdmin', 'callbackRemove')
); );
} }
@ -164,7 +256,7 @@ class facAdmin
throw new Exception(__('No enough right')); throw new Exception(__('No enough right'));
} }
# Delete expired date # Delete unused feed
foreach($posts_ids as $post_id) { foreach($posts_ids as $post_id) {
self::delFeed($core, $post_id); self::delFeed($core, $post_id);
} }
@ -202,11 +294,11 @@ class facAdmin
# Display form # Display form
} else { } else {
$pa->beginPage( $pa->beginPage(
dcPage::breadcrumb(array( dcPage::breadcrumb([
html::escapeHTML($core->blog->name) => '', html::escapeHTML($core->blog->name) => '',
$pa->getCallerTitle() => $pa->getRedirection(true), $pa->getCallerTitle() => $pa->getRedirection(true),
__('Linked feed to this selection') => '' __('Linked feed to this selection') => ''
)) ])
); );
echo echo
@ -218,7 +310,7 @@ class facAdmin
'<p>' . '<p>' .
$core->formNonce() . $core->formNonce() .
$pa->getHiddenFields() . $pa->getHiddenFields() .
form::hidden(array('action'), 'fac_add') . form::hidden(['action'], 'fac_add') .
'<input type="submit" value="' . __('Save') . '" /></p>' . '<input type="submit" value="' . __('Save') . '" /></p>' .
'</form>'; '</form>';
@ -236,6 +328,10 @@ class facAdmin
*/ */
protected static function formFeed(dcCore $core, $url = '', $format = '') protected static function formFeed(dcCore $core, $url = '', $format = '')
{ {
if (!$core->blog->settings->fac->fac_active) {
return null;
}
return return
'<div id="fac">' . '<div id="fac">' .
'<h5>' . __('Linked feed') . '</h5>' . '<h5>' . __('Linked feed') . '</h5>' .
@ -270,10 +366,10 @@ class facAdmin
{ {
$formats = @unserialize($core->blog->settings->fac->fac_formats); $formats = @unserialize($core->blog->settings->fac->fac_formats);
if (!is_array($formats) || empty($formats)) { if (!is_array($formats) || empty($formats)) {
return array(); return [];
} }
$res = array(); $res = [];
foreach($formats as $uid => $f) { foreach($formats as $uid => $f) {
$res[$f['name']] = $uid; $res[$f['name']] = $uid;
} }

View file

@ -18,49 +18,20 @@ if (!defined('DC_CONTEXT_MODULE')) {
$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 --
$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;
}
}
# -- 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_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_formats = @unserialize($s->fac_formats);
if (!is_array($fac_public_tpltypes)) {
$fac_public_tpltypes = array();
}
if (!is_array($fac_formats)) { if (!is_array($fac_formats)) {
$fac_formats = array(); $fac_formats = [];
} }
# -- Set settings -- # -- Set settings --
if (!empty($_POST['save'])) { if (!empty($_POST['save'])) {
try { try {
$fac_active = !empty($_POST['fac_active']); $fac_formats = [];
$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) { foreach($_POST['fac_formats'] as $uid => $f) {
if (!empty($f['name'])) { if (!empty($f['name'])) {
@ -68,11 +39,16 @@ if (!empty($_POST['save'])) {
} }
} }
$s->put('fac_active', $fac_active); // fix 2021.08.21 : formats are now global
$s->put('fac_defaultfeedtitle', $fac_defaultfeedtitle); $s->drop('fac_formats');
$s->put('fac_showfeeddesc', $fac_showfeeddesc); $s->put(
$s->put('fac_public_tpltypes', serialize($fac_public_tpltypes)); 'fac_formats',
$s->put('fac_formats', serialize($fac_formats)); serialize($fac_formats),
'string',
'Formats of feeds contents',
true,
true
);
$core->blog->triggerBlog(); $core->blog->triggerBlog();
@ -82,47 +58,12 @@ if (!empty($_POST['save'])) {
http::redirect( http::redirect(
$list->getURL('module=fac&conf=1&redir=' . $list->getRedir()) $list->getURL('module=fac&conf=1&redir=' . $list->getRedir())
); );
} } catch (Exception $e) {
catch (Exception $e) {
$core->error->add($e->getMessage()); $core->error->add($e->getMessage());
} }
} }
# -- Display form -- # -- Display form --
echo '
<div class="fieldset">
<h4>' . __('Activation') . '</h4>
<p><label class="classic" for="fac_active">' .
form::checkbox('fac_active', 1, $fac_active) .
__('Enable plugin') . '</label></p>
<h5>' . __('Show feed after content on:') . '</h5>';
foreach($types as $k => $v) {
echo '
<p><label class="classic" for="fac_public_tpltypes' . $k . '">' .
form::checkbox(
array('fac_public_tpltypes[]', 'fac_public_tpltypes' . $k),
$v,
in_array($v, $fac_public_tpltypes)
) . __($k) . '</label></p>';
}
echo '
</div>
<div class="fieldset">
<h4>' . __('Feed') . '</h4>
<p><label for="fac_defaultfeedtitle">' . __('Default title') . '</label>' .
form::field('fac_defaultfeedtitle', 65, 255, $fac_defaultfeedtitle) . '</p>
<p class="form-note">' . __('Use %T to insert title of feed.') . '</p>
<p><label class="classic" for="fac_showfeeddesc">' .
form::checkbox('fac_showfeeddesc', 1, $fac_showfeeddesc) .
__('Show description of feed') . '</label></p>
</div>';
$i = 1; $i = 1;
foreach($fac_formats as $uid => $f) { foreach($fac_formats as $uid => $f) {
@ -139,10 +80,10 @@ foreach($fac_formats as $uid => $f) {
<p><label for="fac_formats_' . $uid . '_name">' . <p><label for="fac_formats_' . $uid . '_name">' .
__('Name:') . '</label>' . __('Name:') . '</label>' .
form::field( form::field(
array( [
'fac_formats[' . $uid . '][name]', 'fac_formats[' . $uid . '][name]',
'fac_formats_' . $uid . '_name' 'fac_formats_' . $uid . '_name'
), ],
20, 20,
255, 255,
empty($f['name']) ? '' : $f['name'], empty($f['name']) ? '' : $f['name'],
@ -155,10 +96,10 @@ foreach($fac_formats as $uid => $f) {
<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( [
'fac_formats[' . $uid . '][dateformat]', 'fac_formats[' . $uid . '][dateformat]',
'fac_formats_' . $uid . '_dateformat' 'fac_formats_' . $uid . '_dateformat'
), ],
20, 20,
255, 255,
empty($f['dateformat']) ? '' : $f['dateformat'], empty($f['dateformat']) ? '' : $f['dateformat'],
@ -171,10 +112,10 @@ foreach($fac_formats as $uid => $f) {
<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( [
'fac_formats[' . $uid . '][lineslimit]', 'fac_formats[' . $uid . '][lineslimit]',
'fac_formats_' . $uid . '_lineslimit' 'fac_formats_' . $uid . '_lineslimit'
), ],
5, 5,
4, 4,
empty($f['lineslimit']) ? '' : $f['lineslimit'], empty($f['lineslimit']) ? '' : $f['lineslimit'],
@ -189,10 +130,10 @@ foreach($fac_formats as $uid => $f) {
<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( [
'fac_formats[' . $uid . '][linestitletext]', 'fac_formats[' . $uid . '][linestitletext]',
'fac_formats_' . $uid . '_linestitletext' 'fac_formats_' . $uid . '_linestitletext'
), ],
20, 20,
255, 255,
empty($f['linestitletext']) ? '' : $f['linestitletext'], empty($f['linestitletext']) ? '' : $f['linestitletext'],
@ -210,10 +151,10 @@ foreach($fac_formats as $uid => $f) {
<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( [
'fac_formats[' . $uid . '][linestitleover]', 'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_' . $uid . '_linestitleover' 'fac_formats_' . $uid . '_linestitleover'
), ],
20, 20,
255, 255,
empty($f['linestitleover']) ? '' : $f['linestitleover'], empty($f['linestitleover']) ? '' : $f['linestitleover'],
@ -231,10 +172,10 @@ foreach($fac_formats as $uid => $f) {
<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( [
'fac_formats[' . $uid . '][linestitlelength]', 'fac_formats[' . $uid . '][linestitlelength]',
'fac_formats_' . $uid . '_linestitlelength' 'fac_formats_' . $uid . '_linestitlelength'
), ],
5, 5,
4, 4,
empty($f['linestitlelength']) ? '' : $f['linestitlelength'], empty($f['linestitlelength']) ? '' : $f['linestitlelength'],
@ -248,10 +189,10 @@ foreach($fac_formats as $uid => $f) {
<p><label for="fac_formats_' . $uid . '_showlinesdescription">' . <p><label for="fac_formats_' . $uid . '_showlinesdescription">' .
form::checkbox( form::checkbox(
array( [
'fac_formats[' . $uid . '][showlinesdescription]', 'fac_formats[' . $uid . '][showlinesdescription]',
'fac_formats_' . $uid . '_showlinesdescription' 'fac_formats_' . $uid . '_showlinesdescription'
), ],
1, 1,
!empty($f['showlinesdescription']) !empty($f['showlinesdescription'])
) . ) .
@ -259,10 +200,10 @@ foreach($fac_formats as $uid => $f) {
<p><label for="fac_formats_' . $uid . '_linesdescriptionnohtml">' . <p><label for="fac_formats_' . $uid . '_linesdescriptionnohtml">' .
form::checkbox( form::checkbox(
array( [
'fac_formats[' . $uid . '][linesdescriptionnohtml]', 'fac_formats[' . $uid . '][linesdescriptionnohtml]',
'fac_formats_' . $uid . '_linesdescriptionnohtml' 'fac_formats_' . $uid . '_linesdescriptionnohtml'
), ],
1, 1,
!empty($f['linesdescriptionnohtml']) !empty($f['linesdescriptionnohtml'])
). ).
@ -271,10 +212,10 @@ foreach($fac_formats as $uid => $f) {
<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( [
'fac_formats[' . $uid . '][linesdescriptionlength]', 'fac_formats[' . $uid . '][linesdescriptionlength]',
'fac_formats_' . $uid . '_linesdescriptionlength' 'fac_formats_' . $uid . '_linesdescriptionlength'
), ],
5, 5,
4, 4,
empty($f['linesdescriptionlength']) ? '' : $f['linesdescriptionlength'], empty($f['linesdescriptionlength']) ? '' : $f['linesdescriptionlength'],
@ -288,10 +229,10 @@ foreach($fac_formats as $uid => $f) {
<p><label for="fac_formats_' . $uid . '_showlinescontent">' . <p><label for="fac_formats_' . $uid . '_showlinescontent">' .
form::checkbox( form::checkbox(
array( [
'fac_formats[' . $uid . '][showlinescontent]', 'fac_formats[' . $uid . '][showlinescontent]',
'fac_formats_' . $uid . '_showlinescontent' 'fac_formats_' . $uid . '_showlinescontent'
), ],
1, 1,
!empty($f['showlinescontent']) !empty($f['showlinescontent'])
) . ) .
@ -299,10 +240,10 @@ foreach($fac_formats as $uid => $f) {
<p><label for="fac_formats_' . $uid . '_linescontentnohtml">' . <p><label for="fac_formats_' . $uid . '_linescontentnohtml">' .
form::checkbox( form::checkbox(
array( [
'fac_formats[' . $uid . '][linescontentnohtml]', 'fac_formats[' . $uid . '][linescontentnohtml]',
'fac_formats_' . $uid . '_linescontentnohtml' 'fac_formats_' . $uid . '_linescontentnohtml'
), ],
1, 1,
!empty($f['linescontentnohtml']) !empty($f['linescontentnohtml'])
) . ) .
@ -311,10 +252,10 @@ foreach($fac_formats as $uid => $f) {
<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( [
'fac_formats[' . $uid . '][linescontentlength]', 'fac_formats[' . $uid . '][linescontentlength]',
'fac_formats_' . $uid . '_linescontentlength' 'fac_formats_' . $uid . '_linescontentlength'
), ],
5, 5,
4, 4,
empty($f['linescontentlength']) ? '' : $f['linescontentlength'], empty($f['linescontentlength']) ? '' : $f['linescontentlength'],
@ -341,10 +282,10 @@ echo '
<p><label for="fac_formats_' . $uid . '_name">' . <p><label for="fac_formats_' . $uid . '_name">' .
__('Name:') . '</label>' . __('Name:') . '</label>' .
form::field( form::field(
array( [
'fac_formats[' . $uid . '][name]', 'fac_formats[' . $uid . '][name]',
'fac_formats_' . $uid . '_name' 'fac_formats_' . $uid . '_name'
), ],
20, 20,
255, 255,
'', '',
@ -357,10 +298,10 @@ __('In order to remove a format, leave its name empty.') .
<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( [
'fac_formats[' . $uid . '][dateformat]', 'fac_formats[' . $uid . '][dateformat]',
'fac_formats_' . $uid . '_dateformat' 'fac_formats_' . $uid . '_dateformat'
), ],
20, 20,
255, 255,
'', '',
@ -373,10 +314,10 @@ __('Use date format of Dotclear or leave empty to use default date format of blo
<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( [
'fac_formats[' . $uid . '][lineslimit]', 'fac_formats[' . $uid . '][lineslimit]',
'fac_formats_' . $uid . '_lineslimit' 'fac_formats_' . $uid . '_lineslimit'
), ],
5, 5,
4, 4,
5, 5,
@ -391,10 +332,10 @@ __('Leave lengh empty for no limit.') .
<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( [
'fac_formats[' . $uid . '][linestitletext]', 'fac_formats[' . $uid . '][linestitletext]',
'fac_formats_' . $uid . '_linestitletext' 'fac_formats_' . $uid . '_linestitletext'
), ],
20, 20,
255, 255,
'%T', '%T',
@ -412,10 +353,10 @@ __('Format can be:') .
<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( [
'fac_formats[' . $uid . '][linestitleover]', 'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_' . $uid . '_linestitleover' 'fac_formats_' . $uid . '_linestitleover'
), ],
20, 20,
255, 255,
'%D', '%D',
@ -433,10 +374,10 @@ __('Format can be:') .
<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( [
'fac_formats[' . $uid . '][linestitlelength]', 'fac_formats[' . $uid . '][linestitlelength]',
'fac_formats_' . $uid . '_linestitlelength' 'fac_formats_' . $uid . '_linestitlelength'
), ],
5, 5,
4, 4,
150, 150,
@ -450,10 +391,10 @@ __('Leave lengh empty for no limit.') .
<p><label for="fac_formats_' . $uid . '_showlinesdescription">' . <p><label for="fac_formats_' . $uid . '_showlinesdescription">' .
form::checkbox( form::checkbox(
array( [
'fac_formats[' . $uid . '][showlinesdescription]', 'fac_formats[' . $uid . '][showlinesdescription]',
'fac_formats_' . $uid . '_showlinesdescription' 'fac_formats_' . $uid . '_showlinesdescription'
), ],
1, 1,
0 0
) . ) .
@ -461,10 +402,10 @@ __('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( [
'fac_formats[' . $uid . '][linesdescriptionnohtml]', 'fac_formats[' . $uid . '][linesdescriptionnohtml]',
'fac_formats_' . $uid . '_linesdescriptionnohtml' 'fac_formats_' . $uid . '_linesdescriptionnohtml'
), ],
1, 1,
1 1
) . ) .
@ -473,10 +414,10 @@ __('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( [
'fac_formats[' . $uid . '][linesdescriptionlength]', 'fac_formats[' . $uid . '][linesdescriptionlength]',
'fac_formats_' . $uid . '_linesdescriptionlength' 'fac_formats_' . $uid . '_linesdescriptionlength'
), ],
5, 5,
4, 4,
350, 350,
@ -490,10 +431,10 @@ __('Leave lengh empty for no limit.') .
<p><label for="fac_formats_' . $uid . '_showlinescontent">' . <p><label for="fac_formats_' . $uid . '_showlinescontent">' .
form::checkbox( form::checkbox(
array( [
'fac_formats[' . $uid . '][showlinescontent]', 'fac_formats[' . $uid . '][showlinescontent]',
'fac_formats_' . $uid . '_showlinescontent' 'fac_formats_' . $uid . '_showlinescontent'
), ],
1, 1,
0 0
) . ) .
@ -501,10 +442,10 @@ __('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( [
'fac_formats[' . $uid . '][linescontentnohtml]', 'fac_formats[' . $uid . '][linescontentnohtml]',
'fac_formats_' . $uid . '_linescontentnohtml' 'fac_formats_' . $uid . '_linescontentnohtml'
), ],
1, 1,
1 1
) . ) .
@ -513,10 +454,10 @@ __('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( [
'fac_formats[' . $uid . '][linescontentlength]', 'fac_formats[' . $uid . '][linescontentlength]',
'fac_formats_' . $uid . '_linescontentlength' 'fac_formats_' . $uid . '_linescontentlength'
), ],
5, 5,
4, 4,
350, 350,
@ -558,3 +499,5 @@ __('To add feed to an entry edit this entry and put in sidebar the url of the fe
</div> </div>
</div>'; </div>';
dcPage::helpBlock('fac');

View file

@ -23,7 +23,7 @@ $this->registerModule(
[ [
'permissions' => 'usage,contentadmin', 'permissions' => 'usage,contentadmin',
'type' => 'plugin', 'type' => 'plugin',
'dc_min' => '2.18', 'dc_min' => '2.19',
'support' => 'https://github.com/JcDenis/fac', 'support' => 'https://github.com/JcDenis/fac',
'details' => 'https://plugins.dotaddict.org/dc2/details/fac' 'details' => 'https://plugins.dotaddict.org/dc2/details/fac'
] ]

View file

@ -16,27 +16,26 @@ if (!defined('DC_CONTEXT_ADMIN')) {
} }
# -- Module specs -- # -- Module specs --
$dc_min = '2.19';
$dc_min = '2.6';
$mod_id = 'fac'; $mod_id = 'fac';
$mod_conf = array( $mod_conf = [
array( [
'fac_active', 'fac_active',
'Enabled fac plugin', 'Enabled fac plugin',
false, false,
'boolean' 'boolean'
), ],
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(['post', 'tag', 'archive']),
'string' 'string'
), ],
array( [
'fac_formats', 'fac_formats',
'Formats of feeds contents', 'Formats of feeds contents',
serialize(array( serialize([
uniqid() => array( uniqid() => [
'name' => 'default', 'name' => 'default',
'dateformat' => '', 'dateformat' => '',
'lineslimit' => '5', 'lineslimit' => '5',
@ -49,8 +48,8 @@ $mod_conf = array(
'showlinescontent' => '0', 'showlinescontent' => '0',
'linescontentlength' => '350', 'linescontentlength' => '350',
'linescontentnohtml' => '1' 'linescontentnohtml' => '1'
), ],
uniqid() => array( uniqid() => [
'name' => 'full', 'name' => 'full',
'dateformat' => '', 'dateformat' => '',
'lineslimit' => '20', 'lineslimit' => '20',
@ -63,38 +62,35 @@ $mod_conf = array(
'showlinescontent' => '1', 'showlinescontent' => '1',
'linescontentlength' => '', 'linescontentlength' => '',
'linescontentnohtml' => '1' 'linescontentnohtml' => '1'
) ]
)), ]),
'string' 'string',
), false,
array( true
],
[
'fac_defaultfeedtitle', 'fac_defaultfeedtitle',
'Default title of feed', 'Default title of feed',
'%T', '%T',
'string' 'string'
), ],
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)) {
@ -102,7 +98,6 @@ try {
'%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) {
@ -110,17 +105,13 @@ try {
$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

@ -10,9 +10,8 @@
<p>If you want some help or contribute to the plugin fac, follow these links.</p> <p>If you want some help or contribute to the plugin fac, follow these links.</p>
<ul> <ul>
<li><a href="http://forum.dotclear.org/viewtopic.php?id=43171">Post on Dotclear's forum</a></li> <li><a href="http://forum.dotclear.org/viewtopic.php?id=43171">Post on Dotclear's forum</a></li>
<li><a href="http://lab.dotclear.org/wiki/plugin/fac">SVN repository</a></li> <li><a href="https://github.com/JcDenis/fac">Github repository</a></li>
<li><a href="https://bitbucket.org/JcDenis/fac">HG repository</a></li> <li><a href="https://plugins.dotaddict.org/dc2/details/fac">Dotaddict repository</a></li>
<li><a href="http://jcd.lv/q=fac">Post on author's blog</a></li>
</ul> </ul>
</body> </body>

View file

@ -11,9 +11,8 @@
<p>Si vous souhaitez plus d'aide ou apporter votre contribution à cette extension, voici quelques liens utiles.</p> <p>Si vous souhaitez plus d'aide ou apporter votre contribution à cette extension, voici quelques liens utiles.</p>
<ul> <ul>
<li><a href="http://forum.dotclear.org/viewtopic.php?id=43171">Sujet sur le forum Dotclear</a></li> <li><a href="http://forum.dotclear.org/viewtopic.php?id=43171">Sujet sur le forum Dotclear</a></li>
<li><a href="http://lab.dotclear.org/wiki/plugin/fac">Dépôt svn</a></li> <li><a href="https://github.com/JcDenis/fac">Dépôt Github</a></li>
<li><a href="https://bitbucket.org/JcDenis/fac">Dépôt hg</a></li> <li><a href="https://plugins.dotaddict.org/dc2/details/fac">Dépôt Dotaddict</a></li>
<li><a href="http://jcd.lv/q=fac">Billet dédié sur le blog de l'auteur</a></li>
</ul> </ul>
</body> </body>