Feature #272 - "Configure homepage": Some additional changes and cleaning.

skala
Ivan Tcholakov 16 years ago
parent 7a5fac36b4
commit f4221e5da9
  1. 252
      main/admin/configure_homepage.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();
?>

Loading…
Cancel
Save