fac/_config.php

507 lines
12 KiB
PHP
Raw Normal View History

2021-08-20 15:44:19 +00:00
<?php
2021-09-02 19:08:55 +00:00
/**
* @brief fac, a plugin for Dotclear 2
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and Contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
2021-08-20 15:44:19 +00:00
if (!defined('DC_CONTEXT_MODULE')) {
2021-08-20 16:39:12 +00:00
return null;
2021-08-20 15:44:19 +00:00
}
if (!$core->auth->isSuperAdmin()) {
return null;
}
2021-08-20 15:44:19 +00:00
$redir = empty($_REQUEST['redir']) ?
2021-08-20 16:39:12 +00:00
$list->getURL() . '#plugins' : $_REQUEST['redir'];
2021-08-20 15:44:19 +00:00
# -- Get settings --
$core->blog->settings->addNamespace('fac');
$s = $core->blog->settings->fac;
2021-08-23 20:47:08 +00:00
$fac_formats = @unserialize($s->fac_formats);
2021-08-20 15:44:19 +00:00
if (!is_array($fac_formats)) {
2021-08-23 20:47:08 +00:00
$fac_formats = [];
2021-08-20 15:44:19 +00:00
}
# -- Set settings --
if (!empty($_POST['save'])) {
2021-08-20 16:39:12 +00:00
try {
2021-08-23 20:47:08 +00:00
$fac_formats = [];
2021-08-20 16:39:12 +00:00
foreach($_POST['fac_formats'] as $uid => $f) {
if (!empty($f['name'])) {
$fac_formats[$uid] = $f;
}
}
2021-08-23 20:47:08 +00:00
// 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
);
2021-08-20 16:39:12 +00:00
$core->blog->triggerBlog();
dcPage::addSuccessNotice(
__('Configuration successfully updated.')
2021-08-20 16:39:12 +00:00
);
http::redirect(
$list->getURL('module=fac&conf=1&redir=' . $list->getRedir())
);
2021-08-23 20:47:08 +00:00
} catch (Exception $e) {
2021-08-20 16:39:12 +00:00
$core->error->add($e->getMessage());
}
2021-08-20 15:44:19 +00:00
}
# -- Display form --
$i = 1;
foreach($fac_formats as $uid => $f) {
2021-08-20 16:39:12 +00:00
if (empty($f['name'])) {
continue;
}
echo '
<div class="fieldset">
<h4>' . sprintf(__('Format %s'), $i) . '</h4>
<div class="two-boxes"><h5>' . __('General') . '</h5>
<p><label for="fac_formats_' . $uid . '_name">' .
__('Name:') . '</label>' .
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][name]',
'fac_formats_' . $uid . '_name'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
20,
255,
empty($f['name']) ? '' : $f['name'],
'maximal'
) . '</p>
<p class="form-note">' .
__('In order to remove a format, leave its name empty.') .
'</p>
<p><label for="fac_formats_' . $uid . '_dateformat">' .
__('Date format:') . '</label>' .
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][dateformat]',
'fac_formats_' . $uid . '_dateformat'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
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><label for="fac_formats_' . $uid . '_lineslimit">' .
__('Entries limit:') . '</label>' .
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][lineslimit]',
'fac_formats_' . $uid . '_lineslimit'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
5,
4,
empty($f['lineslimit']) ? '' : $f['lineslimit'],
'maximal'
) . '</p>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
'</p>
</div><div class="two-boxes"><h5>' . __('Title') . '</h5>
<p><label for="fac_formats_' . $uid . '_linestitletext">' .
__('Title format:') . '</label>' .
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][linestitletext]',
'fac_formats_' . $uid . '_linestitletext'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
20,
255,
empty($f['linestitletext']) ? '' : $f['linestitletext'],
'maximal'
) . '</p>
<p class="form-note">' .
__('Format can be:') .
'%D : ' . __('Date') .
', %T : ' . __('Title') .
', %A : ' . __('Author') .
', %E : ' . __('Description') .
', %C : ' . __('Content') .
'</p>
<p><label for="fac_formats_' . $uid . '_linestitleover">' .
__('Over title format:') . '</label>' .
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_' . $uid . '_linestitleover'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
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><label for="fac_formats_' . $uid . '_linestitlelength">' .
__('Maximum length of title:') . '</label>' .
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][linestitlelength]',
'fac_formats_' . $uid . '_linestitlelength'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
5,
4,
empty($f['linestitlelength']) ? '' : $f['linestitlelength'],
'maximal'
) . '</p>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
'</p>
</div><div class="two-boxes"><h5>' . __('Description') . '</h5>
<p><label for="fac_formats_' . $uid . '_showlinesdescription">' .
form::checkbox(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][showlinesdescription]',
'fac_formats_' . $uid . '_showlinesdescription'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
1,
!empty($f['showlinesdescription'])
) .
__('Show description of entries') . '</label></p>
<p><label for="fac_formats_' . $uid . '_linesdescriptionnohtml">' .
form::checkbox(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][linesdescriptionnohtml]',
'fac_formats_' . $uid . '_linesdescriptionnohtml'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
1,
!empty($f['linesdescriptionnohtml'])
).
__('Remove html of description') . '</label></p>
<p><label for="fac_formats_' . $uid . '_linesdescriptionlength">' .
__('Maximum length of description:') . '</label>' .
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][linesdescriptionlength]',
'fac_formats_' . $uid . '_linesdescriptionlength'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
5,
4,
empty($f['linesdescriptionlength']) ? '' : $f['linesdescriptionlength'],
'maximal'
) . '</p>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
'</p>
</div><div class="two-boxes"><h5>' . __('Content') . '</h5>
<p><label for="fac_formats_' . $uid . '_showlinescontent">' .
form::checkbox(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][showlinescontent]',
'fac_formats_' . $uid . '_showlinescontent'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
1,
!empty($f['showlinescontent'])
) .
__('Show content of entries') . '</label></p>
<p><label for="fac_formats_' . $uid . '_linescontentnohtml">' .
form::checkbox(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][linescontentnohtml]',
'fac_formats_' . $uid . '_linescontentnohtml'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
1,
!empty($f['linescontentnohtml'])
) .
__('Remove html of content') . '</label></p>
<p><label for="fac_formats_' . $uid . '_linescontentlength">' .
__('Maximum length of content:') . '</label>' .
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][linescontentlength]',
'fac_formats_' . $uid . '_linescontentlength'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
5,
4,
empty($f['linescontentlength']) ? '' : $f['linescontentlength'],
'maximal'
) . '</p>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
'</p>
</div>
</div>';
$i++;
2021-08-20 15:44:19 +00:00
}
$uid = uniqid();
echo '
<div class="fieldset">
2021-08-20 16:39:12 +00:00
<h4>' . __('New format') . '</h4>
2021-08-20 15:44:19 +00:00
2021-08-20 16:39:12 +00:00
<div class="two-boxes"><h5>' . __('General') . '</h5>
2021-08-20 15:44:19 +00:00
2021-08-20 16:39:12 +00:00
<p><label for="fac_formats_' . $uid . '_name">' .
__('Name:') . '</label>' .
2021-08-20 15:44:19 +00:00
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][name]',
'fac_formats_' . $uid . '_name'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
20,
255,
'',
'maximal'
) . '</p>
2021-08-20 15:44:19 +00:00
<p class="form-note">'.
2021-08-20 16:39:12 +00:00
__('In order to remove a format, leave its name empty.') .
2021-08-20 15:44:19 +00:00
'</p>
2021-08-20 16:39:12 +00:00
<p><label for="fac_formats_' . $uid . '_dateformat">' .
__('Date format:') . '</label>' .
2021-08-20 15:44:19 +00:00
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][dateformat]',
'fac_formats_' . $uid . '_dateformat'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
20,
255,
'',
'maximal'
) . '</p>
<p class="form-note">' .
__('Use date format of Dotclear or leave empty to use default date format of blog.') .
2021-08-20 15:44:19 +00:00
'</p>
2021-08-20 16:39:12 +00:00
<p><label for="fac_formats_' . $uid . '_lineslimit">' .
__('Entries limit:') . '</label>' .
2021-08-20 15:44:19 +00:00
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][lineslimit]',
'fac_formats_' . $uid . '_lineslimit'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
5,
4,
5,
'maximal'
) . '</p>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
2021-08-20 15:44:19 +00:00
'</p>
2021-08-20 16:39:12 +00:00
</div><div class="two-boxes"><h5>' . __('Title') . '</h5>
2021-08-20 15:44:19 +00:00
2021-08-20 16:39:12 +00:00
<p><label for="fac_formats_' . $uid . '_linestitletext">' .
__('Title format:') . '</label>' .
2021-08-20 15:44:19 +00:00
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][linestitletext]',
'fac_formats_' . $uid . '_linestitletext'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
20,
255,
'%T',
'maximal'
) . '</p>
<p class="form-note">' .
__('Format can be:') .
'%D : ' . __('Date') .
', %T : ' . __('Title') .
', %A : ' . __('Author') .
', %E : ' . __('Description') .
', %C : ' . __('Content') .
2021-08-20 15:44:19 +00:00
'</p>
2021-08-20 16:39:12 +00:00
<p><label for="fac_formats_' . $uid . '_linestitleover">' .
__('Over title format:') . '</label>' .
2021-08-20 15:44:19 +00:00
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][linestitleover]',
'fac_formats_' . $uid . '_linestitleover'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
20,
255,
'%D',
'maximal'
) . '</p>
<p class="form-note">' .
__('Format can be:') .
'%D : ' . __('Date') .
', %T : ' . __('Title') .
', %A : ' . __('Author') .
', %E : ' . __('Description') .
', %C : ' . __('Content') .
2021-08-20 15:44:19 +00:00
'</p>
2021-08-20 16:39:12 +00:00
<p><label for="fac_formats_' . $uid . '_linestitlelength">' .
__('Maximum length of title:') . '</label>' .
2021-08-20 15:44:19 +00:00
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][linestitlelength]',
'fac_formats_' . $uid . '_linestitlelength'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
5,
4,
150,
'maximal'
) . '</p>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
2021-08-20 15:44:19 +00:00
'</p>
2021-08-20 16:39:12 +00:00
</div><div class="two-boxes"><h5>' . __('Description') . '</h5>
2021-08-20 15:44:19 +00:00
2021-08-20 16:39:12 +00:00
<p><label for="fac_formats_' . $uid . '_showlinesdescription">' .
2021-08-20 15:44:19 +00:00
form::checkbox(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][showlinesdescription]',
'fac_formats_' . $uid . '_showlinesdescription'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
1,
0
) .
__('Show description of entries') . '</label></p>
<p><label for="fac_formats_' . $uid . '_linesdescriptionnohtml">' .
2021-08-20 15:44:19 +00:00
form::checkbox(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][linesdescriptionnohtml]',
'fac_formats_' . $uid . '_linesdescriptionnohtml'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
1,
1
) .
__('Remove html of description') . '</label></p>
<p><label for="fac_formats_' . $uid . '_linesdescriptionlength">' .
__('Maximum length of description:') . '</label>' .
2021-08-20 15:44:19 +00:00
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][linesdescriptionlength]',
'fac_formats_' . $uid . '_linesdescriptionlength'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
5,
4,
350,
'maximal'
) . '</p>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
2021-08-20 15:44:19 +00:00
'</p>
2021-08-20 16:39:12 +00:00
</div><div class="two-boxes"><h5>' . __('Content') . '</h5>
2021-08-20 15:44:19 +00:00
2021-08-20 16:39:12 +00:00
<p><label for="fac_formats_' . $uid . '_showlinescontent">' .
2021-08-20 15:44:19 +00:00
form::checkbox(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][showlinescontent]',
'fac_formats_' . $uid . '_showlinescontent'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
1,
0
) .
__('Show content of entries') . '</label></p>
<p><label for="fac_formats_' . $uid . '_linescontentnohtml">' .
2021-08-20 15:44:19 +00:00
form::checkbox(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][linescontentnohtml]',
'fac_formats_' . $uid . '_linescontentnohtml'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
1,
1
) .
__('Remove html of content') . '</label></p>
<p><label for="fac_formats_' . $uid . '_linescontentlength">' .
__('Maximum length of content:') . '</label>' .
2021-08-20 15:44:19 +00:00
form::field(
2021-08-23 20:47:08 +00:00
[
2021-08-20 16:39:12 +00:00
'fac_formats[' . $uid . '][linescontentlength]',
'fac_formats_' . $uid . '_linescontentlength'
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
5,
4,
350,
'maximal'
) . '</p>
<p class="form-note">' .
__('Leave lengh empty for no limit.') .
2021-08-20 15:44:19 +00:00
'</p>
</div>
</div>
<div class="fieldset">
2021-08-20 16:39:12 +00:00
<h4>' . __('Informations') . '</h4>
2021-08-20 15:44:19 +00:00
<div class="two-boxes">
2021-08-20 16:39:12 +00:00
<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.') .
2021-08-20 15:44:19 +00:00
'</p>
</div><div class="two-boxes">
2021-08-20 16:39:12 +00:00
<h5>' . __('Structure') . '</h5>
<pre>' . html::escapeHTML('
2021-08-20 15:44:19 +00:00
<div class="post-fac">
2021-08-20 16:39:12 +00:00
<h3>' . __('Title of feed') . '</h3>
<p>' . __('Description of feed') . '</p>
2021-08-20 15:44:19 +00:00
<dl>
2021-08-20 16:39:12 +00:00
<dt>' . __('Title of entry') . '</dt>
<dd>' . __('Description of entry') . '</dd>
2021-08-20 15:44:19 +00:00
</dl>
</div>
2021-08-20 16:39:12 +00:00
') . '</pre>
2021-08-20 15:44:19 +00:00
</div>
2021-08-23 20:47:08 +00:00
</div>';
dcPage::helpBlock('fac');