split super vs admin configs
This commit is contained in:
parent
59583a33d0
commit
f75c3c88ba
8 changed files with 230 additions and 192 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
152
_admin.php
152
_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
|
||||
'<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)
|
||||
*
|
||||
|
@ -58,22 +150,26 @@ class facAdmin
|
|||
{
|
||||
global $core;
|
||||
|
||||
if (!$core->blog->settings->fac->fac_active) {
|
||||
return null;
|
||||
}
|
||||
|
||||
# Get existing linked feed
|
||||
$fac_url = $fac_format = '';
|
||||
if ($post) {
|
||||
|
||||
$rs = $core->meta->getMetadata(array(
|
||||
$rs = $core->meta->getMetadata([
|
||||
'meta_type' => 'fac',
|
||||
'post_id' => $post->post_id,
|
||||
'limit' => 1
|
||||
));
|
||||
]);
|
||||
$fac_url = $rs->isEmpty() ? '' : $rs->meta_id;
|
||||
|
||||
$rs = $core->meta->getMetadata(array(
|
||||
$rs = $core->meta->getMetadata([
|
||||
'meta_type' => 'facformat',
|
||||
'post_id' => $post->post_id,
|
||||
'limit' => 1
|
||||
));
|
||||
]);
|
||||
$fac_format = $rs->isEmpty() ? '' : $rs->meta_id;
|
||||
}
|
||||
|
||||
|
@ -122,25 +218,21 @@ class facAdmin
|
|||
*/
|
||||
public static function adminPostsActionsPage(dcCore $core, dcPostsActionsPage $pa)
|
||||
{
|
||||
if (!$core->blog->settings->fac->fac_active) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$pa->addAction(
|
||||
array(
|
||||
__('Linked feed') => array(
|
||||
__('Add feed') => 'fac_add'
|
||||
)
|
||||
),
|
||||
array('facAdmin', 'callbackAdd')
|
||||
[__('Linked feed') => [__('Add feed') => 'fac_add']],
|
||||
['facAdmin', 'callbackAdd']
|
||||
);
|
||||
|
||||
if (!$core->auth->check('delete,contentadmin', $core->blog->id)) {
|
||||
return null;
|
||||
}
|
||||
$pa->addAction(
|
||||
array(
|
||||
__('Linked feed') => array(
|
||||
__('Remove feed') => 'fac_remove'
|
||||
)
|
||||
),
|
||||
array('facAdmin', 'callbackRemove')
|
||||
[__('Linked feed') => [__('Remove feed') => 'fac_remove']],
|
||||
['facAdmin', 'callbackRemove']
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -164,7 +256,7 @@ class facAdmin
|
|||
throw new Exception(__('No enough right'));
|
||||
}
|
||||
|
||||
# Delete expired date
|
||||
# Delete unused feed
|
||||
foreach($posts_ids as $post_id) {
|
||||
self::delFeed($core, $post_id);
|
||||
}
|
||||
|
@ -182,7 +274,7 @@ class facAdmin
|
|||
*/
|
||||
public static function callbackAdd(dcCore $core, dcPostsActionsPage $pa, ArrayObject $post)
|
||||
{
|
||||
# No entry
|
||||
# No entry
|
||||
$posts_ids = $pa->getIDs();
|
||||
if (empty($posts_ids)) {
|
||||
throw new Exception(__('No entry selected'));
|
||||
|
@ -202,11 +294,11 @@ class facAdmin
|
|||
# Display form
|
||||
} else {
|
||||
$pa->beginPage(
|
||||
dcPage::breadcrumb(array(
|
||||
dcPage::breadcrumb([
|
||||
html::escapeHTML($core->blog->name) => '',
|
||||
$pa->getCallerTitle() => $pa->getRedirection(true),
|
||||
__('Linked feed to this selection') => ''
|
||||
))
|
||||
])
|
||||
);
|
||||
|
||||
echo
|
||||
|
@ -218,7 +310,7 @@ class facAdmin
|
|||
'<p>' .
|
||||
$core->formNonce() .
|
||||
$pa->getHiddenFields() .
|
||||
form::hidden(array('action'), 'fac_add') .
|
||||
form::hidden(['action'], 'fac_add') .
|
||||
'<input type="submit" value="' . __('Save') . '" /></p>' .
|
||||
'</form>';
|
||||
|
||||
|
@ -236,6 +328,10 @@ class facAdmin
|
|||
*/
|
||||
protected static function formFeed(dcCore $core, $url = '', $format = '')
|
||||
{
|
||||
if (!$core->blog->settings->fac->fac_active) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return
|
||||
'<div id="fac">' .
|
||||
'<h5>' . __('Linked feed') . '</h5>' .
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
187
_config.php
187
_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 '
|
||||
<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;
|
||||
foreach($fac_formats as $uid => $f) {
|
||||
|
@ -139,10 +80,10 @@ foreach($fac_formats as $uid => $f) {
|
|||
<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'],
|
||||
|
@ -155,10 +96,10 @@ foreach($fac_formats as $uid => $f) {
|
|||
<p><label for="fac_formats_' . $uid . '_dateformat">' .
|
||||
__('Date format:') . '</label>' .
|
||||
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) {
|
|||
<p><label for="fac_formats_' . $uid . '_lineslimit">' .
|
||||
__('Entries limit:') . '</label>' .
|
||||
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) {
|
|||
<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'],
|
||||
|
@ -210,10 +151,10 @@ foreach($fac_formats as $uid => $f) {
|
|||
<p><label for="fac_formats_' . $uid . '_linestitleover">' .
|
||||
__('Over title format:') . '</label>' .
|
||||
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) {
|
|||
<p><label for="fac_formats_' . $uid . '_linestitlelength">' .
|
||||
__('Maximum length of title:') . '</label>' .
|
||||
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) {
|
|||
|
||||
<p><label for="fac_formats_' . $uid . '_showlinesdescription">' .
|
||||
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) {
|
|||
|
||||
<p><label for="fac_formats_' . $uid . '_linesdescriptionnohtml">' .
|
||||
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) {
|
|||
<p><label for="fac_formats_' . $uid . '_linesdescriptionlength">' .
|
||||
__('Maximum length of description:') . '</label>' .
|
||||
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) {
|
|||
|
||||
<p><label for="fac_formats_' . $uid . '_showlinescontent">' .
|
||||
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) {
|
|||
|
||||
<p><label for="fac_formats_' . $uid . '_linescontentnohtml">' .
|
||||
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) {
|
|||
<p><label for="fac_formats_' . $uid . '_linescontentlength">' .
|
||||
__('Maximum length of content:') . '</label>' .
|
||||
form::field(
|
||||
array(
|
||||
[
|
||||
'fac_formats[' . $uid . '][linescontentlength]',
|
||||
'fac_formats_' . $uid . '_linescontentlength'
|
||||
),
|
||||
],
|
||||
5,
|
||||
4,
|
||||
empty($f['linescontentlength']) ? '' : $f['linescontentlength'],
|
||||
|
@ -341,10 +282,10 @@ echo '
|
|||
<p><label for="fac_formats_' . $uid . '_name">' .
|
||||
__('Name:') . '</label>' .
|
||||
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.') .
|
|||
<p><label for="fac_formats_' . $uid . '_dateformat">' .
|
||||
__('Date format:') . '</label>' .
|
||||
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
|
|||
<p><label for="fac_formats_' . $uid . '_lineslimit">' .
|
||||
__('Entries limit:') . '</label>' .
|
||||
form::field(
|
||||
array(
|
||||
[
|
||||
'fac_formats[' . $uid . '][lineslimit]',
|
||||
'fac_formats_' . $uid . '_lineslimit'
|
||||
),
|
||||
],
|
||||
5,
|
||||
4,
|
||||
5,
|
||||
|
@ -391,10 +332,10 @@ __('Leave lengh empty for no limit.') .
|
|||
<p><label for="fac_formats_' . $uid . '_linestitletext">' .
|
||||
__('Title format:') . '</label>' .
|
||||
form::field(
|
||||
array(
|
||||
[
|
||||
'fac_formats[' . $uid . '][linestitletext]',
|
||||
'fac_formats_' . $uid . '_linestitletext'
|
||||
),
|
||||
],
|
||||
20,
|
||||
255,
|
||||
'%T',
|
||||
|
@ -412,10 +353,10 @@ __('Format can be:') .
|
|||
<p><label for="fac_formats_' . $uid . '_linestitleover">' .
|
||||
__('Over title format:') . '</label>' .
|
||||
form::field(
|
||||
array(
|
||||
[
|
||||
'fac_formats[' . $uid . '][linestitleover]',
|
||||
'fac_formats_' . $uid . '_linestitleover'
|
||||
),
|
||||
],
|
||||
20,
|
||||
255,
|
||||
'%D',
|
||||
|
@ -433,10 +374,10 @@ __('Format can be:') .
|
|||
<p><label for="fac_formats_' . $uid . '_linestitlelength">' .
|
||||
__('Maximum length of title:') . '</label>' .
|
||||
form::field(
|
||||
array(
|
||||
[
|
||||
'fac_formats[' . $uid . '][linestitlelength]',
|
||||
'fac_formats_' . $uid . '_linestitlelength'
|
||||
),
|
||||
],
|
||||
5,
|
||||
4,
|
||||
150,
|
||||
|
@ -450,10 +391,10 @@ __('Leave lengh empty for no limit.') .
|
|||
|
||||
<p><label for="fac_formats_' . $uid . '_showlinesdescription">' .
|
||||
form::checkbox(
|
||||
array(
|
||||
[
|
||||
'fac_formats[' . $uid . '][showlinesdescription]',
|
||||
'fac_formats_' . $uid . '_showlinesdescription'
|
||||
),
|
||||
],
|
||||
1,
|
||||
0
|
||||
) .
|
||||
|
@ -461,10 +402,10 @@ __('Show description of entries') . '</label></p>
|
|||
|
||||
<p><label for="fac_formats_' . $uid . '_linesdescriptionnohtml">' .
|
||||
form::checkbox(
|
||||
array(
|
||||
[
|
||||
'fac_formats[' . $uid . '][linesdescriptionnohtml]',
|
||||
'fac_formats_' . $uid . '_linesdescriptionnohtml'
|
||||
),
|
||||
],
|
||||
1,
|
||||
1
|
||||
) .
|
||||
|
@ -473,10 +414,10 @@ __('Remove html of description') . '</label></p>
|
|||
<p><label for="fac_formats_' . $uid . '_linesdescriptionlength">' .
|
||||
__('Maximum length of description:') . '</label>' .
|
||||
form::field(
|
||||
array(
|
||||
[
|
||||
'fac_formats[' . $uid . '][linesdescriptionlength]',
|
||||
'fac_formats_' . $uid . '_linesdescriptionlength'
|
||||
),
|
||||
],
|
||||
5,
|
||||
4,
|
||||
350,
|
||||
|
@ -490,10 +431,10 @@ __('Leave lengh empty for no limit.') .
|
|||
|
||||
<p><label for="fac_formats_' . $uid . '_showlinescontent">' .
|
||||
form::checkbox(
|
||||
array(
|
||||
[
|
||||
'fac_formats[' . $uid . '][showlinescontent]',
|
||||
'fac_formats_' . $uid . '_showlinescontent'
|
||||
),
|
||||
],
|
||||
1,
|
||||
0
|
||||
) .
|
||||
|
@ -501,10 +442,10 @@ __('Show content of entries') . '</label></p>
|
|||
|
||||
<p><label for="fac_formats_' . $uid . '_linescontentnohtml">' .
|
||||
form::checkbox(
|
||||
array(
|
||||
[
|
||||
'fac_formats[' . $uid . '][linescontentnohtml]',
|
||||
'fac_formats_' . $uid . '_linescontentnohtml'
|
||||
),
|
||||
],
|
||||
1,
|
||||
1
|
||||
) .
|
||||
|
@ -513,10 +454,10 @@ __('Remove html of content') . '</label></p>
|
|||
<p><label for="fac_formats_' . $uid . '_linescontentlength">' .
|
||||
__('Maximum length of content:') . '</label>' .
|
||||
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
|
|||
|
||||
</div>
|
||||
|
||||
</div>';
|
||||
</div>';
|
||||
|
||||
dcPage::helpBlock('fac');
|
|
@ -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'
|
||||
]
|
||||
|
|
59
_install.php
59
_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;
|
||||
}
|
|
@ -10,9 +10,8 @@
|
|||
<p>If you want some help or contribute to the plugin fac, follow these links.</p>
|
||||
<ul>
|
||||
<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://bitbucket.org/JcDenis/fac">HG repository</a></li>
|
||||
<li><a href="http://jcd.lv/q=fac">Post on author's blog</a></li>
|
||||
<li><a href="https://github.com/JcDenis/fac">Github repository</a></li>
|
||||
<li><a href="https://plugins.dotaddict.org/dc2/details/fac">Dotaddict repository</a></li>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
|
|
|
@ -11,9 +11,8 @@
|
|||
<p>Si vous souhaitez plus d'aide ou apporter votre contribution à cette extension, voici quelques liens utiles.</p>
|
||||
<ul>
|
||||
<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://bitbucket.org/JcDenis/fac">Dépôt hg</a></li>
|
||||
<li><a href="http://jcd.lv/q=fac">Billet dédié sur le blog de l'auteur</a></li>
|
||||
<li><a href="https://github.com/JcDenis/fac">Dépôt Github</a></li>
|
||||
<li><a href="https://plugins.dotaddict.org/dc2/details/fac">Dépôt Dotaddict</a></li>
|
||||
</ul>
|
||||
|
||||
</body>
|
||||
|
|
Loading…
Reference in a new issue