use url handler for css

This commit is contained in:
Jean-Christian Paul Denis 2021-10-30 22:05:31 +02:00
parent e462baba87
commit b2b7484206
Signed by: JcDenis
GPG Key ID: 1B5B8C5B90B6C951
2 changed files with 23 additions and 7 deletions

View File

@ -20,3 +20,10 @@ $d = dirname(__FILE__) . '/inc/';
$__autoload['libEPC'] = $d . 'lib.epc.php'; $__autoload['libEPC'] = $d . 'lib.epc.php';
$__autoload['epcRecords'] = $d . 'lib.epc.records.php'; $__autoload['epcRecords'] = $d . 'lib.epc.records.php';
$__autoload['adminEpcList'] = $d . 'lib.epc.pager.php'; $__autoload['adminEpcList'] = $d . 'lib.epc.pager.php';
$core->url->register(
'epccss',
'epc.css',
'^epc\.css',
['publicEnhancePostContent', 'css']
);

View File

@ -45,12 +45,16 @@ class publicEnhancePostContent
*/ */
public static function publicHeadContent(dcCore $core) public static function publicHeadContent(dcCore $core)
{ {
echo dcUtils::cssLoad($core->blog->url . $core->url->getURLFor('epccss'));
}
public static function css($args)
{
$css = [];
$filters = libEPC::blogFilters(); $filters = libEPC::blogFilters();
foreach($filters as $name => $filter) { foreach($filters as $name => $filter) {
if (empty($filter['class']) || empty($filter['style'])) {
if (empty($filter['class'])
|| empty($filter['style'])) {
continue; continue;
} }
@ -63,11 +67,16 @@ class publicEnhancePostContent
} }
if (!empty($res)) { if (!empty($res)) {
echo $css[] =
"\n<!-- CSS for enhancePostContent " . $name . " --> \n" . "/* CSS for enhancePostContent " . $name . " */ \n" . $res . "\n";
"<style type=\"text/css\"> " . $res . "</style> \n";
} }
} }
header('Content-Type: text/css; charset=UTF-8');
echo implode("\n", $css);
exit;
} }
/** /**