enhancePostContent/_prepend.php

79 lines
1.9 KiB
PHP
Raw Normal View History

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_RC_PATH')) {
return null;
2021-08-23 23:55:52 +00:00
}
2021-10-31 22:22:34 +00:00
$filters = [
'Tag',
'Search',
'Acronym',
'Abbreviation',
'Definition',
'Citation',
'Link',
'Replace',
'Update',
2022-11-13 20:30:48 +00:00
'Twitter',
2021-10-31 22:22:34 +00:00
];
2022-11-13 20:30:48 +00:00
$d = __DIR__ . '/inc/';
2021-08-23 23:55:52 +00:00
2022-11-30 23:40:48 +00:00
Clearbricks::lib()->autoload([
2022-12-12 22:40:10 +00:00
'enhancePostContent' => $d . 'class.enhancepostcontent.php',
2022-12-21 21:27:20 +00:00
'epcFilter' => $d . 'class.epcfilter.php',
'epcRecords' => $d . 'class.epcrecords.php',
'epcUpgrade' => $d . 'class.epcupgrade.php',
'adminEpcList' => $d . 'class.adminepclist.php',
2022-11-30 23:40:48 +00:00
]);
2021-10-30 20:05:31 +00:00
2021-11-01 09:33:43 +00:00
foreach ($filters as $f) {
2022-12-12 22:40:10 +00:00
Clearbricks::lib()->autoload(['epcFilter' . $f => $d . 'class.epcfilter' . strtolower($f) . '.php']);
2022-11-13 20:30:48 +00:00
dcCore::app()->addBehavior('enhancePostContentFilters', ['epcFilter' . $f, 'create']);
2021-10-31 22:22:34 +00:00
}
2022-11-13 20:30:48 +00:00
dcCore::app()->url->register(
2021-10-30 20:05:31 +00:00
'epccss',
'epc.css',
'^epc\.css',
2022-12-07 23:04:35 +00:00
function ($args) {
2022-11-30 23:41:34 +00:00
$css = [];
2022-12-12 22:40:10 +00:00
$filters = enhancePostContent::getFilters();
2022-11-30 23:41:34 +00:00
foreach ($filters as $id => $filter) {
if ('' == $filter->class || '' == $filter->style) {
continue;
}
$res = '';
foreach ($filter->class as $k => $class) {
$styles = $filter->style;
$style = html::escapeHTML(trim($styles[$k]));
if ('' != $style) {
$res .= $class . ' {' . $style . '} ';
}
}
if (!empty($res)) {
$css[] = '/* CSS for enhancePostContent ' . $id . " */ \n" . $res . "\n";
}
}
header('Content-Type: text/css; charset=UTF-8');
echo implode("\n", $css);
exit;
}
2021-11-01 09:33:43 +00:00
);