diff --git a/CHANGELOG.md b/CHANGELOG.md
index 57f026b..a96c351 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -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
* fix context filters
diff --git a/README.md b/README.md
index 1ca864b..967abbc 100644
--- a/README.md
+++ b/README.md
@@ -12,9 +12,10 @@ to link en extenal feed to the bottom of an entry.
fac requires:
+ * superadmin to configure feeds formats
* admin permissions to configure plugin
* usage,contentadmin permissions to link feeds
- * Dotclear 2.6
+ * Dotclear 2.19
* A theme that contents behavior publicEntryAfterContent
## 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
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"
to link a feed to this post.
diff --git a/_admin.php b/_admin.php
index 9c22eb9..35e937b 100644
--- a/_admin.php
+++ b/_admin.php
@@ -17,12 +17,9 @@ if (!defined('DC_CONTEXT_ADMIN')) {
$core->blog->settings->addNamespace('fac');
-# Not active
-if (!$core->blog->settings->fac->fac_active) {
- return null;
-}
-
# Admin behaviors
+$core->addBehavior('adminBlogPreferencesForm', ['facAdmin', 'adminBlogPreferencesForm']);
+$core->addBehavior('adminBeforeBlogSettingsUpdate', ['facAdmin', 'adminBeforeBlogSettingsUpdate']);
$core->addBehavior('adminPostHeaders', ['facAdmin', 'adminPostHeaders']);
$core->addBehavior('adminPostFormItems', ['facAdmin', 'adminPostFormItems']);
$core->addBehavior('adminAfterPostCreate', ['facAdmin', 'adminAfterPostSave']);
@@ -37,6 +34,101 @@ $core->addBehavior('adminPostsActionsPage', ['facAdmin', 'adminPostsActionsPage'
*/
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
+ '
' .
$core->formNonce() .
$pa->getHiddenFields() .
- form::hidden(array('action'), 'fac_add') .
+ form::hidden(['action'], 'fac_add') .
'
' .
'';
@@ -236,6 +328,10 @@ class facAdmin
*/
protected static function formFeed(dcCore $core, $url = '', $format = '')
{
+ if (!$core->blog->settings->fac->fac_active) {
+ return null;
+ }
+
return
'' .
'
' . __('Linked feed') . ' ' .
@@ -270,10 +366,10 @@ class facAdmin
{
$formats = @unserialize($core->blog->settings->fac->fac_formats);
if (!is_array($formats) || empty($formats)) {
- return array();
+ return [];
}
- $res = array();
+ $res = [];
foreach($formats as $uid => $f) {
$res[$f['name']] = $uid;
}
diff --git a/_config.php b/_config.php
index 8254d19..4392759 100644
--- a/_config.php
+++ b/_config.php
@@ -18,49 +18,20 @@ if (!defined('DC_CONTEXT_MODULE')) {
$redir = empty($_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 --
$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_formats = @unserialize($s->fac_formats);
-if (!is_array($fac_public_tpltypes)) {
- $fac_public_tpltypes = array();
-}
if (!is_array($fac_formats)) {
- $fac_formats = array();
+ $fac_formats = [];
}
# -- 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();
+ $fac_formats = [];
foreach($_POST['fac_formats'] as $uid => $f) {
if (!empty($f['name'])) {
@@ -68,11 +39,16 @@ if (!empty($_POST['save'])) {
}
}
- $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));
+ // fix 2021.08.21 : formats are now global
+ $s->drop('fac_formats');
+ $s->put(
+ 'fac_formats',
+ serialize($fac_formats),
+ 'string',
+ 'Formats of feeds contents',
+ true,
+ true
+ );
$core->blog->triggerBlog();
@@ -82,47 +58,12 @@ if (!empty($_POST['save'])) {
http::redirect(
$list->getURL('module=fac&conf=1&redir=' . $list->getRedir())
);
- }
- catch (Exception $e) {
+ } catch (Exception $e) {
$core->error->add($e->getMessage());
}
}
# -- Display form --
-echo '
-
-
' . __('Activation') . '
-
-
' .
-form::checkbox('fac_active', 1, $fac_active) .
-__('Enable plugin') . '
-
-
' . __('Show feed after content on:') . ' ';
-
-foreach($types as $k => $v) {
- echo '
-
' .
- form::checkbox(
- array('fac_public_tpltypes[]', 'fac_public_tpltypes' . $k),
- $v,
- in_array($v, $fac_public_tpltypes)
- ) . __($k) . '
';
-}
-echo '
-
-
-
-
' . __('Feed') . '
-
-
' . __('Default title') . ' ' .
-form::field('fac_defaultfeedtitle', 65, 255, $fac_defaultfeedtitle) . '
-
' . __('Use %T to insert title of feed.') . '
-
-
' .
-form::checkbox('fac_showfeeddesc', 1, $fac_showfeeddesc) .
-__('Show description of feed') . '
-
-
';
$i = 1;
foreach($fac_formats as $uid => $f) {
@@ -139,10 +80,10 @@ foreach($fac_formats as $uid => $f) {
' .
__('Name:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][name]',
'fac_formats_' . $uid . '_name'
- ),
+ ],
20,
255,
empty($f['name']) ? '' : $f['name'],
@@ -155,10 +96,10 @@ foreach($fac_formats as $uid => $f) {
' .
__('Date format:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][dateformat]',
'fac_formats_' . $uid . '_dateformat'
- ),
+ ],
20,
255,
empty($f['dateformat']) ? '' : $f['dateformat'],
@@ -171,10 +112,10 @@ foreach($fac_formats as $uid => $f) {
' .
__('Entries limit:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][lineslimit]',
'fac_formats_' . $uid . '_lineslimit'
- ),
+ ],
5,
4,
empty($f['lineslimit']) ? '' : $f['lineslimit'],
@@ -189,10 +130,10 @@ foreach($fac_formats as $uid => $f) {
' .
__('Title format:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][linestitletext]',
'fac_formats_' . $uid . '_linestitletext'
- ),
+ ],
20,
255,
empty($f['linestitletext']) ? '' : $f['linestitletext'],
@@ -210,10 +151,10 @@ foreach($fac_formats as $uid => $f) {
' .
__('Over title format:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_' . $uid . '_linestitleover'
- ),
+ ],
20,
255,
empty($f['linestitleover']) ? '' : $f['linestitleover'],
@@ -231,10 +172,10 @@ foreach($fac_formats as $uid => $f) {
' .
__('Maximum length of title:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][linestitlelength]',
'fac_formats_' . $uid . '_linestitlelength'
- ),
+ ],
5,
4,
empty($f['linestitlelength']) ? '' : $f['linestitlelength'],
@@ -248,10 +189,10 @@ foreach($fac_formats as $uid => $f) {
' .
form::checkbox(
- array(
+ [
'fac_formats[' . $uid . '][showlinesdescription]',
'fac_formats_' . $uid . '_showlinesdescription'
- ),
+ ],
1,
!empty($f['showlinesdescription'])
) .
@@ -259,10 +200,10 @@ foreach($fac_formats as $uid => $f) {
' .
form::checkbox(
- array(
+ [
'fac_formats[' . $uid . '][linesdescriptionnohtml]',
'fac_formats_' . $uid . '_linesdescriptionnohtml'
- ),
+ ],
1,
!empty($f['linesdescriptionnohtml'])
).
@@ -271,10 +212,10 @@ foreach($fac_formats as $uid => $f) {
' .
__('Maximum length of description:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][linesdescriptionlength]',
'fac_formats_' . $uid . '_linesdescriptionlength'
- ),
+ ],
5,
4,
empty($f['linesdescriptionlength']) ? '' : $f['linesdescriptionlength'],
@@ -288,10 +229,10 @@ foreach($fac_formats as $uid => $f) {
' .
form::checkbox(
- array(
+ [
'fac_formats[' . $uid . '][showlinescontent]',
'fac_formats_' . $uid . '_showlinescontent'
- ),
+ ],
1,
!empty($f['showlinescontent'])
) .
@@ -299,10 +240,10 @@ foreach($fac_formats as $uid => $f) {
' .
form::checkbox(
- array(
+ [
'fac_formats[' . $uid . '][linescontentnohtml]',
'fac_formats_' . $uid . '_linescontentnohtml'
- ),
+ ],
1,
!empty($f['linescontentnohtml'])
) .
@@ -311,10 +252,10 @@ foreach($fac_formats as $uid => $f) {
' .
__('Maximum length of content:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][linescontentlength]',
'fac_formats_' . $uid . '_linescontentlength'
- ),
+ ],
5,
4,
empty($f['linescontentlength']) ? '' : $f['linescontentlength'],
@@ -341,10 +282,10 @@ echo '
' .
__('Name:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][name]',
'fac_formats_' . $uid . '_name'
- ),
+ ],
20,
255,
'',
@@ -357,10 +298,10 @@ __('In order to remove a format, leave its name empty.') .
' .
__('Date format:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][dateformat]',
'fac_formats_' . $uid . '_dateformat'
- ),
+ ],
20,
255,
'',
@@ -373,10 +314,10 @@ __('Use date format of Dotclear or leave empty to use default date format of blo
' .
__('Entries limit:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][lineslimit]',
'fac_formats_' . $uid . '_lineslimit'
- ),
+ ],
5,
4,
5,
@@ -391,10 +332,10 @@ __('Leave lengh empty for no limit.') .
' .
__('Title format:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][linestitletext]',
'fac_formats_' . $uid . '_linestitletext'
- ),
+ ],
20,
255,
'%T',
@@ -412,10 +353,10 @@ __('Format can be:') .
' .
__('Over title format:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_' . $uid . '_linestitleover'
- ),
+ ],
20,
255,
'%D',
@@ -433,10 +374,10 @@ __('Format can be:') .
' .
__('Maximum length of title:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][linestitlelength]',
'fac_formats_' . $uid . '_linestitlelength'
- ),
+ ],
5,
4,
150,
@@ -450,10 +391,10 @@ __('Leave lengh empty for no limit.') .
' .
form::checkbox(
- array(
+ [
'fac_formats[' . $uid . '][showlinesdescription]',
'fac_formats_' . $uid . '_showlinesdescription'
- ),
+ ],
1,
0
) .
@@ -461,10 +402,10 @@ __('Show description of entries') . '
' .
form::checkbox(
- array(
+ [
'fac_formats[' . $uid . '][linesdescriptionnohtml]',
'fac_formats_' . $uid . '_linesdescriptionnohtml'
- ),
+ ],
1,
1
) .
@@ -473,10 +414,10 @@ __('Remove html of description') . '
' .
__('Maximum length of description:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][linesdescriptionlength]',
'fac_formats_' . $uid . '_linesdescriptionlength'
- ),
+ ],
5,
4,
350,
@@ -490,10 +431,10 @@ __('Leave lengh empty for no limit.') .
' .
form::checkbox(
- array(
+ [
'fac_formats[' . $uid . '][showlinescontent]',
'fac_formats_' . $uid . '_showlinescontent'
- ),
+ ],
1,
0
) .
@@ -501,10 +442,10 @@ __('Show content of entries') . '
' .
form::checkbox(
- array(
+ [
'fac_formats[' . $uid . '][linescontentnohtml]',
'fac_formats_' . $uid . '_linescontentnohtml'
- ),
+ ],
1,
1
) .
@@ -513,10 +454,10 @@ __('Remove html of content') . '
' .
__('Maximum length of content:') . ' ' .
form::field(
- array(
+ [
'fac_formats[' . $uid . '][linescontentlength]',
'fac_formats_' . $uid . '_linescontentlength'
- ),
+ ],
5,
4,
350,
@@ -557,4 +498,6 @@ __('To add feed to an entry edit this entry and put in sidebar the url of the fe
-';
\ No newline at end of file
+';
+
+dcPage::helpBlock('fac');
\ No newline at end of file
diff --git a/_define.php b/_define.php
index 43768ba..997825a 100644
--- a/_define.php
+++ b/_define.php
@@ -23,7 +23,7 @@ $this->registerModule(
[
'permissions' => 'usage,contentadmin',
'type' => 'plugin',
- 'dc_min' => '2.18',
+ 'dc_min' => '2.19',
'support' => 'https://github.com/JcDenis/fac',
'details' => 'https://plugins.dotaddict.org/dc2/details/fac'
]
diff --git a/_install.php b/_install.php
index dcccebb..dc2021f 100644
--- a/_install.php
+++ b/_install.php
@@ -16,27 +16,26 @@ if (!defined('DC_CONTEXT_ADMIN')) {
}
# -- Module specs --
-
-$dc_min = '2.6';
+$dc_min = '2.19';
$mod_id = 'fac';
-$mod_conf = array(
- array(
+$mod_conf = [
+ [
'fac_active',
'Enabled fac plugin',
false,
'boolean'
- ),
- array(
+ ],
+ [
'fac_public_tpltypes',
'List of templates types which used fac',
- serialize(array('post', 'tag', 'archive')),
+ serialize(['post', 'tag', 'archive']),
'string'
- ),
- array(
+ ],
+ [
'fac_formats',
'Formats of feeds contents',
- serialize(array(
- uniqid() => array(
+ serialize([
+ uniqid() => [
'name' => 'default',
'dateformat' => '',
'lineslimit' => '5',
@@ -49,8 +48,8 @@ $mod_conf = array(
'showlinescontent' => '0',
'linescontentlength' => '350',
'linescontentnohtml' => '1'
- ),
- uniqid() => array(
+ ],
+ uniqid() => [
'name' => 'full',
'dateformat' => '',
'lineslimit' => '20',
@@ -63,38 +62,35 @@ $mod_conf = array(
'showlinescontent' => '1',
'linescontentlength' => '',
'linescontentnohtml' => '1'
- )
- )),
- 'string'
- ),
- array(
+ ]
+ ]),
+ 'string',
+ false,
+ true
+ ],
+ [
'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'),
- '>='
- )) {
-
+ '>=')) {
return null;
}
-
# Check Dotclear version
if (!method_exists('dcUtils', 'versionsCompare')
|| dcUtils::versionsCompare(DC_VERSION, $dc_min, '<', false)) {
@@ -102,7 +98,6 @@ try {
'%s requires Dotclear %s', $mod_id, $dc_min
));
}
-
# Set module settings
$core->blog->settings->addNamespace($mod_id);
foreach($mod_conf as $v) {
@@ -110,17 +105,13 @@ try {
$v[0], $v[2], $v[3], $v[1], false, true
);
}
-
# Set module version
$core->setVersion(
$mod_id,
$core->plugins->moduleInfo($mod_id, 'version')
);
-
return true;
-}
-catch (Exception $e) {
+} catch (Exception $e) {
$core->error->add($e->getMessage());
-
return false;
}
\ No newline at end of file
diff --git a/locales/en/help/fac.html b/locales/en/help/fac.html
index f782827..792d9d9 100644
--- a/locales/en/help/fac.html
+++ b/locales/en/help/fac.html
@@ -10,9 +10,8 @@
If you want some help or contribute to the plugin fac, follow these links.