Feature #272 - Reworks in the course homepage and the course navigation menu about translation of the tool icons.

skala
Ivan Tcholakov 16 years ago
parent 49306a1050
commit f296431381
  1. 70
      main/inc/lib/course_home.lib.php
  2. 18
      main/inc/tool_navigation_menu.inc.php

@ -14,12 +14,6 @@ class CourseHome {
$charset = api_get_system_encoding();
$TBL_ACCUEIL = Database :: get_course_table(TABLE_TOOL_LIST);
$TABLE_TOOLS = Database :: get_main_table(TABLE_MAIN_COURSE_MODULE);
$translated_icons = array(
'file_html.gif', 'file_html_na.gif',
'scormbuilder.gif', 'scormbuilder_na.gif',
'blog.gif', 'blog_na.gif',
'external.gif', 'external_na.gif'
);
$numcols = 3;
$table = new HTML_Table('width="100%"');
@ -62,9 +56,6 @@ class CourseHome {
// Grabbing all the tools from $course_tool_table
while ($tool = Database::fetch_array($result)) {
if (!in_array($tool['img'], $translated_icons)) {
$tool['name_translated'] = get_lang(ucfirst($tool['name']));
}
$all_tools[] = $tool;
}
@ -105,12 +96,12 @@ class CourseHome {
foreach ($all_tools as & $tool) {
if (api_get_session_id() != 0 && in_array($tool['name'], array('course_maintenance', 'course_setting'))) {
continue;
continue;
}
$cell_content = '';
// The name of the tool
$tool_name = !empty($tool['name_translated']) ? $tool['name_translated'] : @htmlspecialchars($tool['name'], ENT_QUOTES, $charset); // RH: added htmlspecialchars
$tool_name = self::translate_tool_name($tool);
$link_annex = '';
// The url of the tool
@ -212,12 +203,6 @@ class CourseHome {
$charset = api_get_system_encoding();
$web_code_path = api_get_path(WEB_CODE_PATH);
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$translated_icons = array(
'file_html.gif', 'file_html_na.gif',
'scormbuilder.gif', 'scormbuilder_na.gif',
'blog.gif', 'blog_na.gif',
'external.gif', 'external_na.gif'
);
switch ($course_tool_category) {
@ -325,11 +310,7 @@ class CourseHome {
echo '<a href="'. htmlspecialchars($tool['link']).(($tool['image'] == 'external.gif' || $tool['image'] == 'external_na.gif') ? '' : $qm_or_amp.api_get_cidreq()).'" target="' , $tool['target'], '" '.$class.'>';
}
if (in_array($tool['image'], $translated_icons)) {
$tool_name = @htmlspecialchars($tool['name'], ENT_QUOTES, $charset);
} else {
$tool_name = get_lang(ucfirst($tool['name']));
}
$tool_name = self::translate_tool_name($tool);
echo Display::return_icon($tool['image'], $tool_name),'&nbsp;', $tool_name,'</a>';
// This part displays the links to hide or remove a tool.
@ -379,7 +360,7 @@ class CourseHome {
}
}
if (is_array($lnk)) {
foreach($lnk as $this_link) {
foreach ($lnk as & $this_link) {
if (!$tool['adminlink']) {
echo '<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;id='.$tool['id'].'&amp;'.$this_link['cmd'].'">'.$this_link['name'].'</a>';
}
@ -578,12 +559,6 @@ class CourseHome {
$course_tool_table = Database::get_course_table(TABLE_TOOL_LIST);
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$is_platform_admin = api_is_platform_admin();
$translated_icons = array(
'file_html.gif', 'file_html_na.gif',
'scormbuilder.gif', 'scormbuilder_na.gif',
'blog.gif', 'blog_na.gif',
'external.gif', 'external_na.gif'
);
$i = 0;
if (isset($all_tools_list)) {
@ -682,13 +657,7 @@ class CourseHome {
}
echo $toollink;
if (in_array($tool['image'], $translated_icons)) {
$tool_name = stripslashes($tool['name']);
} else {
$list = explode('_', $tool['name']);
foreach ($list as & $item) { $item = ucfirst($item); }
$tool_name = get_lang('Tool'.implode($list));
}
$tool_name = self::translate_tool_name($tool);
Display::display_icon($tool['image'], $tool_name, array('class' => 'tool-icon', 'id' => 'toolimage_'.$tool['id']));
// Validacion when belongs to a session
@ -764,4 +733,33 @@ class CourseHome {
return $output;
}
/**
* Retrieves the name-field within a tool-record and translates it on necessity.
* @param array $tool The input record.
* @return string Returns the name of the corresponding tool.
*/
public static function translate_tool_name(& $tool) {
static $already_translated_icons = array(
'file_html.gif', 'file_html_na.gif',
'scormbuilder.gif', 'scormbuilder_na.gif',
'blog.gif', 'blog_na.gif',
'external.gif', 'external_na.gif'
);
if (in_array($tool['image'], $already_translated_icons)) {
$tool_name = Security::remove_XSS(stripslashes($tool['name']));
} else {
$variable = 'Tool'.api_underscore_to_camel_case($tool['name']); // The newly opened language variables.
$variable_old = ucfirst($tool['name']); // The old language variables as a second chance exist.
if (api_is_translated($variable)) {
$tool_name = get_lang($variable);
} elseif (api_is_translated($variable_old)) {
$tool_name = get_lang($variable_old);
} else {
$tool_name = get_lang($variable);
}
}
return $tool_name;
}
}

@ -6,6 +6,7 @@
*
* @package dokeos.include
*/
require_once api_get_path(LIBRARY_PATH).'course_home.lib.php'; // For using the method CourseHome::translate_tool_name();
define('SHORTCUTS_HORIZONTAL', 0);
define('SHORTCUTS_VERTICAL', 1);
@ -30,7 +31,7 @@ function get_navigation_items($include_admin_tools = false) {
$user_id = api_get_user_id();
$course_tools_table = Database :: get_course_table(TABLE_TOOL_LIST,$database);
$course_tools_table = Database :: get_course_table(TABLE_TOOL_LIST, $database);
/* Link to the Course homepage */
@ -44,17 +45,9 @@ function get_navigation_items($include_admin_tools = false) {
$sql_result = Database::query($sql_menu_query);
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) {
$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') {
$navigation_items[$row['id']]['name'] = get_lang(ucfirst($navigation_items[$row['id']]['name']));
}
$navigation_items[$row['id']]['name'] = CourseHome::translate_tool_name($row);
}
}
@ -67,7 +60,7 @@ function get_navigation_items($include_admin_tools = false) {
WHERE link='course_info/infocours.php'";
$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']));
$course_setting_visual_name = CourseHome::translate_tool_name($course_setting_info);
if (api_get_session_id() == 0) {
// course settings item
$navigation_items['course_settings']['image'] = $course_setting_info['image'];
@ -212,9 +205,6 @@ 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')) {
/*
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'] . '"';
*/
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'].'"';

Loading…
Cancel
Save