Esempio n. 1
0
$cidReset = true;
$tidReset = true;
$_SESSION['courseSessionCode'] = null;
// Include Library and configuration files
require './claroline/inc/claro_init_global.inc.php';
// main init
include claro_get_conf_repository() . 'CLHOME.conf.php';
// conf file
require_once dirname(__FILE__) . '/claroline/inc/lib/coursesearchbox.class.php';
require_once dirname(__FILE__) . '/claroline/inc/lib/course/courselist.lib.php';
if (get_conf('display_former_homepage', false) || !claro_is_user_authenticated()) {
    // Main template
    $template = new CoreTemplate('platform_index.tpl.php');
    // Languages
    $template->assign('languages', get_language_to_display_list());
    $template->assign('currentLanguage', language::current_language());
    // Last user action
    $lastUserAction = isset($_SESSION['last_action']) && $_SESSION['last_action'] != '1970-01-01 00:00:00' ? $_SESSION['last_action'] : date('Y-m-d H:i:s');
    $template->assign('lastUserAction', $lastUserAction);
    // Manage the search box and search results
    $searchBox = new CourseSearchBox($_SERVER['REQUEST_URI']);
    $template->assign('searchBox', $searchBox);
    if (claro_is_user_authenticated()) {
        // User course (activated and deactivated) lists and search results (if any)
        if (empty($_REQUEST['viewCategory'])) {
            $courseTreeView = CourseTreeNodeViewFactory::getUserCourseTreeView(claro_get_current_user_id());
        } else {
            $courseTreeView = CourseTreeNodeViewFactory::getUserCategoryCourseTreeView(claro_get_current_user_id(), $_REQUEST['viewCategory']);
        }
        $template->assign('templateMyCourses', $courseTreeView);
        // User commands
Esempio n. 2
0
/**
 * Generate the cache php file with the needed include of activated module of the platform.
 * @return boolean true if succeed, false on failure
 */
function generate_module_cache()
{
    $module_cache_filename = get_conf('module_cache_filename', 'moduleCache.inc.php');
    $cacheRepositorySys = get_path('rootSys') . get_conf('cacheRepository', 'tmp/cache/');
    $module_cache_filepath = $cacheRepositorySys . $module_cache_filename;
    if (!file_exists($cacheRepositorySys)) {
        claro_mkdir($cacheRepositorySys, CLARO_FILE_PERMISSIONS, true);
    }
    $tbl = claro_sql_get_main_tbl();
    $sql = "SELECT `label`\n              FROM `" . $tbl['module'] . "`\n             WHERE activation = 'activated'";
    $module_list = claro_sql_query_fetch_all($sql);
    if (file_exists($cacheRepositorySys) && is_writable($cacheRepositorySys)) {
        if (file_exists($module_cache_filepath) && !is_writable($module_cache_filepath)) {
            return claro_failure::set_failure('cannot write to cache file ' . $module_cache_filepath);
        } else {
            if (false !== ($handle = fopen($module_cache_filepath, 'w'))) {
                $cache = '<?php #auto created by claroline modify it at your own risks' . "\n";
                $cache .= 'if (count( get_included_files() ) == 1) die();' . "\n";
                $cache .= "\n" . '# ---- start of cache ----' . "\n\n";
                foreach ($module_list as $module) {
                    $functionsFilePath = get_module_path($module['label']) . '/functions.php';
                    if (file_exists($functionsFilePath)) {
                        $cache .= '# ' . $module['label'] . "\n";
                        $cache .= 'if (file_exists(get_module_path("' . addslashes($module['label']) . '")."/functions.php") ){' . "\n";
                        $cache .= 'set_current_module_label("' . addslashes($module['label']) . '");' . "\n";
                        $cache .= 'load_module_config("' . addslashes($module['label']) . '");' . "\n";
                        $cache .= 'language::load_module_translation("' . addslashes($module['label']) . '","' . language::current_language() . '");' . "\n";
                        $cache .= 'require get_module_path("' . addslashes($module['label']) . '")."/functions.php";' . "\n";
                        $cache .= 'clear_current_module_label();' . "\n";
                        $cache .= '}' . "\n";
                    }
                }
                $cache .= "\n";
                fwrite($handle, $cache);
                fclose($handle);
            } else {
                return claro_failure::set_failure('Cannot open path %path', array('%path' => $module_cache_filepath));
            }
        }
    } else {
        // FIXME E_USER_ERROR instead of E_USER_NOTICE
        return claro_failure::set_failure('Directory %directory is not writable', array('%directory' => $cacheRepositorySys));
    }
    generate_module_names_translation_cache();
    return true;
}
Esempio n. 3
0
 public static function load_module_translation($moduleLabel = null, $language = null)
 {
     global $_lang;
     $moduleLabel = is_null($moduleLabel) ? get_current_module_label() : $moduleLabel;
     // In a module
     if (!empty($moduleLabel)) {
         $module_path = get_module_path($moduleLabel);
         $language = is_null($language) ? language::current_language() : $language;
         // load english by default if exists
         if (file_exists($module_path . '/lang/lang_english.php')) {
             /* FIXME : DEPRECATED !!!!! */
             $mod_lang = array();
             include $module_path . '/lang/lang_english.php';
             $_lang = array_merge($_lang, $mod_lang);
             if (claro_debug_mode()) {
                 pushClaroMessage(__FUNCTION__ . "::" . $moduleLabel . '::' . 'English lang file loaded', 'debug');
             }
         } else {
             // no language file to load
             if (claro_debug_mode()) {
                 pushClaroMessage(__FUNCTION__ . "::" . $moduleLabel . '::' . 'English lang file  not found', 'debug');
             }
         }
         // load requested language if exists
         if ($language != 'english' && file_exists($module_path . '/lang/lang_' . $language . '.php')) {
             /* FIXME : CODE DUPLICATION see 263-274 !!!!! */
             /* FIXME : DEPRECATED !!!!! */
             $mod_lang = array();
             include $module_path . '/lang/lang_' . $language . '.php';
             $_lang = array_merge($_lang, $mod_lang);
             if (claro_debug_mode()) {
                 pushClaroMessage(__FUNCTION__ . "::" . $moduleLabel . '::' . ucfirst($language) . ' lang file loaded', 'debug');
             }
         } elseif ($language != 'english') {
             // no language file to load
             if (claro_debug_mode()) {
                 pushClaroMessage(__FUNCTION__ . "::" . $moduleLabel . '::' . ucfirst($language) . ' lang file  not found', 'debug');
             }
         } else {
             // nothing to do
         }
     } else {
         // Not in a module
     }
 }
Esempio n. 4
0
/**
 * Get html select box for a user language preference
 *
 * @return string html
 * @since 1.8
 */
function user_display_preferred_language_select_box()
{
    $language_list = get_language_to_display_list();
    $form = '';
    if (is_array($language_list) && count($language_list) > 1) {
        // get the the current language
        $user_language = language::current_language();
        // build language selector form
        $form .= claro_html_form_select('language', $language_list, $user_language, array('id' => 'language_selector'));
    }
    return $form;
}