function showPopup() { global $mainframe; jimport('joomla.application.helper'); $client = JApplicationHelper::getClientInfo($mainframe->getClientID()); // settings from config.xml $dumpConfig =& JComponentHelper::getParams('com_dump'); $w = $dumpConfig->get('popupwidth', 500); $h = $dumpConfig->get('popupheight', 500); // build the url $url = JURI::base(true) . '/index.php?option=com_dump&view=tree&tmpl=component'; /* @TODO remove this and implement this in a later version using JRoute // only add Itemid in Site if ( $mainframe->isSite() ) { $url .= '&Itemid=' . DumpHelper::getComponentItemid( 'com_dump' ); } */ // create the javascript // We can't use $document, because it's already rendered $nl = "\n"; $script = $nl . '<!-- J!Dump -->' . $nl . '<script type="text/javascript">' . $nl . '// <!--' . $nl . 'window.open( "' . $url . '", "dump_' . $client->name . '", "height=' . $h . ',width=' . $w . ',toolbar=0,status=0,menubar=0,scrollbars=1,resizable=1");' . $nl . '// -->' . $nl . '</script>' . $nl . '<!-- / J!Dump -->'; // add the code to the header (thanks jenscski) // JResponse::appendBody( $script ); $body = JResponse::getBody(); $body = str_replace('</head>', $script . '</head>', $body); JResponse::setBody($body); }
/** * Converting the site URL to fit to the HTTP request * */ function onAfterInitialise() { global $_PROFILER; $app =& JFactory::getApplication(); $user =& JFactory::getUser(); if ($app->isAdmin() || JDEBUG) { return; } if (!$user->get('guest') && $_SERVER['REQUEST_METHOD'] == 'GET') { $this->_cache->setCaching(true); } $data = $this->_cache->get(); if ($data !== false) { // the following code searches for a token in the cached page and replaces it with the // proper token. $token = JUtility::getToken(); $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#'; $replacement = '<input type="hidden" name="' . $token . '" value="1" />'; $data = preg_replace($search, $replacement, $data); JResponse::setBody($data); echo JResponse::toString($app->getCfg('gzip')); if (JDEBUG) { $_PROFILER->mark('afterCache'); echo implode('', $_PROFILER->getBuffer()); } $app->close(); } }
function setStyle() { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); if ($doc->getType() != 'html') { return; } //include_once AK_LIB_PATH.DS.'dom'.DS.'simple_html_dom.php'; $body = JResponse::getBody(); $body = explode('</head>', $body); $base = JURI::root(); $style = "\n"; if ($app->isSite()) { if (JVERSION < 3.0) { $style .= '<link rel="stylesheet" href="' . AK_ADMIN_CSS_URL . '/system.css" type="text/css" />' . "\n"; } $style .= '<link rel="stylesheet" href="' . AK_CSS_URL . '/custom-typo.css" type="text/css" />' . "\n"; $style .= '<link rel="stylesheet" href="' . AK_CSS_URL . '/custom.css" type="text/css" />' . "\n"; } else { if (JVERSION < 3.0) { $style .= '<link rel="stylesheet" href="' . AK_ADMIN_CSS_URL . '/system.css" type="text/css" />' . "\n"; } $style .= '<link rel="stylesheet" href="' . AK_CSS_URL . '/custom-admin.css" type="text/css" />' . "\n"; } $body[0] .= $style; //Fold content $replace['{fold}'] = '<div class="ak-fold-warp"><div class="ak-fold-outter"><div class="ak-fold-inner">'; $replace['{/fold}'] = '</div></div><div class="ak-fold-button"></div></div><div class="clearfix"></div>'; if ($app->isSite()) { $body[1] = strtr($body[1], $replace); } $body = implode('</head>', $body); JResponse::setBody($body); }
function onAfterRender() { $app = JFactory::getApplication(); if ($app->isAdmin()) { return; } // Initialise variables $id = $this->params->get('id', ''); $webvisor = $this->params->get('webvisor', ''); $clickMap = $this->params->get('clickMap', ''); $linksOut = $this->params->get('linksOut', ''); $accurateTrackBounce = $this->params->get('accurateTrackBounce', ''); $noIndex = $this->params->get('noIndex', ''); $noIndexWrapper = $this->params->get('noindexWrapper', '1'); //getting body code and storing as buffer $buffer = JResponse::getBody(); //embed Yandex Metrika code $webvisor = $webvisor ? 'true' : 'false'; $clickMap = $clickMap ? 'true' : 'false'; $linksOut = $linksOut ? 'true' : 'false'; $accurateTrackBounce = $accurateTrackBounce ? 'true' : 'false'; $noIndex = $noIndex ? 'ut:"noindex",' : ''; $javascript = '<!-- Yandex.Metrika counter --><script type="text/javascript">(function (d, w, c) { (w[c] = w[c] || []).push(function() { try { w.yaCounter' . $id . ' = new Ya.Metrika({id:' . $id . ', clickmap:' . $clickMap . ', trackLinks:' . $linksOut . ', accurateTrackBounce:' . $accurateTrackBounce . ',' . $noIndex . ' webvisor:' . $webvisor . '}); } catch(e) {} }); var n = d.getElementsByTagName("script")[0], s = d.createElement("script"), f = function () { n.parentNode.insertBefore(s, n); }; s.type = "text/javascript"; s.async = true; s.src = (d.location.protocol == "https:" ? "https:" : "http:") + "//mc.yandex.ru/metrika/watch.js"; if (w.opera == "[object Opera]") { d.addEventListener("DOMContentLoaded", f); } else { f(); } })(document, window, "yandex_metrika_callbacks");</script><noscript><div><img src="//mc.yandex.ru/watch/' . $id . '" style="position:absolute; left:-9999px;" alt="" /></div></noscript><!-- /Yandex.Metrika counter -->'; if ($noIndexWrapper) { $javascript = '<!--noindex-->' . $javascript . '<!--/noindex-->'; } $buffer = preg_replace("/<\\/body>/", $javascript . "\n\n</body>", $buffer); //output the buffer JResponse::setBody($buffer); return true; }
public function onAfterRender() { if ($this->app->isAdmin()) { return; } $app = JFactory::getApplication(); $option = $app->input->get('option'); $view = $app->input->get('view'); $tmpl = $app->input->get('tmpl'); $body = JResponse::GetBody(); if ($app->isSite() && $tmpl != 'component') { $_cls = explode(',', $this->_params->get('item_class')); if (empty($_cls)) { return; } $cls = array(); for ($i = 0; $i < count($_cls); $i++) { $cls[] = trim($_cls[$i]); } $cls_str = implode(', ', $cls); $body = str_replace('</body>', $this->_addScriptQV($cls_str) . '</body>', $body); JResponse::setBody($body); return true; } $is_ajax = !empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest'; $is_ajax_qv = (int) JRequest::getVar('isajax_qv', 0); if ($is_ajax && $is_ajax_qv) { $body = JResponse::GetBody(); preg_match("~<body.*?>(.*?)<\\/body>~is", $body, $match); echo '<div id="sj_quickview">' . $match[1] . '</div>'; die; //die(json_encode('<div id="sj_quickview">'.$match[1].'</div>')); } }
function onAfterRender() { $fbml = '<html xmlns:fb="http://www.facebook.com/2008/fbml"'; $html = JResponse::getBody(); $html = JString::str_ireplace('<html', $fbml, $html); JResponse::setBody($html); }
/** * Converting the site URL to fit to the HTTP request */ function onAfterRender() { $app =& JFactory::getApplication(); if ($app->getName() != 'site') { return true; } //Replace src links $base = JURI::base(true) . '/'; $buffer = JResponse::getBody(); $regex = '#href="index.php\\?([^"]*)#m'; $buffer = preg_replace_callback($regex, array('plgSystemSEF', 'route'), $buffer); $protocols = '[a-zA-Z0-9]+:'; //To check for all unknown protocals (a protocol must contain at least one alpahnumeric fillowed by : $regex = '#(src|href)="(?!/|' . $protocols . '|\\#|\')([^"]*)"#m'; $buffer = preg_replace($regex, "\$1=\"{$base}\$2\"", $buffer); $regex = '#(onclick="window.open\\(\')(?!/|' . $protocols . '|\\#)([^/]+[^\']*?\')#m'; $buffer = preg_replace($regex, '$1' . $base . '$2', $buffer); // ONMOUSEOVER / ONMOUSEOUT $regex = '#(onmouseover|onmouseout)="this.src=([\']+)(?!/|' . $protocols . '|\\#|\')([^"]+)"#m'; $buffer = preg_replace($regex, '$1="this.src=$2' . $base . '$3$4"', $buffer); // Background image $regex = '#style\\s*=\\s*[\'\\"](.*):\\s*url\\s*\\([\'\\"]?(?!/|' . $protocols . '|\\#)([^\\)\'\\"]+)[\'\\"]?\\)#m'; $buffer = preg_replace($regex, 'style="$1: url(\'' . $base . '$2$3\')', $buffer); // OBJECT <param name="xx", value="yy"> -- fix it only inside the <param> tag $regex = '#(<param\\s+)name\\s*=\\s*"(movie|src|url)"[^>]\\s*value\\s*=\\s*"(?!/|' . $protocols . '|\\#|\')([^"]*)"#m'; $buffer = preg_replace($regex, '$1name="$2" value="' . $base . '$3"', $buffer); // OBJECT <param value="xx", name="yy"> -- fix it only inside the <param> tag $regex = '#(<param\\s+[^>]*)value\\s*=\\s*"(?!/|' . $protocols . '|\\#|\')([^"]*)"\\s*name\\s*=\\s*"(movie|src|url)"#m'; $buffer = preg_replace($regex, '<param value="' . $base . '$2" name="$3"', $buffer); // OBJECT data="xx" attribute -- fix it only in the object tag $regex = '#(<object\\s+[^>]*)data\\s*=\\s*"(?!/|' . $protocols . '|\\#|\')([^"]*)"#m'; $buffer = preg_replace($regex, '$1data="' . $base . '$2"$3', $buffer); JResponse::setBody($buffer); return true; }
function onAfterRender() { if (class_exists('JEventDispatcher', false)) { $dispatcher = JEventDispatcher::getInstance(); } else { $dispatcher = JDispatcher::getInstance(); } $dispatcher->trigger('onNextendBeforeCompileHead'); ob_start(); if (class_exists('N2AssetsManager')) { echo N2AssetsManager::getCSS(); echo N2AssetsManager::getJs(); } $head = ob_get_clean(); if ($head != '') { $application = JFactory::getApplication(); if (class_exists('JApplicationWeb') && method_exists($application, 'getBody')) { $body = $application->getBody(); $mode = 'JApplicationWeb'; } else { $body = JResponse::getBody(); $mode = 'JResponse'; } $body = preg_replace('/<\\/head>/', $head . '</head>', $body, 1); switch ($mode) { case 'JResponse': JResponse::setBody($body); break; default: $application->setBody($body); } } }
public function onAfterRender() { $fbml = '<html xmlns:fb="http://ogp.me/ns/fb#" '; $html = JResponse::getBody(); $html = JString::str_ireplace('<html', $fbml, $html); JResponse::setBody($html); }
function onAfterRender() { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); // we don't care about /administrator or pages that aren't html if ($app->isAdmin() || JRequest::getVar('format') == 'raw' || $app->isSite() && $doc->getType() != 'html') { return true; } // default favicon and individual menu-item assignments $default = (int) $this->params->get('default', 0); $assignmentsobject = (array) $this->params->get('assignments'); $assignments = array(); foreach ($assignmentsobject as $key => $assignment) { $assignments[$key] = (array) $assignment; } // no default and no assignments = no point if (!$default && !count($assignments)) { return true; } $favicon = $this->getFavicon($default, $assignments); // no favicon found and no valid default if (!$favicon) { return true; } $buffer = JResponse::getBody(); $link = '<link href="' . $favicon . '" rel="shortcut icon" type="image/vnd.microsoft.icon" />'; preg_match('/<link href=.* rel="shortcut icon" type=.*\\/>/', $buffer, $position, PREG_OFFSET_CAPTURE); if (isset($position[0]) && isset($position[0][0]) && strlen($position[0][0])) { $buffer = str_replace($position[0][0], $link, $buffer); } else { $buffer = str_replace("</head>", "\t{$link}\n</head>", $buffer); } JResponse::setBody($buffer); }
public function _renderStatus() { $date = JFactory::getDate(); $jparam = new JConfig(); if (!JFile::exists(JPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_community' . DS . 'community.xml')) { return false; } if (JFile::exists($jparam->tmp_path . DS . 'jomsocialupdate.ini')) { $lastcheckdate = JFile::read($jparam->tmp_path . DS . 'jomsocialupdate.ini'); } else { $lastcheckdate = $date->toFormat(); } JFile::write($jparam->tmp_path . DS . 'jomsocialupdate.ini', $lastcheckdate); $dayInterval = 1; // days $currentdate = $date->toFormat(); $checkVersion = strtotime($currentdate) > strtotime($lastcheckdate) + $dayInterval * 60 * 60 * 24; // Load language $lang = JFactory::getLanguage(); $lang->load('com_community', JPATH_ROOT . DS . 'administrator'); $button = $this->_getButton($checkVersion); $html = JResponse::getBody(); $html = str_replace('<div id="module-status">', '<div id="module-status">' . $button, $html); // Load AJAX library for the back end. $jax = new JAX(rtrim(JURI::root(), '/') . '/plugins/system/pc_includes'); $jax->setReqURI(rtrim(JURI::root(), '/') . '/administrator/index.php'); $jaxScript = $jax->getScript(); JResponse::setBody($html . $jaxScript); }
function onAfterRender() { $app =& JFactory::getApplication(); if ($app->getName() != 'site') { return true; } $buffer = JResponse::getBody(); if (strripos($buffer, '_svg.png') !== false) { include 'plugins/system/svg_helper/Modernizr/modernizr-server.php'; if (isset($_COOKIE['svg-check']) && strripos($_COOKIE['svg-check'], 'svg:1') !== false) { $buffer = str_replace('_svg.png', '_png.svg', $buffer); } } /* Older versions compatibility start */ $extension = $this->params->get('extension'); if (strripos($buffer, $extension) !== false) { include 'plugins/system/svg_helper/Modernizr/modernizr-server.php'; if ($this->params->get('enable_replacement') == 1) { if (isset($_COOKIE['svg-check']) && strripos($_COOKIE['svg-check'], 'svg:1') !== false) { $buffer = str_replace($extension, 'svg', $buffer); } else { $buffer = str_replace($extension, 'png', $buffer); } } } /* Older versions compatibility end */ if ($buffer != '') { JResponse::setBody($buffer); } return true; }
/** * Output a correct response code when site is offline * to let know search engines that site data * should not be discarded or discounted */ function plgSh404sefofflinecode() { $app = JFactory::getApplication(); // are we in the backend, or not offline ? if (!defined('SH404SEF_IS_RUNNING') || $app->isAdmin() || !$app->getCfg('offline')) { return; } // get plugin params $plugin =& JPluginHelper::getPlugin('sh404sefcore', 'sh404sefofflinecode'); $pluginParams = new JRegistry(); $pluginParams->loadString($plugin->params); $disallowAdminAccess = $pluginParams->get('disallowAdminAccess', 0); if (!$disallowAdminAccess) { // admins are allowed, lets check if current user // is an admin, or if user is trying to log in $user =& JFactory::getUser(); $option = JRequest::getCmd('option'); $task = JRequest::getCmd('task'); if ($option == 'com_users' && $task == 'user.login') { // Check for request forgeries JRequest::checkToken() or jexit('Invalid Token'); $loggingIn = true; } else { $loggingIn = false; } // if already logged inadmin, or admin logging in, let it go if ($user->authorize('core.manage', 'com_sh404sef') || $loggingIn) { return; } } // need to render offline screen if ($disallowAdminAccess) { // admins not allowed, use our own // simplified template. Most likely being hacked so // close doors as much as possible $template = ''; $file = 'sh404sef_offline_template.php'; $directory = JPATH_ROOT . DS . 'plugins' . DS . 'sh404sefcore'; } else { // admin can access, use Joomla! offline template, // that includes a login form $template = $app->getTemplate(); $file = 'offline.php'; $directory = JPATH_THEMES; } $params = array('template' => $template, 'file' => $file, 'directory' => $directory); $document =& JFactory::getDocument(); $data = $document->render($app->getCfg('caching'), $params); // header : service unavailable JResponse::setHeader('HTTP/1.0 503', true); // give it some time $retryAfter = $pluginParams->get('retry_after_delay', 7400); // set header Jresponse::setheader('Retry-After', gmdate('D, d M Y H:i:s', time() + $retryAfter) . ' GMT'); // echo document JResponse::setBody($data); echo JResponse::toString($app->getCfg('gzip')); // and terminate $app->close(); }
/** * Converting the site URL to fit to the HTTP request * */ function onAfterInitialise() { global $_PROFILER; $app = JFactory::getApplication(); $user = JFactory::getUser(); if ($app->isAdmin()) { return; } if (count($app->getMessageQueue())) { return; } if ($user->get('guest') && $app->input->getMethod() == 'GET') { $this->_cache->setCaching(true); } $data = $this->_cache->get($this->_cache_key); if ($data !== false) { // Set cached body JResponse::setBody($data); echo JResponse::toString($app->getCfg('gzip')); if (JDEBUG) { $_PROFILER->mark('afterCache'); } $app->close(); } }
/** * Render the error page based on an exception. * * @param Exception $error The exception for which to render the error page. * * @return void * * @since 3.0 */ public static function render(Exception $error) { try { $app = JFactory::getApplication(); $document = JDocument::getInstance('error'); if (!$document) { // We're probably in an CLI environment exit($error->getMessage()); $app->close(0); } $config = JFactory::getConfig(); // Get the current template from the application $template = $app->getTemplate(); // Push the error object into the document $document->setError($error); if (ob_get_contents()) { ob_end_clean(); } $document->setTitle(JText::_('Error') . ': ' . $error->getCode()); $data = $document->render(false, array('template' => $template, 'directory' => JPATH_THEMES, 'debug' => $config->get('debug'))); // Failsafe to get the error displayed. if (empty($data)) { exit($error->getMessage()); } else { // Do not allow cache JResponse::allowCache(false); JResponse::setBody($data); echo JResponse::toString(); } } catch (Exception $e) { exit('Error displaying the error page: ' . $e->getMessage()); } }
function onAfterRender() { global $mainframe; $jatypo = JRequest::getCmd('jatypo'); if (!$mainframe->isAdmin() && !$jatypo) { return; } $tmpl = dirname(__FILE__) . DS . 'jatypo' . DS . 'tmpl' . DS . 'default.php'; $html = $this->loadTemplate($tmpl); //$html = file_get_contents ($tmpl); //if (preg_match ('/<body[^>]*>(.*)<\/body>/s', $html, $matches)) $html = $matches[1]; $buffer = JResponse::getBody(); if ($mainframe->isAdmin()) { if (preg_match('/id=\\"editor-xtd-buttons\\"/', $buffer)) { //exist editor //$html = "<div id=\"jatypo-wrap\">$html</div>"; $buffer = preg_replace('/<\\/body>/', "\n{$html}\n</body>", $buffer); JResponse::setBody($buffer); } return; } //replace body by the sample $buffer = preg_replace('/<body([^>]*)>.*<\\/body>/s', "<body\\1>{$html}</body>", $buffer); JResponse::setBody($buffer); }
/** * Registers a handler to filter the final output * * @param callable $handler A function( $body ) { return $bodyChanged; } * @return self To allow chaining. */ public function registerOnAfterRenderBodyFilter($handler) { $this->registerEvent('onAfterRender', function () use($handler) { \JResponse::setBody($handler(\JResponse::getBody())); }); return $this; }
/** * Converting the site URL to fit to the HTTP request * */ function onAfterInitialise() { global $mainframe, $_PROFILER; $user =& JFactory::getUser(); if ($mainframe->isAdmin() || JDEBUG) { return; } if (!$user->get('aid') && $_SERVER['REQUEST_METHOD'] == 'GET') { $this->_cache->setCaching(true); } $data = $this->_cache->get(); if ($data !== false) { // the following code searches for a token in the cached page and replaces it with the // proper token. $token = JUtility::getToken(); $search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#'; $replacement = '<input type="hidden" name="' . $token . '" value="1" />'; $data = preg_replace($search, $replacement, $data); /** HTGMOD **/ // do the same thing for the JomSocial ajax token $search = '/jax_token_var = \'[0-9a-f]{32}\'/'; $replacement = 'jax_token_var = \'' . $token . '\''; $data = preg_replace($search, $replacement, $data); /** END HTGMOD **/ JResponse::setBody($data); echo JResponse::toString($mainframe->getCfg('gzip')); if (JDEBUG) { $_PROFILER->mark('afterCache'); echo implode('', $_PROFILER->getBuffer()); } $mainframe->close(); } }
function onAfterRender() { if ((defined('JCOMMENTS_CSS') || defined('JCOMMENTS_JS')) && !defined('JCOMMENTS_SHOW')) { $app =& JFactory::getApplication(); if ($app->getName() != 'site') { return true; } $buffer = JResponse::getBody(); $regexpJS = '#(\\<script(\\stype=\\"text\\/javascript\\")? src="[^\\"]*\\/com_jcomments\\/[^\\>]*\\>\\<\\/script\\>[\\s\\r\\n]*?)#ismU'; $regexpCSS = '#(\\<link rel="stylesheet" href="[^\\"]*\\/com_jcomments\\/[^>]*>[\\s\\r\\n]*?)#ismU'; $jcommentsTestJS = '#(JCommentsEditor|new JComments)#ismU'; $jcommentsTestCSS = '#(comment-link|jcomments-links)#ismU'; $jsFound = preg_match($jcommentsTestJS, $buffer); $cssFound = preg_match($jcommentsTestCSS, $buffer); if (!$jsFound) { // remove JavaScript if JComments isn't loaded $buffer = preg_replace($regexpJS, '', $buffer); } if (!$cssFound && !$jsFound) { // remove CSS if JComments isn't loaded $buffer = preg_replace($regexpCSS, '', $buffer); } if ($buffer != '') { JResponse::setBody($buffer); } } return true; }
function onAfterRender() { $plugin =& JPluginHelper::getPlugin('system', 'phocapdffabrik'); $pluginP = new JParameter($plugin->params); $pdfDestination = $pluginP->get('pdf_destination', 'S'); /*global $mainframe; if ($mainframe->isAdmin()) { return; }*/ // IE 7 bug include_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_phocapdf' . DS . 'helpers' . DS . 'phocapdfbrowser.php'; $document =& JFactory::getDocument(); $doctype = $document->getType(); if ($doctype == 'html') { $bodySite = JResponse::getBody(); if ($pdfDestination == 'I' || $pdfDestination == 'D') { // Remome OnClick $bodySite = preg_replace_callback('/<a(.+)href="(.*)format=pdf(.*)"(.+)onclick="(.*)"/Ui', array('plgSystemPhocaPDFFabrik', 'phocaPDFCallbackOnClick'), $bodySite); } else { //$bodySite = preg_replace_callback('/<a(.+)href="(.*)format=pdf(.*)"/Ui', array('plgSystemPhocaPDFFabrik', 'phocaPDFCallback'), $bodySite); // IE 7 bug $bodySite = preg_replace_callback('/<a(.+)href="(.*)format=pdf(.*)"(.+)onclick="(.*)"/Ui', array('plgSystemPhocaPDFFabrik', 'phocaPDFCallbackOnClickIE'), $bodySite); } JResponse::setBody($bodySite); } return true; }
function onAfterRender() { $type = $this->params->get('type', ''); $trackerCode = $this->params->get('code', ''); $domain = $this->params->get('domain', 'auto'); $verify = $this->params->get('verify', ''); $javascript = ''; $app = JFactory::getApplication(); if ($app->isAdmin()) { return; } $buffer = JResponse::getBody(); if ($verify) { $javascript .= "\n\n<meta name=\"google-site-verification\" content=\"" . $verify . "\" />\n\n"; } if ($type == 'asynchronous') { $javascript .= "<script type=\"text/javascript\">\n " . $enhancedOutput . "\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', '" . $trackerCode . "']);\n"; $javascript .= "_gaq.push(['_trackPageview']);\n (function() {\n var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n</script>\n<!-- Asynchonous Google Analytics Plugin by PB Web Development -->"; } if ($type == 'universal') { $javascript .= "\n<script>\n (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n })(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n ga('create', '" . $trackerCode . "', '" . $domain . "');\n ga('send', 'pageview');\n\n</script>\n<!-- Universal Google Analytics Plugin by PB Web Development -->\n"; } $buffer = preg_replace("/<\\/head>/", "\n\n" . $javascript . "\n\n</head>", $buffer); JResponse::setBody($buffer); return true; }
/** * * Process data after render * @return string */ function onAfterRender() { $app = JFactory::getApplication(); if ($app->isAdmin()) { return; } $body = JResponse::getBody(); $plgParams = $this->plgParams; $disable_map = $plgParams->get('disable_map', 0); if ($disable_map) { $body = $this->removeCode($body); JResponse::setBody($body); return; } if (!preg_match($this->_plgCodeNew, $body) && !preg_match($this->_plgCode, $body)) { return; } $body = $this->stylesheet($this->plugin, $body); //ignore short-code that placed in text/editor field $pattern = '#value\\s*=\\s*"[^"]*?{jamap.*?}(\\s*{/jamap})?[^"]*?"#'; $pattern2 = '#<textarea[^>]*?>[\\s\\S]*?{jamap.*?}(\\s*{/jamap})?[\\s\\S]*?</textarea>#'; $body = preg_replace_callback($pattern, array($this, 'escapeMap'), $body); $body = preg_replace_callback($pattern2, array($this, 'escapeMap'), $body); //generate map $body = preg_replace_callback($this->_plgCodeNew, array($this, 'genMap'), $body); $body = preg_replace_callback($this->_plgCode, array($this, 'genMap'), $body); //restore short codes $body = str_replace(array('{[jamap]', '{/[jamap]}'), array('{jamap', '{/jamap}'), $body); JResponse::setBody($body); }
private function _renderStatus() { $date = JFactory::getDate(); $jparam = new JConfig(); if (!JFile::exists(JPATH_ROOT . '/administrator/components/com_community/community.xml')) { return false; } if (JFile::exists(JPATH_ROOT . '/administrator/components/com_community/jomsocialupdate.ini')) { $lastcheckdate = JFile::read(JPATH_ROOT . '/administrator/components/com_community/jomsocialupdate.ini'); } else { $lastcheckdate = $date->format('Y-m-d H:i:s'); } JFile::write(JPATH_ROOT . '/administrator/components/com_community/jomsocialupdate.ini', $lastcheckdate); $dayInterval = 1; // days $currentdate = $date->format('Y-m-d H:i:s'); $checkVersion = strtotime($currentdate) > strtotime($lastcheckdate) + $dayInterval * 60 * 60 * 24; // Load language $lang = JFactory::getLanguage(); $lang->load('com_community', JPATH_ROOT . '/administrator'); $button = $this->_getButton($checkVersion); $html = JResponse::getBody(); $html = str_replace('<div id="module-status">', '<div id="module-status">' . $button, $html); // Load AJAX library for the back end. $jaxScript = ''; $noHTML = JRequest::getInt('no_html', 0); $format = JRequest::getWord('format', 'html'); if (!$noHTML && $format == 'html') { require_once AZRUL_SYSTEM_PATH . '/pc_includes/ajax.php'; $jax = new JAX(AZRUL_SYSTEM_LIVE . '/pc_includes'); $jax->setReqURI(rtrim(JURI::root(), '/') . '/administrator/index.php'); $jaxScript = $jax->getScript(); } JResponse::setBody($html . $jaxScript); }
function addCustomTagsToDocument($tags) { if (empty($tags)) return ; $content = ''; if (AriJoomlaUtils::isJoomla15()) { $content = JResponse::getBody(); } else { $content = @ob_get_contents(); @ob_clean(); } $content = preg_replace('/(<\/head\s*>)/i', join('', $tags) . '$1', $content); if (AriJoomlaUtils::isJoomla15()) { JResponse::setBody($content); } else { echo $content; } }
function onAfterRender() { $buffer = JResponse::getBody(); $buffer = preg_replace('#<head>([\\s\\S]+?)<\\/head>#', '<head>$1' . $this->loadStyles() . '</head>', $buffer); JResponse::setBody($buffer); return true; }
/** * Render the application * * @access public */ function render() { $document =& JFactory::getDocument(); $config =& JFactory::getConfig(); $user =& JFactory::getUser(); switch ($document->getType()) { case 'html': //set metadata $document->setTitle(JText::_('PAGE_TITLE')); break; default: break; } // Define component path define('JPATH_COMPONENT', JPATH_BASE . DS . 'installer'); define('JPATH_COMPONENT_SITE', JPATH_SITE . DS . 'installer'); define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . DS . 'installer'); // Execute the component ob_start(); require_once JPATH_COMPONENT . DS . 'installer.php'; $contents = ob_get_contents(); ob_end_clean(); $params = array('template' => 'template', 'file' => 'index.php', 'directory' => JPATH_THEMES); $document->setBuffer($contents, 'installation'); $document->setTitle(JText::_('PAGE_TITLE')); $data = $document->render(false, $params); JResponse::setBody($data); }
/** * Converting the site URL to fit to the HTTP request * */ function onAfterInitialise() { global $_PROFILER; $app = JFactory::getApplication(); $user = JFactory::getUser(); if ($app->isAdmin() || JDEBUG) { return; } if (count($app->getMessageQueue())) { return; } if ($user->get('guest') && $_SERVER['REQUEST_METHOD'] == 'GET') { $this->_cache->setCaching(true); } $data = $this->_cache->get(); if ($data !== false) { JResponse::setBody($data); echo JResponse::toString($app->getCfg('gzip')); if (JDEBUG) { $_PROFILER->mark('afterCache'); echo implode('', $_PROFILER->getBuffer()); } $app->close(); } }
function _modifyResponsiveTemplate() { // Get the current HTML body. $body = trim(JResponse::getBody()); // Correct doctype declaration. $doctype = '<!doctype html>'; // Modified flag. $modified = false; // Found doctype declaration. if (preg_match('#<\\!doctype(.*?)>#is', $body, $match)) { // Make sure it's the correct type. if (strtolower($match[0]) != $doctype) { $body = str_replace($match[0], $doctype, $body); $modified = true; } } else { // No doctype declaration, just add it. $body = $doctype . "\n" . $body; $modified = true; } // Set the new body only if we've modified it. if ($modified) { JResponse::setBody($body); } }
public function onAfterRender() { // only in html and feeds if (JFactory::getDocument()->getType() !== 'html' && JFactory::getDocument()->getType() !== 'feed') { return; } $html = JResponse::getBody(); if ($html == '') { return; } if (JFactory::getDocument()->getType() != 'html') { $this->helpers->get('replace')->replaceTags($html, 'body'); $this->helpers->get('clean')->cleanLeftoverJunk($html); JResponse::setBody($html); return; } // only do stuff in body list($pre, $body, $post) = nnText::getBody($html); $this->helpers->get('replace')->replaceTags($body, 'body'); $html = $pre . $body . $post; $this->helpers->get('clean')->cleanLeftoverJunk($html); // replace head with newly generated head // this is necessary because the plugins might have added scripts/styles to the head $this->helpers->get('head')->updateHead($html); JResponse::setBody($html); }
public function __construct() { $this->body = JResponse::getBody(); $this->bInfo = null; $buf = $this->parseIt(); JResponse::setBody($buf); }