/** * Register a module with params and dependencies to call list. * Registered modules will call automatic after page loaded * * @param string $module Name of the module that will call * @param mixed $params Parameters when execute the module * @param boolean $inline If value is true, inline javascript code to call a module will be returned * * @return void */ public static function loadScript($module, $params = array(), $inline = false) { self::$_hasModules = true; if ($inline === true) { return "\n\t\t\t\t<script type=\"text/javascript\">\n\t\t\t\t\t(JoomlaShine = window.JoomlaShine || {});\n\t\t\t\t\t(!window.jQuery || (JoomlaShine.jQueryBackup = jQuery));\n\t\t\t\t\t(!JoomlaShine.jQuery || (jQuery = JoomlaShine.jQuery));\n\n\t\t\t\t\trequire(['{$module}'], function (ModuleObject) {\n\t\t\t\t\t\tJSNLoadedModules['{$module}'] = new ModuleObject(" . json_encode($params) . ");\n\t\t\t\t\t});\n\n\t\t\t\t\t(!window.jQuery || (JoomlaShine.jQuery = jQuery));\n\t\t\t\t\t(!JoomlaShine.jQueryBackup || (jQuery = JoomlaShine.jQueryBackup));\n\t\t\t\t</script>\n\t\t\t"; } $module = array('module' => $module, 'params' => $params); $moduleKey = md5(json_encode($module)); // Add module name to call list self::$_scriptModules[$moduleKey] = $module; }