2021-08-23 23:55:52 +00:00
|
|
|
<?php
|
2021-09-02 18:35:25 +00:00
|
|
|
/**
|
|
|
|
* @brief enhancePostContent, a plugin for Dotclear 2
|
2021-11-01 09:33:43 +00:00
|
|
|
*
|
2021-09-02 18:35:25 +00:00
|
|
|
* @package Dotclear
|
|
|
|
* @subpackage Plugin
|
2021-11-01 09:33:43 +00:00
|
|
|
*
|
2021-09-02 18:35:25 +00:00
|
|
|
* @author Jean-Christian Denis and Contributors
|
2021-11-01 09:33:43 +00:00
|
|
|
*
|
2021-09-02 18:35:25 +00:00
|
|
|
* @copyright Jean-Christian Denis
|
|
|
|
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
|
|
|
*/
|
2021-08-23 23:55:52 +00:00
|
|
|
if (!defined('DC_CONTEXT_ADMIN')) {
|
2021-08-24 20:05:23 +00:00
|
|
|
return null;
|
2021-08-23 23:55:52 +00:00
|
|
|
}
|
|
|
|
|
2022-12-12 23:44:33 +00:00
|
|
|
dcCore::app()->blog->settings->addNamespace(basename(__DIR__));
|
2021-08-24 20:50:53 +00:00
|
|
|
|
2022-11-13 20:30:48 +00:00
|
|
|
require __DIR__ . '/_widgets.php';
|
2021-08-23 23:55:52 +00:00
|
|
|
|
|
|
|
# Admin menu
|
2022-11-13 20:30:48 +00:00
|
|
|
dcCore::app()->menu[dcAdmin::MENU_PLUGINS]->addItem(
|
2021-08-24 20:05:23 +00:00
|
|
|
__('Enhance post content'),
|
2022-12-12 23:44:33 +00:00
|
|
|
dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
|
|
|
|
urldecode(dcPage::getPF(basename(__DIR__) . '/icon.svg')),
|
|
|
|
preg_match('/' . preg_quote(dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__))) . '(&.*)?$/', $_SERVER['REQUEST_URI']),
|
2022-11-14 19:57:03 +00:00
|
|
|
dcCore::app()->auth->check(dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_CONTENT_ADMIN]), dcCore::app()->blog->id)
|
2021-08-23 23:55:52 +00:00
|
|
|
);
|
|
|
|
|
2022-11-25 22:27:50 +00:00
|
|
|
# Dashboard favorites
|
|
|
|
dcCore::app()->addBehavior('adminDashboardFavoritesV2', function (dcFavorites $favs) {
|
2022-12-12 23:44:33 +00:00
|
|
|
$favs->register(basename(__DIR__), [
|
2022-11-25 22:27:50 +00:00
|
|
|
'title' => __('Enhance post content'),
|
2022-12-12 23:44:33 +00:00
|
|
|
'url' => dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)),
|
|
|
|
'small-icon' => urldecode(dcPage::getPF(basename(__DIR__) . '/icon.svg')),
|
|
|
|
'large-icon' => urldecode(dcPage::getPF(basename(__DIR__) . '/icon.svg')),
|
2022-11-30 23:40:16 +00:00
|
|
|
'permissions' => dcCore::app()->auth->makePermissions([dcAuth::PERMISSION_CONTENT_ADMIN]),
|
2022-11-25 22:27:50 +00:00
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
# Preference form
|
|
|
|
dcCore::app()->addBehavior('adminBlogPreferencesFormV2', function (dcSettings $blog_settings) {
|
2022-12-21 21:27:20 +00:00
|
|
|
$active = (bool) $blog_settings->get(basename(__DIR__))->get('active');
|
2022-12-12 22:40:10 +00:00
|
|
|
$allowedtplvalues = enhancePostContent::blogAllowedTplValues();
|
|
|
|
$allowedpubpages = enhancePostContent::blogAllowedPubPages();
|
2022-11-25 22:27:50 +00:00
|
|
|
|
|
|
|
echo
|
|
|
|
'<div class="fieldset"><h4 id="epc_params">' . __('Enhance post content') . '</h4>' .
|
|
|
|
'<div class="two-cols">' .
|
|
|
|
'<div class="col">' .
|
|
|
|
'<p><label class="classic">' .
|
|
|
|
form::checkbox('epc_active', '1', $active) .
|
|
|
|
__('Enable plugin') . '</label></p>' .
|
|
|
|
'<p class="form-note">' .
|
|
|
|
__('This enable public widgets and contents filter.') .
|
|
|
|
'</p>' .
|
2022-12-12 23:44:33 +00:00
|
|
|
'<p><a href="' . dcCore::app()->adminurl->get('admin.plugin.' . basename(__DIR__)) . '">' .
|
2022-11-25 22:27:50 +00:00
|
|
|
__('Set content filters') . '</a></p>' .
|
|
|
|
'</div>' .
|
|
|
|
'<div class="col">' .
|
|
|
|
'<h5>' . __('Extra') . '</h5>' .
|
|
|
|
'<p>' . __('This is a special feature to edit list of allowed template values and public pages where this plugin works.') . '</p>' .
|
|
|
|
'<p><label for="epc_allowedtplvalues">' . __('Allowed DC template values:') . '</label>' .
|
2022-12-12 22:40:10 +00:00
|
|
|
form::field('epc_allowedtplvalues', 100, 0, enhancePostContent::implode($allowedtplvalues)) . '</p>' .
|
2022-11-25 22:27:50 +00:00
|
|
|
'<p class="form-note">' . __('Use "readable_name1:template_value1;readable_name2:template_value2;" like "entry content:EntryContent;entry excerpt:EntryExcerpt;".') . '</p>' .
|
|
|
|
'<p><label for="epc_allowedpubpages">' . __('Allowed public pages:') . '</label>' .
|
2022-12-12 22:40:10 +00:00
|
|
|
form::field('epc_allowedpubpages', 100, 0, enhancePostContent::implode($allowedpubpages)) . '</p>' .
|
2022-11-25 22:27:50 +00:00
|
|
|
'<p class="form-note">' . __('Use "readable_name1:template_page1;readable_name2:template_page2;" like "post page:post.html;home page:home.html;".') . '</p>' .
|
|
|
|
'</div>' .
|
|
|
|
'</div>' .
|
|
|
|
'<br class="clear" />' .
|
|
|
|
'</div>';
|
|
|
|
});
|
2021-08-23 23:55:52 +00:00
|
|
|
|
2022-11-25 22:27:50 +00:00
|
|
|
# Save preference
|
|
|
|
dcCore::app()->addBehavior('adminBeforeBlogSettingsUpdate', function (dcSettings $blog_settings) {
|
|
|
|
$active = !empty($_POST['epc_active']);
|
2022-12-12 22:40:10 +00:00
|
|
|
$allowedtplvalues = enhancePostContent::explode($_POST['epc_allowedtplvalues']);
|
|
|
|
$allowedpubpages = enhancePostContent::explode($_POST['epc_allowedpubpages']);
|
2021-08-23 23:55:52 +00:00
|
|
|
|
2022-12-21 21:27:20 +00:00
|
|
|
$blog_settings->get(basename(__DIR__))->put('active', $active);
|
|
|
|
$blog_settings->get(basename(__DIR__))->put('allowedtplvalues', json_encode($allowedtplvalues));
|
|
|
|
$blog_settings->get(basename(__DIR__))->put('allowedpubpages', json_encode($allowedpubpages));
|
2022-11-25 22:27:50 +00:00
|
|
|
});
|
2021-08-24 20:50:53 +00:00
|
|
|
|
2022-11-25 22:27:50 +00:00
|
|
|
# List filter
|
|
|
|
dcCore::app()->addBehavior('adminFiltersListsV2', function (ArrayObject $sorts) {
|
|
|
|
$sorts['epc'] = [
|
|
|
|
__('Enhance post content'),
|
|
|
|
[
|
2021-11-01 09:33:43 +00:00
|
|
|
__('Date') => 'epc_upddt',
|
|
|
|
__('Key') => 'epc_key',
|
2021-08-24 20:50:53 +00:00
|
|
|
__('Value') => 'epc_value',
|
2022-11-13 20:30:48 +00:00
|
|
|
__('ID') => 'epc_id',
|
2022-11-25 22:27:50 +00:00
|
|
|
],
|
|
|
|
'epc_upddt',
|
|
|
|
'desc',
|
|
|
|
[__('records per page'), 20],
|
|
|
|
];
|
|
|
|
});
|