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
===========================================================
* Switch to Dotclear 2.6
* Fix missing feed description
fac 0.6.1 - 2010-11-12
===========================================================
* Fixed install on nightly build
fac 0.6 - 2010-08-16
===========================================================
* Added compatibility with plugin muppet
fac 0.5 - 2010-06-05
===========================================================
* Switched to DC 2.2
* Added predefined format (thx to Jean-Michel) (closes #459)
fac 0.4.1 - 2010-04-10
===========================================================
* Fixed typo (thx to Jean-Michel) (closes #458)
fac 0.4 - 2010-05-25
===========================================================
* Fixed Timeout error
* Fixed DC 2.1.7
fac 0.3 - 2010-04-10
===========================================================
* Added options to format feed
* Added DC 2.2 compatibility
* Removed class and used metadata
* Changed admin page design
fac 0.2 - 2010-02-17
===========================================================
* Fixed some fields in admin
fac 0.1 - 2010-02-16
===========================================================
* First lab release

View File

@ -3,8 +3,7 @@
#
# This file is part of fac, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -13,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
@ -21,35 +19,16 @@ $core->blog->settings->addNamespace('fac');
# Not active
if (!$core->blog->settings->fac->fac_active) {
return null;
}
# Admin behaviors
$core->addBehavior(
'adminPostHeaders',
array('facAdmin', 'adminPostHeaders')
);
$core->addBehavior(
'adminPostFormItems',
array('facAdmin', 'adminPostFormItems')
);
$core->addBehavior(
'adminAfterPostCreate',
array('facAdmin', 'adminAfterPostSave')
);
$core->addBehavior(
'adminAfterPostUpdate',
array('facAdmin', 'adminAfterPostSave')
);
$core->addBehavior(
'adminBeforePostDelete',
array('facAdmin', 'adminBeforePostDelete')
);
$core->addBehavior(
'adminPostsActionsPage',
array('facAdmin', 'adminPostsActionsPage')
);
$core->addBehavior('adminPostHeaders', ['facAdmin', 'adminPostHeaders']);
$core->addBehavior('adminPostFormItems', ['facAdmin', 'adminPostFormItems']);
$core->addBehavior('adminAfterPostCreate', ['facAdmin', 'adminAfterPostSave']);
$core->addBehavior('adminAfterPostUpdate', ['facAdmin', 'adminAfterPostSave']);
$core->addBehavior('adminBeforePostDelete', ['facAdmin', 'adminBeforePostDelete']);
$core->addBehavior('adminPostsActionsPage', ['facAdmin', 'adminPostsActionsPage']);
/**
* @ingroup DC_PLUGIN_FAC
@ -114,8 +93,7 @@ class facAdmin
global $core;
if (!isset($_POST['fac_url'])
|| !isset($_POST['fac_format'])
) {
|| !isset($_POST['fac_format'])) {
return null;
}
@ -154,7 +132,6 @@ class facAdmin
);
if (!$core->auth->check('delete,contentadmin', $core->blog->id)) {
return null;
}
$pa->addAction(
@ -213,8 +190,7 @@ class facAdmin
# Save action
if (!empty($post['fac_url'])
&& !empty($post['fac_format'])
) {
&& !empty($post['fac_format'])) {
foreach($posts_ids as $post_id) {
self::delFeed($core, $post_id);
self::addFeed($core, $post_id, $post);
@ -222,10 +198,9 @@ class facAdmin
dcPage::addSuccessNotice(__('Linked feed added.'));
$pa->redirect(true);
}
# Display form
else {
} else {
$pa->beginPage(
dcPage::breadcrumb(array(
html::escapeHTML($core->blog->name) => '',
@ -235,16 +210,16 @@ class facAdmin
);
echo
'<form action="'.$pa->getURI().'" method="post">'.
$pa->getCheckboxes().
'<form action="' . $pa->getURI() . '" method="post">' .
$pa->getCheckboxes() .
self::formFeed($core).
self::formFeed($core) .
'<p>'.
$core->formNonce().
$pa->getHiddenFields().
form::hidden(array('action'), 'fac_add').
'<input type="submit" value="'.__('Save').'" /></p>'.
'<p>' .
$core->formNonce() .
$pa->getHiddenFields() .
form::hidden(array('action'), 'fac_add') .
'<input type="submit" value="' . __('Save') . '" /></p>' .
'</form>';
$pa->endPage();
@ -259,29 +234,29 @@ class facAdmin
* @param string $format Feed format
* @return string Feed form content
*/
protected static function formFeed(dcCore $core, $url='', $format='')
protected static function formFeed(dcCore $core, $url = '', $format = '')
{
return
'<div id="fac">'.
'<h5>'.__('Linked feed').'</h5>'.
'<p><label for="fac_url">'.
__('Feed URL:').'</label>'.
'<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>'.
) . '</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>' : '').
) . '</p>' .
($url ? '<p><a href="' . $url . '" title="' . $url . '">' . __('view feed') . '</a></p>' : '') .
'</div>';
}
@ -295,7 +270,6 @@ class facAdmin
{
$formats = @unserialize($core->blog->settings->fac->fac_formats);
if (!is_array($formats) || empty($formats)) {
return array();
}
@ -330,8 +304,7 @@ class facAdmin
protected static function addFeed($core, $post_id, $options)
{
if (empty($options['fac_url'])
|| empty($options['fac_format'])
) {
|| empty($options['fac_format'])) {
return null;
}

View File

@ -3,8 +3,7 @@
#
# This file is part of fac, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -13,22 +12,21 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_MODULE')) {
return null;
}
$redir = empty($_REQUEST['redir']) ?
$list->getURL().'#plugins' : $_REQUEST['redir'];
$list->getURL() . '#plugins' : $_REQUEST['redir'];
# -- Combos of types of supported public pages --
$types = array(
$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(
@ -57,7 +55,6 @@ if (!is_array($fac_formats)) {
# -- Set settings --
if (!empty($_POST['save'])) {
try {
$fac_active = !empty($_POST['fac_active']);
$fac_defaultfeedtitle = (string) $_POST['fac_defaultfeedtitle'];
@ -83,8 +80,7 @@ if (!empty($_POST['save'])) {
__('Configuration has been successfully updated.')
);
http::redirect(
$list->getURL('module=fac&conf=1&redir='.
$list->getRedir())
$list->getURL('module=fac&conf=1&redir=' . $list->getRedir())
);
}
catch (Exception $e) {
@ -94,241 +90,238 @@ if (!empty($_POST['save'])) {
# -- Display form --
echo '
<div class="fieldset">
<h4>'.__('Activation').'</h4>
<h4>' . __('Activation') . '</h4>
<p><label class="classic" for="fac_active">'.
form::checkbox('fac_active', 1, $fac_active).
__('Enable plugin').'</label></p>
<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>';
<h5>' . __('Show feed after content on:') . '</h5>';
foreach($types as $k => $v) {
echo '
<p><label class="classic" for="fac_public_tpltypes'.$k.'">'.
<p><label class="classic" for="fac_public_tpltypes' . $k . '">' .
form::checkbox(
array('fac_public_tpltypes[]', 'fac_public_tpltypes'.$k),
array('fac_public_tpltypes[]', 'fac_public_tpltypes' . $k),
$v,
in_array($v,$fac_public_tpltypes)
).__($k).'</label></p>';
in_array($v, $fac_public_tpltypes)
) . __($k) . '</label></p>';
}
echo '
</div>
<div class="fieldset">
<h4>'.__('Feed').'</h4>
<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 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>
<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) {
if (empty($f['name'])) {
continue;
}
echo '
<div class="fieldset">
<h4>'.sprintf(__('Format %s'), $i).'</h4>
<h4>' . sprintf(__('Format %s'), $i) . '</h4>
<div class="two-boxes"><h5>'.__('General').'</h5>
<div class="two-boxes"><h5>' . __('General') . '</h5>
<p><label for="fac_formats_'.$uid.'_name">'.
__('Name:').'</label>'.
<p><label for="fac_formats_' . $uid . '_name">' .
__('Name:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][name]',
'fac_formats_'.$uid.'_name'
'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 class="form-note">' .
__('In order to remove a format, leave its name empty.') .
'</p>
<p><label for="fac_formats_'.$uid.'_dateformat">'.
__('Date format:').'</label>'.
<p><label for="fac_formats_' . $uid . '_dateformat">' .
__('Date format:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][dateformat]',
'fac_formats_'.$uid.'_dateformat'
'fac_formats[' . $uid . '][dateformat]',
'fac_formats_' . $uid . '_dateformat'
),
20,
255,
empty($f['dateformat']) ? '' : $f['dateformat'],
'maximal'
).'</p>
<p class="form-note">'.
__('Use date format of Dotclear or leave empty to use default date format of blog.').
) . '</p>
<p class="form-note">' .
__('Use date format of Dotclear or leave empty to use default date format of blog.') .
'</p>
<p><label for="fac_formats_'.$uid.'_lineslimit">'.
__('Entries limit:').'</label>'.
<p><label for="fac_formats_' . $uid . '_lineslimit">' .
__('Entries limit:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][lineslimit]',
'fac_formats_'.$uid.'_lineslimit'
'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>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
'</p>
</div><div class="two-boxes"><h5>'.__('Title').'</h5>
</div><div class="two-boxes"><h5>' . __('Title') . '</h5>
<p><label for="fac_formats_'.$uid.'_linestitletext">'.
__('Title format:').'</label>'.
<p><label for="fac_formats_' . $uid . '_linestitletext">' .
__('Title format:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][linestitletext]',
'fac_formats_'.$uid.'_linestitletext'
'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 class="form-note">' .
__('Format can be:') .
'%D : ' . __('Date') .
', %T : ' . __('Title') .
', %A : ' . __('Author') .
', %E : ' . __('Description') .
', %C : ' . __('Content') .
'</p>
<p><label for="fac_formats_'.$uid.'_linestitleover">'.
__('Over title format:').'</label>'.
<p><label for="fac_formats_' . $uid . '_linestitleover">' .
__('Over title format:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][linestitleover]',
'fac_formats_'.$uid.'_linestitleover'
'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_' . $uid . '_linestitleover'
),
20,
255,
empty($f['linestitleover']) ? '' : $f['linestitleover'],
'maximal'
).'</p>
<p class="form-note">'.
__('Format can be:').
'%D : '.__('Date').
', %T : '.__('Title').
', %A : '.__('Author').
', %E : '.__('Description').
', %C : '.__('Content').
) . '</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.'_linestitlelength">'.
__('Maximum length of title:').'</label>'.
<p><label for="fac_formats_' . $uid . '_linestitlelength">' .
__('Maximum length of title:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][linestitlelength]',
'fac_formats_'.$uid.'_linestitlelength'
'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>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
'</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(
array(
'fac_formats['.$uid.'][showlinesdescription]',
'fac_formats_'.$uid.'_showlinesdescription'
'fac_formats[' . $uid . '][showlinesdescription]',
'fac_formats_' . $uid . '_showlinesdescription'
),
1,
!empty($f['showlinesdescription'])
).
__('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(
array(
'fac_formats['.$uid.'][linesdescriptionnohtml]',
'fac_formats_'.$uid.'_linesdescriptionnohtml'
'fac_formats[' . $uid . '][linesdescriptionnohtml]',
'fac_formats_' . $uid . '_linesdescriptionnohtml'
),
1,
!empty($f['linesdescriptionnohtml'])
).
__('Remove html of description').'</label></p>
__('Remove html of description') . '</label></p>
<p><label for="fac_formats_'.$uid.'_linesdescriptionlength">'.
__('Maximum length of description:').'</label>'.
<p><label for="fac_formats_' . $uid . '_linesdescriptionlength">' .
__('Maximum length of description:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][linesdescriptionlength]',
'fac_formats_'.$uid.'_linesdescriptionlength'
'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>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
'</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(
array(
'fac_formats['.$uid.'][showlinescontent]',
'fac_formats_'.$uid.'_showlinescontent'
'fac_formats[' . $uid . '][showlinescontent]',
'fac_formats_' . $uid . '_showlinescontent'
),
1,
!empty($f['showlinescontent'])
).
__('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(
array(
'fac_formats['.$uid.'][linescontentnohtml]',
'fac_formats_'.$uid.'_linescontentnohtml'
'fac_formats[' . $uid . '][linescontentnohtml]',
'fac_formats_' . $uid . '_linescontentnohtml'
),
1,
!empty($f['linescontentnohtml'])
).
__('Remove html of content').'</label></p>
) .
__('Remove html of content') . '</label></p>
<p><label for="fac_formats_'.$uid.'_linescontentlength">'.
__('Maximum length of content:').'</label>'.
<p><label for="fac_formats_' . $uid . '_linescontentlength">' .
__('Maximum length of content:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][linescontentlength]',
'fac_formats_'.$uid.'_linescontentlength'
'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>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
'</p>
</div>
@ -341,196 +334,196 @@ foreach($fac_formats as $uid => $f) {
$uid = uniqid();
echo '
<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">'.
__('Name:').'</label>'.
<p><label for="fac_formats_' . $uid . '_name">' .
__('Name:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][name]',
'fac_formats_'.$uid.'_name'
'fac_formats[' . $uid . '][name]',
'fac_formats_' . $uid . '_name'
),
20,
255,
'',
'maximal'
).'</p>
) . '</p>
<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><label for="fac_formats_'.$uid.'_dateformat">'.
__('Date format:').'</label>'.
<p><label for="fac_formats_' . $uid . '_dateformat">' .
__('Date format:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][dateformat]',
'fac_formats_'.$uid.'_dateformat'
'fac_formats[' . $uid . '][dateformat]',
'fac_formats_' . $uid . '_dateformat'
),
20,
255,
'',
'maximal'
).'</p>
<p class="form-note">'.
__('Use date format of Dotclear or leave empty to use default date format of blog.').
) . '</p>
<p class="form-note">' .
__('Use date format of Dotclear or leave empty to use default date format of blog.') .
'</p>
<p><label for="fac_formats_'.$uid.'_lineslimit">'.
__('Entries limit:').'</label>'.
<p><label for="fac_formats_' . $uid . '_lineslimit">' .
__('Entries limit:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][lineslimit]',
'fac_formats_'.$uid.'_lineslimit'
'fac_formats[' . $uid . '][lineslimit]',
'fac_formats_' . $uid . '_lineslimit'
),
5,
4,
5,
'maximal'
).'</p>
<p class="form-note">'.
__('Leave lengh empty for no limit.').
) . '</p>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
'</p>
</div><div class="two-boxes"><h5>'.__('Title').'</h5>
</div><div class="two-boxes"><h5>' . __('Title') . '</h5>
<p><label for="fac_formats_'.$uid.'_linestitletext">'.
__('Title format:').'</label>'.
<p><label for="fac_formats_' . $uid . '_linestitletext">' .
__('Title format:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][linestitletext]',
'fac_formats_'.$uid.'_linestitletext'
'fac_formats[' . $uid . '][linestitletext]',
'fac_formats_' . $uid . '_linestitletext'
),
20,
255,
'%T',
'maximal'
).'</p>
<p class="form-note">'.
__('Format can be:').
'%D : '.__('Date').
', %T : '.__('Title').
', %A : '.__('Author').
', %E : '.__('Description').
', %C : '.__('Content').
) . '</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.'_linestitleover">'.
__('Over title format:').'</label>'.
<p><label for="fac_formats_' . $uid . '_linestitleover">' .
__('Over title format:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][linestitleover]',
'fac_formats_'.$uid.'_linestitleover'
'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_' . $uid . '_linestitleover'
),
20,
255,
'%D',
'maximal'
).'</p>
<p class="form-note">'.
__('Format can be:').
'%D : '.__('Date').
', %T : '.__('Title').
', %A : '.__('Author').
', %E : '.__('Description').
', %C : '.__('Content').
) . '</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.'_linestitlelength">'.
__('Maximum length of title:').'</label>'.
<p><label for="fac_formats_' . $uid . '_linestitlelength">' .
__('Maximum length of title:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][linestitlelength]',
'fac_formats_'.$uid.'_linestitlelength'
'fac_formats[' . $uid . '][linestitlelength]',
'fac_formats_' . $uid . '_linestitlelength'
),
5,
4,
150,
'maximal'
).'</p>
<p class="form-note">'.
__('Leave lengh empty for no limit.').
) . '</p>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
'</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(
array(
'fac_formats['.$uid.'][showlinesdescription]',
'fac_formats_'.$uid.'_showlinesdescription'
'fac_formats[' . $uid . '][showlinesdescription]',
'fac_formats_' . $uid . '_showlinesdescription'
),
1,
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(
array(
'fac_formats['.$uid.'][linesdescriptionnohtml]',
'fac_formats_'.$uid.'_linesdescriptionnohtml'
'fac_formats[' . $uid . '][linesdescriptionnohtml]',
'fac_formats_' . $uid . '_linesdescriptionnohtml'
),
1,
1
).
__('Remove html of description').'</label></p>
) .
__('Remove html of description') . '</label></p>
<p><label for="fac_formats_'.$uid.'_linesdescriptionlength">'.
__('Maximum length of description:').'</label>'.
<p><label for="fac_formats_' . $uid . '_linesdescriptionlength">' .
__('Maximum length of description:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][linesdescriptionlength]',
'fac_formats_'.$uid.'_linesdescriptionlength'
'fac_formats[' . $uid . '][linesdescriptionlength]',
'fac_formats_' . $uid . '_linesdescriptionlength'
),
5,
4,
350,
'maximal'
).'</p>
<p class="form-note">'.
__('Leave lengh empty for no limit.').
) . '</p>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
'</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(
array(
'fac_formats['.$uid.'][showlinescontent]',
'fac_formats_'.$uid.'_showlinescontent'
'fac_formats[' . $uid . '][showlinescontent]',
'fac_formats_' . $uid . '_showlinescontent'
),
1,
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(
array(
'fac_formats['.$uid.'][linescontentnohtml]',
'fac_formats_'.$uid.'_linescontentnohtml'
'fac_formats[' . $uid . '][linescontentnohtml]',
'fac_formats_' . $uid . '_linescontentnohtml'
),
1,
1
).
__('Remove html of content').'</label></p>
) .
__('Remove html of content') . '</label></p>
<p><label for="fac_formats_'.$uid.'_linescontentlength">'.
__('Maximum length of content:').'</label>'.
<p><label for="fac_formats_' . $uid . '_linescontentlength">' .
__('Maximum length of content:') . '</label>' .
form::field(
array(
'fac_formats['.$uid.'][linescontentlength]',
'fac_formats_'.$uid.'_linescontentlength'
'fac_formats[' . $uid . '][linescontentlength]',
'fac_formats_' . $uid . '_linescontentlength'
),
5,
4,
350,
'maximal'
).'</p>
<p class="form-note">'.
__('Leave lengh empty for no limit.').
) . '</p>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
'</p>
</div>
@ -538,29 +531,29 @@ __('Leave lengh empty for no limit.').
</div>
<div class="fieldset">
<h4>'.__('Informations').'</h4>
<h4>' . __('Informations') . '</h4>
<div class="two-boxes">
<h5>'.__('Theme').'</h5>
<p>'.
__('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.').
<h5>' . __('Theme') . '</h5>
<p>' .
__('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.') .
'</p>
</div><div class="two-boxes">
<h5>'.__('Structure').'</h5>
<pre>'.html::escapeHTML('
<h5>' . __('Structure') . '</h5>
<pre>' . html::escapeHTML('
<div class="post-fac">
<h3>'.__('Title of feed').'</h3>
<p>'.__('Description of feed').'</p>
<h3>' . __('Title of feed') . '</h3>
<p>' . __('Description of feed') . '</p>
<dl>
<dt>'.__('Title of entry').'</dt>
<dd>'.__('Description of entry').'</dd>
<dt>' . __('Title of entry') . '</dt>
<dd>' . __('Description of entry') . '</dd>
</dl>
</div>
').'</pre>
') . '</pre>
</div>

