예제 #1
0
 function onAfterRender()
 {
     $app = JFactory::getApplication();
     $doc = JFactory::getDocument();
     if ($app->getName() != 'site' || $doc->getType() !== 'html') {
         return true;
     }
     $data = $app->getBody();
     if ($this->params->get('useAnywhere', '0') == '1') {
         $data = do_shortcode($data);
     }
     $headerStyles = CthShortcodes::getInstance()->_headerStyles;
     $headerScripts = CthShortcodes::getInstance()->_headerScripts;
     $footerScripts = CthShortcodes::getInstance()->_footerScripts;
     $footerScriptsScript = CthShortcodes::getInstance()->_footerScriptsScript;
     $headerStyles = array_unique($headerStyles);
     $headerScripts = array_unique($headerScripts);
     $footerScripts = array_unique($footerScripts);
     $header_styles_scripts = '';
     foreach ($headerStyles as $style) {
         $header_styles_scripts .= '<link rel="stylesheet" href="' . $style . '" />' . "\n";
     }
     foreach ($headerScripts as $script) {
         $header_styles_scripts .= '<script type="text/javascript" src="' . $script . '"></script>' . "\n";
     }
     $data = str_replace('</head>', $header_styles_scripts . "\n</head>", $data);
     $footer_scripts = '';
     foreach ($footerScripts as $script) {
         $footer_scripts .= '<script type="text/javascript" src="' . $script . '"></script>' . "\n";
     }
     $footer_scripts .= '<script type="text/javascript">' . $footerScriptsScript . '</script>';
     $data = str_replace('</body>', $footer_scripts . "\n</body>", $data);
     $app->setBody($data);
 }