protected static function getContents() { /** get contents of front-end page **/ try { if (function_exists('curl_init')) { $response = self::curlResponse(self::$_renderUrl); // Parse front-end content list($head, $body) = explode('</head>', $response->contents); list($temp, $head) = explode('<head>', $head); list($body, $temp) = explode('</body>', $body); $head = preg_replace(array('#<base\\s+href="[^"]+"\\s*/>#', '#<meta\\s+[^>]+/>#', '#<title>[^\\r\\n]+</title>#'), '', $head); $body = preg_replace('#<body[^>]*>#', '', $body); self::$_contents = array('head' => $head, 'body' => $body); } else { throw new Exception(JText::_('JSN_EXTFW_ERROR_CURL_NOT_ENABLE')); } } catch (Exception $e) { throw $e; } }
/** * Handle onAfterDispatch event to load template override. * * @return void */ public function onAfterDispatch() { $app = JFactory::getApplication(); $doc = JFactory::getDocument(); if ($app->isSite() and $doc->getType() == 'html' and JSNTplTemplateRecognization::detect()) { if ($app->input->getInt('jsntpl_position', 0) && $app->input->getInt('tp', 0)) { $config = JFactory::getConfig(); $secret = $config->get('secret'); if (md5($secret) == $app->input->getCmd('secret_key', '')) { JSNTplTemplatePositionrender::renderEmptyComponent(); JSNTplTemplatePositionrender::renderEmptyModule(); } } } }
public function getModulePositionAction() { $document = JFactory::getDocument(); $config = JFactory::getConfig(); $secret = $config->get('secret'); $defaultTemplate = JSNTplTemplatePositionrender::getDefaultTemplate(); if ($this->app->input->getCmd('template', '') != $defaultTemplate->name) { echo JText::_('JSN_TPLFW_ERROR_THE_MODULE_POSITION_CHOOSER_IS_AVAILABLE_IF_THIS_TEMPLATE_IS_SET_HOME_TEMPLATE'); exit; } $previewModulePositionsIsEnabled = JComponentHelper::getParams('com_templates')->get('template_positions_display', 0); if (!$previewModulePositionsIsEnabled) { JSNTplTemplatePositionrender::enablePreviewMode(); } $onPositionClick = "\n\t\tif ( !\$(this).hasClass('active-position') ){\n\t\t\twindow.parent.jQuery.JSNTplMMShortcodeModulePositionSelectPosition(\$(this).find('p').text());\n\t\t}\n\t\t"; $_customScript = "\n\t\t\tvar changeposition;\n\t\t\t(function(\$){\n\t\t\t\t\$(document).ready(function (){\n\t\t\t\t\t\$('#jsn-tpl-megamenu').hide();\n\t\t\t\t\tvar posOutline\t= \$('.jsn-position');\n\t\t\t\t\tvar _idAlter\t= false;\n\t\t\t\t\tif (\$('.jsn-position').length == 0) {\n\t\t\t\t\t\tposOutline\t= \$('.mod-preview');\n\t\t\t\t\t\t_idAlter\t= true;\n\t\t\t\t\t}else{\n\t\t\t\t\t\tposOutline.css({'z-index':'9999', 'position':'relative'});\n\t\t\t\t\t}\n\t\t\t\t\tposOutline.each(function(){\n\t\t\t\t\t\tif(_idAlter){\n\t\t\t\t\t\t\tpreviewInfo = \$(this).children('.mod-preview-info').text();\n\n\t\t\t\t\t\t\t_splitted = previewInfo.split('[');\n\t\t\t\t\t\t\tif(_splitted.length > 1){\n\t\t\t\t\t\t\t\tposname\t= _splitted[0];\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t_splitted = posname.split(': ');\n\t\t\t\t\t\t\tif(_splitted.length > 1){\n\t\t\t\t\t\t\t\tposname\t= _splitted[1];\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tposname = \$.trim(posname);\n\n\t\t\t\t\t\t\t\$(this).attr('id', posname + '-jsnposition');\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\$(this)[0].oncontextmenu = function() {\n\t\t\t\t\t\t\treturn false;\n\t\t\t\t\t\t}\n\t\t\t\t\t})\n\t\t\t\t\t.click(function () {\n\t\t\t\t\t\t" . $onPositionClick . "\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t})(jQuery);\n\t\t"; JSNTplTemplatePositionrender::renderPage(JURI::root() . 'index.php?tp=1&jsntpl_position=1&secret_key=' . md5($secret)); echo JSNTplTemplatePositionrender::getHeader(); echo '<div id="jsn-page-container">' . JSNTplTemplatePositionrender::getBody() . '</div>'; echo '<link rel="stylesheet" href="' . JUri::root(true) . '/plugins/system/jsntplframework/assets/joomlashine/css/jsn-positions.css' . '" type="text/css" />'; echo '<script type="text/javascript">' . $_customScript . '</script>'; exit; }