View File

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

View File

@ -3,8 +3,7 @@
#
# This file is part of fac, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -13,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}

View File

@ -3,8 +3,7 @@
#
# This file is part of fac, a plugin for Dotclear 2.
#
# Copyright (c) 2009-2013 Jean-Christian Denis and contributors
# contact@jcdenis.fr http://jcd.lv
# Copyright (c) 2009-2021 Jean-Christian Denis and contributors
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
@ -13,7 +12,6 @@
# -- END LICENSE BLOCK ------------------------------------
if (!defined('DC_RC_PATH')) {
return null;
}
@ -41,38 +39,34 @@ class facPublic
# Not active or not a post
if (!$core->blog->settings->fac->fac_active
|| !$_ctx->exists('posts')
) {
|| !$_ctx->exists('posts')) {
return null;
}
# Not in page to show
$types = @unserialize($core->blog->settings->fac->fac_public_tpltypes);
if (!is_array($types)
|| !in_array($core->url->type,$types)
) {
|| !in_array($core->url->type,$types)) {
return null;
}
# Get related feed
$fac_url = $core->meta->getMetadata(array(
$fac_url = $core->meta->getMetadata([
'meta_type' => 'fac',
'post_id' => $_ctx->posts->post_id,
'limit' => 1
));
]);
if ($fac_url->isEmpty()) {
return null;
}
# Get related format
$fac_format = $core->meta->getMetadata(array(
$fac_format = $core->meta->getMetadata([
'meta_type' => 'facformat',
'post_id' => $_ctx->posts->post_id,
'limit' => 1
));
]);
if ($fac_format->isEmpty()) {
return null;
}
@ -95,11 +89,9 @@ class facPublic
$formats = @unserialize($core->blog->settings->fac->fac_formats);
if (empty($formats)
|| !is_array($formats)
|| !isset($formats[$fac_format->meta_id])
) {
|| !isset($formats[$fac_format->meta_id])) {
$format = $default_format;
}
else {
} else {
$format = array_merge(
$default_format,
$formats[$fac_format->meta_id]
@ -107,24 +99,22 @@ class facPublic
}
# Read feed url
$cache = is_dir(DC_TPL_CACHE.'/fac') ? DC_TPL_CACHE.'/fac' : null;
$cache = is_dir(DC_TPL_CACHE . '/fac') ? DC_TPL_CACHE . '/fac' : null;
try {
$feed = feedReader::quickParse($fac_url->meta_id,$cache);
}
catch (Exception $e) {
$feed = feedReader::quickParse($fac_url->meta_id, $cache);
} catch (Exception $e) {
$feed = null;
}
# No entries
if (!$feed) {
return null;
}
# Feed title
$feedtitle = '';
if ('' != $core->blog->settings->fac->fac_defaultfeedtitle) {
$feedtitle = '<h3>'.html::escapeHTML(empty($feed->title) ?
$feedtitle = '<h3>' . html::escapeHTML(empty($feed->title) ?
str_replace(
'%T',
__('a related feed'),
@ -135,30 +125,29 @@ class facPublic
$feed->title,
$core->blog->settings->fac->fac_defaultfeedtitle
)
).'</h3>';
) . '</h3>';
}
# Feed desc
$feeddesc = '';
if ($core->blog->settings->fac->fac_showfeeddesc
&& '' != $feed->description
) {
&& '' != $feed->description) {
$feeddesc =
'<p>'.context::global_filter($feed->description,1,1,0,0,0).'</p>';
'<p>' . context::global_filter($feed->description, 1, 1, 0, 0, 0) . '</p>';
}
# Date format
$dateformat = '' != $format['dateformat'] ?
$format['dateformat'] :
$core->blog->settings->system->date_format.','.$core->blog->settings->system->time_format;
$core->blog->settings->system->date_format . ',' . $core->blog->settings->system->time_format;
# Enrties limit
$entrieslimit = abs((integer) $format['lineslimit']);
$uselimit = $entrieslimit > 0 ? true : false;
echo
'<div class="post-fac">'.
$feedtitle.$feeddesc.
'<div class="post-fac">' .
$feedtitle . $feeddesc .
'<dl>';
$i = 0;
@ -222,23 +211,21 @@ class facPublic
# Entries description
$description = '';
if ($format['showlinesdescription']
&& '' != $item->description
) {
$description = '<dd>'.
&& '' != $item->description) {
$description = '<dd>' .
context::global_filter(
$item->description,
0,
(integer) $format['linesdescriptionnohtml'],
abs((integer) $format['linesdescriptionlength']),
0,0
).'</dd>';
) . '</dd>';
}
# Entries content
$content = '';
if ($format['showlinescontent']
&& '' != $item->content
) {
&& '' != $item->content) {
$content = '<dd>'.
context::global_filter(
$item->content,
@ -247,13 +234,13 @@ class facPublic
abs((integer) $format['linescontentlength']),
0,
0
).'</dd>';
) . '</dd>';
}
echo
'<dt><a href="'.$item->link.'" '.
'title="'.$overtitle.'">'.$title.'</a></dt>'.
$description.$content;
'<dt><a href="' . $item->link . '" ' .
'title="' . $overtitle . '">' . $title . '</a></dt>' .
$description . $content;
$i++;
if ($uselimit && $i == $entrieslimit) {

View File

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