/** * 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', 'file_html.png', 'file_html_na.png', 'scormbuilder.gif', 'scormbuilder_na.gif', 'blog.gif', 'blog_na.gif', 'external.gif', 'external_na.gif'); if (in_array($tool['image'], $already_translated_icons)) { $toolName = Security::remove_XSS(stripslashes($tool['name'])); } else { $toolName = get_lang('Tool' . api_underscore_to_camel_case($tool['name'])); } return $toolName; }
/** * 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 { /* // The following (slow) code was made in the past for transitional purposes. // We assume that the new language variables Tool* have been already translated. $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. 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); } */ $tool_name = get_lang('Tool' . api_underscore_to_camel_case($tool['name'])); } return $tool_name; }
if (isset($data['delete_icon'])) { CourseHome::deleteIcon($id); } $currentUrlReturn = api_get_self() . '?' . api_get_cidreq(); header('Location: ' . $currentUrlReturn); exit; } break; case 'list': default: $toolList = CourseHome::toolsIconsAction(api_get_course_int_id(), api_get_session_id()); $iconsTools = '<div id="custom-icons">'; $iconsTools .= Display::page_header(get_lang('CustomizeIcons'), null, 'h4'); $iconsTools .= '<div class="row">'; foreach ($toolList as $tool) { $toolIconName = 'Tool' . api_underscore_to_camel_case($tool['name']); $toolIconName = isset(${$toolIconName}) ? get_lang($toolIconName) : $tool['name']; $iconsTools .= '<div class="col-md-2">'; $iconsTools .= '<div class="items-tools">'; if (!empty($tool['custom_icon'])) { $image = getCustomWebIconPath() . $tool['custom_icon']; $icon = Display::img($image, $toolIconName); } else { $image = substr($tool['image'], 0, strpos($tool['image'], '.')) . '.png'; $icon = Display::return_icon($image, $toolIconName, array('id' => 'tool_' . $tool['id']), ICON_SIZE_BIG, false); } $delete = !empty($tool['custom_icon']) ? "<a class=\"btn btn-default\" onclick=\"javascript:\n if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "')) return false;\" href=\"" . api_get_self() . '?action=delete_icon&id=' . $tool['iid'] . '&' . api_get_cidreq() . "\">\n <em class=\"fa fa-trash-o\"></em></a>" : ""; $edit = '<a class="btn btn-default" href="' . api_get_self() . '?action=edit_icon&id=' . $tool['iid'] . '&' . api_get_cidreq() . '"><em class="fa fa-pencil"></em></a>'; $iconsTools .= '<div class="icon-tools">' . $icon . '</div>'; $iconsTools .= '<div class="name-tools">' . $toolIconName . '</div>'; $iconsTools .= '<div class="toolbar">' . $edit . $delete . '</div>';
$currentUrlReturn = api_get_self() . '?' . api_get_cidreq(); header('Location: ' . $currentUrlReturn); exit; } break; case 'list': default: $toolList = CourseHome::toolsIconsAction(api_get_course_int_id(), api_get_session_id()); $iconsTools = '<div id="custom-icons">'; $iconsTools .= Display::page_header(get_lang('CustomizeIcons'), null, 'h4'); $iconsTools .= '<div class="row">'; foreach ($toolList as $tool) { if ($tool['id'] > 20) { $toolIconName = $tool['name']; } else { $toolIconName = get_lang('Tool' . api_underscore_to_camel_case($tool['name'])); } $iconsTools .= '<div class="col-md-2">'; $iconsTools .= '<div class="items-tools">'; if (!empty($tool['custom_icon'])) { $image = getCustomWebIconPath() . $tool['custom_icon']; $icon = Display::img($image, $toolIconName); } else { $image = substr($tool['image'], 0, strpos($tool['image'], '.')) . '.png'; $icon = Display::return_icon($image, $toolIconName, array('id' => 'tool_' . $tool['id']), ICON_SIZE_BIG, false); } $delete = !empty($tool['custom_icon']) ? "<a class=\"btn btn-default\" onclick=\"javascript:\n if(!confirm('" . addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES, $charset)) . "')) return false;\" href=\"" . api_get_self() . '?action=delete_icon&id=' . $tool['iid'] . '&' . api_get_cidreq() . "\">\n <em class=\"fa fa-trash-o\"></em></a>" : ""; $edit = '<a class="btn btn-default" href="' . api_get_self() . '?action=edit_icon&id=' . $tool['iid'] . '&' . api_get_cidreq() . '"><em class="fa fa-pencil"></em></a>'; $iconsTools .= '<div class="icon-tools">' . $icon . '</div>'; $iconsTools .= '<div class="name-tools">' . $toolIconName . '</div>'; $iconsTools .= '<div class="toolbar">' . $edit . $delete . '</div>';