/**
  * Return the homepage, including announcements
  * @return string The portal's homepage as an HTML string
  * @assert () != ''
  */
 public function returnHomePage()
 {
     // Including the page for the news
     $html = null;
     $home = api_get_path(SYS_DATA_PATH) . api_get_home_path();
     $home_top_temp = null;
     if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\\.html$/', $_GET['include'])) {
         $open = @(string) file_get_contents(api_get_path(SYS_PATH) . $home . $_GET['include']);
         $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
     } else {
         $user_selected_language = api_get_user_language();
         if (!file_exists($home . 'home_news_' . $user_selected_language . '.html')) {
             if (file_exists($home . 'home_top.html')) {
                 $home_top_temp = file($home . 'home_top.html');
             } else {
                 //$home_top_temp = file('home/'.'home_top.html');
             }
             if (!empty($home_top_temp)) {
                 $home_top_temp = implode('', $home_top_temp);
             }
         } else {
             if (file_exists($home . 'home_top_' . $user_selected_language . '.html')) {
                 $home_top_temp = file_get_contents($home . 'home_top_' . $user_selected_language . '.html');
             } else {
                 $home_top_temp = file_get_contents($home . 'home_top.html');
             }
         }
         if (empty($home_top_temp) && api_is_platform_admin()) {
             $home_top_temp = get_lang('PortalHomepageDefaultIntroduction');
         }
         $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
         if (!empty($open)) {
             $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
         }
     }
     return $html;
 }
Exemple #2
0
/**
 * Displays a combo box so the user can select his/her preferred language.
 * @param string The desired name= value for the select
 * @param bool Whether we use the JQuery Chozen library or not
 * (in some cases, like the indexing language picker, it can alter the presentation)
 * @return string
 */
function api_get_languages_combo($name = 'language')
{
    $ret = '';
    // Retrieve a complete list of all the languages.
    $languages = api_get_languages();
    if (count($languages) < 2) {
        return $ret;
    }
    $default = api_get_user_language();
    $ret .= '<select name="' . $name . '" id="language_chosen">';
    foreach ($languages as $iso => $value) {
        if ($iso == $default) {
            $selected = ' selected="selected"';
        } else {
            $selected = '';
        }
        $ret .= sprintf('<option value=%s" %s>%s</option>', $iso, $selected, $value);
    }
    $ret .= '</select>';
    return $ret;
}
Exemple #3
0
 /**
  * @return null|string
  */
 public function returnMenu()
 {
     return null;
     $navigation = $this->navigation_array;
     $navigation = $navigation['navigation'];
     // Displaying the tabs
     $lang = api_get_user_language();
     // Preparing home folder for multiple urls
     if (api_get_multiple_access_url()) {
         $access_url_id = api_get_current_access_url_id();
         if ($access_url_id != -1) {
             $url_info = api_get_current_access_url_info();
             $url = api_remove_trailing_slash(preg_replace('/https?:\\/\\//i', '', $url_info['url']));
             $clean_url = api_replace_dangerous_char($url);
             $clean_url = str_replace('/', '-', $clean_url);
             $clean_url .= '/';
             $homep = $this->app['path.data'] . 'home/' . $clean_url;
             //homep for Home Path
             //we create the new dir for the new sites
             if (!is_dir($homep)) {
                 mkdir($homep, api_get_permissions_for_new_directories());
             }
         }
     } else {
         $homep = $this->app['path.data'] . 'home/';
     }
     $ext = '.html';
     $menutabs = 'home_tabs';
     $home_top = '';
     if (is_file($homep . $menutabs . '_' . $lang . $ext) && is_readable($homep . $menutabs . '_' . $lang . $ext)) {
         $home_top = @(string) file_get_contents($homep . $menutabs . '_' . $lang . $ext);
     } elseif (is_file($homep . $menutabs . $lang . $ext) && is_readable($homep . $menutabs . $lang . $ext)) {
         $home_top = @(string) file_get_contents($homep . $menutabs . $lang . $ext);
     }
     $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top)));
     $open = str_replace('{rel_path}', $this->app['path.data'], $home_top);
     $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
     $lis = '';
     if (!empty($open)) {
         if (strpos($open, 'show_menu') === false) {
             if (api_is_anonymous()) {
                 $navigation[SECTION_CAMPUS] = null;
             }
         } else {
             $lis .= $open;
         }
     }
     if (count($navigation) > 0 || !empty($lis)) {
         $pre_lis = '';
         foreach ($navigation as $section => $navigation_info) {
             if (isset($GLOBALS['this_section'])) {
                 $current = $section == $GLOBALS['this_section'] ? ' id="current" class="active" ' : '';
             } else {
                 $current = '';
             }
             if (!empty($navigation_info['title'])) {
                 $pre_lis .= '<li' . $current . ' ><a  href="' . $navigation_info['url'] . '" target="_top">' . $navigation_info['title'] . '</a></li>';
             }
         }
         $lis = $pre_lis . $lis;
     }
     $menu = null;
     if (!empty($lis)) {
         $menu .= $lis;
     }
     return $menu;
 }
