skala
Julio Montoya 16 years ago
commit 3e78b58d8a
  1. 252
      main/admin/configure_homepage.php
  2. 38
      main/inc/lib/internationalization.lib.php
  3. 2
      main/inc/lib/internationalization_database/conversion/character_map_selector.php
  4. 1
      main/inc/lib/internationalization_database/language_detection/update_language_profiles.php
  5. 3
      main/inc/lib/internationalization_database/name_order_conventions.php
  6. 4
      main/inc/lib/internationalization_database/non_utf8_encodings.php
  7. 30
      main/inc/lib/internationalization_internal.lib.php
  8. 2
      tests/main/gradebook/lib/be/category.class.test.php
  9. 2
      tests/test_manager.inc.php
  10. 12
      tests/test_suite.php

@ -1,29 +1,6 @@
<?php // $Id: configure_homepage.php 22243 2009-07-20 15:08:31Z ivantcholakov $ <?php
/* /* For licensing terms, see /license.txt */
==============================================================================
Dokeos - elearning and course management software
Copyright (c) 2004-2009 Dokeos SPRL
Copyright (c) 2003 Ghent University (UGent)
Copyright (c) 2001 Universite catholique de Louvain (UCL)
Copyright (c) Olivier Brouckaert
For a full list of contributors, see "credits.txt".
The full license can be read in "license.txt".
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
See the GNU General Public License for more details.
Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
Mail: info@dokeos.com
==============================================================================
*/
// name of the language file that needs to be included
$language_file = array('admin', 'accessibility'); $language_file = array('admin', 'accessibility');
$cidReset = true; $cidReset = true;
@ -35,40 +12,40 @@ $_SESSION['this_section']=$this_section;
$this_page = ''; $this_page = '';
api_protect_admin_script(); api_protect_admin_script();
require_once(api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php'); require_once api_get_path(LIBRARY_PATH).'WCAG/WCAG_rendering.php';
require_once(api_get_path(LIBRARY_PATH).'fileUpload.lib.php'); require_once api_get_path(LIBRARY_PATH).'fileUpload.lib.php';
require_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once(api_get_path(LIBRARY_PATH).'security.lib.php'); require_once api_get_path(LIBRARY_PATH).'security.lib.php';
$action = Security::remove_XSS($_GET['action']); $action = Security::remove_XSS($_GET['action']);
$tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY); $tbl_category = Database::get_main_table(TABLE_MAIN_CATEGORY);
$tool_name = get_lang('ConfigureHomePage'); $tool_name = get_lang('ConfigureHomePage');
$interbreadcrumb[]=array('url' => 'index.php',"name" => get_lang('PlatformAdmin')); $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
if (!empty($action)) { if (!empty($action)) {
$interbreadcrumb[]=array('url' => 'configure_homepage.php',"name" => get_lang('ConfigureHomePage')); $interbreadcrumb[] = array('url' => 'configure_homepage.php', 'name' => get_lang('ConfigureHomePage'));
switch ($action) { switch ($action) {
case "edit_top": case 'edit_top':
$tool_name=get_lang("EditHomePage"); $tool_name = get_lang('EditHomePage');
break; break;
case "edit_news": case 'edit_news':
$tool_name=get_lang("EditNews"); $tool_name = get_lang('EditNews');
break; break;
case "edit_notice": case 'edit_notice':
$tool_name=get_lang("EditNotice"); $tool_name = get_lang('EditNotice');
break; break;
case "insert_link": case 'insert_link':
$tool_name=get_lang("InsertLink"); $tool_name = get_lang('InsertLink');
break; break;
case "edit_link": case 'edit_link':
$tool_name=get_lang("EditLink"); $tool_name = get_lang('EditLink');
break; break;
case "insert_tabs": case 'insert_tabs':
$tool_name=get_lang("InsertTabs"); $tool_name = get_lang('InsertTabs');
break; break;
case "edit_tabs": case 'edit_tabs':
$tool_name=get_lang("EditTabs"); $tool_name = get_lang('EditTabs');
break; break;
} }
} }
@ -102,12 +79,10 @@ if(!empty($_SESSION['user_language_choice'])) {
// ----- Ensuring availability of main files in the corresponding language ----- // ----- Ensuring availability of main files in the corresponding language -----
if ($_configuration['multiple_access_urls']==true) { if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id(); $access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1) { if ($access_url_id != -1) {
$url_info = api_get_access_url($access_url_id); $url_info = api_get_access_url($access_url_id);
// "http://" and the final "/" replaced
//$url = substr($url_info['url'],7,strlen($url_info['url'])-8);
$url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url'])); $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url']));
$clean_url = replace_dangerous_char($url); $clean_url = replace_dangerous_char($url);
$clean_url = str_replace('/','-',$clean_url); $clean_url = str_replace('/','-',$clean_url);
@ -138,7 +113,7 @@ $homef = array($menuf,$newsf,$topf,$noticef,$menutabs);
// If language-specific file does not exist, create it by copying default file // If language-specific file does not exist, create it by copying default file
foreach ($homef as $my_file) { foreach ($homef as $my_file) {
if ($_configuration['multiple_access_urls']==true) { if ($_configuration['multiple_access_urls']) {
if (!file_exists($homep_new.$my_file.'_'.$lang.$ext)) { if (!file_exists($homep_new.$my_file.'_'.$lang.$ext)) {
copy($homep.$my_file.$ext,$homep_new.$my_file.'_'.$lang.$ext); copy($homep.$my_file.$ext,$homep_new.$my_file.'_'.$lang.$ext);
} }
@ -148,7 +123,7 @@ foreach($homef as $my_file) {
} }
} }
} }
if ($_configuration['multiple_access_urls']==true) { if ($_configuration['multiple_access_urls']) {
$homep = $homep_new; $homep = $homep_new;
} }
@ -174,7 +149,7 @@ global $_configuration;
// Start analysing requested actions // Start analysing requested actions
if (!empty($action)) { if (!empty($action)) {
if ($_POST['formSent']) { if ($_POST['formSent']) {
//variables used are $homep for home path, $menuf for menu file, $newsf // Variables used are $homep for home path, $menuf for menu file, $newsf
// for news file, $topf for top file, $noticef for noticefile, // for news file, $topf for top file, $noticef for noticefile,
// $ext for '.html' // $ext for '.html'
switch ($action) { switch ($action) {
@ -190,7 +165,7 @@ if(!empty($action)) {
// Write // Write
if (file_exists($homep.$topf.'_'.$lang.$ext)) { if (file_exists($homep.$topf.'_'.$lang.$ext)) {
if (is_writable($homep.$topf.'_'.$lang.$ext)) { if (is_writable($homep.$topf.'_'.$lang.$ext)) {
$fp=fopen($homep.$topf.'_'.$lang.$ext,"w"); $fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
fputs($fp, $home_top); fputs($fp, $home_top);
fclose($fp); fclose($fp);
} else { } else {
@ -198,7 +173,7 @@ if(!empty($action)) {
} }
} else { } else {
//File does not exist //File does not exist
$fp=fopen($homep.$topf.'_'.$lang.$ext,"w"); $fp = fopen($homep.$topf.'_'.$lang.$ext, 'w');
fputs($fp, $home_top); fputs($fp, $home_top);
fclose($fp); fclose($fp);
} }
@ -207,26 +182,18 @@ if(!empty($action)) {
case 'edit_notice': case 'edit_notice':
// Filter // Filter
$notice_title = trim(strip_tags(stripslashes($_POST['notice_title']))); $notice_title = trim(strip_tags(stripslashes($_POST['notice_title'])));
$notice_text=trim(str_replace(array("\r","\n"),array("","<br />"),strip_tags(stripslashes($_POST['notice_text']),'<a>'))); $notice_text = trim(str_replace(array("\r", "\n"), array('', '<br />'), strip_tags(stripslashes($_POST['notice_text']), '<a>')));
/*if(empty($notice_title))
{
$errorMsg=get_lang('PleaseEnterNoticeTitle');
}
elseif(empty($notice_text))
{
$errorMsg=get_lang('PleaseEnterNoticeText');
}*/
if (empty($notice_title) || empty($notice_text)) { if (empty($notice_title) || empty($notice_text)) {
$errorMsg = get_lang('NoticeWillBeNotDisplayed'); $errorMsg = get_lang('NoticeWillBeNotDisplayed');
} }
// Write // Write
if (file_exists($homep.$noticef.'_'.$lang.$ext)) { if (file_exists($homep.$noticef.'_'.$lang.$ext)) {
if (is_writable($homep.$noticef.'_'.$lang.$ext)) { if (is_writable($homep.$noticef.'_'.$lang.$ext)) {
$fp=fopen($homep.$noticef.'_'.$lang.$ext,"w"); $fp = fopen($homep.$noticef.'_'.$lang.$ext, 'w');
if ($errorMsg == '') { if ($errorMsg == '') {
fputs($fp, "<b>$notice_title</b><br />\n$notice_text"); fputs($fp, "<b>$notice_title</b><br />\n$notice_text");
} else { } else {
fputs($fp,""); fputs($fp, '');
} }
fclose($fp); fclose($fp);
} else { } else {
@ -234,60 +201,51 @@ if(!empty($action)) {
} }
} else { } else {
//File does not exist //File does not exist
$fp=fopen($homep.$noticef.'_'.$lang.$ext,"w"); $fp = fopen($homep.$noticef.'_'.$lang.$ext, 'w');
fputs($fp, "<b>$notice_title</b><br />\n$notice_text"); fputs($fp, "<b>$notice_title</b><br />\n$notice_text");
fclose($fp); fclose($fp);
} }
break; break;
case 'edit_news': case 'edit_news':
//Filter //Filter
//$s_languages_news=$_POST["news_languages"]; //$s_languages_news=$_POST["news_languages"]; // TODO: Why this line has been disabled?
if (api_get_setting('wcag_anysurfer_public_pages') == 'true') { if (api_get_setting('wcag_anysurfer_public_pages') == 'true') {
$home_news = WCAG_rendering::prepareXHTML(); $home_news = WCAG_rendering::prepareXHTML();
} else { } else {
$home_news = trim(stripslashes($_POST['home_news'])); $home_news = trim(stripslashes($_POST['home_news']));
} }
//Write //Write
if($s_languages_news!="all"){ if ($s_languages_news != 'all') {
if (file_exists($homep.$newsf.'_'.$s_languages_news.$ext)) { if (file_exists($homep.$newsf.'_'.$s_languages_news.$ext)) {
if (is_writable($homep.$newsf.'_'.$s_languages_news.$ext)) { if (is_writable($homep.$newsf.'_'.$s_languages_news.$ext)) {
$fp=fopen($homep.$newsf.'_'.$s_languages_news.$ext,"w"); $fp = fopen($homep.$newsf.'_'.$s_languages_news.$ext, 'w');
fputs($fp, $home_news); fputs($fp, $home_news);
fclose($fp); fclose($fp);
} } else {
else{
$errorMsg = get_lang('HomePageFilesNotWritable'); $errorMsg = get_lang('HomePageFilesNotWritable');
} }
} } else {
//File not exists // File does not exist
else{ $fp = fopen($homep.$newsf.'_'.$s_languages_news.$ext, 'w');
$fp=fopen($homep.$newsf.'_'.$s_languages_news.$ext,"w");
fputs($fp, $home_news); fputs($fp, $home_news);
fclose($fp); fclose($fp);
} }
} } else {
else //we update all the news file // We update all the news file
{
$_languages = api_get_languages(); $_languages = api_get_languages();
foreach ($_languages["name"] as $key => $value) { foreach ($_languages["name"] as $key => $value) {
$english_name = $_languages["folder"][$key]; $english_name = $_languages["folder"][$key];
if (file_exists($homep.$newsf.'_'.$english_name.$ext)) { if (file_exists($homep.$newsf.'_'.$english_name.$ext)) {
if (is_writable($homep.$newsf.'_'.$english_name.$ext)) { if (is_writable($homep.$newsf.'_'.$english_name.$ext)) {
$fp=fopen($homep.$newsf.'_'.$english_name.$ext,"w"); $fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
fputs($fp, $home_news); fputs($fp, $home_news);
fclose($fp); fclose($fp);
} } else {
else{
$errorMsg = get_lang('HomePageFilesNotWritable'); $errorMsg = get_lang('HomePageFilesNotWritable');
} }
} } else {
//File not exists // File does not exist
else{ $fp = fopen($homep.$newsf.'_'.$english_name.$ext, 'w');
$fp=fopen($homep.$newsf.'_'.$english_name.$ext,"w");
fputs($fp, $home_news); fputs($fp, $home_news);
fclose($fp); fclose($fp);
} }
@ -313,15 +271,13 @@ if(!empty($action)) {
if ($link_url == 'http://') { if ($link_url == 'http://') {
$link_url = ''; $link_url = '';
} } elseif (!empty($link_url) && !strstr($link_url,'://')) {
elseif(!empty($link_url) && !strstr($link_url,'://')) {
$link_url='http://'.$link_url; $link_url='http://'.$link_url;
} }
$menuf = ($action == 'insert_tabs' || $action == 'edit_tabs')? $menutabs : $menuf; $menuf = ($action == 'insert_tabs' || $action == 'edit_tabs')? $menutabs : $menuf;
if (!is_writable($homep.$menuf.'_'.$lang.$ext)) { if (!is_writable($homep.$menuf.'_'.$lang.$ext)) {
$errorMsg = get_lang('HomePageFilesNotWritable'); $errorMsg = get_lang('HomePageFilesNotWritable');
} } elseif (empty($link_name)) {
elseif(empty($link_name)) {
$errorMsg = get_lang('PleaseEnterLinkName'); $errorMsg = get_lang('PleaseEnterLinkName');
} else { } else {
// New links are added as new files in the home/ directory // New links are added as new files in the home/ directory
@ -355,10 +311,8 @@ if(!empty($action)) {
// fill it with default text // fill it with default text
if (!file_exists(api_get_path(SYS_PATH).'home/'.$filename)) { if (!file_exists(api_get_path(SYS_PATH).'home/'.$filename)) {
$fp = @fopen(api_get_path(SYS_PATH).'home/'.$filename, 'w'); $fp = @fopen(api_get_path(SYS_PATH).'home/'.$filename, 'w');
if ($fp) { if ($fp) {
fputs($fp, get_lang('MyTextHere')); fputs($fp, get_lang('MyTextHere'));
fclose($fp); fclose($fp);
} }
} }
@ -367,7 +321,6 @@ if(!empty($action)) {
// write to it (if the file doesn't exist, create it) // write to it (if the file doesn't exist, create it)
if ($action == 'edit_link' && !empty($link_html)) { if ($action == 'edit_link' && !empty($link_html)) {
$fp = @fopen(api_get_path(SYS_PATH).'home/'.$filename, 'w'); $fp = @fopen(api_get_path(SYS_PATH).'home/'.$filename, 'w');
if ($fp) { if ($fp) {
fputs($fp, $link_html); fputs($fp, $link_html);
fclose($fp); fclose($fp);
@ -384,11 +337,9 @@ if(!empty($action)) {
break; break;
} }
} }
$home_menu[$insert_where + 1] = '<li><a href="'.$link_url.'" target="'.($target_blank ? '_blank' : '_self').'"><span>'.$link_name.'</span></a></li>'; $home_menu[$insert_where + 1] = '<li><a href="'.$link_url.'" target="'.($target_blank ? '_blank' : '_self').'"><span>'.$link_name.'</span></a></li>';
} } else {
else // If the request is about a link edition, change the link // If the request is about a link edition, change the link
{
$home_menu[$link_index]='<li><a href="'.$link_url.'" target="'.($target_blank?'_blank':'_self').'"><span>'.$link_name.'</span></a></li>'; $home_menu[$link_index]='<li><a href="'.$link_url.'" target="'.($target_blank?'_blank':'_self').'"><span>'.$link_name.'</span></a></li>';
} }
// Re-build the file from the home_menu array // Re-build the file from the home_menu array
@ -396,24 +347,22 @@ if(!empty($action)) {
// Write // Write
if (file_exists($homep.$menuf.'_'.$lang.$ext)) { if (file_exists($homep.$menuf.'_'.$lang.$ext)) {
if (is_writable($homep.$menuf.'_'.$lang.$ext)) { if (is_writable($homep.$menuf.'_'.$lang.$ext)) {
$fp=fopen($homep.$menuf.'_'.$lang.$ext,"w"); $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
fputs($fp, $home_menu); fputs($fp, $home_menu);
fclose($fp); fclose($fp);
if (file_exists($homep.$menuf.$ext)) { if (file_exists($homep.$menuf.$ext)) {
if (is_writable($homep.$menuf.$ext)) { if (is_writable($homep.$menuf.$ext)) {
$fpo=fopen($homep.$menuf.$ext,"w"); $fpo = fopen($homep.$menuf.$ext, 'w');
fputs($fpo, $home_menu); fputs($fpo, $home_menu);
fclose($fpo); fclose($fpo);
} }
} }
} else { } else {
$errorMsg = get_lang('HomePageFilesNotWritable'); $errorMsg = get_lang('HomePageFilesNotWritable');
} }
} } else {
else //File does not exist //File does not exist
{ $fp = fopen($homep.$menuf.'_'.$lang.$ext, 'w');
$fp=fopen($homep.$menuf.'_'.$lang.$ext,"w");
fputs($fp, $home_menu); fputs($fp, $home_menu);
fclose($fp); fclose($fp);
} }
@ -479,18 +428,11 @@ if(!empty($action)) {
case 'edit_notice': case 'edit_notice':
// This request is only the preparation for the update of the home_notice // This request is only the preparation for the update of the home_notice
$home_notice = ''; $home_notice = '';
if(is_file($homep.$noticef.'_'.$lang.$ext) if (is_file($homep.$noticef.'_'.$lang.$ext) && is_readable($homep.$noticef.'_'.$lang.$ext)) {
&& is_readable($homep.$noticef.'_'.$lang.$ext))
{
$home_notice = file($homep.$noticef.'_'.$lang.$ext); $home_notice = file($homep.$noticef.'_'.$lang.$ext);
} } elseif (is_file($homep.$noticef.$lang.$ext) && is_readable($homep.$noticef.$lang.$ext)) {
elseif(is_file($homep.$noticef.$lang.$ext)
&& is_readable($homep.$noticef.$lang.$ext))
{
$home_notice = file($homep.$noticef.$lang.$ext); $home_notice = file($homep.$noticef.$lang.$ext);
} } else {
else
{
$errorMsg = get_lang('HomePageFilesNotReadable'); $errorMsg = get_lang('HomePageFilesNotReadable');
} }
if (empty($home_notice)) { if (empty($home_notice)) {
@ -499,25 +441,16 @@ if(!empty($action)) {
$notice_title = strip_tags($home_notice[0]); $notice_title = strip_tags($home_notice[0]);
$notice_title = api_to_system_encoding($notice_title, api_detect_encoding($notice_title)); $notice_title = api_to_system_encoding($notice_title, api_detect_encoding($notice_title));
$notice_text = strip_tags(str_replace('<br />', "\n", $home_notice[1]), '<a>'); $notice_text = strip_tags(str_replace('<br />', "\n", $home_notice[1]), '<a>');
$notice_text = api_to_system_encoding($notice_text, api_detect_encoding($notice_text)); $notice_text = api_to_system_encoding($notice_text, api_detect_encoding(strip_tags($notice_text)));
break; break;
case 'edit_news': case 'edit_news':
// This request is the preparation for the update of the home_news page // This request is the preparation for the update of the home_news page
$home_news = ''; $home_news = '';
if(is_file($homep.$newsf.'_'.$lang.$ext) if (is_file($homep.$newsf.'_'.$lang.$ext) && is_readable($homep.$newsf.'_'.$lang.$ext)) {
&& is_readable($homep.$newsf.'_'.$lang.$ext))
{
$home_news = file_get_contents($homep.$newsf.'_'.$lang.$ext); $home_news = file_get_contents($homep.$newsf.'_'.$lang.$ext);
// $home_news=file($homep.$newsf.$ext); } elseif (is_file($homep.$newsf.$lang.$ext) && is_readable($homep.$newsf.$lang.$ext)) {
// $home_news=implode('',$home_news);
}
elseif(is_file($homep.$newsf.$lang.$ext)
&& is_readable($homep.$newsf.$lang.$ext))
{
$home_news = file_get_contents($homep.$newsf.$lang.$ext); $home_news = file_get_contents($homep.$newsf.$lang.$ext);
} } else {
else
{
$errorMsg = get_lang('HomePageFilesNotReadable'); $errorMsg = get_lang('HomePageFilesNotReadable');
} }
$home_news = api_to_system_encoding($home_news, api_detect_encoding(strip_tags($home_news))); $home_news = api_to_system_encoding($home_news, api_detect_encoding(strip_tags($home_news)));
@ -526,18 +459,11 @@ if(!empty($action)) {
// This request is the preparation for the addition of an item in home_menu // This request is the preparation for the addition of an item in home_menu
$home_menu = ''; $home_menu = '';
$menuf = ($action == 'edit_tabs')? $menutabs : $menuf; $menuf = ($action == 'edit_tabs')? $menutabs : $menuf;
if(is_file($homep.$menuf.'_'.$lang.$ext) if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
&& is_readable($homep.$menuf.'_'.$lang.$ext))
{
$home_menu = file($homep.$menuf.'_'.$lang.$ext); $home_menu = file($homep.$menuf.'_'.$lang.$ext);
} } elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
elseif(is_file($homep.$menuf.$lang.$ext)
&& is_readable($homep.$menuf.$lang.$ext))
{
$home_menu = file($homep.$menuf.$lang.$ext); $home_menu = file($homep.$menuf.$lang.$ext);
} } else {
else
{
$errorMsg = get_lang('HomePageFilesNotReadable'); $errorMsg = get_lang('HomePageFilesNotReadable');
} }
if (empty($home_menu)) { if (empty($home_menu)) {
@ -552,18 +478,11 @@ if(!empty($action)) {
case 'insert_tabs': case 'insert_tabs':
// This request is the preparation for the addition of an item in home_menu // This request is the preparation for the addition of an item in home_menu
$home_menu = ''; $home_menu = '';
if(is_file($homep.$menutabs.'_'.$lang.$ext) if (is_file($homep.$menutabs.'_'.$lang.$ext) && is_readable($homep.$menutabs.'_'.$lang.$ext)) {
&& is_readable($homep.$menutabs.'_'.$lang.$ext))
{
$home_menu = file($homep.$menutabs.'_'.$lang.$ext); $home_menu = file($homep.$menutabs.'_'.$lang.$ext);
} } elseif (is_file($homep.$menutabs.$lang.$ext) && is_readable($homep.$menutabs.$lang.$ext)) {
elseif(is_file($homep.$menutabs.$lang.$ext)
&& is_readable($homep.$menutabs.$lang.$ext))
{
$home_menu = file($homep.$menutabs.$lang.$ext); $home_menu = file($homep.$menutabs.$lang.$ext);
} } else {
else
{
$errorMsg = get_lang('HomePageFilesNotReadable'); $errorMsg = get_lang('HomePageFilesNotReadable');
} }
if (empty($home_menu)) { if (empty($home_menu)) {
@ -580,18 +499,11 @@ if(!empty($action)) {
// This request is the preparation for the edition of the links array // This request is the preparation for the edition of the links array
$home_menu = ''; $home_menu = '';
$menuf = ($action == 'edit_tabs')? $menutabs : $menuf; $menuf = ($action == 'edit_tabs')? $menutabs : $menuf;
if(is_file($homep.$menuf.'_'.$lang.$ext) if (is_file($homep.$menuf.'_'.$lang.$ext) && is_readable($homep.$menuf.'_'.$lang.$ext)) {
&& is_readable($homep.$menuf.'_'.$lang.$ext))
{
$home_menu = file($homep.$menuf.'_'.$lang.$ext); $home_menu = file($homep.$menuf.'_'.$lang.$ext);
} } elseif(is_file($homep.$menuf.$lang.$ext) && is_readable($homep.$menuf.$lang.$ext)) {
elseif(is_file($homep.$menuf.$lang.$ext)
&& is_readable($homep.$menuf.$lang.$ext))
{
$home_menu = file($homep.$menuf.$lang.$ext); $home_menu = file($homep.$menuf.$lang.$ext);
} } else {
else
{
$errorMsg = get_lang('HomePageFilesNotReadable'); $errorMsg = get_lang('HomePageFilesNotReadable');
} }
if (empty($home_menu)) { if (empty($home_menu)) {
@ -648,11 +560,9 @@ if(!empty($action)) {
break; break;
}//end of second switch($action) (when POST['formSent'] was not set, yet) }//end of second switch($action) (when POST['formSent'] was not set, yet)
}// end of "else" in if($_POST['formSent']) condition }// end of "else" in if($_POST['formSent']) condition
} } else {
else //if $action is empty, then prepare a list of the course categories to display (?) //if $action is empty, then prepare a list of the course categories to display (?)
{ $Categories = Database::store_result(Database::query("SELECT name FROM $tbl_category WHERE parent_id IS NULL ORDER BY tree_pos"));
$result=Database::query("SELECT name FROM $tbl_category WHERE parent_id IS NULL ORDER BY tree_pos");
$Categories=Database::store_result($result);
} }
// ------------------------- // -------------------------
@ -685,7 +595,6 @@ switch($action){
Display::display_normal_message($errorMsg); Display::display_normal_message($errorMsg);
//echo '</td></tr>'; //echo '</td></tr>';
} }
?> ?>
<table border="0" cellpadding="5" cellspacing="0"> <table border="0" cellpadding="5" cellspacing="0">
@ -712,7 +621,7 @@ switch($action){
case 'edit_link': case 'edit_link':
if (!empty($errorMsg)) { if (!empty($errorMsg)) {
Display::display_normal_message($errorMsg); //main API Display::display_normal_message($errorMsg);
} }
$default = array(); $default = array();
@ -783,8 +692,8 @@ switch($action){
} else { } else {
$name = $newsf; $name = $newsf;
$open = @file_get_contents($homep.$newsf.'_'.$lang.$ext); $open = @file_get_contents($homep.$newsf.'_'.$lang.$ext);
} }
$open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open)));
if (!empty($errorMsg)) { if (!empty($errorMsg)) {
Display::display_normal_message($errorMsg); //main API Display::display_normal_message($errorMsg); //main API
@ -861,7 +770,7 @@ switch($action){
<?php <?php
$access_url_id = 1; $access_url_id = 1;
// we only show the category options for the main Dokeos installation // we only show the category options for the main Dokeos installation
if ($_configuration['multiple_access_urls']==true) { if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id(); $access_url_id = api_get_current_access_url_id();
} }
echo '<td width="50%">'; echo '<td width="50%">';
@ -1001,10 +910,5 @@ switch($action){
<?php <?php
break; break;
} }
/*
==============================================================================
FOOTER
==============================================================================
*/
Display::display_footer(); Display::display_footer();
?>

@ -1,4 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */
/** /**
* File: internationalization.lib.php * File: internationalization.lib.php
* Internationalization library for Chamilo 1.8.7 LMS * Internationalization library for Chamilo 1.8.7 LMS
@ -44,9 +46,7 @@ define ('LANGUAGE_DETECT_MAX_DELTA', 140000);
/** /**
* ----------------------------------------------------------------------------
* Initialization * Initialization
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -81,9 +81,7 @@ function api_set_internationalization_default_encoding($encoding) {
/** /**
* ----------------------------------------------------------------------------
* Language support * Language support
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -358,14 +356,12 @@ function api_is_latin1_compatible($language) {
/** /**
* ----------------------------------------------------------------------------
* Language recognition * Language recognition
* Based on the publication: * Based on the publication:
* W. B. Cavnar and J. M. Trenkle. N-gram-based text categorization. * W. B. Cavnar and J. M. Trenkle. N-gram-based text categorization.
* Proceedings of SDAIR-94, 3rd Annual Symposium on Document Analysis * Proceedings of SDAIR-94, 3rd Annual Symposium on Document Analysis
* and Information Retrieval, 1994. * and Information Retrieval, 1994.
* @link http://citeseer.ist.psu.edu/cache/papers/cs/810/http:zSzzSzwww.info.unicaen.frzSz~giguetzSzclassifzSzcavnar_trenkle_ngram.pdf/n-gram-based-text.pdf * @link http://citeseer.ist.psu.edu/cache/papers/cs/810/http:zSzzSzwww.info.unicaen.frzSz~giguetzSzclassifzSzcavnar_trenkle_ngram.pdf/n-gram-based-text.pdf
* ----------------------------------------------------------------------------
*/ */
function api_detect_language(&$string, $encoding = null) { function api_detect_language(&$string, $encoding = null) {
@ -385,9 +381,7 @@ function api_detect_language(&$string, $encoding = null) {
/** /**
* ----------------------------------------------------------------------------
* Date and time formats * Date and time formats
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -485,9 +479,7 @@ function api_get_months_long($language = null) {
/** /**
* ----------------------------------------------------------------------------
* Name order conventions * Name order conventions
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -594,9 +586,7 @@ function api_sort_by_first_name($language = null) {
/** /**
* ----------------------------------------------------------------------------
* A safe way to calculate binary lenght of a string (as number of bytes) * A safe way to calculate binary lenght of a string (as number of bytes)
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -620,9 +610,7 @@ function api_byte_count(& $string) {
/** /**
* ----------------------------------------------------------------------------
* Multibyte string conversion functions * Multibyte string conversion functions
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -1089,9 +1077,7 @@ function api_utf8_decode_xml($string, $to_encoding = null) {
/** /**
* ----------------------------------------------------------------------------
* Common multibyte string functions * Common multibyte string functions
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -2093,9 +2079,7 @@ function api_ucwords($string, $encoding = null) {
/** /**
* ----------------------------------------------------------------------------
* String operations using regular expressions * String operations using regular expressions
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -2219,9 +2203,7 @@ function api_preg_split($pattern, $subject, $limit = -1, $flags = 0, $encoding =
/** /**
* ----------------------------------------------------------------------------
* Obsolete string operations using regular expressions, to be deprecated * Obsolete string operations using regular expressions, to be deprecated
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -2428,9 +2410,7 @@ function api_split($pattern, $string, $limit = null) {
/** /**
* ----------------------------------------------------------------------------
* String comparison * String comparison
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -2507,9 +2487,7 @@ function api_strnatcmp($string1, $string2, $language = null, $encoding = null) {
/** /**
* ----------------------------------------------------------------------------
* Sorting arrays * Sorting arrays
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -2910,9 +2888,7 @@ function api_rsort(&$array, $sort_flag = SORT_REGULAR, $language = null, $encodi
/** /**
* ----------------------------------------------------------------------------
* Common sting operations with arrays * Common sting operations with arrays
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -2951,9 +2927,7 @@ function api_in_array_nocase($needle, $haystack, $strict = false, $encoding = nu
/** /**
* ----------------------------------------------------------------------------
* Encoding management functions * Encoding management functions
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -3220,9 +3194,7 @@ function api_detect_encoding_xml($string, $default_encoding = null) {
/** /**
* ----------------------------------------------------------------------------
* String validation functions concerning certain encodings * String validation functions concerning certain encodings
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -3408,9 +3380,7 @@ function api_is_valid_ascii(&$string) {
/** /**
* ----------------------------------------------------------------------------
* Parsing CSV-data. * Parsing CSV-data.
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -3498,9 +3468,7 @@ function api_fgetcsv($handle, $length = null, $delimiter = ',', $enclosure = '"'
/** /**
* ----------------------------------------------------------------------------
* Miscellaneous routines * Miscellaneous routines
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -3528,9 +3496,7 @@ function api_html_to_text($string) {
/** /**
* ----------------------------------------------------------------------------
* Functions for internal use behind this API * Functions for internal use behind this API
* ----------------------------------------------------------------------------
*/ */
require_once dirname(__FILE__).'/internationalization_internal.lib.php'; require_once dirname(__FILE__).'/internationalization_internal.lib.php';

@ -1,4 +1,6 @@
<?php <?php
/* For licensing terms, see /license.txt */
// See http://demo.icu-project.org/icu-bin/convexp // See http://demo.icu-project.org/icu-bin/convexp
return array( return array(

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */
$_current_dir = str_replace('\\', '/', realpath(dirname(__FILE__))).'/'; $_current_dir = str_replace('\\', '/', realpath(dirname(__FILE__))).'/';

@ -1,4 +1,5 @@
<?php <?php
/* For licensing terms, see /license.txt */
/** /**
* The following table contains two types of conventions concerning person names: * The following table contains two types of conventions concerning person names:
@ -14,8 +15,6 @@
* "sort_by" - determines you preferable way of sorting person names. The possible values are: * "sort_by" - determines you preferable way of sorting person names. The possible values are:
* first_name - sorting names with priority for the first name; * first_name - sorting names with priority for the first name;
* last_name - sorting names with priority for the last name. * last_name - sorting names with priority for the last name.
*
* For licensing terms, see dokeos_license.txt.
*/ */
return array( return array(
'afrikaans' => array( 'format' => 'title first_name last_name', 'sort_by' => 'first_name' ), 'afrikaans' => array( 'format' => 'title first_name last_name', 'sort_by' => 'first_name' ),

@ -1,10 +1,10 @@
<?php <?php
/* For licensing terms, see /license.txt */
/** /**
* Historical data about non UTF-8 encodings that might be used in Dokeos LMS. * Historical data about non UTF-8 encodings that might be used in Chamilo LMS.
* The following list may have some inconsistencies. * The following list may have some inconsistencies.
* Put the probably most used for your language encoding at the first place. * Put the probably most used for your language encoding at the first place.
* For licensing terms, see dokeos_license.txt.
*/ */
return array( return array(
'afrikaans' => array('ISO-8859-15', 'WINDOWS-1252'), 'afrikaans' => array('ISO-8859-15', 'WINDOWS-1252'),

@ -1,6 +1,7 @@
<?php <?php
/* For licensing terms, see /license.txt */
/** /**
* ==============================================================================
* File: internationalization_internal.lib.php * File: internationalization_internal.lib.php
* Main API extension library for Chamilo 1.8.7 LMS, * Main API extension library for Chamilo 1.8.7 LMS,
* contains functions for internal use only. * contains functions for internal use only.
@ -8,7 +9,6 @@
* @author Ivan Tcholakov, <ivantcholakov@gmail.com>, 2009, 2010 * @author Ivan Tcholakov, <ivantcholakov@gmail.com>, 2009, 2010
* @author More authors, mentioned in the correpsonding fragments of this source. * @author More authors, mentioned in the correpsonding fragments of this source.
* @package chamilo.library * @package chamilo.library
* ==============================================================================
* *
* Note: All functions and data structures here are not to be used directly. * Note: All functions and data structures here are not to be used directly.
* See the file internationalization.lib.php which contains the "public" API. * See the file internationalization.lib.php which contains the "public" API.
@ -16,9 +16,7 @@
/** /**
* ----------------------------------------------------------------------------
* Internal constants * Internal constants
* ----------------------------------------------------------------------------
*/ */
// A regular expression for accessing declared encoding within xml-formatted text. // A regular expression for accessing declared encoding within xml-formatted text.
@ -28,9 +26,7 @@ define('_PCRE_XML_ENCODING', '/<?xml.*encoding=[\'"](.*?)[\'"].*?>/m');
/** /**
* ----------------------------------------------------------------------------
* Global variables used by some callback functions * Global variables used by some callback functions
* ----------------------------------------------------------------------------
*/ */
$_api_encoding = null; $_api_encoding = null;
@ -38,9 +34,7 @@ $_api_collator = null;
/** /**
* ----------------------------------------------------------------------------
* Appendix to "Language support" * Appendix to "Language support"
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -90,14 +84,12 @@ function _api_get_latin1_compatible_languages() {
/** /**
* ----------------------------------------------------------------------------
* Appendix to "Language recognition" * Appendix to "Language recognition"
* Based on the publication: * Based on the publication:
* W. B. Cavnar and J. M. Trenkle. N-gram-based text categorization. * W. B. Cavnar and J. M. Trenkle. N-gram-based text categorization.
* Proceedings of SDAIR-94, 3rd Annual Symposium on Document Analysis * Proceedings of SDAIR-94, 3rd Annual Symposium on Document Analysis
* and Information Retrieval, 1994. * and Information Retrieval, 1994.
* @link http://citeseer.ist.psu.edu/cache/papers/cs/810/http:zSzzSzwww.info.unicaen.frzSz~giguetzSzclassifzSzcavnar_trenkle_ngram.pdf/n-gram-based-text.pdf * @link http://citeseer.ist.psu.edu/cache/papers/cs/810/http:zSzzSzwww.info.unicaen.frzSz~giguetzSzclassifzSzcavnar_trenkle_ngram.pdf/n-gram-based-text.pdf
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -222,9 +214,7 @@ function & _api_compare_n_grams(&$n_grams, $encoding, $max_delta = LANGUAGE_DETE
/** /**
* ----------------------------------------------------------------------------
* Appendix to "Date and time formats" * Appendix to "Date and time formats"
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -254,9 +244,7 @@ function &_api_get_day_month_names($language = null) {
/** /**
* ----------------------------------------------------------------------------
* Appendix to "Name order conventions" * Appendix to "Name order conventions"
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -318,9 +306,7 @@ function _api_clean_person_name($person_name) {
/** /**
* ----------------------------------------------------------------------------
* Appendix to "Multibyte string conversion functions" * Appendix to "Multibyte string conversion functions"
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -682,9 +668,7 @@ function _api_convert_encoding_xml_callback($matches) {
/** /**
* ----------------------------------------------------------------------------
* Appendix to "Common multibyte string functions" * Appendix to "Common multibyte string functions"
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -770,9 +754,7 @@ function _api_utf8_ucwords_callback($matches) {
/** /**
* ----------------------------------------------------------------------------
* Appendix to "Common sting operations with arrays" * Appendix to "Common sting operations with arrays"
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -793,9 +775,7 @@ function _api_array_utf8_decode($variable) {
/** /**
* ----------------------------------------------------------------------------
* Appendix to "String comparison" * Appendix to "String comparison"
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -925,9 +905,7 @@ function _api_get_collator_sort_flag($sort_flag = SORT_REGULAR) {
/** /**
* ----------------------------------------------------------------------------
* ICU locales (accessible through intl extension). * ICU locales (accessible through intl extension).
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -979,9 +957,7 @@ function api_get_default_locale() {
/** /**
* ----------------------------------------------------------------------------
* Appendix to "Encoding management functions" * Appendix to "Encoding management functions"
* ----------------------------------------------------------------------------
*/ */
/** /**
@ -1229,9 +1205,7 @@ function _api_html_entity_supports($encoding) {
/** /**
* ----------------------------------------------------------------------------
* Upgrading the PHP5 mbstring extension * Upgrading the PHP5 mbstring extension
* ----------------------------------------------------------------------------
*/ */
// A multibyte replacement of strchr(). This function exists in PHP 5 >= 5.2.0 // A multibyte replacement of strchr(). This function exists in PHP 5 >= 5.2.0

@ -16,7 +16,7 @@ class TestCategoryClass extends UnitTestCase {
$this->category->set_user_id(1); $this->category->set_user_id(1);
$this->category->set_course_code('COURSECATEGORYCLASS'); $this->category->set_course_code('COURSECATEGORYCLASS');
$this->category->set_certificate_min_score(20); $this->category->set_certificate_min_score(20);
$this->category->set_parent_id(1); $this->category->set_parent_id(0);
$this->category->set_session_id(1); $this->category->set_session_id(1);
$this->category->set_weight(1); $this->category->set_weight(1);
$this->category->set_visible(1); $this->category->set_visible(1);

@ -255,7 +255,7 @@ if ($handle = opendir($path)) {
----------------------------------------------------------- -----------------------------------------------------------
*/ */
if (!headers_sent()) { if (!headers_sent() && session_id() != "") {
$res=api_session_destroy(); $res=api_session_destroy();
} }
} }

@ -172,12 +172,12 @@ class TestsSuite extends TestSuite {
//$this->addFile(api_get_path(SYS_TEST_PATH).'main/forum/forumfunction.inc.test.php'); //$this->addFile(api_get_path(SYS_TEST_PATH).'main/forum/forumfunction.inc.test.php');
/**GRADEBOOK*/ /**GRADEBOOK*/
//$this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/attendancelink.class.test.php'); $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/attendancelink.class.test.php');
//$this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/category.class.test.php'); $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/category.class.test.php');
//$this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/dropboxlink.class.test.php'); $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/dropboxlink.class.test.php');
//$this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/evaluation.class.test.php'); $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/evaluation.class.test.php');
//$this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/exerciselink.class.test.php'); $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/exerciselink.class.test.php');
//$this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/forumthreadlink.class.test.php'); $this->addFile(api_get_path(SYS_TEST_PATH).'main/gradebook/lib/be/forumthreadlink.class.test.php');
/**NEW SCORM*/ /**NEW SCORM*/
//$this->addTestFile(dirname(__FILE__).'/main/newscorm/openoffice_presentation.class.test.php'); //$this->addTestFile(dirname(__FILE__).'/main/newscorm/openoffice_presentation.class.test.php');

Loading…
Cancel
Save