Skip to content

Commit

Permalink
Исключения для удаления скриптов и стилей. При исключении работают др…
Browse files Browse the repository at this point in the history
…угие правила.
  • Loading branch information
Arkadiy-Sedelnikov committed Apr 20, 2017
1 parent add052f commit b59ab3e
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions jscssmanipulate.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function onBeforeCompileHead()
{
$app = JFactory::getApplication();
if ($app->isAdmin()) {
return;
return true;
}

$doc = JFactory::getDocument();
Expand Down Expand Up @@ -55,14 +55,9 @@ function onBeforeCompileHead()

$debug && $debugInfo .= '<li>' . $searchUrl . ' ==> ';

if (!empty($params->remove)) {
if($this->checkExceptions($params->remove_exceptions)){
$debug && $debugInfo .= '<span class="label label-primary">EXCEPTIONS</span>';
}
else{
$debug && $debugInfo .= '<span class="label label-danger">REMOVED</span>';
unset($doc->_scripts[$searchUrl]);
}
if (!empty($params->remove) && !$this->checkExceptions($params->remove_exceptions, $debug, $debugInfo)) {
$debug && $debugInfo .= '<span class="label label-danger">REMOVED</span>';
unset($doc->_scripts[$searchUrl]);
} else {
if (!empty($params->defer)) {
$debug && $debugInfo .= '<span class="label label-success">DEFER</span>';
Expand Down Expand Up @@ -99,14 +94,9 @@ function onBeforeCompileHead()

$debug && $debugInfo .= '<li>' . $searchUrl . ' ==> ';

if (!empty($params->remove)) {
if($this->checkExceptions($params->remove_exceptions)){
$debug && $debugInfo .= '<span class="label label-primary">EXCEPTIONS</span>';
}
else{
$debug && $debugInfo .= '<span class="label label-danger">REMOVED</span>';
unset($doc->_styleSheets[$searchUrl]);
}
if (!empty($params->remove) && !$this->checkExceptions($params->remove_exceptions, $debug, $debugInfo)) {
$debug && $debugInfo .= '<span class="label label-danger">REMOVED</span>';
unset($doc->_styleSheets[$searchUrl]);
} else if (!empty($params->foother)) {
$debug && $debugInfo .= '<span class="label label-danger">MOVED TO FOOTHER</span>';
$this->footherCss[$searchUrl] = $doc->_styleSheets[$searchUrl];
Expand Down Expand Up @@ -222,8 +212,7 @@ private function prepareConfig()
return $config;
}

private function checkExceptions($removeExceptions){
$return = false;
private function checkExceptions($removeExceptions, $debug, &$debugInfo){
$removeExceptions = trim($removeExceptions);
if(empty($removeExceptions)){
return false;
Expand All @@ -244,6 +233,12 @@ private function checkExceptions($removeExceptions){
$aCheck[] = (int)in_array($input->getString($removeException[0], ''), $values);
}

return !in_array(0, $aCheck);
$exception = !in_array(0, $aCheck);

if($exception){
$debug && $debugInfo .= '<span class="label label-primary">EXCEPTION</span>';
}

return $exception;
}
}

0 comments on commit b59ab3e

Please sign in to comment.