diff --git a/main/course_info/download.php b/main/course_info/download.php index 15c71c2ac7..59a660b350 100755 --- a/main/course_info/download.php +++ b/main/course_info/download.php @@ -52,7 +52,7 @@ $content_type = ''; if (in_array(strtolower($extension), array('xml','csv')) && (api_is_platform_admin(true) || api_is_drh())) { $content_type = 'application/force-download'; } -elseif (strtolower($extension) == 'zip' && $_cid && $is_courseAdmin) { +elseif (strtolower($extension) == 'zip' && $_cid) { $content_type = 'application/force-download'; } @@ -60,6 +60,11 @@ if (empty($content_type)) { api_not_allowed(true); } + +/* +=============================================================================================== +*/ + header('Expires: Wed, 01 Jan 1990 00:00:00 GMT'); header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT'); header('Cache-Control: public'); diff --git a/main/dropbox/dropbox_functions.inc.php b/main/dropbox/dropbox_functions.inc.php index eb7185ce58..43627f0c92 100755 --- a/main/dropbox/dropbox_functions.inc.php +++ b/main/dropbox/dropbox_functions.inc.php @@ -1217,18 +1217,27 @@ function cleanup_temp_dropbox() { } /** -* @desc generates the contents of a html file that gives an overview of all the files in the zip file. -* This is to know the information of the files that are inside the zip file (who send it, the comment, ...) -* @author Patrick Cool , Ghent University -* @version march 2006 -*/ + * @desc Generates the contents of a html file that gives an overview of all the files in the zip file. + * This is to know the information of the files that are inside the zip file (who send it, the comment, ...) + * @author Patrick Cool , Ghent University, March 2006 + * @author Ivan Tcholakov, 2010, code for html metadata has been added. + */ function generate_html_overview($files, $dont_show_columns = array(), $make_link = array()) { - $return = "\n\n\t".get_lang('OverviewOfFilesInThisZip')."\n"; - $return .= "\n\n\n"; + $return = ''."\n"; + $return .= ''."\n"; + + $return .= "\n\t".get_lang('OverviewOfFilesInThisZip')."\n"; + $return .= "\t".''."\n"; + $return .= "\n\n"; + $return .= ''."\n\n"; + $return .= "
\n"; $counter = 0; foreach ($files as $key => $value) { - // We add the header + + // Adding the header. if ($counter == 0) { $columns_array = array_keys($value); $return .= "\n"; @@ -1238,11 +1247,11 @@ function generate_html_overview($files, $dont_show_columns = array(), $make_link } $column[] = $columns_array_value; } - $return .= "\n"; + $return .= "\n\n"; } $counter++; - // We add the content + // Adding the content. $return .= "\n"; foreach ($column as $column_key => $column_value) { if (!in_array($column_value,$dont_show_columns)) { @@ -1255,9 +1264,7 @@ function generate_html_overview($files, $dont_show_columns = array(), $make_link $return .= ""; } } - $return .= "\n"; - - + $return .= "\n\n"; } $return .= "\n
\n\n"; $return .= "\n"; diff --git a/main/dropbox/index.php b/main/dropbox/index.php index b69d6ca50d..b6170a105c 100755 --- a/main/dropbox/index.php +++ b/main/dropbox/index.php @@ -426,8 +426,9 @@ if ($_GET['action'] != 'add') { $new_icon = ' '.Display::return_icon('new.gif', get_lang('New')); } - $dropbox_file_data[] = build_document_icon_tag('file', $dropbox_file->title); - $dropbox_file_data[] = ''.Display::return_icon('filesave.gif', get_lang('Download'), array('style' => 'float:right;')).''.$dropbox_file->title.''.$new_icon.'
'.$dropbox_file->description; + $link_open = ''; + $dropbox_file_data[] = $link_open.build_document_icon_tag('file', $dropbox_file->title).''; + $dropbox_file_data[] = ''.Display::return_icon('filesave.gif', get_lang('Download'), array('style' => 'float:right;')).''.$link_open.$dropbox_file->title.''.$new_icon.'
'.$dropbox_file->description; $dropbox_file_data[] = ceil(($dropbox_file->filesize) / 1024).' '.get_lang('kB'); $dropbox_file_data[] = $dropbox_file->author; //$dropbox_file_data[] = $dropbox_file->description; @@ -466,8 +467,9 @@ if ($_GET['action'] != 'add') { $movelist[$category['cat_id']] = $category['cat_name']; $dropbox_category_data[] = $category['cat_id']; // This is where the checkbox icon for the files appear // The icon of the category - $dropbox_category_data[] = build_document_icon_tag('folder', $category['cat_name']); - $dropbox_category_data[] = ''.Display::return_icon('folder_zip.gif', get_lang('Save'), array('width' => '16px', 'height' => '16px', 'style' => 'float:right;')).''.$category['cat_name'].''; + $link_open = ''; + $dropbox_category_data[] = $link_open.build_document_icon_tag('folder', $category['cat_name']).''; + $dropbox_category_data[] = ''.Display::return_icon('folder_zip.gif', get_lang('Save'), array('width' => '16px', 'height' => '16px', 'style' => 'float:right;')).''.$link_open.$category['cat_name'].''; $dropbox_category_data[] = ''; $dropbox_category_data[] = ''; $dropbox_category_data[] = ''; @@ -571,8 +573,9 @@ if ($_GET['action'] != 'add') { if ($view_dropbox_category_sent == $dropbox_file->category) { $dropbox_file_data[] = $dropbox_file->id; - $dropbox_file_data[] = build_document_icon_tag('file', $dropbox_file->title); - $dropbox_file_data[] = ''.Display::return_icon('filesave.gif', get_lang('Save'), array('style' => 'float:right;')).''.$dropbox_file->title.'
'.$dropbox_file->description; + $link_open = ''; + $dropbox_file_data[] = $link_open.build_document_icon_tag('file', $dropbox_file->title).''; + $dropbox_file_data[] = ''.Display::return_icon('filesave.gif', get_lang('Save'), array('style' => 'float:right;')).''.$link_open.$dropbox_file->title.'
'.$dropbox_file->description; $dropbox_file_data[] = ceil(($dropbox_file->filesize)/1024).' '.get_lang('kB'); foreach ($dropbox_file->recipients as $recipient) { $receivers_celldata = display_user_link_work($recipient['user_id'], $recipient['name']).', '.$receivers_celldata; @@ -605,9 +608,10 @@ if ($_GET['action'] != 'add') { foreach ($dropbox_categories as $category) { $dropbox_category_data = array(); if ($category['sent'] == '1') { - $dropbox_category_data[] = $category['cat_id']; // this is where the checkbox icon for the files appear - $dropbox_category_data[] = build_document_icon_tag('folder', $category['cat_name']); - $dropbox_category_data[] = ''.Display::return_icon('folder_zip.gif', get_lang('Save'), array('width' => '16px', 'height' => '16px', 'style' => 'float:right;')).''.$category['cat_name'].''; + $dropbox_category_data[] = $category['cat_id']; // This is where the checkbox icon for the files appear. + $link_open = ''; + $dropbox_category_data[] = $link_open.build_document_icon_tag('folder', $category['cat_name']).''; + $dropbox_category_data[] = ''.Display::return_icon('folder_zip.gif', get_lang('Save'), array('width' => '16px', 'height' => '16px', 'style' => 'float:right;')).''.$link_open.$category['cat_name'].''; //$dropbox_category_data[] = ''; $dropbox_category_data[] = ''; //$dropbox_category_data[] = ''; diff --git a/main/inc/banner.inc.php b/main/inc/banner.inc.php index edbd44335a..f44811c39d 100755 --- a/main/inc/banner.inc.php +++ b/main/inc/banner.inc.php @@ -1,14 +1,14 @@ @@ -63,18 +63,16 @@ if (!empty($_cid) and $_cid != -1 and isset($_course)) { } else { echo '
'; } -//not to let the header disappear if there's nothing on the left +//Don't let the header disappear if there's nothing on the left echo '
 
'; -/* - Plugins for banner section -*/ +/* Plugins for banner section */ + api_plugin('header'); $web_course_path = api_get_path(WEB_COURSE_PATH); -/* - External link section -*/ +/* External link section */ + if (isset($_course['extLink']) && $_course['extLink']['name'] != '') { echo ' / '; if ($_course['extLink']['url'] != '') { @@ -106,7 +104,6 @@ if ((api_get_setting('showonline', 'world') == 'true' AND !$_user['user_id']) OR echo '
  • '; // Display the who's online of the platform if ((api_get_setting('showonline', 'world') == 'true' AND !$_user['user_id']) OR (api_get_setting('showonline', 'users') == 'true' AND $_user['user_id'])) { - //echo ''.$number.''; echo ''.get_lang('UsersOnline').': '.$number.''; } @@ -129,8 +126,8 @@ if (api_is_allowed_to_edit()) { // Show help ?>
  • | - - <?php echo get_lang('Help'); ?> 
  • + + <?php echo get_lang('Help'); ?>  '.Display::return_icon('edit.gif', get_lang('Edit')).''; - $delete_link = ''.Display::return_icon('delete.gif', get_lang('Delete')).''; - $tab_string = str_replace(array('href="'.api_get_path(WEB_PATH).'index.php?include=',''),array('href="'.api_get_path(WEB_CODE_PATH).'admin/'.basename(api_get_self()).'?action=open_link&link=',''.$edit_link.$delete_link.''),$enreg); + $delete_link = ''.Display::return_icon('delete.gif', get_lang('Delete')).''; + $tab_string = str_replace(array('href="'.api_get_path(WEB_PATH).'index.php?include=', ''), array('href="'.api_get_path(WEB_CODE_PATH).'admin/'.basename(api_get_self()).'?action=open_link&link=', $edit_link.$delete_link.''), $enreg); echo $tab_string; } } @@ -352,7 +349,7 @@ $navigation = array(); // part 1: Course Homepage. If we are in a course then the first breadcrumb is a link to the course homepage // hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb $my_session_name = is_null($session_name) ? '' : ' ('.$session_name.')'; -if (isset ($_cid) and $_cid != -1 and isset($_course) and !isset($_GET['hide_course_breadcrumb'])) { +if (isset($_cid) and $_cid != -1 and isset($_course) and !isset($_GET['hide_course_breadcrumb'])) { $navigation_item['url'] = $web_course_path . $_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : ''); switch (api_get_setting('breadcrumbs_course_homepage')) { case 'get_lang': @@ -409,7 +406,7 @@ if (api_get_setting('show_toolshortcuts') == 'true') { echo ''; } -if (isset ($dokeos_database_connection)) { +if (isset($dokeos_database_connection)) { // connect to the main database. // if single database, don't pefix table names with the main database name in SQL queries // (ex. SELECT * FROM `table`) @@ -433,9 +430,8 @@ if (!empty($header_hide_main_div) && $header_hide_main_div === true) { function confirmation (name) { - if (confirm(\" ". api_convert_encoding(get_lang('AreYouSureToDelete'), 'UTF-8', $charset) ." \"+ name + \" ?\")) + if (confirm(\" ". api_utf8_encode(get_lang('AreYouSureToDelete')) ." \"+ name + \" ?\")) {return true;} else {return false;} } "; -/* ------------------------------------------------------------ - Variables - - some need defining before inclusion of libraries ------------------------------------------------------------ -*/ +/* Variables + - some need defining before inclusion of libraries */ $sType = isset($sType) ? $sType : ''; -if($sType=="MP3") $sType="audio"; +if ($sType=="MP3") $sType="audio"; // Resource type $sType = strtolower($sType); // Choosing the repository to be used. -if (api_is_in_course()) -{ - if (!api_is_in_group()) - { +if (api_is_in_course()) { + if (!api_is_in_group()) { // 1. We are inside a course and not in a group. - if (api_is_allowed_to_edit()) - { + if (api_is_allowed_to_edit()) { // 1.1. Teacher $base_work_dir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/'; $http_www = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/'; - } - else - { + } else { // 1.2. Student $base_work_dir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document/shared_folder/'.api_get_user_id().'/'; $http_www = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document/shared_folder/'.api_get_user_id().'/'; } - } - else - { + } else { // 2. Inside a course and inside a group. $base_work_dir = api_get_path(SYS_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/'; $http_www = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/document'.$group_properties['directory'].'/'; } -} -else -{ - if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin') - { +} else { + if (api_is_platform_admin() && $_SESSION['this_section'] == 'platform_admin') { // 3. Platform administration activities. $base_work_dir = $_configuration['root_sys'].'home/default_platform_document/'; $http_www = $_configuration['root_web'].'home/default_platform_document/'; - } - else - { + } else { // 4. The user is outside courses. $base_work_dir = $_configuration['root_sys'].'main/upload/users/'.api_get_user_id().'/my_files/'; $http_www = $_configuration['root_web'].'main/upload/users/'.api_get_user_id().'/my_files/'; @@ -90,36 +78,27 @@ else } // Set the upload path according to the resource type. -if ($sType == 'audio') -{ +if ($sType == 'audio') { check_and_create_resource_directory($base_work_dir, '/audio', get_lang('Audio')); $base_work_dir = $base_work_dir.'audio/'; $http_www = $http_www.'audio/'; $path = "/audio/"; -} -elseif ($sType == 'flash') -{ +} elseif ($sType == 'flash') { check_and_create_resource_directory($base_work_dir, '/flash', get_lang('Flash')); $base_work_dir = $base_work_dir.'flash/'; $http_www = $http_www.'flash/'; $path = "/flash/"; -} -elseif ($sType == 'images') -{ +} elseif ($sType == 'images') { check_and_create_resource_directory($base_work_dir, '/images', get_lang('Images')); $base_work_dir = $base_work_dir.'images/'; $http_www = $http_www.'images/'; $path = "/images/"; -} -elseif ($sType == 'video') -{ +} elseif ($sType == 'video') { check_and_create_resource_directory($base_work_dir, '/video', get_lang('Video')); $base_work_dir = $base_work_dir.'video/'; $http_www = $http_www.'video/'; $path = "/video/"; -} -elseif ($sType == 'video/flv') -{ +} elseif ($sType == 'video/flv') { check_and_create_resource_directory($base_work_dir, '/video', get_lang('Video')); check_and_create_resource_directory($base_work_dir, '/video/flv', 'flv'); $base_work_dir = $base_work_dir.'video/flv/'; @@ -127,7 +106,7 @@ elseif ($sType == 'video/flv') $path = "/video/flv/"; } -$course_dir = $_course['path']."/document/".$sType; +$course_dir = $_course['path'].'/document/'.$sType; $sys_course_path = api_get_path(SYS_COURSE_PATH); $dbl_click_id = 0; // used to avoid double-click @@ -135,44 +114,20 @@ $is_allowed_to_edit = api_is_allowed_to_edit(); $req_gid = ''; -/* ------------------------------------------------------------ - Libraries ------------------------------------------------------------ -*/ -//libraries are included by default - -include_once(api_get_path(LIBRARY_PATH) . 'fileDisplay.lib.php'); -include_once(api_get_path(LIBRARY_PATH) . 'document.lib.php'); -include_once(api_get_path(LIBRARY_PATH) . 'tablesort.lib.php'); - -/* ------------------------------------------------------------ - Constants and variables ------------------------------------------------------------ -*/ +/* Constants and variables */ $course_quota = DocumentManager::get_course_quota(); -/* -============================================================================== - MAIN SECTION -============================================================================== -*/ - +/* MAIN SECTION */ -/* ------------------------------------------------------------ - Header ------------------------------------------------------------ -*/ +/* Header */ -$tool_name = get_lang("Doc"); // title of the page (should come from the language file) +$tool_name = get_lang('Doc'); // Title of the page (should come from the language file) ?> @@ -182,7 +137,7 @@ if(api_get_setting('stylesheets')<>'') ?> @@ -191,99 +146,70 @@ if(api_get_setting('stylesheets')<>'') $is_allowed_to_edit = api_is_allowed_to_edit(); -if($is_allowed_to_edit) // TEACHER ONLY -{ +if ($is_allowed_to_edit) { // TEACHER ONLY - /*====================================== - DELETE FILE OR DIRECTORY - ======================================*/ + /* DELETE FILE OR DIRECTORY */ - if ( isset($_GET['delete']) ) - { - include_once(api_get_path(LIBRARY_PATH) . 'fileManage.lib.php'); - if(DocumentManager::delete_document($_course,$_GET['delete'],$base_work_dir)) - { - Display::display_normal_message(api_convert_encoding(get_lang('DocDeleted'), 'UTF-8', $charset)); - } - else - { - Display::display_normal_message(api_convert_encoding(get_lang('DocDeleteError'), 'UTF-8', $charset)); + if (isset($_GET['delete'])) { + if (DocumentManager::delete_document($_course,$_GET['delete'], $base_work_dir)) { + Display::display_normal_message(api_utf8_encode(get_lang('DocDeleted'))); + } else { + Display::display_normal_message(api_utf8_encode(get_lang('DocDeleteError'))); } } - if( isset($_POST['action'])) - { - switch($_POST['action']) - { + if (isset($_POST['action'])) { + switch ($_POST['action']) { case 'delete': - foreach($_POST['path'] as $index => $path) - { - DocumentManager::delete_document($_course,$path,$base_work_dir); + foreach ($_POST['path'] as $index => $path) { + DocumentManager::delete_document($_course, $path, $base_work_dir); } - Display::display_normal_message(api_convert_encoding(get_lang('DocDeleted'), 'UTF-8', $charset)); + Display::display_normal_message(api_utf8_encode(get_lang('DocDeleted'))); break; } } } -/* ------------------------------------------------------------ - GET ALL DOCUMENT DATA FOR CURDIRPATH ------------------------------------------------------------ -*/ +/* GET ALL DOCUMENT DATA FOR CURDIRPATH */ $docs_and_folders = getlist ($base_work_dir.'/'); -?> - -'); - //print_r($docs_and_folders); - //echo(''); - //************************************************************************************************* +if ($docs_and_folders) { //do we need the title field for the document name or not? //we get the setting here, so we only have to do it once $use_document_title = api_get_setting('use_document_title'); //create a sortable table with our data $sortable_data = array(); - while (list ($key, $id) = each($docs_and_folders)) - { + while (list ($key, $id) = each($docs_and_folders)) { // Skip directories. - if ($id['filetype'] != 'file') - { + if ($id['filetype'] != 'file') { continue; } $row = array (); //if the item is invisible, wrap it in a span with class invisible - $invisibility_span_open = ($id['visibility']==0)?'':''; + $invisibility_span_open = ($id['visibility'] == 0) ? '' : ''; //size (or total size of a directory) - $size = $id['filetype']=='folder' ? get_total_folder_size($id['path'],$is_allowed_to_edit) : $id[size]; + $size = $id['filetype'] == 'folder' ? get_total_folder_size($id['path'], $is_allowed_to_edit) : $id[size]; //get the title or the basename depending on what we're using - if ($use_document_title=='true' AND $id['title']<>'') - { + if ($use_document_title == 'true' AND $id['title'] != '') { $document_name=$id['title']; - } - else - { - $document_name=basename($id['path']); + } else { + $document_name = basename($id['path']); } //$row[] = $key; //testing //data for checkbox /* - if ($is_allowed_to_edit AND count($docs_and_folders)>1) - { + if ($is_allowed_to_edit AND count($docs_and_folders) > 1) { $row[] = $id['path']; } */ // icons with hyperlinks - $row[]= ''.build_document_icon_tag($id['filetype'],$id['path']).''; + $row[]= ''.build_document_icon_tag($id['filetype'],$id['path']).''; //document title with hyperlink - $row[] = ''.$id['title'].''; + $row[] = ''.$id['title'].''; //comments => display comment under the document name //$row[] = $invisibility_span_open.nl2br(htmlspecialchars($id['comment'])).$invisibility_span_close; $display_size = format_file_size($size); @@ -294,66 +220,56 @@ if($docs_and_folders) $sortable_data[] = $row; } - //******************************************************************************************* - -} -else -{ - $sortable_data=array(); +} else { + $sortable_data = array(); //$table_footer='
    '.get_lang('NoDocsInFolder').'
    '; } -$table = new SortableTableFromArray($sortable_data,4,10); +$table = new SortableTableFromArray($sortable_data, 4, 10); $query_vars['curdirpath'] = $curdirpath; -if(isset($_SESSION['_gid'])) -{ +if (isset($_SESSION['_gid'])) { $query_vars['gidReq'] = $_SESSION['_gid']; } $table->set_additional_parameters($query_vars); $column = 0; /* -if ($is_allowed_to_edit AND count($docs_and_folders)>1) -{ - $table->set_header($column++,'',false); +if ($is_allowed_to_edit AND count($docs_and_folders) > 1) { + $table->set_header($column++, '', false); } */ -$table->set_header($column++, api_htmlentities(get_lang('Type'), ENT_QUOTES, $charset)); -$table->set_header($column++, api_htmlentities(get_lang('Title'), ENT_QUOTES, $charset)); +$table->set_header($column++, api_htmlentities(get_lang('Type'), ENT_QUOTES)); +$table->set_header($column++, api_htmlentities(get_lang('Title'), ENT_QUOTES)); //$column_header[] = array(get_lang('Comment'),true); => display comment under the document name -$table->set_header($column++, api_htmlentities(get_lang('Size'), ENT_QUOTES, $charset)); -$table->set_header($column++, api_htmlentities(get_lang('Date'), ENT_QUOTES, $charset)); +$table->set_header($column++, api_htmlentities(get_lang('Size'), ENT_QUOTES)); +$table->set_header($column++, api_htmlentities(get_lang('Date'), ENT_QUOTES)); //currently only delete action -> take only DELETE right into account /* -if (count($docs_and_folders)>1) -{ - if ($is_allowed_to_edit) - { +if (count($docs_and_folders) > 1) { + if ($is_allowed_to_edit) { $form_actions = array(); $form_action['delete'] = get_lang('Delete'); - $table->set_form_actions($form_action,'path'); + $table->set_form_actions($form_action, 'path'); } } */ -echo api_convert_encoding($table->get_table_html(), 'UTF-8', $charset); -echo api_convert_encoding($table_footer, 'UTF-8', $charset); - -////////// functions //////////// - +echo api_utf8_encode($table->get_table_html()); +echo api_utf8_encode($table_footer); +// Functions ?> > + if (defined('DOKEOS_HOMEPAGE') && DOKEOS_HOMEPAGE) + echo 'onload="javascript: if(document.formLogin) { document.formLogin.login.focus(); }"'; ?>> add_html_editor('intro_content', null, null, false, $editor_config); $form->addElement('style_submit_button', 'intro_cmdUpdate', get_lang('SaveIntroText'), 'class="save"'); - -/*========================================================= - INTRODUCTION MICRO MODULE - COMMANDS SECTION (IF ALLOWED) - ========================================================*/ +/* INTRODUCTION MICRO MODULE - COMMANDS SECTION (IF ALLOWED) */ if ($intro_editAllowed) { + /* Replace command */ - if ( $intro_cmdUpdate ) { - if ( $form->validate()) { + if ($intro_cmdUpdate) { + if ($form->validate()) { $form_values = $form->exportValues(); $intro_content = Security::remove_XSS(stripslashes(api_html_entity_decode($form_values['intro_content'])), COURSEMANAGERLOWSECURITY); - if ( ! empty($intro_content) ) { + if (!empty($intro_content)) { $sql = "REPLACE $TBL_INTRODUCTION SET id='$moduleId',intro_text='".Database::escape_string($intro_content)."'"; Database::query($sql); - Display::display_confirmation_message(get_lang('IntroductionTextUpdated'),false); + Display::display_confirmation_message(get_lang('IntroductionTextUpdated'), false); } else { $intro_cmdDel = true; // got to the delete command } - } else { $intro_cmdEdit = true; } @@ -117,13 +110,10 @@ if ($intro_editAllowed) { Database::query("DELETE FROM $TBL_INTRODUCTION WHERE id='".$moduleId."'"); Display::display_confirmation_message(get_lang('IntroductionTextDeleted')); } - } -/*=========================================== - INTRODUCTION MICRO MODULE - DISPLAY SECTION - ===========================================*/ +/* INTRODUCTION MICRO MODULE - DISPLAY SECTION */ /* Retrieves the module introduction text, if exist */ @@ -135,9 +125,11 @@ $intro_content = $intro_dbResult['intro_text']; /* Determines the correct display */ if ($intro_cmdEdit || $intro_cmdAdd) { + $intro_dispDefault = false; $intro_dispForm = true; $intro_dispCommand = false; + } else { $intro_dispDefault = true; @@ -148,7 +140,6 @@ if ($intro_cmdEdit || $intro_cmdAdd) { } else { $intro_dispCommand = false; } - } /* Executes the display */ @@ -156,7 +147,6 @@ if ($intro_cmdEdit || $intro_cmdAdd) { if ($intro_dispForm) { $default['intro_content'] = $intro_content; $form->setDefaults($default); - //echo '
    '; echo '
    '; $form->display(); echo '
    '; @@ -164,21 +154,21 @@ if ($intro_dispForm) { $style_introduction_section = 'style="margin-left:10%;margin-right:10%;"'; $thematic_description_html = ''; -if ($tool==TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) { - +if ($tool == TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) { + $course_description = new CourseDescription(); $course_description->set_session_id(api_get_session_id()); $thematic_description = $course_description->get_data_by_description_type(8); - + if (!empty($thematic_description)) { - + $style_introduction_section = 'style="width:65%;float:left;margin-left:10%;"'; - - $thematic_advance = get_lang('ThematicAdvance').' '.$course_description->get_progress_porcent(false,8); - if (api_is_allowed_to_edit(null,true)) { - $thematic_advance = ''.get_lang('ThematicAdvance').' '.$course_description->get_progress_porcent(false,8).''; + + $thematic_advance = get_lang('ThematicAdvance').' '.$course_description->get_progress_porcent(false, 8); + if (api_is_allowed_to_edit(null, true)) { + $thematic_advance = ''.get_lang('ThematicAdvance').' '.$course_description->get_progress_porcent(false, 8).''; } - + $thematic_description_html = '
    @@ -188,8 +178,7 @@ if ($tool==TOOL_COURSE_HOMEPAGE && !isset($_GET['intro_cmdEdit'])) {
    '.Display::return_icon('postit_bottom.png').'
    '; - - } + } } echo '
    '; @@ -203,11 +192,11 @@ if ($intro_dispDefault) { if ($intro_dispCommand) { - if ( empty($intro_content) ) { + if (empty($intro_content)) { - //displays "Add intro" Commands + // Displays "Add intro" commands echo "

    \n"; - if (!empty ($GLOBALS["_cid"])) { + if (!empty ($GLOBALS['_cid'])) { echo "\n".get_lang('AddIntro')."\n"; } else { echo "\n".get_lang('AddIntro')."\n"; @@ -216,9 +205,9 @@ if ($intro_dispCommand) { } else { - // displays "edit intro && delete intro" Commands + // Displays "edit intro && delete intro" commands echo "

    \n"; - if (!empty ($GLOBALS["_cid"])) { + if (!empty ($GLOBALS['_cid'])) { echo "\"".get_lang('Modify')."\"\n"; echo "\"".get_lang('Delete')."\"\n"; } else { @@ -235,5 +224,3 @@ echo '

    '; echo $thematic_description_html; echo '
    '; - -?> diff --git a/main/inc/latex.php b/main/inc/latex.php index 86f3825ade..e329e77e17 100755 --- a/main/inc/latex.php +++ b/main/inc/latex.php @@ -6,53 +6,20 @@ , Ghent University +/* INIT SECTION */ - For a full list of contributors, see "credits.txt". - The full license can be read in "license.txt". +include '../inc/global.inc.php'; - 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, 44 rue des palais, B-1030 Brussels, Belgium - Mail: info@dokeos.com -============================================================================== -*/ - - -/* -============================================================================== - INIT SECTION -============================================================================== -*/ -include("../inc/global.inc.php"); - -/* -============================================================================== - FUNCTIONS -============================================================================== -*/ +/* FUNCTIONS */ // put your functions here // if the list gets large, divide them into different sections: // display functions, tool logic functions, database functions // try to place your functions into an API library or separate functions file - it helps reuse -/* -============================================================================== - MAIN CODE -============================================================================== -*/ +/* MAIN CODE */ $code = Security::remove_XSS($_GET['code']); @@ -61,16 +28,13 @@ echo '

    '.get_lang('LatexCode').'

    '; echo stripslashes($code); echo '
    '; - echo '
    '; echo '

    '.get_lang('LatexFormula').'

    '; echo ''.get_lang('LatexCode').''; echo '
    '; -/* -============================================================================== - FOOTER -============================================================================== -*/ + +/* FOOTER */ + ?> \ No newline at end of file diff --git a/main/inc/lib/document.lib.php b/main/inc/lib/document.lib.php index 5ef1428a3b..8c17f8a9cc 100755 --- a/main/inc/lib/document.lib.php +++ b/main/inc/lib/document.lib.php @@ -26,10 +26,8 @@ $baseServDir = api_get_path(SYS_PATH); $baseServUrl = $_configuration['url_append'].'/'; $baseWorkDir = $sys_course_path.(!empty($courseDir) ? $courseDir : ''); -/* - DocumentManager CLASS - the class and its functions -*/ +/* DocumentManager CLASS + the class and its functions */ class DocumentManager { @@ -41,7 +39,7 @@ class DocumentManager { * @return the document folder quuta of the current course, in bytes * @todo eliminate globals */ - public static function get_course_quota () { + public static function get_course_quota() { global $_course, $maxFilledSpace; $course_code = Database::escape_string($_course['sysCode']); @@ -70,7 +68,7 @@ class DocumentManager { * @author Bert Vanderkimpen * */ - public static function file_get_mime_type ($filename) { + public static function file_get_mime_type($filename) { // All MIME types in an array (from 1.6, this is the authorative source) // Please, keep this alphabetical if you add something to this list! $mime_types = array( @@ -245,7 +243,7 @@ class DocumentManager { //$filename will be an array if a . was found if (is_array($extension)) { - $extension = (strtolower($extension[sizeof($extension) - 1])); + $extension = strtolower($extension[sizeof($extension) - 1]); } //file without extension else { @@ -253,7 +251,7 @@ class DocumentManager { } //if the extension is found, return the content type - if (isset ($mime_types[$extension])) { + if (isset($mime_types[$extension])) { return $mime_types[$extension]; } //else return octet-stream @@ -449,7 +447,7 @@ class DocumentManager { * @param boolean $can_see_invisible * @return array with all document data */ - public static function get_all_document_data ($_course, $path = '/', $to_group_id = 0, $to_user_id = NULL, $can_see_invisible = false) { + public static function get_all_document_data($_course, $path = '/', $to_group_id = 0, $to_user_id = NULL, $can_see_invisible = false) { $TABLE_ITEMPROPERTY = Database::get_course_table(TABLE_ITEM_PROPERTY, $_course['dbName']); $TABLE_DOCUMENT = Database::get_course_table(TABLE_DOCUMENT, $_course['dbName']); $TABLE_COURSE = Database::get_main_table(TABLE_MAIN_COURSE); @@ -786,12 +784,12 @@ class DocumentManager { //Change path of subfolders and documents in database $old_item_path = $deleted_items['path']; $new_item_path = $new_path.substr($old_item_path, strlen($path)); - /*/ - * trying to fix this bug FS#2681 + /* + // Trying to fix this bug FS#2681 echo $base_work_dir.$old_item_path; - echo "
    "; + echo "
    "; echo $base_work_dir.$new_item_path; - echo "
    ";echo "
    "; + echo "

    "; rename($base_work_dir.$old_item_path, $base_work_dir.$new_item_path); */ self::unset_document_as_template($deleted_items['id'], api_get_course_id(), api_get_user_id()); @@ -1106,7 +1104,7 @@ class DocumentManager { } } else { //no starting '/', making it relative to current document's path - if(substr($second_part, 0, 2) == './') { + if (substr($second_part, 0, 2) == './') { $second_part = substr($second_part, 2); } $files_list[] = array($second_part, 'local', 'rel'); @@ -1124,7 +1122,7 @@ class DocumentManager { //leave that second part behind now $source = substr($source, 0, strpos($source, '?')); if (strpos($source, '://') > 0) { - if (strpos($source,api_get_path(WEB_PATH)) !== false) { + if (strpos($source, api_get_path(WEB_PATH)) !== false) { //we found the current portal url $files_list[] = array($source, 'local', 'url'); $in_files_list[] = DocumentManager::get_resources_from_source_html($source, true, TOOL_DOCUMENT, $recursivity+1); @@ -1168,7 +1166,7 @@ class DocumentManager { $new_abs_path = realpath($dir.$source); $in_files_list[] = DocumentManager::get_resources_from_source_html($new_abs_path, true, TOOL_DOCUMENT, $recursivity + 1); if (count($in_files_list) > 0) { - $files_list = array_merge($files_list,$in_files_list); + $files_list = array_merge($files_list, $in_files_list); } } } @@ -1176,7 +1174,7 @@ class DocumentManager { //found some protocol there if (strpos($source, api_get_path(WEB_PATH)) !== false) { //we found the current portal url - $files_list[] = array($source,'local','url'); + $files_list[] = array($source, 'local', 'url'); $in_files_list[] = DocumentManager::get_resources_from_source_html($source, true, TOOL_DOCUMENT, $recursivity + 1); if (count($in_files_list) > 0) { $files_list = array_merge($files_list, $in_files_list); @@ -1290,7 +1288,7 @@ class DocumentManager { ); } catch (Exception $e) { - error_log('Caught exception: '. $e->getMessage(),0) ; + error_log('Caught exception: '. $e->getMessage(), 0) ; } if ($res) { for ($i = 0; $i < count($regs[1]); $i++) { diff --git a/main/inc/lib/main_api.lib.php b/main/inc/lib/main_api.lib.php index ccbddf12f2..cef5d4d930 100755 --- a/main/inc/lib/main_api.lib.php +++ b/main/inc/lib/main_api.lib.php @@ -3860,24 +3860,37 @@ function api_is_element_in_the_session($tool, $element_id, $session_id = null) { */ function replace_dangerous_char($filename, $strict = 'loose') { - static $search = array(' ', '/', '\\', '"', '\'', '?', '*', '>', '<', '|', ':', '$', '(', ')', '^', '[', ']', '#'); - static $replace = array('_', '-', '-', '-', '_', '-', '-', '', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-'); - static $search_strict = array('-'); - static $replace_strict = array('_'); - - $filename = api_transliterate($filename, 'x', api_detect_encoding($filename)); - + // Safe replacements for some non-letter characters. + static $search = array("\0", ' ', "\t", "\n", "\r", "\x0B", '/', "\\", '"', "'", '?', '*', '>', '<', '|', ':', '$', '(', ')', '^', '[', ']', '#', '+', '&', '%'); + static $replace = array('', '_', '_', '_', '_', '_', '-', '-', '-', '_', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-', '-'); + + // Encoding detection. + $encoding = api_detect_encoding($filename); + // Converting html-entities into encoded characters. + $filename = api_html_entity_decode($filename, ENT_QUOTES, $encoding); + // Transliteration to ASCII letters, they are not dangerous for filesystems. + $filename = api_transliterate($filename, 'x', $encoding); + + // Trimming leading/trailing whitespace. $filename = trim($filename); // Trimming any leading/trailing dots. $filename = trim($filename, '.'); $filename = trim($filename); - // Replacing other remaining dangerous characters. + + // Replacing remaining dangerous non-letter characters. $filename = str_replace($search, $replace, $filename); if ($strict == 'strict') { - $filename = str_replace($search_strict, $replace_strict, $filename); + $filename = str_replace('-', '_', $filename); $filename = preg_replace('/[^0-9A-Za-z_.\-]/', '', $filename); } - // Length is limited, so the file name to be acceptable by some operating systems. + + // Length is to be limited, so the file name to be acceptable by some operating systems. + $extension = (string)strrchr($filename, '.'); + $extension_len = strlen($extension); + if ($extension_len > 0 && $extension_len < 250) { + $filename = substr($filename, 0, -$extension_len); + return substr($filename, 0, 250 - $extension_len).$extension; + } return substr($filename, 0, 250); } diff --git a/main/inc/local.inc.php b/main/inc/local.inc.php index 7749884ea6..9b590b6a49 100755 --- a/main/inc/local.inc.php +++ b/main/inc/local.inc.php @@ -4,7 +4,7 @@ * * SCRIPT PURPOSE * - * This script initializes and manages Dokeos session information. It + * This script initializes and manages Chamilo session information. It * keeps available session information up to date. * * You can request a course id. It will check if the course Id requested is the @@ -232,7 +232,7 @@ if (api_get_setting('allow_terms_conditions')=='true') { $uData = Database::fetch_array($result); if ($uData['auth_source'] == PLATFORM_AUTH_SOURCE) { - //the authentification of this user is managed by Dokeos itself + //the authentification of this user is managed by Chamilo itself $password = trim(stripslashes($password)); // determine if the password needs to be encrypted before checking // $userPasswordCrypted is set in an external configuration file @@ -343,10 +343,10 @@ if (api_get_setting('allow_terms_conditions')=='true') { // see configuration.php to define these include_once($extAuthSource[$key]['login']); /* >>>>>>>> External authentication modules <<<<<<<<< */ - } else // no standard Dokeos login - try external authentification + } else // no standard Chamilo login - try external authentification { //huh... nothing to do... we shouldn't get here - error_log('Dokeos Authentication file '. $extAuthSource[$uData['auth_source']]['login']. ' could not be found - this might prevent your system from doing the corresponding authentication process',0); + error_log('Chamilo Authentication file '. $extAuthSource[$uData['auth_source']]['login']. ' could not be found - this might prevent your system from doing the corresponding authentication process',0); } if (!empty($_SESSION['request_uri'])) { @@ -403,7 +403,7 @@ if (api_get_setting('allow_terms_conditions')=='true') { * - Implement user interface for api_get_setting('sso_authentication') * } elseif (api_get_setting('sso_authentication')=='true') { * - Work on a better validation for webservices paths. Current is very poor and exit - * - $master variable should be recovered from dokeos settings. + * - $master variable should be recovered from chamilo settings. */ $master = array( 'domain' => api_get_setting('sso_authentication_domain'), // 'localhost/project/drupal5', diff --git a/main/inc/reduced_header.inc.php b/main/inc/reduced_header.inc.php index 3f785b35a2..39c1919a89 100755 --- a/main/inc/reduced_header.inc.php +++ b/main/inc/reduced_header.inc.php @@ -1,17 +1,15 @@ tag -* IT IS A COPY OF header.inc.php EXCEPT that it doesn't start the body -* output. -* -* @package dokeos.include -============================================================================== -*/ - -/*---------------------------------------- - HEADERS SECTION - --------------------------------------*/ + * This script displays the Dokeos header up to the tag + * IT IS A COPY OF header.inc.php EXCEPT that it doesn't start the body + * output. + * + * @package chamilo.include + */ + +/* HEADERS SECTION */ /* * HTTP HEADER @@ -19,10 +17,8 @@ header('Content-Type: text/html; charset='.api_get_system_encoding()); -if ( isset($httpHeadXtra) && $httpHeadXtra ) -{ - foreach($httpHeadXtra as $thisHttpHead) - { +if (isset($httpHeadXtra) && $httpHeadXtra) { + foreach ($httpHeadXtra as & $thisHttpHead) { header($thisHttpHead); } } @@ -33,18 +29,17 @@ $document_language = api_get_language_isocode(); /* * HTML HEADER */ + ?> <?php -if(!empty($nameTools)) -{ +if (!empty($nameTools)) { echo $nameTools.' - '; } -if(!empty($_course['official_code'])) -{ +if (!empty($_course['official_code'])) { echo $_course['official_code'].' - '; } @@ -60,40 +55,32 @@ echo api_get_setting('siteName'); $platform_theme = api_get_setting('stylesheets'); // plataform's css $my_style = $platform_theme; -if (api_get_setting('user_selected_theme') == 'true') -{ +if (api_get_setting('user_selected_theme') == 'true') { $useri = api_get_user_info(); $user_theme = $useri['theme']; - if(!empty($user_theme) && $user_theme != $my_style) - { + if (!empty($user_theme) && $user_theme != $my_style) { $my_style = $user_theme; // user's css } } $mycourseid = api_get_course_id(); -if (!empty($mycourseid) && $mycourseid != -1) -{ - if (api_get_setting('allow_course_theme') == 'true') - { +if (!empty($mycourseid) && $mycourseid != -1) { + if (api_get_setting('allow_course_theme') == 'true') { $mycoursetheme=api_get_course_setting('course_theme'); - if (!empty($mycoursetheme) && $mycoursetheme!=-1) - { - if(!empty($mycoursetheme) && $mycoursetheme != $my_style) - { + if (!empty($mycoursetheme) && $mycoursetheme != -1) { + if (!empty($mycoursetheme) && $mycoursetheme != $my_style) { $my_style = $mycoursetheme; // course's css } } $mycourselptheme=api_get_course_setting('allow_learning_path_theme'); - if (!empty($mycourselptheme) && $mycourselptheme!=-1 && $mycourselptheme== 1) - { + if (!empty($mycourselptheme) && $mycourselptheme != -1 && $mycourselptheme == 1) { global $lp_theme_css; // it comes from the lp_controller.php global $lp_theme_config; // it comes from the lp_controller.php if (!empty($lp_theme_css)) { $theme=$lp_theme_css; - if(!empty($theme) && $theme != $my_style) - { + if (!empty($theme) && $theme != $my_style) { $my_style = $theme; // LP's css } } @@ -102,34 +89,27 @@ if (!empty($mycourseid) && $mycourseid != -1) } } -if (!empty($lp_theme_log)){ - $my_style=$platform_theme; +if (!empty($lp_theme_log)) { + $my_style = $platform_theme; } // Sets the css reference it is call from lp_nav.php, lp_toc.php, lp_message, lp_log.php -if (!empty($scorm_css_header)) -{ - if (!empty($my_style)) - { - $scorm_css=api_get_path(WEB_CODE_PATH).'css/'.$my_style.'/scorm.css'; - $scormfs_css=api_get_path(WEB_CODE_PATH).'css/'.$my_style.'/scormfs.css'; - } - else - { - $scorm_css='scorm.css'; - $scormfs_css='scormfs.css'; +if (!empty($scorm_css_header)) { + if (!empty($my_style)) { + $scorm_css = api_get_path(WEB_CSS_PATH).$my_style.'/scorm.css'; + $scormfs_css = api_get_path(WEB_CSS_PATH).$my_style.'/scormfs.css'; + } else { + $scorm_css = 'scorm.css'; + $scormfs_css = 'scormfs.css'; } - if(!empty($display_mode) && $display_mode == 'fullscreen') - { + if (!empty($display_mode) && $display_mode == 'fullscreen') { $htmlHeadXtra[] = '<style type="text/css" media="screen, projection"> /*<![CDATA[*/ @import "'.$scormfs_css.'"; /*]]>*/ </style>'; - } - else - { + } else { $htmlHeadXtra[] = '<style type="text/css" media="screen, projection"> /*<![CDATA[*/ @import "'.$scorm_css.'"; @@ -139,12 +119,11 @@ if (!empty($scorm_css_header)) } -if($my_style!='') -{ +if ($my_style != '') { ?> <style type="text/css" media="screen, projection"> /*<![CDATA[*/ -@import "<?php echo api_get_path(WEB_CODE_PATH); ?>css/<?php echo $my_style;?>/default.css"; +@import "<?php echo api_get_path(WEB_CSS_PATH), $my_style; ?>/default.css"; /*]]>*/ </style> <?php @@ -188,11 +167,9 @@ if ( ( navigator.userAgent.toLowerCase().indexOf('msie') != -1 ) && ( navigator. </script> <?php -if ( isset($htmlHeadXtra) && $htmlHeadXtra ) -{ - foreach($htmlHeadXtra as $this_html_head) - { - echo($this_html_head); +if (isset($htmlHeadXtra) && $htmlHeadXtra) { + foreach ($htmlHeadXtra as & $this_html_head) { + echo $this_html_head; } } ?> diff --git a/main/inc/tool_navigation_menu.inc.php b/main/inc/tool_navigation_menu.inc.php index 94838c379f..8c4327e69e 100755 --- a/main/inc/tool_navigation_menu.inc.php +++ b/main/inc/tool_navigation_menu.inc.php @@ -1,82 +1,66 @@ <?php -// $Id: tool_navigation_menu.inc.php 22072 2009-07-14 15:14:42Z jhp1411 $ -/* For licensing terms, see /chamilo_license.txt */ +/* For licensing terms, see /license.txt */ + /** -============================================================================== -* Navigation menu display code -* -* @package dokeos.include -============================================================================== -*/ -define('SHORTCUTS_HORIZONTAL',0); -define('SHORTCUTS_VERTICAL',1); + * Navigation menu display code + * + * @package dokeos.include + */ + +define('SHORTCUTS_HORIZONTAL', 0); +define('SHORTCUTS_VERTICAL', 1); + /** * Build the navigation items to show in a course menu * @param boolean $include_admin_tools */ -function get_navigation_items($include_admin_tools = false) -{ +function get_navigation_items($include_admin_tools = false) { global $is_courseMember; global $_user; global $_course; - if (!empty($_course['db_name'])) - { + if (!empty($_course['db_name'])) { $database = $_course['db_name']; } $navigation_items = array (); $course_id = api_get_course_id(); - if (!empty ($course_id) && ($course_id != -1)) - { + if (!empty($course_id) && $course_id != -1) { + $user_id = api_get_user_id(); $course_tools_table = Database :: get_course_table(TABLE_TOOL_LIST,$database); - /* - -------------------------------------------------------------- - Link to the Course homepage - -------------------------------------------------------------- - */ + /* Link to the Course homepage */ $navigation_items['home']['image'] = 'home.gif'; $navigation_items['home']['link'] = api_get_path(REL_COURSE_PATH).Security::remove_XSS($_SESSION['_course']['path']).'/index.php'; $navigation_items['home']['name'] = get_lang('CourseHomepageLink'); - /* - -------------------------------------------------------------- - Link to the different tools - -------------------------------------------------------------- - */ + /* Link to the different tools */ $sql_menu_query = "SELECT * FROM $course_tools_table WHERE visibility='1' and admin='0' ORDER BY id ASC"; $sql_result = Database::query($sql_menu_query); - while ($row = Database::fetch_array($sql_result)) - { + while ($row = Database::fetch_array($sql_result)) { $navigation_items[$row['id']] = $row; /* if (!stristr($row['link'], 'http://')) */ - if (stripos($row['link'], 'http://') === false && stripos($row['link'], 'https://') === false) - { + if (stripos($row['link'], 'http://') === false && stripos($row['link'], 'https://') === false) { $navigation_items[$row['id']]['link'] = api_get_path(REL_CODE_PATH).$row['link']; /* $navigation_items[$row['id']]['name'] = $row['image'] == 'scormbuilder.gif' ? $navigation_items[$row['id']]['name'] : get_lang(ucfirst($navigation_items[$row['id']]['name'])); */ - if ($row['image'] != 'scormbuilder.gif' && $row['image'] != 'blog.gif') - { + if ($row['image'] != 'scormbuilder.gif' && $row['image'] != 'blog.gif') { $navigation_items[$row['id']]['name'] = get_lang(ucfirst($navigation_items[$row['id']]['name'])); } } } - /* - -------------------------------------------------------------- - Admin (edit rights) only links + + /* Admin (edit rights) only links - Course settings (course admin only) - - Course rights (roles & rights overview) - -------------------------------------------------------------- - */ + - Course rights (roles & rights overview) */ if ($include_admin_tools) { $course_settings_sql = "SELECT name,image FROM $course_tools_table @@ -84,7 +68,7 @@ function get_navigation_items($include_admin_tools = false) $sql_result = Database::query($course_settings_sql); $course_setting_info = Database::fetch_array($sql_result); $course_setting_visual_name = get_lang(api_ucfirst($course_setting_info['name'])); - if (api_get_session_id()==0) { + if (api_get_session_id() == 0) { // course settings item $navigation_items['course_settings']['image'] = $course_setting_info['image']; $navigation_items['course_settings']['link'] = api_get_path(REL_CODE_PATH).'course_info/infocours.php'; @@ -92,7 +76,7 @@ function get_navigation_items($include_admin_tools = false) } } } - foreach($navigation_items as $key => $navigation_item) { + foreach ($navigation_items as $key => $navigation_item) { if (strstr($navigation_item['link'], '?')) { //link already contains a parameter, add course id parameter with & $parameter_separator = '&'; @@ -108,11 +92,10 @@ function get_navigation_items($include_admin_tools = false) /** * Show a navigation menu */ -function show_navigation_menu() -{ +function show_navigation_menu() { $navigation_items = get_navigation_items(true); $course_id = api_get_course_id(); - if(api_get_setting('show_navigation_menu') == 'icons') { + if (api_get_setting('show_navigation_menu') == 'icons') { echo '<div style="float:right;width: 40px;position:absolute;right:10px;top:10px;">'; show_navigation_tool_shortcuts($orientation = SHORTCUTS_VERTICAL); echo '</div>'; @@ -121,7 +104,7 @@ function show_navigation_menu() ?> <script type="text/javascript"> /* <![CDATA[ */ - function createCookie(name,value,days) + function createCookie(name, value, days) { if (days) { @@ -136,7 +119,7 @@ function show_navigation_menu() { var nameEQ = name + "="; var ca = document.cookie.split(';'); - for(var i=0;i < ca.length;i++) + for (var i = 0; i < ca.length; i++) { var c = ca[i]; while (c.charAt(0)==' ') c = c.substring(1,c.length); @@ -150,7 +133,7 @@ function show_navigation_menu() center_el = document.getElementById('center'); swap_menu_link_el = document.getElementById('swap_menu_link'); - if(toolnavlist_el.style.display == 'none') + if (toolnavlist_el.style.display == 'none') { toolnavlist_el.style.display = ''; if (center_el) @@ -186,26 +169,22 @@ function show_navigation_menu() $url_item = parse_url($navigation_item['link']); $url_current = parse_url($_SERVER['REQUEST_URI']); - if (strpos($navigation_item['link'],'chat')!==false && api_get_course_setting('allow_open_chat_window',$course_id)==true) { - echo '<a href="javascript: void(0);" onclick="window.open(\''.$navigation_item['link'].'\',\'window_chat'.$_SESSION['_cid'].'\',config=\'height=\'+380+\', width=\'+625+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $navigation_item['target'] . '"'; + if (strpos($navigation_item['link'], 'chat') !== false && api_get_course_setting('allow_open_chat_window', $course_id)) { + echo '<a href="javascript: void(0);" onclick="javascript: window.open(\''.$navigation_item['link'].'\',\'window_chat'.$_SESSION['_cid'].'\',config=\'height=\'+380+\', width=\'+625+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $navigation_item['target'] . '"'; } else { echo '<a href="'.$navigation_item['link'].'" target="_top" '; } - if (stristr($url_item['path'],$url_current['path'])) - { - if(! isset($_GET['learnpath_id']) || strpos($url_item['query'],'learnpath_id='.$_GET['learnpath_id']) === 0) - { + if (stristr($url_item['path'], $url_current['path'])) { + if (!isset($_GET['learnpath_id']) || strpos($url_item['query'],'learnpath_id='.$_GET['learnpath_id']) === 0) { echo ' id="here"'; } } echo ' title="'.$navigation_item['name'].'">'; - if (api_get_setting('show_navigation_menu') != 'text') - { + if (api_get_setting('show_navigation_menu') != 'text') { echo '<div align="left"><img src="'.api_get_path(WEB_IMG_PATH).$navigation_item['image'].'" alt="'.$navigation_item['name'].'"/></div>'; } - if (api_get_setting('show_navigation_menu') != 'icons') - { + if (api_get_setting('show_navigation_menu') != 'icons') { echo $navigation_item['name']; } echo '</a>'; @@ -217,7 +196,7 @@ function show_navigation_menu() ?> <script type="text/javascript"> /* <![CDATA[ */ - if(readCookie('dokeos_menu_state') == 0) + if (readCookie('dokeos_menu_state') == 0) swap_menu(); } /* ]]> */ @@ -229,11 +208,10 @@ function show_navigation_menu() /** * Show a toolbar with shortcuts to the course tool */ -function show_navigation_tool_shortcuts($orientation = SHORTCUTS_HORIZONTAL) -{ +function show_navigation_tool_shortcuts($orientation = SHORTCUTS_HORIZONTAL) { $navigation_items = get_navigation_items(false); foreach ($navigation_items as $key => $navigation_item) { - if (strpos($navigation_item['link'],'chat')!==false && api_get_course_setting('allow_open_chat_window')==true) { + if (strpos($navigation_item['link'],'chat') !== false && api_get_course_setting('allow_open_chat_window')) { /* echo '<a href="#" onclick="window.open(\''.$navigation_item['link'].'\',\'window_chat'.$_SESSION['_cid'].'\',config=\'height=\'+380+\', width=\'+625+\', left=2, top=2, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, directories=no, status=no\')" target="' . $navigation_item['target'] . '"'; */ @@ -248,9 +226,8 @@ function show_navigation_tool_shortcuts($orientation = SHORTCUTS_HORIZONTAL) echo ' target="_top" title="'.$navigation_item['name'].'">'; echo '<img src="'.api_get_path(WEB_IMG_PATH).$navigation_item['image'].'" alt="'.$navigation_item['name'].'"/>'; echo '</a>'; - if($orientation == SHORTCUTS_VERTICAL){ + if ($orientation == SHORTCUTS_VERTICAL) { echo '<br />'; } } } -?> \ No newline at end of file