public function onAfterRender()
 {
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $input = $app->input;
     if ($document instanceof JDocumentHTML) {
         $template = $document->template;
         $content = $app->getBody();
         if ($this->_application->isAdmin() && $this->_user->id > 0) {
             PowerAdminHistoryHelper::onAfterRender();
             $uri = JUri::root(true);
             preg_match('/<body([^>]+)>/is', $content, $matches);
             $pos = strpos(@$matches[0], 'jsn-master');
             if ($input->getVar('tmpl', '') != 'component' && $input->getVar('format', '') != 'raw') {
                 if ($this->_params->get('enable_adminbar', true) == true) {
                     $content = preg_replace('/<body([^>]*)>(.*)<\\/body>/is', '<body\\1 data-template="' . $template . '"><div id="jsn-adminbar">' . $this->_menuContent . '</div><div id="jsn-body-wrapper">\\2</div></body>', $content);
                 } else {
                     $content = preg_replace('/<body([^>]*)>(.*)<\\/body>/is', '<body\\1" data-template="' . $template . '">\\2</body>', $content);
                 }
             }
             if (!$pos) {
                 if (preg_match('/<body([^>]*)class\\s*=\\s*"([^"]+)"([^>]*)>/is', $content)) {
                     $content = preg_replace('/<body([^>]*)class\\s*=\\s*"([^"]+)"([^>]*)>/is', '<body \\1 class="jsn-master tmpl-' . $template . ' \\2" \\3>', $content);
                 } else {
                     $content = preg_replace('/<body([^>]+)>/is', '<body \\1 class="jsn-master tmpl-' . $template . '">', $content);
                 }
             }
             $view = $app->input->getVar('view', '');
             $option = $app->input->getVar('option', '');
             if ($option == 'com_poweradmin' && ($view == 'changeposition' || $view == 'rawmode' || $view == 'search' || $view == 'configuration' || $view == 'about' || $view == 'templates' || $view == 'positionlisting')) {
                 $content = preg_replace('#<script[^>]+src="' . $uri . '/media/system/js/validate.js"[^>]*></script>#', '', $content);
                 $content = preg_replace('#<script[^>]+src="' . $uri . '/media/system/js/combobox.js"[^>]*></script>#', '', $content);
             }
             if ($option == 'com_poweradmin' && $view == 'rawmode' || $option == 'com_poweradmin' && $view == 'configuration') {
                 // Remove scrollspy jQuery conflict
                 if (preg_match_all("/\\\$\\('\\.subhead'\\)\\.scrollspy\\(\\{[^\r\n]+\\}\\);/", $content, $matches, PREG_SET_ORDER)) {
                     $content = preg_replace("/\\\$\\('\\.subhead'\\)\\.scrollspy\\(\\{[^\r\n]+\\}\\);/", '', $content);
                 }
             }
         }
         $app->setBody($content);
     }
 }
Ejemplo n.º 2
0
 public function onAfterRender()
 {
     $document = JFactory::getDocument();
     if ($document instanceof JDocumentHTML) {
         $template = $document->template;
         $content = JResponse::getBody();
         if ($this->_application->isAdmin() && $this->_user->id > 0) {
             PowerAdminHistoryHelper::onAfterRender();
             preg_match('/<body([^>]+)>/is', $content, $matches);
             $pos = strpos(@$matches[0], 'jsn-master');
             if (JRequest::getCmd('tmpl') != 'component' && JRequest::getCmd('format') != 'raw') {
                 if ($this->_params->get('enable_adminbar', true) == true) {
                     $content = preg_replace('/<body([^>]*)>(.*)<\\/body>/is', '<body\\1 data-template="' . $template . '"><div id="jsn-adminbar">' . $this->_menuContent . '</div><div id="jsn-body-wrapper">\\2</div></body>', $content);
                 } else {
                     $content = preg_replace('/<body([^>]*)>(.*)<\\/body>/is', '<body\\1" data-template="' . $template . '">\\2</body>', $content);
                 }
             }
             if (!$pos) {
                 if (preg_match('/<body([^>]*)class\\s*=\\s*"([^"]+)"([^>]*)>/is', $content)) {
                     $content = preg_replace('/<body([^>]*)class\\s*=\\s*"([^"]+)"([^>]*)>/is', '<body \\1 class="jsn-master tmpl-' . $template . ' \\2" \\3>', $content);
                 } else {
                     $content = preg_replace('/<body([^>]+)>/is', '<body \\1 class="jsn-master tmpl-' . $template . '">', $content);
                 }
             }
         }
         JResponse::setBody($content);
     }
 }