function moodbile_i18n() { global $CFG, $Moodbile; if (moodbile_is_loged()) { $cookie = json_decode($_COOKIE['Moodbile']); $lang = $cookie->lang; } else { if (!isset($CFG['lang'])) { $lang = 'en'; } else { $lang = $CFG['lang']; } } if (file_exists('languages/' . $lang . '/' . $lang . '.js')) { return 'languages/' . $lang . '/' . $lang . '.js'; } else { return 'languages/en/en.js'; } }
/** * Get all JS libs * * @return array with Moodbile libraries */ function moodbile_get_client_scripts() { //Se encargara de unificar los js tanto de los modulos como del sistema global $CFG, $Moodbile; $basepath = $CFG['basepath']; $active_modules = $CFG['active_modules']; $js = array(); //client scripts $js_jq[] = 'misc/jquery/jquery.js'; $js_jq[] = 'misc/jquery/jquery.cooquery.min.js'; $js_jq[] = 'misc/jquery/jquery.json.min.js'; $js_jq[] = 'misc/jquery/jquery.md5.js'; if ($CFG['cache'] !== FALSE) { $js[] = moodbile_performance($CFG['cache'], $js_jq, 'js', 'moodbile.jq'); } else { $js = array_merge_recursive($js, $js_jq); } //client libs $js_lib[] = 'lib/js/core.lib.js'; $js_lib[] = 'lib/js/authentication.lib.js'; $js_lib[] = 'lib/js/ajax.lib.js'; $js_lib[] = 'lib/js/alert.lib.js'; $js_lib[] = 'lib/js/notifications.lib.js'; $js_lib[] = 'lib/js/webdb.lib.js'; $js_lib[] = 'lib/js/templates.lib.js'; $js_lib[] = 'lib/js/fx.lib.js'; $js_lib[] = 'lib/js/infoviewer.lib.js'; $js_lib[] = 'lib/js/filter.lib.js'; $js_lib[] = 'lib/js/toolbar.lib.js'; $js_lib[] = 'lib/js/breadcrumb.lib.js'; $js_lib[] = 'lib/js/footer.lib.js'; if ($CFG['cache'] !== FALSE) { $js[] = moodbile_performance($CFG['cache'], $js_lib, 'js', 'moodbile.lib'); } else { $js = array_merge_recursive($js, $js_lib); } //lang str library $js_lang[] = moodbile_i18n(); if (moodbile_is_loged()) { $cookie = json_decode($_COOKIE['Moodbile']); $lang = $cookie->lang; $filename = 'moodbile.lang.' . $lang; } else { $filename = 'moodbile.lang'; } if ($CFG['cache'] !== FALSE) { $js[] = moodbile_performance($CFG['cache'], $js_lang, 'js', $filename); } else { $js = array_merge_recursive($js, $js_lang); } //module scripts foreach ($active_modules as $module) { $module_files = moodbile_get_module($module); $file = array_intersect($module_files, array($module . '.mod.js')); $key = array_keys($file); $js_mod[] = 'modules/' . $module . '/' . $file[$key[0]]; } if ($CFG['cache'] !== FALSE) { $js[] = moodbile_performance($CFG['cache'], $js_mod, 'js', 'moodbile.mod'); } else { $js = array_merge_recursive($js, $js_mod); } //Solucionar problemas a la hora de abrir la directorios y meterlo en cache if ($themejs = moodbile_get_theme_scripts()) { foreach ($themejs as $themejs) { $js_thm[] = 'themes/' . $CFG['theme'] . '/' . $themejs; } if ($CFG['cache'] !== FALSE) { $js[] = moodbile_performance($CFG['cache'], $js_thm, 'js', 'moodbile.thm'); } else { $js = array_merge_recursive($js, $js_thm); } } $Moodbile['js'] = $js; return $js; }
function moodbile_render_theme() { global $CFG; if ($CFG['cache'] != false && file_exists($filename)) { if (moodbile_is_loged()) { $user_hash = hash('md5', moodbile_get_username()); $filename = "misc/cache/page.{$user_hash}.tpl.html"; } else { $filename = "misc/cache/page.tpl.html"; } $template = $filename; } else { $template = moodbile_get_theme_template(); $variables = moodbile_process_theme_variables(); extract($variables, EXTR_SKIP); } ob_start('ob_gzhandler'); header('Content-Type: text/html; charset=utf-8'); include "{$template}"; $content = ob_get_contents(); if ($CFG['cache'] != false && !file_exists($filename)) { moodbile_performance_create_page_cacheable($content); moodbile_performance_set_page_headers($content); } ob_end_flush(); }
function moodbile_performance_create_page_cacheable($content) { //Crea si es necesario y devuelve ruta de la pagina a incluir o false para que cree pagina if (moodbile_is_loged()) { //get username and give md5 for customize page template $user_hash = hash('md5', moodbile_get_username()); $filename = "misc/cache/page.{$user_hash}.tpl.html"; } else { $filename = "misc/cache/page.tpl.html"; } if (!file_exists($filename)) { file_put_contents($filename, $content); } }