use anonymous function
This commit is contained in:
parent
d5109b2f94
commit
93c2607544
2 changed files with 44 additions and 71 deletions
31
_prepend.php
31
_prepend.php
|
@ -45,5 +45,34 @@ dcCore::app()->url->register(
|
||||||
'epccss',
|
'epccss',
|
||||||
'epc.css',
|
'epc.css',
|
||||||
'^epc\.css',
|
'^epc\.css',
|
||||||
['publicEnhancePostContent', 'css']
|
function($args)
|
||||||
|
{
|
||||||
|
$css = [];
|
||||||
|
$filters = libEPC::getFilters();
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
|
84
_public.php
84
_public.php
|
@ -18,78 +18,22 @@ require __DIR__ . '/_widgets.php';
|
||||||
|
|
||||||
dcCore::app()->blog->settings->addNamespace('enhancePostContent');
|
dcCore::app()->blog->settings->addNamespace('enhancePostContent');
|
||||||
|
|
||||||
if (dcCore::app()->blog->settings->enhancePostContent->enhancePostContent_active) {
|
if (!dcCore::app()->blog->settings->enhancePostContent->enhancePostContent_active) {
|
||||||
dcCore::app()->addBehavior(
|
return null;
|
||||||
'publicHeadContentV2',
|
|
||||||
['publicEnhancePostContent', 'publicHeadContent']
|
|
||||||
);
|
|
||||||
dcCore::app()->addBehavior(
|
|
||||||
'publicBeforeContentFilterV2',
|
|
||||||
['publicEnhancePostContent', 'publicContentFilter']
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Add filters CSS to page header
|
||||||
* @ingroup DC_PLUGIN_ENHANCEPOSTCONTENT
|
dcCore::app()->addBehavior('publicHeadContent', function() {
|
||||||
* @brief Filter posts content - public methods.
|
echo dcUtils::cssLoad(dcCore::app()->blog->url . dcCore::app()->url->getURLFor('epccss'));
|
||||||
* @since 2.6
|
});
|
||||||
*/
|
// Filter template blocks content
|
||||||
class publicEnhancePostContent
|
dcCore::app()->addBehavior('publicBeforeContentFilterV2', function($tag, $args) {
|
||||||
{
|
$filters = libEPC::getFilters();
|
||||||
/**
|
|
||||||
* Add filters CSS to page header
|
|
||||||
*/
|
|
||||||
public static function publicHeadContent()
|
|
||||||
{
|
|
||||||
echo dcUtils::cssLoad(dcCore::app()->blog->url . dcCore::app()->url->getURLFor('epccss'));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static function css($args)
|
foreach ($filters as $id => $filter) {
|
||||||
{
|
if (!libEPC::testContext($tag, $args, $filter)) {
|
||||||
$css = [];
|
continue;
|
||||||
$filters = libEPC::getFilters();
|
|
||||||
|
|
||||||
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";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
$filter->publicContent($tag, $args);
|
||||||
header('Content-Type: text/css; charset=UTF-8');
|
|
||||||
|
|
||||||
echo implode("\n", $css);
|
|
||||||
|
|
||||||
exit;
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
/**
|
|
||||||
* Filter template blocks content
|
|
||||||
*
|
|
||||||
* @param string $tag Tempalte block name
|
|
||||||
* @param array $args Tempalte Block arguments
|
|
||||||
*/
|
|
||||||
public static function publicContentFilter($tag, $args)
|
|
||||||
{
|
|
||||||
$filters = libEPC::getFilters();
|
|
||||||
|
|
||||||
foreach ($filters as $id => $filter) {
|
|
||||||
if (!libEPC::testContext($tag, $args, $filter)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
$filter->publicContent($tag, $args);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in a new issue