示例#1
0
/**
 * On after render system event
 *
 * @return  void
 */
function onAfterRenderTj()
{
    TjStrapper::initializeVars();
    if (!TjStrapper::validateLoading()) {
        return false;
    }
    $jbolo_dynamic_js = $jsChatTemplates = $jsScripts1 = '';
    $cssScripts = $jsScripts2 = array();
    if (TjStrapper::$load_com_jbolo_assets) {
        if (TjStrapper::$com_jbolo_installed == 1) {
            if (method_exists(TjStrapper::$jboloFrontendHelper, "getJBoloCssFiles")) {
                $cssFiles = TjStrapper::$jboloFrontendHelper->getJBoloCssFiles();
                // Call CSS loader function.
                TjStrapper::getCSSscripts($cssScripts, $cssFiles);
            }
            // Get all dynamic JS code required for JBOLo.
            if (method_exists(TjStrapper::$jboloFrontendHelper, "getJboloDynamicJs")) {
                $jbolo_dynamic_js = TjStrapper::$jboloFrontendHelper->getJboloDynamicJs();
            }
            // Get all jQuery chat templates reqyired for JBOLO.
            if (method_exists(TjStrapper::$jboloFrontendHelper, "getJboloJqueryChatTemplates")) {
                $jsChatTemplates = TjStrapper::$jboloFrontendHelper->getJboloJqueryChatTemplates();
            }
        }
    }
    if (TjStrapper::$com_jlike_installed == 1) {
        $cssFiles = TjStrapper::getJlikeCssArray();
        // Call CSS loader function.
        TjStrapper::getCSSscripts($cssScripts, $cssFiles);
    }
    $cssFiles = TjStrapper::getTJCssArray();
    // Call CSS loader function.
    TjStrapper::getCSSscripts($cssScripts, $cssFiles);
    if (TjStrapper::$fix_js == 1) {
        // Get first JS files.
        $jsFiles1 = TjStrapper::getTechjoomlaJSArray($firstThingsFirst = 1);
        // Remove JS files if those files are alraedy present in document
        $jsFiles1 = TjStrapper::remove_duplicate_files($jsFiles1);
        // Call JS loader function.
        TjStrapper::getJSscripts($jsScripts1, $jsFiles1);
        $jsScripts1 = implode("\n", $jsScripts1);
    }
    // Get other JS files.
    $jsFiles2 = TjStrapper::getTechjoomlaJSArray($firstThingsFirst = 0);
    // Get first things scripts eg variable declaration
    $allScriptDeclarations = '';
    if (!empty(TjStrapper::$firstThingsScriptDeclaration)) {
        $allScriptDeclarations = '<script type="text/javascript">' . implode(' ', TjStrapper::$firstThingsScriptDeclaration) . '</script>';
    }
    // Remove JS files if those files are alraedy present in document
    $jsFiles2 = TjStrapper::remove_duplicate_files($jsFiles2);
    // Call JS loader function.
    TjStrapper::getJSscripts($jsScripts2, $jsFiles2);
    // Insert all scripts into head tag.
    // Get page HTML.
    $body = JResponse::getBody();
    // Set all css and js and dynamic js
    $includescripts = implode("\n", $cssScripts) . $allScriptDeclarations . $jsScripts1 . $jbolo_dynamic_js . implode("\n", $jsScripts2) . $jsChatTemplates;
    if (TjStrapper::$fix_js == 1) {
        // Push JS into head at start or end of head tag.
        if (TjStrapper::$headtag_position) {
            $body = TjStrapper::str_replace_first('<head>', '<head>' . $includescripts, $body);
        } else {
            $body = TjStrapper::str_replace_first('</head>', $includescripts . '</head>', $body);
        }
    } else {
        $body = TjStrapper::str_replace_first('</head>', $includescripts . '</head>', $body);
    }
    // Push jbolo HTML before closing body tag.
    if (TjStrapper::$load_com_jbolo_assets) {
        if (TjStrapper::$com_jbolo_installed == 1) {
            $jbolo_html_code = '';
            if (method_exists(TjStrapper::$jboloFrontendHelper, "getJboloHtmlCode")) {
                $jbolo_html_code = TjStrapper::$jboloFrontendHelper->getJboloHtmlCode();
            }
            $body = str_replace('</body>', $jbolo_html_code . '</body>', $body);
        }
    }
    JResponse::setBody($body);
    return true;
}