Compare commits
No commits in common. "master" and "v2023.10.11" have entirely different histories.
master
...
v2023.10.1
18
CHANGELOG.md
18
CHANGELOG.md
@ -1,21 +1,3 @@
|
||||
enhancePostContent 2023.10.24
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Fix widgets
|
||||
|
||||
enhancePostContent 2023.10.16
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Code review
|
||||
|
||||
enhancePostContent 2023.10.13
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
* Require PHP 8.1
|
||||
* Upgrade to last minute change to Dotclear 2.28
|
||||
|
||||
enhancePostContent 2023.10.11
|
||||
===========================================================
|
||||
* Require Dotclear 2.28
|
||||
|
10
README.md
10
README.md
@ -1,7 +1,7 @@
|
||||
# README
|
||||
|
||||
[![Release](https://img.shields.io/badge/release-2023.10.24-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/enhancePostContent/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.10.24-c44d58.svg)
|
||||
[![Release](https://img.shields.io/badge/release-2023.10.08-a2cbe9.svg)](https://git.dotclear.watch/JcDenis/enhancePostContent/releases)
|
||||
![Date](https://img.shields.io/badge/date-2023.10.08-c44d58.svg)
|
||||
[![Dotclear](https://img.shields.io/badge/dotclear-v2.28-137bbb.svg)](https://fr.dotclear.org/download)
|
||||
[![Dotaddict](https://img.shields.io/badge/dotaddict-official-9ac123.svg)](https://plugins.dotaddict.org/dc2/details/enhancePostContent)
|
||||
[![License](https://img.shields.io/badge/license-GPL--2.0-ececec.svg)](https://git.dotclear.watch/JcDenis/enhancePostContent/src/branch/master/LICENSE)
|
||||
@ -14,10 +14,10 @@ _enhancePostContent_ is a plugin for the open-source web publishing software cal
|
||||
|
||||
## REQUIREMENTS
|
||||
|
||||
* admin permissions to set up plugin
|
||||
* content admin permissions to manage fitlers
|
||||
* Dotclear 2.28
|
||||
* PHP 8.1+
|
||||
* Dotclear admin permissions to set up plugin
|
||||
* Dotclear content admin permissions to manage fitlers
|
||||
|
||||
## USAGE
|
||||
|
||||
@ -40,6 +40,6 @@ you should also add widgets.
|
||||
|
||||
## CONTRIBUTORS
|
||||
|
||||
* Jean-Christian Denis (author)
|
||||
* Jean-Christian Denis
|
||||
|
||||
You are welcome to contribute to this code.
|
||||
|
@ -9,13 +9,14 @@
|
||||
* Add features to words in post content.
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
$this->registerModule(
|
||||
'Enhance post content',
|
||||
'Add features to words in post content',
|
||||
'Jean-Christian Denis and Contributors',
|
||||
'2023.10.24',
|
||||
'2023.10.11',
|
||||
[
|
||||
'type' => 'plugin',
|
||||
'requires' => [['core', '2.28']],
|
||||
|
@ -2,10 +2,10 @@
|
||||
<modules xmlns:da="http://dotaddict.org/da/">
|
||||
<module id="enhancePostContent">
|
||||
<name>Enhance post content</name>
|
||||
<version>2023.10.24</version>
|
||||
<version>2023.10.11</version>
|
||||
<author>Jean-Christian Denis and Contributors</author>
|
||||
<desc>Add features to words in post content</desc>
|
||||
<file>https://git.dotclear.watch/JcDenis/enhancePostContent/releases/download/v2023.10.24/plugin-enhancePostContent.zip</file>
|
||||
<file>https://git.dotclear.watch/JcDenis/enhancePostContent/releases/download/v2023.10.11/plugin-enhancePostContent.zip</file>
|
||||
<da:dcmin>2.28</da:dcmin>
|
||||
<da:details>https://git.dotclear.watch/JcDenis/enhancePostContent/src/branch/master/README.md</da:details>
|
||||
<da:support>https://git.dotclear.watch/JcDenis/enhancePostContent/issues</da:support>
|
||||
|
@ -1,10 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* @brief The plugin enhancePostContent resources
|
||||
* @ingroup enhancePostContent
|
||||
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @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
|
||||
*/
|
||||
\Dotclear\App::backend()->resources()->set('help', 'enhancePostContent', __DIR__ . '/help/help.html');
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return;
|
||||
}
|
||||
|
||||
dcCore::app()->resources['help']['enhancePostContent'] = __DIR__ . '/help/help.html';
|
||||
|
@ -1,10 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* @file
|
||||
* @brief The plugin enhancePostContent resources
|
||||
* @ingroup enhancePostContent
|
||||
* @brief enhancePostContent, a plugin for Dotclear 2
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @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
|
||||
*/
|
||||
\Dotclear\App::backend()->resources()->set('help', 'enhancePostContent', __DIR__ . '/help/help.html');
|
||||
if (!defined('DC_RC_PATH')) {
|
||||
return;
|
||||
}
|
||||
|
||||
dcCore::app()->resources['help']['enhancePostContent'] = __DIR__ . '/help/help.html';
|
||||
|
@ -7,6 +7,7 @@ namespace Dotclear\Plugin\enhancePostContent;
|
||||
use ArrayObject;
|
||||
use Dotclear\App;
|
||||
use Dotclear\Core\Backend\Favorites;
|
||||
use Dotclear\Core\BlogSettings;
|
||||
use Dotclear\Core\Process;
|
||||
use Dotclear\Helper\Html\Form\{
|
||||
Checkbox,
|
||||
@ -18,13 +19,13 @@ use Dotclear\Helper\Html\Form\{
|
||||
Para,
|
||||
Text
|
||||
};
|
||||
use Dotclear\Interface\Core\BlogSettingsInterface;
|
||||
|
||||
/**
|
||||
* @brief enhancePostContent backend class.
|
||||
* @ingroup enhancePostContent
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Backend extends Process
|
||||
@ -54,7 +55,7 @@ class Backend extends Process
|
||||
]);
|
||||
},
|
||||
// backend user preference form
|
||||
'adminBlogPreferencesFormV2' => function (BlogSettingsInterface $blog_settings): void {
|
||||
'adminBlogPreferencesFormV2' => function (BlogSettings $blog_settings): void {
|
||||
$active = (bool) $blog_settings->get(My::id())->get('active');
|
||||
$allowedtplvalues = Epc::blogAllowedTemplateValue();
|
||||
$allowedpubpages = Epc::blogAllowedTemplatePage();
|
||||
@ -99,7 +100,7 @@ class Backend extends Process
|
||||
// allowedtplvalues
|
||||
(new Para())->items([
|
||||
(new Label(__('Allowed DC template values:'), Label::OUTSIDE_LABEL_BEFORE))->for('epc_allowedtplvalues'),
|
||||
(new Input('epc_allowedtplvalues'))->size(100)->maxlength(0)->value(Epc::encodeMulti($allowedtplvalues)),
|
||||
(new Input('epc_allowedtplvalues'))->size(100)->maxlenght(0)->value(Epc::encodeMulti($allowedtplvalues)),
|
||||
]),
|
||||
(new Note())
|
||||
->class('form-note')
|
||||
@ -107,7 +108,7 @@ class Backend extends Process
|
||||
// allowedpubpages
|
||||
(new Para())->items([
|
||||
(new Label(__('Allowed public pages:'), Label::OUTSIDE_LABEL_BEFORE))->for('epc_allowedpubpages'),
|
||||
(new Input('epc_allowedpubpages'))->size(100)->maxlength(0)->value(Epc::encodeMulti($allowedpubpages)),
|
||||
(new Input('epc_allowedpubpages'))->size(100)->maxlenght(0)->value(Epc::encodeMulti($allowedpubpages)),
|
||||
]),
|
||||
(new Note())
|
||||
->class('form-note')
|
||||
@ -120,7 +121,7 @@ class Backend extends Process
|
||||
->render();
|
||||
},
|
||||
// backend user preference save
|
||||
'adminBeforeBlogSettingsUpdate' => function (BlogSettingsInterface $blog_settings): void {
|
||||
'adminBeforeBlogSettingsUpdate' => function (BlogSettings $blog_settings): void {
|
||||
$active = !empty($_POST['epc_active']);
|
||||
$allowedtplvalues = Epc::decodeMulti($_POST['epc_allowedtplvalues']);
|
||||
$allowedpubpages = Epc::decodeMulti($_POST['epc_allowedpubpages']);
|
||||
@ -145,7 +146,7 @@ class Backend extends Process
|
||||
];
|
||||
},
|
||||
// widgets registration
|
||||
'initWidgets' => Widgets::initWidgets(...),
|
||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
@ -18,6 +18,7 @@ use Dotclear\Helper\Html\Html;
|
||||
* @ingroup enhancePostContent
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class BackendList extends Listing
|
||||
|
39
src/Epc.php
39
src/Epc.php
@ -1,5 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief enhancePostContent, 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
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\enhancePostContent;
|
||||
@ -26,6 +36,7 @@ __('RSS feeds');
|
||||
* @ingroup enhancePostContent
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Epc
|
||||
@ -110,22 +121,22 @@ class Epc
|
||||
/**
|
||||
* Get list of allowed templates name->[tag,callback] to list on epc widgets.
|
||||
*
|
||||
* @return array<string, array<string, mixed>> The templates name->[id,cb] values
|
||||
* @return array The templates name->[id,cb] values
|
||||
*/
|
||||
public static function widgetAllowedTemplateValue(): array
|
||||
{
|
||||
$list = new ArrayObject([
|
||||
'entry excerpt' => [
|
||||
'id' => 'entryexcerpt',
|
||||
'cb' => self::widgetContentEntryExcerpt(...),
|
||||
'cb' => [self::class, 'widgetContentEntryExcerpt'],
|
||||
],
|
||||
'entry content' => [
|
||||
'id' => 'entrycontent',
|
||||
'cb' => self::widgetContentEntryContent(...),
|
||||
'cb' => [self::class, 'widgetContentEntryContent'],
|
||||
],
|
||||
'comment content' => [
|
||||
'id' => 'commentcontent',
|
||||
'cb' => self::widgetContentCommentContent(...),
|
||||
'cb' => [self::class, 'widgetContentCommentContent'],
|
||||
],
|
||||
]);
|
||||
|
||||
@ -409,13 +420,13 @@ class Epc
|
||||
*/
|
||||
public static function widgetContentEntryExcerpt(?WidgetsElement $widget = null): string
|
||||
{
|
||||
if (!App::frontend()->context()->exists('posts')) {
|
||||
if (!App::frontend()->ctx->exists('posts')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$content = '';
|
||||
while (App::frontend()->context()->__get('posts')?->fetch()) {
|
||||
$content .= App::frontend()->context()->__get('posts')->f('post_excerpt');
|
||||
while (App::frontend()->ctx->__get('posts')?->fetch()) {
|
||||
$content .= App::frontend()->__get('posts')->f('post_excerpt');
|
||||
}
|
||||
|
||||
return $content;
|
||||
@ -430,13 +441,13 @@ class Epc
|
||||
*/
|
||||
public static function widgetContentEntryContent(?WidgetsElement $widget = null): string
|
||||
{
|
||||
if (!App::frontend()->context()->exists('posts')) {
|
||||
if (!App::frontend()->ctx->exists('posts')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$content = '';
|
||||
while (App::frontend()->context()->__get('posts')?->fetch()) {
|
||||
$content .= App::frontend()->context()->__get('posts')->f('post_content');
|
||||
while (App::frontend()->ctx->__get('posts')?->fetch()) {
|
||||
$content .= App::frontend()->ctx->__get('posts')->f('post_content');
|
||||
}
|
||||
|
||||
return $content;
|
||||
@ -451,13 +462,13 @@ class Epc
|
||||
*/
|
||||
public static function widgetContentCommentContent(?WidgetsElement $widget = null): string
|
||||
{
|
||||
if (!App::frontend()->context()->exists('posts')) {
|
||||
if (!App::frontend()->ctx->exists('posts')) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$content = '';
|
||||
while (App::frontend()->context()->__get('posts')->fetch()) {
|
||||
$comments = App::blog()->getComments(['post_id' => App::frontend()->context()->__get('posts')->f('post_id')]);
|
||||
while (App::frontend()->ctx->__get('posts')->fetch()) {
|
||||
$comments = App::blog()->getComments(['post_id' => App::frontend()->ctx->__get('posts')->f('post_id')]);
|
||||
while ($comments->fetch()) {
|
||||
$content .= $comments->__call('getContent', []);
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ use Exception;
|
||||
* All filter must extends this class.
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
abstract class EpcFilter
|
||||
|
@ -11,15 +11,12 @@ namespace Dotclear\Plugin\enhancePostContent;
|
||||
* Use Epc::getFilters() to get loaded stack
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class EpcFilters
|
||||
{
|
||||
/**
|
||||
* The filters stack.
|
||||
*
|
||||
* @var array<int, EpcFilter> $stack
|
||||
*/
|
||||
/** @var array<int,EpcFilter> $satck The filters stack */
|
||||
private array $stack = [];
|
||||
|
||||
/**
|
||||
|
@ -16,6 +16,7 @@ use Exception;
|
||||
* @ingroup enhancePostContent
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class EpcRecord
|
||||
|
@ -12,6 +12,7 @@ use Dotclear\Core\Process;
|
||||
* @ingroup enhancePostContent
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Frontend extends Process
|
||||
@ -36,7 +37,7 @@ class Frontend extends Process
|
||||
'publicBeforeContentFilterV2' => function (string $tag, array $args): void {
|
||||
foreach (Epc::getFilters()->dump() as $filter) {
|
||||
// test context
|
||||
if (in_array((string) App::frontend()->context()->__get('current_tpl'), $filter->page)
|
||||
if (in_array((string) App::frontend()->ctx->__get('current_tpl'), $filter->page)
|
||||
&& in_array($tag, $filter->template)
|
||||
&& $args[0] != '' //content
|
||||
&& empty($args['encode_xml'])
|
||||
@ -49,7 +50,7 @@ class Frontend extends Process
|
||||
}
|
||||
},
|
||||
// Widgets
|
||||
'initWidgets' => Widgets::initWidgets(...),
|
||||
'initWidgets' => [Widgets::class, 'initWidgets'],
|
||||
]);
|
||||
|
||||
return true;
|
||||
|
@ -14,6 +14,7 @@ use Exception;
|
||||
* @ingroup enhancePostContent
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Install extends Process
|
||||
|
@ -1,5 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @brief enhancePostContent, 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
|
||||
*/
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\enhancePostContent;
|
||||
@ -37,6 +47,7 @@ use Exception;
|
||||
* @ingroup enhancePostContent
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Manage extends Process
|
||||
@ -265,7 +276,7 @@ class Manage extends Process
|
||||
->for('filter_style' . $k),
|
||||
(new Input(['filter_style[]', 'filter_style' . $k]))
|
||||
->size(60)
|
||||
->maxlength(255)
|
||||
->maxlenght(255)
|
||||
->value(Html::escapeHTML($filter->style[$k])),
|
||||
]);
|
||||
}
|
||||
@ -337,7 +348,7 @@ class Manage extends Process
|
||||
->for('filter_notag'),
|
||||
(new Input('filter_notag'))
|
||||
->size(60)
|
||||
->maxlength(255)
|
||||
->maxlenght(255)
|
||||
->value(Epc::encodeSingle($filter->notag)),
|
||||
]),
|
||||
(new Note())
|
||||
@ -406,7 +417,7 @@ class Manage extends Process
|
||||
->for('new_key'),
|
||||
(new Input('new_key'))
|
||||
->size(60)
|
||||
->maxlength(255)
|
||||
->maxlenght(255)
|
||||
->required(true),
|
||||
]),
|
||||
(new Para())
|
||||
@ -415,7 +426,7 @@ class Manage extends Process
|
||||
->for('new_value'),
|
||||
(new Input('new_value'))
|
||||
->size(60)
|
||||
->maxlength(255)
|
||||
->maxlenght(255)
|
||||
->required(true),
|
||||
]),
|
||||
(new Para())
|
||||
|
@ -12,6 +12,7 @@ use Dotclear\Module\MyPlugin;
|
||||
* @ingroup enhancePostContent
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class My extends MyPlugin
|
||||
|
@ -13,6 +13,7 @@ use Dotclear\Helper\Html\Html;
|
||||
* @ingroup enhancePostContent
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Prepend extends Process
|
||||
@ -29,7 +30,7 @@ class Prepend extends Process
|
||||
}
|
||||
|
||||
// register epc filters
|
||||
App::behavior()->addBehavior('enhancePostContentFilters', function (EpcFilters $stack): void {
|
||||
app::behavior()->addBehavior('enhancePostContentFilters', function (EpcFilters $stack): void {
|
||||
foreach (Epc::DEFAULT_FILTERS as $class) {
|
||||
$stack->add(new $class());
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ use Dotclear\Plugin\Uninstaller\Uninstaller;
|
||||
* @ingroup enhancePostContent
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Uninstall extends Process
|
||||
|
@ -15,6 +15,7 @@ use Dotclear\Plugin\widgets\WidgetsElement;
|
||||
* @ingroup enhancePostContent
|
||||
*
|
||||
* @author Jean-Christian Denis
|
||||
* @copyright Jean-Christian Denis
|
||||
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
|
||||
*/
|
||||
class Widgets
|
||||
@ -29,7 +30,7 @@ class Widgets
|
||||
$w->create(
|
||||
'epclist',
|
||||
My::name(),
|
||||
self::parseWidget(...),
|
||||
[self::class, 'parseWidget'],
|
||||
null,
|
||||
__('List filtered contents.')
|
||||
);
|
||||
@ -86,7 +87,7 @@ class Widgets
|
||||
|
||||
# Page
|
||||
if (!My::settings()->get('active')
|
||||
|| !in_array(App::frontend()->context()->__get('current_tpl'), ['post.html', 'page.html'])
|
||||
|| !in_array(App::frontend()->ctx->__get('current_tpl'), ['post.html', 'page.html'])
|
||||
) {
|
||||
return '';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user