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
|
|
|
|
*/
|
2023-04-09 08:17:36 +00:00
|
|
|
declare(strict_types=1);
|
2021-08-23 23:55:52 +00:00
|
|
|
|
2023-04-09 08:17:36 +00:00
|
|
|
namespace Dotclear\Plugin\enhancePostContent;
|
2021-08-23 23:55:52 +00:00
|
|
|
|
2023-04-09 08:17:36 +00:00
|
|
|
use dcCore;
|
|
|
|
use dcNsProcess;
|
|
|
|
use dcUtils;
|
2021-08-23 23:55:52 +00:00
|
|
|
|
2023-04-09 08:17:36 +00:00
|
|
|
class Frontend extends dcNsProcess
|
|
|
|
{
|
|
|
|
public static function init(): bool
|
|
|
|
{
|
|
|
|
static::$init = My::phpCompliant();
|
|
|
|
|
|
|
|
return static::$init;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static function process(): bool
|
|
|
|
{
|
|
|
|
if (!static::$init) {
|
|
|
|
return false;
|
|
|
|
}
|
2021-08-23 23:55:52 +00:00
|
|
|
|
2023-04-09 08:17:36 +00:00
|
|
|
if (!dcCore::app()->blog->settings->get(My::id())->get('active')) {
|
2023-04-09 21:52:07 +00:00
|
|
|
return false;
|
2021-08-24 20:05:23 +00:00
|
|
|
}
|
2023-04-09 08:17:36 +00:00
|
|
|
|
|
|
|
dcCore::app()->addBehaviors([
|
|
|
|
// add CSS URL to header
|
2023-04-09 21:52:07 +00:00
|
|
|
'publicHeadContent' => function (): void {
|
2023-04-09 08:17:36 +00:00
|
|
|
echo dcUtils::cssLoad(dcCore::app()->blog->url . dcCore::app()->url->getURLFor('epccss'));
|
|
|
|
},
|
|
|
|
// Filter template blocks content
|
|
|
|
'publicBeforeContentFilterV2' => function (string $tag, array $args): void {
|
|
|
|
$filters = Epc::getFilters();
|
|
|
|
|
|
|
|
foreach ($filters as $id => $filter) {
|
|
|
|
if (!Epc::testContext($tag, $args, $filter)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$filter->publicContent($tag, $args);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
// Widgets
|
2023-04-09 21:52:07 +00:00
|
|
|
'initWidgets' => [Widgets::class, 'initWidgets'],
|
2023-04-09 08:17:36 +00:00
|
|
|
]);
|
|
|
|
|
|
|
|
return true;
|
2021-08-24 20:05:23 +00:00
|
|
|
}
|
2023-04-09 08:17:36 +00:00
|
|
|
}
|