Avoid warning messages if input is an array in choose_image function

skala
Julio Montoya 15 years ago
parent 02d09d32a6
commit 3b6d294e95
  1. 18
      main/inc/lib/fileDisplay.lib.php
  2. 24
      main/newscorm/learnpath.class.php

@ -90,19 +90,19 @@ function choose_image($file_name)
/* FUNCTION CORE */
$extension = array();
if (ereg('\.([[:alnum:]]+)$', $file_name, $extension))
{
$extension[1] = strtolower($extension[1]);
foreach ($type as $generic_type => $extension_list)
{
if (in_array($extension[1], $extension_list))
if (!is_array($file_name)) {
if (ereg('\.([[:alnum:]]+)$', $file_name, $extension)) {
$extension[1] = strtolower($extension[1]);
foreach ($type as $generic_type => $extension_list)
{
return $image[$generic_type];
if (in_array($extension[1], $extension_list))
{
return $image[$generic_type];
}
}
}
}
return 'defaut.gif';
}

@ -3,8 +3,10 @@
/**
* This (abstract?) class defines the parent attributes and methods for the dokeos learnpaths and scorm
* learnpaths. It is used by the scorm class.
*
* @package chamilo.learnpath
* @author Yannick Warnier <ywarnier@beeznest.org>
* @author Julio Montoya <gugli100@gmail.com> Improvements
* @license GNU/GPL - See license in root directory for details
*/
/**
@ -7236,23 +7238,23 @@ class learnpath {
*/
function write_resources_tree($resources_sorted, $num = 0) {
include_once (api_get_path(LIBRARY_PATH) . 'fileDisplay.lib.php');
require_once (api_get_path(LIBRARY_PATH) . 'fileDisplay.lib.php');
if (count($resources_sorted) > 0) {
foreach ($resources_sorted as $key => $resource) {
if (is_int($resource['id'])) { // it's a folder
if (is_int($resource['id'])) {
// it's a folder
$return .= '<div><div style="margin-left:' . ($num * 15) . 'px;margin-right:5px;"><img style="cursor: pointer;" src="../img/nolines_plus.gif" align="absmiddle" id="img_' . $resource["id"] . '" onclick="testResources(\'' . $resource["id"] . '\',\'img_' . $resource["id"] . '\')"><img alt="" src="../img/lp_folder.gif" title="" align="absmiddle" />&nbsp;<span onclick="testResources(\'' . $resource["id"] . '\',\'img_' . $resource["id"] . '\')" style="cursor: pointer;" >' . $key . '</span></div><div style="display: none;" id="' . $resource['id'] . '">';
$return .= $this->write_resources_tree($resource['files'], $num +1);
$return .= "</div></div>\r\n";
$return .= '</div></div>';
} else {
// it's a file
$icon = choose_image($resource);
$position = strrpos($icon, '.');
$icon = substr($icon, 0, $position) . '_small.gif';
$return .= '<div><div style="margin-left:' . (($num +1) * 15) . 'px;margin-right:5px;"><a href="' . api_get_self() . '?cidReq=' . $_GET['cidReq'] . '&amp;action=add_item&amp;type=' . TOOL_DOCUMENT . '&amp;file=' . $key . '&amp;lp_id=' . $this->lp_id . '"><img alt="" src="../img/' . $icon . '" title="" />&nbsp;' . $resource . "</a></div></div>\r\n";
if (!is_array($resource)) {
// it's a file
$icon = choose_image($resource);
$position = strrpos($icon, '.');
$icon = substr($icon, 0, $position) . '_small.gif';
$return .= '<div><div style="margin-left:' . (($num +1) * 15) . 'px;margin-right:5px;"><a href="' . api_get_self() . '?cidReq=' . $_GET['cidReq'] . '&amp;action=add_item&amp;type=' . TOOL_DOCUMENT . '&amp;file=' . $key . '&amp;lp_id=' . $this->lp_id . '"><img alt="" src="../img/' . $icon . '" title="" />&nbsp;' . $resource .'</a></div></div>';
}
}
}
}
return $return;

Loading…
Cancel
Save