Exemple #4
0
function api_get_language_interface()
{
    $valid_languages = api_get_languages();
    $user_language = api_get_user_language();
    $courseInfo = api_get_course_info();
    $language_interface = 'english';
    $languageFromLogin = api_get_language_selected_in_login();
    if (!empty($languageFromLogin)) {
        $language_interface = $languageFromLogin;
    }
    if (!empty($valid_languages)) {
        // User language or platform lang
        //platformLanguage
        //if (!empty($user_language)) {
        $language_interface = $user_language;
        //}
        // Course language
        if (!empty($courseInfo) && isset($courseInfo['language'])) {
            $language_interface = $courseInfo['language'];
        }
        //error_log('$language_interface: '.$language_interface);
        // Lang priorities could be: course_lang, user_profil_lang, user_selected_lang , platform_lang
        $language_priority1 = api_get_setting('languagePriority1');
        $language_priority2 = api_get_setting('languagePriority2');
        $language_priority3 = api_get_setting('languagePriority3');
        $language_priority4 = api_get_setting('languagePriority4');
        /*error_log('$language_interface1: '.$language_priority1);
          error_log('$language_interface2: '.$language_priority2);
          error_log('$language_interface3: '.$language_priority3);
          error_log('$language_interface4: '.$language_priority4);*/
        if (!empty($language_priority4) && api_get_language_from_type($language_priority4) !== false) {
            $language_interface = api_get_language_from_type($language_priority4);
        }
        if (!empty($language_priority3) && api_get_language_from_type($language_priority3) !== false) {
            $language_interface = api_get_language_from_type($language_priority3);
        }
        if (!empty($language_priority2) && api_get_language_from_type($language_priority2) !== false) {
            $language_interface = api_get_language_from_type($language_priority2);
        }
        if (!empty($language_priority1) && api_get_language_from_type($language_priority1) !== false) {
            $language_interface = api_get_language_from_type($language_priority1);
        }
        // If user lang is not valid get the default platform lang
        if (empty($language_interface) || !in_array($language_interface, $valid_languages['folder'])) {
            $language_interface = api_get_setting('platformLanguage');
        }
    }
    return $language_interface;
}
/* INIT SECTION */
// Language files that need to be included.
$language_file = array('admin', 'agenda', 'announcements');
// Resetting the course id.
$cidReset = true;
// Setting the section (for the tabs).
$this_section = SECTION_PLATFORM_ADMIN;
$_SESSION['this_section'] = $this_section;
$action = isset($_GET['action']) ? $_GET['action'] : null;
// Access restrictions
api_protect_admin_script(true);
// Setting breadcrumbs.
$interbreadcrumb[] = array("url" => 'index.php', "name" => get_lang('PlatformAdmin'));
$tool_name = null;
if (empty($_GET['lang'])) {
    $_GET['lang'] = api_get_user_language();
}
$usergroup = new UserGroup();
if (!empty($action)) {
    $interbreadcrumb[] = array("url" => "system_announcements.php", "name" => get_lang('SystemAnnouncements'));
    if ($action == 'add') {
        $interbreadcrumb[] = array("url" => '#', "name" => get_lang('AddAnnouncement'));
    }
    if ($action == 'edit') {
        $interbreadcrumb[] = array("url" => '#', "name" => get_lang('Edit'));
    }
} else {
    $tool_name = get_lang('SystemAnnouncements');
}
// Displaying the header.
Display::display_header($tool_name);