fac/_config.php

506 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
2022-11-20 20:13:56 +00:00
*
2021-09-02 19:08:55 +00:00
* @package Dotclear
* @subpackage Plugin
2022-11-20 20:13:56 +00:00
*
2021-09-02 19:08:55 +00:00
* @author Jean-Christian Denis and Contributors
2022-11-20 20:13:56 +00:00
*
2021-09-02 19:08:55 +00:00
* @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
}
2022-11-20 20:13:56 +00:00
if (!dcCore::app()->auth->isSuperAdmin()) {
return null;
}
2022-11-20 20:13:56 +00:00
$redir = empty($_REQUEST['redir']) ?
dcCore::app()->admin->list->getURL() . '#plugins' : $_REQUEST['redir'];
2021-08-20 15:44:19 +00:00
# -- Get settings --
$s = dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
2021-08-20 15:44:19 +00:00
$fac_formats = json_decode($s->get('formats'), true);
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
2022-11-20 20:13:56 +00:00
foreach ($_POST['fac_formats'] as $uid => $f) {
2021-08-20 16:39:12 +00:00
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('formats');
2021-08-23 20:47:08 +00:00
$s->put(
'formats',
json_encode($fac_formats),
2022-11-20 20:13:56 +00:00
'string',
'Formats of feeds contents',
true,
2021-08-23 20:47:08 +00:00
true
);
2021-08-20 16:39:12 +00:00
2022-11-20 20:13:56 +00:00
dcCore::app()->blog->triggerBlog();
2021-08-20 16:39:12 +00:00
2022-11-20 20:13:56 +00:00
dcAdminNotices::addSuccessNotice(
__('Configuration successfully updated.')
2021-08-20 16:39:12 +00:00
);
http::redirect(
dcCore::app()->admin->list->getURL('module=' . basename(__DIR__) . '&conf=1&redir=' . dcCore::app()->admin->list->getRedir())
2021-08-20 16:39:12 +00:00
);
2021-08-23 20:47:08 +00:00
} catch (Exception $e) {
2022-11-20 20:13:56 +00:00
dcCore::app()->error->add($e->getMessage());
2021-08-20 16:39:12 +00:00
}
2021-08-20 15:44:19 +00:00
}
# -- Display form --
$i = 1;
2022-11-20 20:13:56 +00:00
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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'fac_formats_' . $uid . '_linesdescriptionnohtml',
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
1,
!empty($f['linesdescriptionnohtml'])
2022-11-20 20:13:56 +00:00
) .
2021-08-20 16:39:12 +00:00
__('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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'fac_formats_' . $uid . '_name',
2021-08-23 20:47:08 +00:00
],
2021-08-20 16:39:12 +00:00
20,
255,
'',
'maximal'
) . '</p>
2022-11-20 20:13:56 +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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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">' .
2022-11-20 20:13:56 +00:00
__('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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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>
2022-11-20 20:13:56 +00:00
<p class="form-note">' .
2021-08-20 16:39:12 +00:00
__('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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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]',
2022-11-20 20:13:56 +00:00
'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>';
2022-11-20 20:13:56 +00:00
dcPage::helpBlock('fac');