/**
  * Get document information
  */
 private function get_information($course_id, $doc_id)
 {
     $course_information = api_get_course_info($course_id);
     $course_id = $course_information['real_id'];
     $course_path = $course_information['path'];
     if (!empty($course_information)) {
         $item_property_table = Database::get_course_table(TABLE_ITEM_PROPERTY);
         $doc_table = Database::get_course_table(TABLE_DOCUMENT);
         $doc_id = intval($doc_id);
         $sql = "SELECT * FROM       {$doc_table}\n                    WHERE      {$doc_table}.id = {$doc_id} AND c_id = {$course_id}\n                    LIMIT 1";
         $dk_result = Database::query($sql);
         $sql = "SELECT insert_user_id FROM       {$item_property_table}\n                    WHERE   ref = {$doc_id} AND tool = '" . TOOL_DOCUMENT . "' AND c_id = {$course_id}\n                    LIMIT 1";
         $name = '';
         if ($row = Database::fetch_array($dk_result)) {
             $name = $row['title'];
             $url = api_get_path(WEB_COURSE_PATH) . '%s/document%s';
             $url = sprintf($url, $course_path, $row['path']);
             // Get the image path
             $icon = choose_image(basename($row['path']));
             $thumbnail = Display::returnIconPath($icon);
             $image = $thumbnail;
             //FIXME: use big images
             // get author
             $author = '';
             $item_result = Database::query($sql);
             if ($row = Database::fetch_array($item_result)) {
                 $user_data = api_get_user_info($row['insert_user_id']);
                 $author = api_get_person_name($user_data['firstName'], $user_data['lastName']);
             }
         }
         return array($thumbnail, $image, $name, $author, $url);
         // FIXME: is it posible to get an author here?
     } else {
         return array();
     }
 }
Beispiel #2
0
    //-- if chapter head
    if ($module['contentType'] == CTLABEL_) {
        $tool_content .= '      <b>' . q($module['name']) . '</b>';
    }
    //-- if user can access module
    else {
        if ($module['contentType'] == CTEXERCISE_) {
            $moduleImg = 'fa-pencil-square-o';
        } elseif ($module['contentType'] == CTLINK_) {
            $moduleImg = 'fa-link';
        } elseif ($module['contentType'] == CTCOURSE_DESCRIPTION_) {
            $moduleImg = 'fa-info-circle';
        } elseif ($module['contentType'] == CTMEDIA_ or $module['contentType'] == CTMEDIALINK_) {
            $moduleImg = 'fa-film';
        } else {
            $moduleImg = choose_image(basename($module['path']));
        }
        $contentType_alt = selectAlt($module['contentType']);
        $tool_content .= icon($moduleImg, $contentType_alt) . q($module['name']) . '</small>';
    }

    $tool_content .= '</td>' . "\n";

    if ($module['contentType'] == CTSCORM_) {
        $session_time = preg_replace("/\.[0-9]{0,2}/", "", $module['session_time']);
        $total_time = preg_replace("/\.[0-9]{0,2}/", "", $module['total_time']);
        $global_time = addScormTime($global_time, $total_time);
    } elseif ($module['contentType'] == CTLABEL_ || $module['contentType'] == CTEXERCISE_) {
        $session_time = $module['session_time'];
        $total_time = $module['total_time'];
    } else {
 /**
  * @param array $course_info
  * @param int $session_id
  * @param array $resource
  * @param int $lp_id
  * @param bool $add_move_button
  * @param string $target
  * @param string $overwrite_url
  * @return null|string
  */
 private static function parseFile($course_info, $session_id, $resource, $lp_id, $add_move_button, $target, $overwrite_url)
 {
     $img_path = api_get_path(WEB_IMG_PATH);
     $img_sys_path = api_get_path(SYS_CODE_PATH) . 'img/';
     $web_code_path = api_get_path(WEB_CODE_PATH);
     $documentId = $resource['id'];
     $path = $resource['path'];
     if (empty($path)) {
         $num = 0;
     } else {
         $num = substr_count($path, '/') - 1;
     }
     // It's a file.
     $icon = choose_image($path);
     $position = strrpos($icon, '.');
     $icon = substr($icon, 0, $position) . '_small.gif';
     $my_file_title = $resource['title'];
     $visibility = $resource['visibility'];
     // If title is empty we try to use the path
     if (empty($my_file_title)) {
         $my_file_title = basename($path);
     }
     // Show the "image name" not the filename of the image.
     if ($lp_id) {
         //LP URL
         $url = api_get_path(WEB_CODE_PATH) . 'newscorm/lp_controller.php?' . api_get_cidreq() . '&amp;action=add_item&amp;type=' . TOOL_DOCUMENT . '&amp;file=' . $documentId . '&amp;lp_id=' . $lp_id;
         if (!empty($overwrite_url)) {
             $url = $overwrite_url . '&cidReq=' . $course_info['code'] . '&id_session=' . $session_id . '&document_id=' . $documentId . '';
         }
     } else {
         // Direct document URL
         $url = $web_code_path . 'document/document.php?cidReq=' . $course_info['code'] . '&id_session=' . $session_id . '&id=' . $documentId;
         if (!empty($overwrite_url)) {
             $url = $overwrite_url . '&cidReq=' . $course_info['code'] . '&id_session=' . $session_id . '&document_id=' . $documentId;
         }
     }
     $img = $img_path . $icon;
     if (!file_exists($img_sys_path . $icon)) {
         $img = $img_path . 'icons/16/default_small.gif';
     }
     $link = Display::url('<img alt="" src="' . $img . '" title="" />&nbsp;' . $my_file_title, $url, array('target' => $target));
     $visibilityClass = null;
     if ($visibility == 0) {
         $visibilityClass = ' invisible ';
     }
     $return = null;
     if ($lp_id == false) {
         $return .= '<li class="doc_resource ' . $visibilityClass . ' " data_id="' . $documentId . '" data_type="document" title="' . $my_file_title . '" >';
     } else {
         $return .= '<li class="doc_resource lp_resource_element ' . $visibilityClass . ' " data_id="' . $documentId . '" data_type="document" title="' . $my_file_title . '" >';
     }
     $return .= '<div class="item_data" style="margin-left:' . $num * 18 . 'px;margin-right:5px;">';
     if ($add_move_button) {
         $return .= '<a class="moved" href="#">';
         $return .= Display::return_icon('move_everywhere.png', get_lang('Move'), array(), ICON_SIZE_TINY);
         $return .= '</a> ';
     }
     $return .= $link;
     $return .= '</div></li>';
     return $return;
 }
Beispiel #4
0
         $style = 'invisible ';
     } else {
         continue;
         // skip the display of this file
     }
 } else {
     $style = '';
 }
 //modify style if the file is recently added since last login
 if (claro_is_user_authenticated() && $claro_notifier->is_a_notified_document(claro_get_current_course_id(), $date, claro_get_current_user_id(), claro_get_current_group_id(), claro_get_current_tool_id(), $thisFile)) {
     $classItem = ' hot';
 } else {
     $classItem = '';
 }
 if ($thisFile['type'] == A_FILE) {
     $image = choose_image($thisFile['path']);
     $size = format_file_size($thisFile['size']);
     $date = format_date($thisFile['date']);
     $urlFileName = claro_htmlspecialchars(claro_get_file_download_url($thisFile['path']));
     //$urlFileName = "goto/?doc_url=".rawurlencode($cmdFileName);
     //format_url($baseServUrl.$courseDir.$curDirPath."/".$fileName));
     $target = get_conf('openNewWindowForDoc') ? 'target="_blank"' : '';
 } elseif ($thisFile['type'] == A_DIRECTORY) {
     $image = 'folder';
     $size = '&nbsp;';
     $date = '&nbsp;';
     $urlFileName = claro_htmlspecialchars(Url::Contextualize($_SERVER['PHP_SELF'] . '?cmd=exChDir&amp;file=' . $cmdFileName));
     $target = '';
 }
 $out .= '<tr align="center">' . "\n" . '<td align="left">';
 if (is_image($thisFile['path'])) {
Beispiel #5
0
function display_my_documents($dialogBox, $style)
{
    global $curDirName;
    global $curDirPath;
    global $parentDir;
    global $langUp;
    global $langName;
    global $langSize;
    global $langDate;
    global $langAddModulesButton;
    global $fileList;
    global $themeimg;
    global $langSelection, $langDirectory, $course_code;
    $output = '';
    /*
     * DISPLAY
     */
    $dspCurDirName = htmlspecialchars($curDirName);
    // $cmdCurDirPath = rawurlencode($curDirPath);
    $cmdParentDir = rawurlencode($parentDir);
    $output .= '<form action="' . $_SERVER['SCRIPT_NAME'] . '?course=' . $course_code . '" method="POST">';
    /* --------------------------------------
       DIALOG BOX SECTION
       -------------------------------------- */
    $colspan = 5;
    if (!empty($dialogBox)) {
        $output .= disp_message_box($dialogBox, $style) . "<br />";
    }
    /* --------------------------------------
       CURRENT DIRECTORY LINE
       -------------------------------------- */
    /* CURRENT DIRECTORY */
    if ($curDirName) {
        $output .= '
        <table class="table-default">
        <tr>
          <td width="1" class="right">' . icon('fa-folder-o') . '</td>
          <td>' . $langDirectory . ': <b>' . $dspCurDirName . '</b></td>';
        /* GO TO PARENT DIRECTORY */
        if ($curDirName) {
            $linkup = "<a href='{$_SERVER['SCRIPT_NAME']}?course={$course_code}&amp;openDir={$cmdParentDir}'>";
            $output .= "<td width='1'>{$linkup}<img src='{$themeimg}/folder_up.png' " . "hspace='5' alt='{$langUp}' title='langUp' /></a></td>" . "<td width='10' class='right'><small>{$linkup}{$langUp}</a></small></td>";
        }
        $output .= '</tr></table>';
    }
    $output .= '
    <div class="table-responsive">
    <table class="table-default" >';
    $output .= "\n    <tr class='list-header'>\n      <th colspan='2'><div align='left'>&nbsp;&nbsp;{$langName}</div></th>\n      <th>{$langSize}</th>\n      <th>{$langDate}</th>\n      <th>{$langSelection}</th>\n    </tr>";
    /* --------------------------------------
       DISPLAY FILE LIST
       -------------------------------------- */
    if ($fileList) {
        $iterator = 0;
        $ind = 1;
        while (list($fileKey, $fileName) = each($fileList['name'])) {
            if ($ind % 2 == 0) {
                $style = 'class="even"';
            } else {
                $style = 'class="odd"';
            }
            $dspFileName = htmlspecialchars($fileList['filename'][$fileKey]);
            $cmdFileName = str_replace("%2F", "/", rawurlencode($curDirPath . "/" . $fileName));
            if ($fileList['visible'][$fileKey] == 0) {
                continue;
                // skip the display of this file
            }
            if ($fileList['type'][$fileKey] == A_FILE) {
                $image = choose_image($fileName);
                $size = format_file_size($fileList['size'][$fileKey]);
                $date = nice_format($fileList['date'][$fileKey]);
                $file_url = file_url($fileList['path'][$fileKey], $dspFileName);
                $play_url = file_playurl($fileList['path'][$fileKey], $dspFileName);
                $urlFileName = MultimediaHelper::chooseMediaAhrefRaw($file_url, $play_url, $dspFileName, $dspFileName);
            } elseif ($fileList['type'][$fileKey] == A_DIRECTORY) {
                $image = 'fa-folder';
                $size = '&nbsp;';
                $date = '&nbsp;';
                $urlFileName = '<a href="' . $_SERVER['SCRIPT_NAME'] . '?course=' . $course_code . '&amp;openDir=' . $cmdFileName . '">' . $dspFileName . '</a>';
            }
            $output .= '
                <tr ' . $style . '>
                <td class="center" width="1">' . icon($image, '') . '</td>
                <td align="left">' . $urlFileName . '</td>
                <td width="80" class="center">' . $size . '</td>
                <td width="80" class="center">' . $date . '</td>';
            if ($fileList['type'][$fileKey] == A_FILE) {
                $iterator++;
                $output .= '
                <td width="10" class="center">
                        <input type="checkbox" name="insertDocument_' . $iterator . '" id="insertDocument_' . $iterator . '" value="' . $curDirPath . "/" . $fileName . '" />
                        <input type="hidden" name="filenameDocument_' . $iterator . '" id="filenameDocument_' . $iterator . '" value="' . $dspFileName . '" />
                </td>';
            } else {
                $output .= '<td>&nbsp;</td>';
            }
            $output .= '</tr>';
            /* COMMENTS */
            if ($fileList['comment'][$fileKey] != "") {
                $fileList['comment'][$fileKey] = htmlspecialchars($fileList['comment'][$fileKey]);
                $fileList['comment'][$fileKey] = parse_user_text($fileList['comment'][$fileKey]);
                $output .= '
                <tr class="even">
                <td>&nbsp;</td>
                <td colspan="' . $colspan . '"><span class="comment">' . $fileList['comment'][$fileKey] . '</span></td>
                </tr>';
            }
            $ind++;
        }
        // end each ($fileList)
        // form button
        $output .= '
    <tr>
      <th colspan="' . $colspan . '"><div class="pull-right">
        <input type="hidden" name="openDir" value="' . $curDirPath . '" />
        <input type="hidden" name="maxDocForm" value ="' . $iterator . '" />
        <input class="btn btn-primary" type="submit" name="submitInsertedDocument" value="' . $langAddModulesButton . '">        
      </th>
    </tr>';
    } else {
        $output .= '<tr><td colspan="4">&nbsp;</td></tr>';
    }
    $output .= '</table></div></form>';
    return $output;
}
Beispiel #6
0
/**
 * list documents while inserting them in course unit
 * @global type $id
 * @global type $webDir
 * @global type $course_code
 * @global type $tool_content
 * @global type $group_sql
 * @global type $langDirectory
 * @global type $langUp
 * @global type $langName
 * @global type $langSize
 * @global type $langDate
 * @global type $langType
 * @global type $langAddModulesButton
 * @global type $langChoice
 * @global type $langNoDocuments
 * @global type $course_code 
 */
function list_docs()
{
    global $id, $webDir, $course_code, $tool_content, $group_sql, $langDirectory, $langUp, $langName, $langSize, $langDate, $langType, $langAddModulesButton, $langChoice, $langNoDocuments, $course_code, $langCommonDocs, $pageName;
    $basedir = $webDir . '/courses/' . $course_code . '/document';
    $path = get_dir_path('path');
    $dir_param = get_dir_path('dir');
    $dir_setter = $dir_param ? '&amp;dir=' . $dir_param : '';
    $dir_html = $dir_param ? "<input type='hidden' name='dir' value='{$dir_param}'>" : '';
    if ($id == -1) {
        $common_docs = true;
        $pageName = $langCommonDocs;
        $group_sql = "course_id = -1 AND subsystem = " . COMMON . "";
        $basedir = $webDir . '/courses/commondocs';
        $result = Database::get()->queryArray("SELECT * FROM document\n                                    WHERE {$group_sql} AND\n                                          visible = 1 AND\n                                          path LIKE ?s AND\n                                          path NOT LIKE ?s", "{$path}/%", "{$path}/%/%");
    } else {
        $common_docs = false;
        $result = Database::get()->queryArray("SELECT * FROM document\n                                    WHERE {$group_sql} AND\n                                          path LIKE ?s AND\n                                          path NOT LIKE ?s", "{$path}/%", "{$path}/%/%");
    }
    $fileinfo = array();
    $urlbase = $_SERVER['SCRIPT_NAME'] . "?course={$course_code}{$dir_setter}&amp;type=doc&amp;id={$id}&amp;path=";
    foreach ($result as $row) {
        $fullpath = $basedir . $row->path;
        if ($row->extra_path) {
            $size = 0;
        } else {
            $size = file_exists($fullpath) ? filesize($fullpath) : 0;
        }
        $fileinfo[] = array('id' => $row->id, 'is_dir' => is_dir($fullpath), 'size' => $size, 'title' => $row->title, 'name' => htmlspecialchars($row->filename), 'format' => $row->format, 'path' => $row->path, 'visible' => $row->visible, 'comment' => $row->comment, 'copyrighted' => $row->copyrighted, 'date' => $row->date_modified, 'object' => MediaResourceFactory::initFromDocument($row));
    }
    if (count($fileinfo) == 0) {
        $tool_content .= "<div class='alert alert-warning'>{$langNoDocuments}</div>";
    } else {
        if (empty($path)) {
            $dirname = '';
            $parenthtml = '';
            $colspan = 5;
        } else {
            $dirname = Database::get()->querySingle("SELECT filename FROM document\n                                                                   WHERE {$group_sql} AND path = ?s", $path);
            $parentpath = dirname($path);
            $dirname = "/" . htmlspecialchars($dirname);
            $parentlink = $urlbase . $parentpath;
            $parenthtml = "<th class='right'><a href='{$parentlink}'>{$langUp}</a> " . icon('fa-upload', $langUp, $parentlink) . "</th>";
            $colspan = 4;
        }
        $tool_content .= "<form action='insert.php?course={$course_code}' method='post'><input type='hidden' name='id' value='{$id}' />" . "<table class='table-default'>" . "<tr>" . "<th colspan='{$colspan}'><div align='left'>{$langDirectory}: {$dirname}</div></th>" . $parenthtml . "</tr>" . "<tr>" . "<th>{$langType}</th>" . "<th><div align='left'>{$langName}</div></th>" . "<th width='100'>{$langSize}</th>" . "<th width='80'>{$langDate}</th>" . "<th width='80'>{$langChoice}</th>" . "</tr>";
        $counter = 0;
        foreach (array(true, false) as $is_dir) {
            foreach ($fileinfo as $entry) {
                if ($entry['is_dir'] != $is_dir) {
                    continue;
                }
                $dir = $entry['path'];
                if ($is_dir) {
                    $image = 'fa-folder-o';
                    $file_url = $urlbase . $dir;
                    $link_text = $entry['name'];
                    $link_href = "<a href='{$file_url}'>{$link_text}</a>";
                } else {
                    $image = choose_image('.' . $entry['format']);
                    $file_url = file_url($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code);
                    $dObj = $entry['object'];
                    $dObj->setAccessURL($file_url);
                    $dObj->setPlayURL(file_playurl($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code));
                    $link_href = MultimediaHelper::chooseMediaAhref($dObj);
                }
                if ($entry['visible'] == 'i') {
                    $vis = 'invisible';
                } else {
                    $vis = '';
                }
                $tool_content .= "<tr class='{$vis}'>";
                $tool_content .= "<td width='1' class='center'>" . icon($image, '') . "</td>";
                $tool_content .= "<td>{$link_href}";
                /* * * comments ** */
                if (!empty($entry['comment'])) {
                    $tool_content .= "<br /><div class='comment'>" . standard_text_escape($entry['comment']) . "</div>";
                }
                $tool_content .= "</td>";
                if ($is_dir) {
                    // skip display of date and time for directories
                    $tool_content .= "<td>&nbsp;</td><td>&nbsp;</td>";
                } else {
                    $size = format_file_size($entry['size']);
                    $date = nice_format($entry['date'], true, true);
                    $tool_content .= "<td class='center'>{$size}</td><td class='center'>{$date}</td>";
                }
                $tool_content .= "<td class='center'><input type='checkbox' name='document[]' value='{$entry['id']}' /></td>";
                $tool_content .= "</tr>";
                $counter++;
            }
        }
        $tool_content .= "<tr><th colspan={$colspan}><div align='right'>";
        $tool_content .= "<input class='btn btn-primary' type='submit' name='submit_doc' value='{$langAddModulesButton}' /></div></th>";
        $tool_content .= "</tr></table>{$dir_html}</form>";
    }
}
Beispiel #7
0
 /**
  * Generate and return an HTML list of resources based on a given array.
  *
  * This list is used to show the course creator a list of available resources to choose from
  * when creating a learning path.
  * @param	array	Array of elements to add to the list
  * @param	integer Enables the tree display by shifting the new elements a certain distance to the right
  * @return	string	The HTML list
  */
 function write_resources_tree($resources_sorted, $num = 0)
 {
     global $charset;
     include_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
                 $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"] . '\')">' . Display::return_icon('pixel.gif', '', array('class' => 'actionplaceholderminiicon actionsmalllpfolder')) . '&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";
             } else {
                 // it's a file
                 $icon = choose_image($resource);
                 //$position = strrpos($icon, '.');0
                 $icon = $icon . '_16x16';
                 //var_dump($icon);
                 $return .= '<div><div style="margin-left:' . ($num + 1) * 15 . 'px;margin-right:5px;"><a href="' . api_get_self() . '?cidReq=' . Security::remove_XSS($_GET['cidReq']) . '&amp;action=add_item&amp;type=' . TOOL_DOCUMENT . '&amp;file=' . $key . '&amp;lp_id=' . $this->lp_id . '">' . Display::return_icon('pixel.gif', '', array('class' => 'actionplaceholderminiicon ' . $icon)) . '&nbsp;' . api_convert_encoding($resource, $charset, api_get_system_encoding()) . "</a></div></div>\r\n";
             }
         }
     }
     return $return;
 }
Beispiel #8
0
 /**
  * Builds an img html tag for the file type
  *
  * @param string $type (file/folder)
  * @param string $path
  * @return string img html tag
  */
 public static function build_document_icon_tag($type, $path)
 {
     $basename = basename($path);
     $current_session_id = api_get_session_id();
     $is_allowed_to_edit = api_is_allowed_to_edit(null, true);
     $user_image = false;
     if ($type == 'file') {
         $icon = choose_image($basename);
         if (preg_match('/_chnano_.wav$/i', $basename)) {
             $icon = "jplayer_play.png";
             $basename = 'wav' . ' ' . '(Nanogong)';
         } else {
             $basename = substr(strrchr($basename, '.'), 1);
         }
     } else {
         if ($path == '/shared_folder') {
             $icon = 'folder_users.gif';
             if ($is_allowed_to_edit) {
                 $basename = get_lang('HelpUsersFolder');
             } else {
                 $basename = get_lang('UserFolders');
             }
         } elseif (strstr($basename, 'sf_user_')) {
             $userinfo = api_get_user_info(substr($basename, 8));
             $icon = $userinfo['avatar_small'];
             $basename = get_lang('UserFolder') . ' ' . $userinfo['complete_name'];
             $user_image = true;
         } elseif (strstr($path, 'shared_folder_session_')) {
             if ($is_allowed_to_edit) {
                 $basename = '***(' . api_get_session_name($current_session_id) . ')*** ' . get_lang('HelpUsersFolder');
             } else {
                 $basename = get_lang('UserFolders') . ' (' . api_get_session_name($current_session_id) . ')';
             }
             $icon = 'folder_users.gif';
         } else {
             $icon = 'folder_document.gif';
             if ($path == '/audio') {
                 $icon = 'folder_audio.gif';
                 if (api_is_allowed_to_edit()) {
                     $basename = get_lang('HelpDefaultDirDocuments');
                 } else {
                     $basename = get_lang('Audio');
                 }
             } elseif ($path == '/flash') {
                 $icon = 'folder_flash.gif';
                 if (api_is_allowed_to_edit()) {
                     $basename = get_lang('HelpDefaultDirDocuments');
                 } else {
                     $basename = get_lang('Flash');
                 }
             } elseif ($path == '/images') {
                 $icon = 'folder_images.gif';
                 if (api_is_allowed_to_edit()) {
                     $basename = get_lang('HelpDefaultDirDocuments');
                 } else {
                     $basename = get_lang('Images');
                 }
             } elseif ($path == '/video') {
                 $icon = 'folder_video.gif';
                 if (api_is_allowed_to_edit()) {
                     $basename = get_lang('HelpDefaultDirDocuments');
                 } else {
                     $basename = get_lang('Video');
                 }
             } elseif ($path == '/images/gallery') {
                 $icon = 'folder_gallery.gif';
                 if (api_is_allowed_to_edit()) {
                     $basename = get_lang('HelpDefaultDirDocuments');
                 } else {
                     $basename = get_lang('Gallery');
                 }
             } elseif ($path == '/chat_files') {
                 $icon = 'folder_chat.png';
                 if (api_is_allowed_to_edit()) {
                     $basename = get_lang('HelpFolderChat');
                 } else {
                     $basename = get_lang('ChatFiles');
                 }
             } elseif ($path == '/learning_path') {
                 $icon = 'folder_learningpath.gif';
                 if (api_is_allowed_to_edit()) {
                     $basename = get_lang('HelpFolderLearningPaths');
                 } else {
                     $basename = get_lang('LearningPaths');
                 }
             }
         }
     }
     if ($user_image) {
         return Display::img($icon, $basename, array(), false);
     }
     return Display::return_icon($icon, $basename, array());
 }
Beispiel #9
0
    }
}
//end if ADD command
//STEP ONE : display form to add module of the course that are not in this path yet
// this is the same SELECT as "select all 'addable' modules of this course for this learning path"
// **BUT** normally there is less 'addable' modules here than in the first one
$result = claro_sql_query(buildRequestModules());
// Display available modules
$out .= '<form name="addmodule" action="' . $_SERVER['PHP_SELF'] . '?cmdglobal=add">' . "\n" . claro_form_relay_context() . "\n" . '<table class="claroTable">' . "\n" . '<thead>' . "\n" . '<tr align="center" valign="top">' . "\n" . '<th width="10%">' . get_lang('Add module(s)') . '</th>' . "\n" . '<th>' . get_lang('Module') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n\n" . '<tbody>' . "\n\n";
$atleastOne = false;
while ($list = mysql_fetch_array($result)) {
    //CHECKBOX, NAME, RENAME, COMMENT
    if ($list['contentType'] == CTEXERCISE_) {
        $moduleImg = get_icon_url('quiz', 'CLQWZ');
    } else {
        $moduleImg = get_icon_url(choose_image(basename($list['path'])));
    }
    $contentType_alt = selectAlt($list['contentType']);
    $out .= '<tr>' . "\n" . '<td style="vertical-align:top; text-align: center;">' . "\n" . '<input type="checkbox" name="check_' . $list['module_id'] . '" id="check_' . $list['module_id'] . '" />' . "\n" . '</td>' . "\n" . '<td align="left">' . "\n" . '<label for="check_' . $list['module_id'] . '" >' . '<img hspace="5" src="' . $moduleImg . '" alt="' . $contentType_alt . '" /> ' . $list['name'] . '</label>' . "\n" . ($list['comment'] != null ? '<div class="comment">' . $list['comment'] . '</small>' . '</div>' . "\n\n" : '') . '</td>' . "\n" . '</tr>' . "\n\n";
    $atleastOne = true;
}
//end while another module to display
if (!$atleastOne) {
    $out .= '<tr>' . "\n" . '<td colspan="2" align="center">' . get_lang('All modules of this course are already used in this learning path.') . '</td>' . "\n" . '</tr>' . "\n";
}
$out .= '</tbody>' . "\n" . '</table>' . "\n";
// Display button to add selected modules
if ($atleastOne) {
    $out .= '<input type="submit" value="' . get_lang('Add selection') . '" />' . "\n" . '<input type="hidden" name="cmdglobal" value="add" />' . "\n";
}
$out .= '</form>' . '<br /><br />';
Beispiel #10
0
/**
 * @brief display resource documents
 * @global type $is_editor
 * @global type $course_id
 * @global type $langWasDeleted
 * @global type $urlServer
 * @global type $id
 * @global type $course_code
 * @param type $title
 * @param type $comments
 * @param type $resource_id
 * @param type $file_id
 * @return string
 */
function show_doc($title, $comments, $resource_id, $file_id) {
    global $is_editor, $course_id, $langWasDeleted, $head_content,
           $urlServer, $id, $course_code;
 
    $file = Database::get()->querySingle("SELECT * FROM document WHERE course_id = ?d AND id = ?d", $course_id, $file_id);    
    if (!$file) {
        if (!$is_editor) {
            return '';
        }
        $status = 'del';
        $image = 'fa-times';
        $link = "<span class='not_visible'>" . q($title) . " ($langWasDeleted)</span>";
    } else {
        $status = $file->visible;
        if (!$is_editor and ( !resource_access($file->visible, $file->public))) {
            return '';
        }
        if ($file->format == '.dir') {
            $image = 'fa-folder-o';
            $download_hidden_link = '';
            $link = "<a href='{$urlServer}modules/document/index.php?course=$course_code&amp;openDir=$file->path&amp;unit=$id'>$file->filename</a>";            
        } else {
            $image = choose_image('.' . $file->format);
            $download_url = "{$urlServer}modules/document/index.php?course=$course_code&amp;download=$file->path";
            $download_hidden_link = "<input type='hidden' value='$download_url'>";
            $file_obj = MediaResourceFactory::initFromDocument($file);
            $file_obj->setAccessURL(file_url($file->path, $file->filename));
            $file_obj->setPlayURL(file_playurl($file->path, $file->filename));
            $link = MultimediaHelper::chooseMediaAhref($file_obj);              
        }
    }
    $class_vis = ($status == '0' or $status == 'del') ? ' class="not_visible"' : '';
    if (!empty($comments)) {
        $comment = '<br />' . $comments;
    } else {
        $comment = '';
    }
    return "
        <tr$class_vis>
          <td width='1'>" . icon($image, '') . "</a></td>
          <td align='left'>$download_hidden_link$link$comment</td>" .
            actions('doc', $resource_id, $status) .
            '</tr>';
}
Beispiel #11
0
/**
 * list documents while inserting them in course unit
 * @global type $id
 * @global type $webDir
 * @global type $course_code
 * @global type $tool_content
 * @global type $group_sql
 * @global type $langDirectory
 * @global type $langUp
 * @global type $langName
 * @global type $langSize
 * @global type $langDate
 * @global type $langType
 * @global type $langAddModulesButton
 * @global type $langChoice
 * @global type $langNoDocuments
 * @global type $course_code 
 */
function list_docs() {
    global $id, $webDir, $course_code, $tool_content,
    $group_sql, $langDirectory, $langUp, $langName, $langSize,
    $langDate, $langType, $langAddModulesButton, $langChoice,
    $langNoDocuments, $course_code, $langCommonDocs, $pageName;

    $basedir = $webDir . '/courses/' . $course_code . '/document';
    $path = get_dir_path('path');
    $dir_param = get_dir_path('dir');
    $dir_setter = $dir_param ? ('&amp;dir=' . $dir_param) : '';
    $dir_html = $dir_param ? "<input type='hidden' name='dir' value='$dir_param'>" : '';

    if ($id == -1) {
        $common_docs = true;
        $pageName = $langCommonDocs;
        $group_sql = "course_id = -1 AND subsystem = " . COMMON . "";
        $basedir = $webDir . '/courses/commondocs';
        $visible_sql = 'visible = 1 AND';
    } else {
        $common_docs = false;
        $visible_sql = '';
    }
    $result = Database::get()->queryArray("SELECT id, course_id, path, filename, format, title, extra_path, date_modified, visible, copyrighted, comment, IF(title = '', filename, title) AS sort_key FROM document
                                WHERE $group_sql AND $visible_sql
                                      path LIKE ?s AND
                                      path NOT LIKE ?s
                                ORDER BY sort_key COLLATE utf8_unicode_ci",
                                "$path/%", "$path/%/%");

    $fileinfo = array();
    $urlbase = $_SERVER['SCRIPT_NAME'] . "?course=$course_code$dir_setter&amp;type=doc&amp;id=$id&amp;path=";

    foreach ($result as $row) {
        $fullpath = $basedir . $row->path;
        if ($row->extra_path) {
            $size = 0;
        } else {
            $size = file_exists($fullpath)? filesize($fullpath): 0;
        }
        $fileinfo[] = array(
            'id' => $row->id,
            'is_dir' => is_dir($fullpath),
            'size' => $size,
            'title' => $row->title,
            'name' => htmlspecialchars($row->filename),
            'format' => $row->format,
            'path' => $row->path,
            'visible' => $row->visible,
            'comment' => $row->comment,
            'copyrighted' => $row->copyrighted,
            'date' => $row->date_modified,
            'object' => MediaResourceFactory::initFromDocument($row));
    }
    if (count($fileinfo) == 0) {
        $tool_content .= "<div class='alert alert-warning'>$langNoDocuments</div>";
    } else {
        if (!empty($path)) {
            $dirname = Database::get()->querySingle("SELECT filename FROM document
                                                                   WHERE $group_sql AND path = ?s", $path);
            $parentpath = dirname($path);
            $dirname =  htmlspecialchars($dirname->filename);
            $parentlink = $urlbase . $parentpath;
            $parenthtml = "<span class='pull-right'><a href='$parentlink'>$langUp " .
                    icon('fa-level-up') . "</a></span>";
            $colspan = 4;
        }
        $tool_content .= "<form action='insert.php?course=$course_code' method='post'><input type='hidden' name='id' value='$id' />" .
                "<table class='table-default'>";
        if( !empty($path)) {
        $tool_content .=
                "<tr>" .
                "<th colspan='$colspan'><div class='text-left'>$langDirectory: $dirname$parenthtml</div></th>" .
                "</tr>" ;
        }
        $tool_content .=
                "<tr class='list-header'>" .
                "<th class='text-left'>$langName</th>" .
                "<th class='text-center'>$langSize</th>" .
                "<th class='text-center'>$langDate</th>" .
                "<th style='width:20px;' class='text-center'>$langChoice</th>" .
                "</tr>";
        $counter = 0;
        foreach (array(true, false) as $is_dir) {
            foreach ($fileinfo as $entry) {
                if ($entry['is_dir'] != $is_dir) {
                    continue;
                }
                $dir = $entry['path'];
                if ($is_dir) {
                    $image = 'fa-folder-o';
                    $file_url = $urlbase . $dir;
                    $link_text = $entry['name'];

                    $link_href = "<a href='$file_url'>$link_text</a>";
                } else {
                    $image = choose_image('.' . $entry['format']);
                    $file_url = file_url($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code);

                    $dObj = $entry['object'];
                    $dObj->setAccessURL($file_url);
                    $dObj->setPlayURL(file_playurl($entry['path'], $entry['name'], $common_docs ? 'common' : $course_code));

                    $link_href = MultimediaHelper::chooseMediaAhref($dObj);
                }
                if ($entry['visible'] == 'i') {
                    $vis = 'invisible';
                } else {
                    $vis = '';                    
                }
                $tool_content .= "<tr class='$vis'>";
                $tool_content .= "<td>" . icon($image, '')."&nbsp;&nbsp;&nbsp;$link_href";

                /* * * comments ** */
                if (!empty($entry['comment'])) {
                    $tool_content .= "<br /><div class='comment'>" .
                            standard_text_escape($entry['comment']) .
                            "</div>";
                }
                $tool_content .= "</td>";
                if ($is_dir) {
                    // skip display of date and time for directories
                    $tool_content .= "<td>&nbsp;</td><td>&nbsp;</td>";
                } else {
                    $size = format_file_size($entry['size']);
                    $date = nice_format($entry['date'], true, true);
                    $tool_content .= "<td class='text-right'>$size</td><td class='text-center'>$date</td>";
                }
                $tool_content .= "<td class='text-center'><input type='checkbox' name='document[]' value='$entry[id]' /></td>";
                $tool_content .= "</tr>";
                $counter++;
            }
        }
        $tool_content .= "</table>";
        $tool_content .= "<div class='text-right'>";
        $tool_content .= "<input class='btn btn-primary' type='submit' name='submit_doc' value='$langAddModulesButton' /></div>$dir_html</form>";
        
    }
}
Beispiel #12
0
$atleastOne = FALSE;


foreach ($result as $list) {

    //CHECKBOX, NAME, RENAME, COMMENT
    if ($list->contentType == CTEXERCISE_) {
        $moduleImg = 'fa-pencil-square-o';
    } else if ($list->contentType == CTLINK_) {
        $moduleImg = 'fa-link';
    } else if ($list->contentType == CTCOURSE_DESCRIPTION_) {
        $moduleImg = 'fa-info-circle';
    } else if ($list->contentType == CTMEDIA_ || $list->contentType == CTMEDIALINK_) {
        $moduleImg = 'fa-film';
    } else {
        $moduleImg = choose_image(basename($list->path));
    }

    $contentType_alt = selectAlt($list->contentType);

    $tool_content .= '<tr>' . "\n"
            . '<td align="left">' . "\n"
            . '<label for="check_' . $list->module_id . '" >' . icon($moduleImg, $contentType_alt) . '&nbsp;<b>' . $list->name . '</b></label>' . "\n";

    // COMMENT
    if ($list->comment != null) {
        $tool_content .= '<br /> <br />' . "\n"
                . '<em>' . $langComments . '</em>: <br />' . $list->comment . '' . "\n";
    }
    $tool_content .= '</td>'
            . '<td align="center">'
Beispiel #13
0
/**
 * This function is used to display the list of document available in the course
 * It also displays the form used to add selected document in the learning path
 *
 * @param string $dialogBox Error or confirmation text
 * @return nothing
 * @author Piraux S�bastien <*****@*****.**>
 * @author Lederer Guillaume <*****@*****.**>
 */
function display_my_documents($dialogBox)
{
    global $is_allowedToEdit;
    global $curDirName;
    global $curDirPath;
    global $parentDir;
    global $fileList;
    /**
     * DISPLAY
     */
    $out = '';
    $out .= '<!-- display_my_documents output -->' . "\n";
    $dspCurDirName = claro_htmlspecialchars($curDirName);
    $cmdCurDirPath = rawurlencode($curDirPath);
    $cmdParentDir = rawurlencode($parentDir);
    $out .= '<br />' . '<form action="' . $_SERVER['PHP_SELF'] . '" method="post">';
    /*--------------------------------------
      DIALOG BOX SECTION
      --------------------------------------*/
    $colspan = 4;
    if (!empty($dialogBox)) {
        $_dialogBox = new DialogBox();
        $_dialogBox->form($dialogBox);
        $out .= $_dialogBox->render();
    }
    /*--------------------------------------
      CURRENT DIRECTORY LINE
      --------------------------------------*/
    /* GO TO PARENT DIRECTORY */
    if ($curDirName) {
        $out .= '<a href="' . $_SERVER['PHP_SELF'] . '?cmd=exChDir&amp;file=' . $cmdParentDir . '">' . "\n" . '<img src="' . get_icon_url('parent') . '" hspace="5" alt="" /> ' . "\n" . '<small>' . get_lang('Up') . '</small>' . "\n" . '</a>' . "\n";
    }
    /* CURRENT DIRECTORY */
    $out .= '<table class="claroTable emphaseLine">' . '<thead>';
    // If the $curDirName is empty, we're in the root point
    // and there is'nt a dir name to display
    if ($curDirName) {
        $out .= '<!-- current dir name -->' . "\n" . '<tr>' . "\n" . '<th class="superHeader" colspan="' . $colspan . '" align="left">' . "\n" . '<img src="' . get_icon_url('opendir') . '" vspace=2 hspace=5 alt="" /> ' . "\n" . $dspCurDirName . "\n" . '</td>' . "\n" . '</tr>' . "\n";
    }
    $out .= '<tr align="center" valign="top">' . "\n" . '<th width="10%">' . get_lang('Add module(s)') . '</th>' . "\n" . '<th>' . get_lang('Name') . '</th>' . "\n" . '<th>' . get_lang('Size') . '</th>' . "\n" . '<th>' . get_lang('Date') . '</th>' . "\n" . '</tr>' . '</thead>' . '<tbody>' . "\n";
    /*--------------------------------------
      DISPLAY FILE LIST
      --------------------------------------*/
    if ($fileList) {
        $iterator = 0;
        while (list($fileKey, $fileName) = each($fileList['name'])) {
            $dspFileName = claro_htmlspecialchars($fileName);
            $cmdFileName = str_replace("%2F", "/", rawurlencode($curDirPath . "/" . $fileName));
            if ($fileList['visibility'][$fileKey] == "i") {
                if ($is_allowedToEdit) {
                    $style = ' class="invisible"';
                } else {
                    $style = "";
                    continue;
                    // skip the display of this file
                }
            } else {
                $style = "";
            }
            if ($fileList['type'][$fileKey] == A_FILE) {
                $image = choose_image($fileName);
                $size = format_file_size($fileList['size'][$fileKey]);
                $date = format_date($fileList['date'][$fileKey]);
                if ($GLOBALS['is_Apache'] && get_conf('secureDocumentDownload')) {
                    // slash argument method - only compatible with Apache
                    $doc_url = $cmdFileName;
                } else {
                    // question mark argument method, for IIS ...
                    $doc_url = '?url=' . $cmdFileName;
                }
                $urlFileName = get_path('clarolineRepositoryWeb') . 'backends/download.php' . $doc_url;
            } elseif ($fileList['type'][$fileKey] == A_DIRECTORY) {
                $image = 'folder';
                $size = '&nbsp;';
                $date = '&nbsp;';
                $urlFileName = $_SERVER['PHP_SELF'] . '?openDir=' . $cmdFileName;
            }
            $out .= '<tr ' . $style . '>' . "\n";
            if ($fileList['type'][$fileKey] == A_FILE) {
                $iterator++;
                $out .= '<td style="vertical-align:top; text-align: center;">' . '<input type="checkbox" name="insertDocument_' . $iterator . '" id="insertDocument_' . $iterator . '" value="' . $curDirPath . "/" . $fileName . '" />' . '</td>' . "\n";
            } else {
                $out .= '<td>&nbsp;</td>';
            }
            $out .= '<td>' . '<a href="' . $urlFileName . '" ' . $style . '>' . '<img src="' . get_icon_url($image) . '" hspace="5" alt="" /> ' . $dspFileName . '</a>';
            // Comments
            if ($fileList['comment'][$fileKey] != "") {
                $fileList['comment'][$fileKey] = claro_htmlspecialchars($fileList['comment'][$fileKey]);
                $fileList['comment'][$fileKey] = claro_parse_user_text($fileList['comment'][$fileKey]);
                $out .= '<div class="comment">' . $fileList['comment'][$fileKey] . '</div>' . "\n";
            }
            $out .= '</td>' . "\n" . '<td><small>' . $size . '</small></td>' . "\n" . '<td><small>' . $date . '</small></td>' . "\n";
            /* NB : Before tracking implementation the url above was simply
             * "<a href=\"",$urlFileName,"\"",$style,">"
             */
            $out .= '</tr>' . "\n";
        }
        // end each ($fileList)
        // form button
        $out .= '</tbody>' . '</table>' . "\n\n" . '<input type="hidden" name="openDir" value="' . $curDirPath . '" />' . "\n" . '<input type="hidden" name="maxDocForm" value ="' . $iterator . '" />' . "\n" . '<input type="submit" name="submitInsertedDocument" value="' . get_lang('Add selection') . '" />';
    } else {
        $out .= '<tr>' . "\n" . '<td colspan="2" align="center">' . get_lang('There is no document for the moment') . '</td>' . "\n" . '</tr>' . "\n" . '</tbody>' . '</table>' . "\n\n";
    }
    $out .= '</form>' . "\n" . '<br /><br />' . '<!-- end of display_my_documents output -->' . "\n";
    return $out;
}
Beispiel #14
0
/**
 * @brief display resource documents
 * @global type $is_editor
 * @global type $course_id
 * @global type $langWasDeleted
 * @global type $urlServer
 * @global type $id
 * @global type $course_code
 * @param type $title
 * @param type $comments
 * @param type $resource_id
 * @param type $file_id
 * @return string
 */
function show_doc($title, $comments, $resource_id, $file_id)
{
    global $is_editor, $course_id, $langWasDeleted, $urlServer, $id, $course_code;
    $file = Database::get()->querySingle("SELECT * FROM document WHERE course_id = ?d AND id = ?d", $course_id, $file_id);
    if (!$file) {
        if (!$is_editor) {
            return '';
        }
        $status = 'del';
        $image = 'fa-times';
        $link = "<span class='not_visible'>" . q($title) . " ({$langWasDeleted})</span>";
    } else {
        $status = $file->visible;
        if (!$is_editor and !resource_access($file->visible, $file->public)) {
            return '';
        }
        if ($file->format == '.dir') {
            $image = 'fa-folder-o';
            $link = "<a href='{$urlServer}modules/document/index.php?course={$course_code}&amp;openDir={$file->path}&amp;unit={$id}'>";
        } else {
            $image = choose_image('.' . $file->format);
            $link = "<a href='" . file_url($file->path, $file->filename) . "' target='_blank'>";
        }
    }
    $class_vis = ($status == '0' or $status == 'del') ? ' class="not_visible"' : '';
    if (!empty($comments)) {
        $comment = '<br />' . $comments;
    } else {
        $comment = '';
    }
    return "\n        <tr{$class_vis}>\n          <td width='1'>{$link}" . icon($image, '') . "</a></td>\n          <td align='left'>{$link}" . q($title) . "</a>{$comment}</td>" . actions('doc', $resource_id, $status) . '</tr>';
}
/**
* This function is to display the added resources (lessons) in the learning path player and builder
* this function is a modification of display_addedresource_link($type, $id) function
* the two ids are a bit confusing, I admit, but I did not want to change Patrick's work, I was
* building upon it. - Denes
*
* Parameters:
* @param completed   - if ="completed" then green presentation with checkbox
* @param id_in_path  - if onclick then this lesson will be considered completed, that is the unique index in the items table
* @param id          - that is the correspondent id in the mirror tool (like Agenda item 2)
* @param type        - that is the correspondent type in the mirror tool (like this is a Link item)
* @param builder     - if ="builder" then onclick shows in new window
* @param icon        - if ="icon" then the small icon will appear
*                      if ="wrap" then wrapped settings are used (and no icon is displayed)
*                      if ="nolink" then only the name is returned with no href and no icon (note:only in this case, the result is not displayed, but returned)
* @todo this function is too long, rewrite
*/
function display_addedresource_link_in_learnpath($type, $id, $completed, $id_in_path, $builder, $icon, $level = 0)
{
	global $learnpath_id, $tbl_learnpath_item, $items;
	global $_course, $curDirPath, $_configuration, $enableDocumentParsing, $_user, $_cid;

	$hyperlink_target_parameter = ''; //or e.g. 'target="_blank"'

	$length = ((($builder == 'builder') and ($icon == 'nolink')) ? 65 : 32);

	if ($builder != 'builder') $origin = 'learnpath';	//origin = learnpath in student view
	$linktype = $type;
	if (($type == 'Link _self') or ($type == 'Link _blank')) $type = 'Link';

	switch ($type)
	{
		case "Agenda":
			$TABLEAGENDA 		= Database::get_course_table(TABLE_AGENDA,$_course['dbName']);
			$result = Database::query("SELECT * FROM $TABLEAGENDA WHERE id=$id");
			$myrow=Database::fetch_array($result);

			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $myrow["title"]=$row['title']; }
			$desc=$row['description'];
			$agenda_id=$row['item_id'];
			echo str_repeat("&nbsp;&gt;",$level);
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
			if ($icon != 'nolink')
			{
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }

			if ($myrow["title"]=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }

			if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
			if ($icon == 'icon') { echo "<img src='../img/agenda.gif' align=\"absmiddle\" alt='agenda'>"; }
			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>";
        		$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Agenda&origin=$origin&agenda_id=$agenda_id#$id_in_path";
				if ($desc != '')
				{
					if ($icon != 'wrap')
					{
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
					}
					else
					{
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
					}
				}
			}
			else
			{
				echo "<a href=\"../calendar/agenda.php?origin=$origin&agenda_id=$agenda_id\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
			}
			break;

		case "Ad_Valvas":
			$tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT,$_course['dbName']);
			$result = Database::query("SELECT * FROM $tbl_announcement WHERE id=$id");
			$myrow=Database::fetch_array($result);

			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $myrow["content"]=$row['title']; }
			$desc=$row['description'];
			$ann_id=$row['item_id'];
			echo str_repeat("&nbsp;&gt;",$level);

			// the title and the text are in the content field and we only want to display the title
			list($title, $text)=split('<br>',$myrow['content']);
			if ($title=='') { $title=$myrow['content']; }
			$title=$myrow['title'];
			$text=$myrow['content'];
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
			if ($icon != 'nolink')
			{
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }

			if ($title=='') {
				$type="Announcement";
				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
				return(true);
			}

			if ($icon == 'nolink') { return(shorten($title,$length)); }
			if ($icon == 'icon') { echo "<img src='../img/valves.gif' align=\"absmiddle\" alt='ad valvas'>"; }
			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path\" class='$completed'>".shorten($title,($length-3*$level))."</a>";
				$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Ad_Valvas&origin=$origin&ann_id=$ann_id#$id_in_path";
				if ($desc != '')
				{
					if ($icon != 'wrap')
					{
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
					}
					else
					{
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
					}
				}
			}
			else
			{
				echo "<a href=\"../announcements/announcements.php?origin=$origin&ann_id=$ann_id\" class='$completed' target='_blank'>".shorten($title,($length-3*$level))."</a>";
			}
			break;

		case "Link" :
			$TABLETOOLLINK	= Database::get_course_table(TABLE_LINK,$_course['dbName']);
			$result= Database::query("SELECT * FROM $TABLETOOLLINK WHERE id=$id");
			$myrow=Database::fetch_array($result);

			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $myrow["title"]=$row['title']; }
			$desc=$row['description'];
			echo str_repeat("&nbsp;&gt;",$level);

			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
			if ($icon != 'nolink')
			{
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }

			if ($myrow["title"]=='')
			{
				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
				return(true);
			}

			if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
			if ($icon == 'icon')
			{
				if ($linktype=='Link _self') { echo "<img src='../img/links.gif' align=\"absmiddle\" alt='links'>"; }
				   else { echo "<img src='../img/link_blank.gif' align=\"absmiddle\" alt='blank links'>"; }
			}
			$thelink=$myrow["url"];
			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>";
				$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=$linktype&origin=$origin&thelink=$thelink#$id_in_path";
				if ($desc != '')
				{
					if ($icon != 'wrap')
					{
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
					}
					else
					{
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
					}
				}
			}
			else
			{
				echo "<a href=\"$thelink\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
			}
			break;

		case "Exercise":
			$TBL_EXERCICES  = Database::get_course_table(TABLE_QUIZ_TEST,$_course['dbName']);
			$result= Database::query("SELECT * FROM $TBL_EXERCICES WHERE id=$id");
			$myrow=Database::fetch_array($result);

			if ($builder=='builder') { $origin='builder'; }
			  //this is needed for the exercise_submit.php can delete the session info about tests

			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $myrow["title"]=$row['title']; }
			$desc=$row['description'];
			echo str_repeat("&nbsp;&gt;",$level);

			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
			if ($icon != 'nolink')
			{
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }

			if ($myrow["title"]=='') {
				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
				return(true);
			}

			if ($icon == 'nolink') { return(shorten($myrow["title"],$length)); }
			if ($icon == 'icon') { echo "<img src='../img/quiz.gif' align=\"absmiddle\" alt='quizz'>"; }
			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path\" class='$completed'>".shorten($myrow["title"],($length-3*$level))."</a>";
				$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Exercise&origin=$origin&exerciseId=".$myrow["id"]."#$id_in_path";
				if ($desc != '')
				{
					if ($icon != 'wrap')
					{
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
					}
					else
					{
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
					}
				}
			}
			else
			{
				echo "<a href=\"../exercice/exercise_submit.php?origin=$origin&exerciseId=".$myrow["id"]."\" class='$completed' target='_blank'>".shorten($myrow["title"],($length-3*$level))."</a>";
			}
			break;

		case "HotPotatoes":
			$TBL_DOCUMENT  = Database::get_course_table(TABLE_DOCUMENT,$_course['dbName']);
			$documentPath=api_get_path(SYS_COURSE_PATH).$_course['path'].'/document';
			$result = Database::query("SELECT * FROM ".$TBL_DOCUMENT." WHERE id=$id");
			$myrow= Database::fetch_array($result);
			$path=$myrow["path"];
			$name=GetQuizName($path,$documentPath);

			if ($builder=='builder') { $origin='builder'; }
			  //this is needed for the exercise_submit.php can delete the session info about tests

			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $name=$row['title']; }
			$desc=$row['description'];
			echo str_repeat("&nbsp;&gt;",$level);

			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
			if ($icon != 'nolink')
			{
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }

			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }

			if ($icon == 'nolink') { return(shorten($name,$length)); }
			if ($icon == 'icon') { echo "<img src='../img/jqz.gif' align=\"absmiddle\" alt='hot potatoes'>"; }

			$cid = $_course['official_code'];

			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>";
				$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=HotPotatoes&origin=$origin&id=$id#$id_in_path";
				if ($desc != '')
				{
					if ($icon != 'wrap')
					{
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
					}
					else
					{
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
					}
				}
			}
			else
			{
				echo "&nbsp;<a href=\"../exercice/showinframes.php?file=$path&cid=$cid&uid=".$_user['user_id']."\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
			}
			break;

		case "Forum":
			$TBL_FORUMS = Database::get_course_table(TABLE_FORUM,$_course['dbName']);
			$result= Database::query("SELECT * FROM $TBL_FORUMS WHERE forum_id=$id");
			$myrow=Database::fetch_array($result);

			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $myrow["forum_name"]=$row['title']; }
			$desc=$row['description'];
			echo str_repeat("&nbsp;&gt;",$level);

			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
			if ($icon != 'nolink')
			{
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }

			if ($myrow["forum_name"]=='') { $type="Forum"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }

			if ($icon == 'nolink') { return(shorten($myrow["forum_name"],$length)); }
			if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
			$forumparameters="forum=".$myrow["forum_id"]."&md5=".$myrow["md5"];
			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path\" class='$completed'>".shorten($myrow["forum_name"],($length-3*$level))."</a>";
				$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Forum&origin=$origin&forumparameters=$forumparameters#$id_in_path";
				if ($desc != '')
				{
					if ($icon != 'wrap')
					{
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
					}
					else
					{
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
					}
				}
			}
			else
			{
				echo "<a href=\"../phpbb/viewforum.php?$forumparameters\" class='$completed' target='_blank'>".shorten($myrow["forum_name"],($length-3*$level))."</a>";
			}
			break;

		case "Thread":  //forum post
        //deprecated
			$tbl_topics      = $_course['dbNameGlu'].'bb_topics';
			$tbl_posts		 = $_course['dbNameGlu'].'bb_posts';
			$TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
			$sql="SELECT * FROM $tbl_topics where topic_id=$id";
			$result= Database::query($sql);
			$myrow=Database::fetch_array($result);

			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $myrow["topic_title"]=$row['title']; }
			$desc=$row['description'];
			echo str_repeat("&nbsp;&gt;",$level);

			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
			if ($icon != 'nolink')
			{
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }

			if ($myrow["topic_title"]=='') { $type="Forum Post"; echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }

			if ($icon == 'nolink') { return(shorten($myrow["topic_title"],$length)); }
			if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path\" class='$completed'>".shorten($myrow["topic_title"],($length-3*$level))."</a>";
				$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Thread&origin=$origin&topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."#$id_in_path";
				if ($desc != '')
				{
					if ($icon != 'wrap')
					{
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
					}
					else
					{
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
					}
				}
			}
			else
			{
				echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow["topic_title"],($length-3*$level))."</a>";
			}
			break;

		case "Post":
        //deprecated
			$tbl_posts       = $_course['dbNameGlu'].'bb_posts';
			$tbl_posts_text  = $_course['dbNameGlu'].'bb_posts_text';
			$TBL_FORUMS = $_course['dbNameGlu']."bb_forums";
			$result= Database::query("SELECT * FROM $tbl_posts where post_id=$id");
			$myrow=Database::fetch_array($result);
			// grabbing the title of the post
			$sql_titel="SELECT * FROM $tbl_posts_text WHERE post_id=".$myrow["post_id"];
			$result_titel=Database::query($sql_titel);
			$myrow_titel=Database::fetch_array($result_titel);

			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $myrow_titel["post_title"]=$row['title']; }
			$desc=$row['description'];
			echo str_repeat("&nbsp;&gt;",$level);

			$posternom=$myrow['nom'];				$posterprenom=$myrow['prenom'];
			$posttime=$myrow['post_time'];			$posttext=$myrow_titel['post_text'];
			$posttitle=$myrow_titel['post_title'];
			$posttext = str_replace('"',"'",$posttext);

			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
			if ($icon != 'nolink')
			{
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }

			if ($myrow_titel["post_title"]=='')
			{
				$type="Forum";
				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true);
			}

			if ($icon == 'nolink') { return(shorten($myrow_titel["post_title"],$length)); }
			if ($icon == 'icon') { echo "<img src='../img/forum.gif' align=\"absmiddle\" alt='forum'>"; }
			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path\" class='$completed'>".shorten($myrow_titel["post_title"],($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Post&origin=$origin&posternom=$posternom&posterprenom=$posterprenom&posttime=$posttime&posttext=$posttext&posttitle=$posttitle#$id_in_path";
				if ($desc != '')
				{
					if ($icon != 'wrap')
					{
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
					}
					else
					{
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
					}
				}
			}
			else
			{
				echo "<a href=\"../phpbb/viewtopic.php?topic=".$myrow["topic_id"]."&forum=".$myrow["forum_id"]."&md5=".$myrow["md5"]."\" class='$completed' target='_blank'>".shorten($myrow_titel["post_title"],($length-3*$level))."</a>";
			}
			break;

		case "Document":
			$dbTable  = Database::get_course_table(TABLE_DOCUMENT,$_course['dbName']);
			$result=Database::query("SELECT * FROM $dbTable WHERE id=$id");
			$myrow=Database::fetch_array($result);

			$pathname=explode("/",$myrow["path"]); // making a correct name for the link
			$last=count($pathname)-1;  // making a correct name for the link
			$filename=$pathname[$last];  // making a correct name for the link
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }

			echo str_repeat("&nbsp;&gt;",$level);

			if ($icon != 'nolink') {
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }
			$image=choose_image($filename);

			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $filename=$row['title']; }
			$desc=$row['description'];

			if (($myrow["path"]=='') and ($filename=='')) {
				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>";
				return(true);
			}

			if ($icon == 'nolink') { return(shorten($filename,$length)); }
			if ($icon == 'icon') { echo "<img src='../img/$image' align=\"absmiddle\" alt='$image'>"; }
			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path\" class='$completed'>".shorten($filename,($length-3*$level))."</a>";
				if ($desc != '')
				{
					if ($icon != 'wrap')
					{
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
					}
					else
					{
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
					}
				} $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Document&origin=$origin&docurl=".$myrow["path"]."#$id_in_path";
			}
			else
			{
				$enableDocumentParsing='yes';
				if (!$enableDocumentParsing)
				{ //this is the solution for the non-parsing version in the builder
					$file=urlencode($myrow["path"]);
					echo "<a href='../document/showinframes.php?file=$file' class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>";
				}
				else
				{
					echo "<a href=\"../document/download.php?doc_url=".$myrow["path"]."\" class='$completed' $hyperlink_target_parameter>".shorten($filename,($length-3*$level))."</a>";
				}
			}
			break;

		case "Assignments":
			$name=get_lang('Assignments');
			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $name=$row['title']; }
			$desc=$row['description'];
			echo str_repeat("&nbsp;&gt;",$level);

			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
			if ($icon != 'nolink')
			{
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }

			if ($name=='')
			{
				echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true);
			}

			if ($icon == 'nolink') { return(shorten($name,$length)); }
			if ($icon == 'icon') { echo "<img src='../img/works.gif' align=\"absmiddle\">"; }
			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Assignments&origin=$origin#$id_in_path";
				if ($desc != '')
				{
					if ($icon != 'wrap')
					{
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>";
					}
					else
					{
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>";
					}
				}
			}
			else
			{
				echo "<a href=\"../work/work.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
			}
			break;
		case "Dropbox":
			$name=get_lang('Dropbox');
			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $name=$row['title']; }
			$desc=$row['description'];
			echo str_repeat("&nbsp;&gt;",$level);

			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
			if ($icon != 'nolink') {
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }

			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }

			if ($icon == 'nolink') { return(shorten($name,$length)); }
			if ($icon == 'icon') { echo "<img src='../img/dropbox.gif' align=\"absmiddle\">"; }

			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Dropbox&origin=$origin#$id_in_path";
				if ($desc != '') {
					if ($icon != 'wrap') {
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
					else {
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
				}
			} else {
				echo "<a href=\"../dropbox/index.php\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
			}
			break;
		case "Introduction_text":
			$name=get_lang('IntroductionText');
			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $name=$row['title']; }
			$desc=$row['description'];
			echo str_repeat("&nbsp;&gt;",$level);

			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
			if ($icon != 'nolink') {
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }

			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }

			if ($icon == 'nolink') { return(shorten($name,$length)); }
			if ($icon == 'icon') { echo "<img src='../img/introduction.gif' align=\"absmiddle\" alt='introduction'>"; }

			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>";
				$items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Introduction_text&origin=$origin#$id_in_path";
				if ($desc != '') {
					if ($icon != 'wrap') {
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
					else {
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
				}
			} else {
				$s = api_get_path(WEB_COURSE_PATH)."$_cid/index.php?intro_cmdEdit=1";
				echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
			}
			break;
		case "Course_description":
			$name=get_lang('CourseDescription');
			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $name=$row['title']; }
			$desc=$row['description'];
			echo str_repeat("&nbsp;&gt;",$level);

			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
			if ($icon != 'nolink') {
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }

			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }

			if ($icon == 'nolink') { return(shorten($name,$length)); }
			if ($icon == 'icon') { echo "<img src='../img/info.gif' align=\"absmiddle\" alt='info'>"; }

			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Course_description&origin=$origin#$id_in_path";
				if ($desc != '') {
					if ($icon != 'wrap') {
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
					else {
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
				}
			} else {
				$s=api_get_path(WEB_CODE_PATH)."course_description";
				echo "<a href=\"$s\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
			}
			break;
		case "Groups":
			$name=get_lang('Groups');
			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $name=$row['title']; }
			$desc=$row['description'];
			echo str_repeat("&nbsp;&gt;",$level);

			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
			if ($icon != 'nolink') {
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }

			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }

			if ($icon == 'nolink') { return(shorten($name,$length)); }
			if ($icon == 'icon') { echo "<img src='../img/group.gif' align=\"absmiddle\" alt='group'>"; }

			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Groups&origin=$origin#$id_in_path";
				if ($desc != '') {
					if ($icon != 'wrap') {
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
					else {
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
				}
			} else {
				echo "<a href=\"../group/group.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
			}
			break;
		case "Users":
			$name=get_lang('Users');
			$sql="select * from $tbl_learnpath_item where id=$id_in_path";
			$result=Database::query($sql);	$row=Database::fetch_array($result);
			if ($row['title'] != '') { $name=$row['title']; }
			$desc=$row['description'];
			echo str_repeat("&nbsp;&gt;",$level);

			if (($builder != 'builder') and ($icon != 'wrap')) { echo "<td>"; }
			if ($icon != 'nolink') {
				if ($completed=='completed') {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on'>";
				}	else {
					echo "<img src='../img/checkbox_on2.gif' border='0' width='13' height='11' alt='on' style='visibility: hidden'>";
					//echo "&nbsp;";
				}
			}
			if (($builder != 'builder') and ($icon != 'wrap')) { echo "</td><td>"; }

			if ($name=='') { echo "<span class='messagesmall'>".get_lang('StepDeleted1')." $type ".get_lang('StepDeleted2')."</span>"; return(true); }

			if ($icon == 'nolink') { return(shorten($name,$length)); }
			if ($icon == 'icon') { echo "<img src='../img/members.gif' align=\"absmiddle\" alt='members'>"; }

			if ($builder != 'builder')
			{
				echo "<a href=\"".api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path\" class='$completed'>".shorten($name,($length-3*$level))."</a>"; $items[]=api_get_self()."?action=closelesson&source_forum=".$_GET['source_forum']."&how=complete&id_in_path=$id_in_path&learnpath_id=$learnpath_id&type=Users&origin=$origin#$id_in_path";
				if ($desc != '') {
					if ($icon != 'wrap') {
						echo "</tr><tr><td></td><td></td><td><div class='description'>&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div></td></tr>"; }
					else {
						echo "<div class='description'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;".shorten($desc,($length-3*$level))."</div>"; }
				}
			} else {
				echo "<a href=\"../user/user.php?origin=$origin\" class='$completed' target='_blank'>".shorten($name,($length-3*$level))."</a>";
			}
			break;
	}//end huge switch-statement
}
/**
 * Gets the name of a resource (generally used in learnpath when no name is provided)
 *
 * @author Yannick Warnier <*****@*****.**>, Dokeos - rebranding
 * @param string 	Course code
 * @param string 	The tool type (using constants declared in main_api.lib.php)
 * @param integer 	The resource ID
 */
function rl_get_resource_name($course_code, $learnpath_id, $id_in_path)
{
    $_course = api_get_course_info($course_code);
    $course_id = $_course['real_id'];
    $tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
    $learnpath_id = intval($learnpath_id);
    $id_in_path = intval($id_in_path);
    $sql_item = "SELECT item_type, title, ref FROM {$tbl_lp_item}\n                 WHERE c_id = {$course_id} AND lp_id = {$learnpath_id} AND id = {$id_in_path}";
    $res_item = Database::query($sql_item);
    if (Database::num_rows($res_item) < 1) {
        return '';
    }
    $row_item = Database::fetch_array($res_item);
    $type = strtolower($row_item['item_type']);
    $id = $row_item['ref'];
    $output = '';
    switch ($type) {
        case TOOL_CALENDAR_EVENT:
            $TABLEAGENDA = Database::get_course_table(TABLE_AGENDA);
            $result = Database::query("SELECT * FROM {$TABLEAGENDA} WHERE c_id = {$course_id} AND id={$id}");
            $myrow = Database::fetch_array($result);
            $output = $myrow['title'];
            break;
        case TOOL_ANNOUNCEMENT:
            $tbl_announcement = Database::get_course_table(TABLE_ANNOUNCEMENT);
            $result = Database::query("SELECT * FROM {$tbl_announcement} WHERE c_id = {$course_id} AND id={$id}");
            $myrow = Database::fetch_array($result);
            $output = $myrow['title'];
            break;
        case TOOL_LINK:
            // Doesn't take $target into account.
            $TABLETOOLLINK = Database::get_course_table(TABLE_LINK);
            $result = Database::query("SELECT * FROM {$TABLETOOLLINK} WHERE c_id = {$course_id} AND id={$id}");
            $myrow = Database::fetch_array($result);
            $output = $myrow['title'];
            break;
        case TOOL_QUIZ:
            $TBL_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
            $result = Database::query("SELECT * FROM {$TBL_EXERCICES} WHERE c_id = {$course_id} AND id={$id}");
            $myrow = Database::fetch_array($result);
            $output = $myrow['title'];
            break;
        case TOOL_FORUM:
            $TBL_FORUMS = Database::get_course_table(TABLE_FORUM);
            $result = Database::query("SELECT * FROM {$TBL_FORUMS} WHERE c_id = {$course_id} AND forum_id={$id}");
            $myrow = Database::fetch_array($result);
            $output = $myrow['forum_name'];
            break;
        case TOOL_THREAD:
            //=topics
            $tbl_post = Database::get_course_table(TABLE_FORUM_POST);
            // Grabbing the title of the post.
            $sql_title = "SELECT * FROM {$tbl_post} WHERE c_id = {$course_id} AND post_id=" . $id;
            $result_title = Database::query($sql_title);
            $myrow_title = Database::fetch_array($result_title);
            $output = $myrow_title['post_title'];
            break;
        case TOOL_POST:
            $tbl_post = Database::get_course_table(TABLE_FORUM_POST);
            //$tbl_post_text = Database::get_course_table(FORUM_POST_TEXT_TABLE);
            $sql = "SELECT * FROM {$tbl_post} p WHERE c_id = {$course_id} AND p.post_id = {$id}";
            $result = Database::query($sql);
            $post = Database::fetch_array($result);
            $output = $post['post_title'];
            break;
        case 'dokeos_chapter':
            $title = $row_item['title'];
            if (!empty($title)) {
                $output = $title;
            } else {
                $output = '-';
            }
            break;
        case TOOL_DOCUMENT:
            $title = $row_item['title'];
            if (!empty($title)) {
                $output = $title;
            } else {
                $output = '-';
            }
            break;
        case 'hotpotatoes':
            $tbl_doc = Database::get_course_table(TABLE_DOCUMENT);
            $result = Database::query("SELECT * FROM {$tbl_doc} WHERE c_id = {$course_id} AND id={$id}");
            $myrow = Database::fetch_array($result);
            $pathname = explode('/', $myrow['path']);
            // Making a correct name for the link.
            $last = count($pathname) - 1;
            // Making a correct name for the link.
            $filename = $pathname[$last];
            // Making a correct name for the link.
            $image = choose_image($filename);
            $ext = explode('.', $filename);
            $ext = strtolower($ext[sizeof($ext) - 1]);
            $myrow['path'] = rawurlencode($myrow['path']);
            $in_frames = in_array($ext, array('htm', 'html', 'gif', 'jpg', 'jpeg', 'png'));
            $output = $filename;
            break;
            /*
            case 'externallink':
                $output = '<img src="../img/links.gif" align="middle" /> <a href="'.$id.'"'.$styling.' '.$target.'>'.$id."</a><br />\n";
                break;
            */
    }
    return stripslashes($output);
}
Beispiel #17
0
 }
 // display the current module name
 $spacingString = '';
 for ($i = 0; $i < $module['children']; $i++) {
     $spacingString .= '<td width="5">&nbsp;</td>';
 }
 $colspan = $maxDeep - $module['children'] + 1;
 $out .= '<tr align="center">' . "\n" . $spacingString . '<td colspan="' . $colspan . '" align="left">';
 //-- if chapter head
 if ($module['contentType'] == CTLABEL_) {
     $out .= '<b>' . claro_utf8_decode($module['name'], get_conf('charset')) . '</b>';
 } else {
     if ($module['contentType'] == CTEXERCISE_) {
         $moduleImgUrl = get_icon_url('quiz', 'CLQWZ');
     } else {
         $moduleImgUrl = get_icon_url(choose_image(basename($module['path'])));
     }
     $contentType_alt = selectAlt($module['contentType']);
     $out .= '<img src="' . $moduleImgUrl . '" alt="' . $contentType_alt . '" />' . claro_utf8_decode($module['name'], get_conf('charset'));
 }
 $out .= '</td>' . "\n";
 if ($module['contentType'] == CTSCORM_) {
     $session_time = preg_replace("/\\.[0-9]{0,2}/", "", $module['session_time']);
     $total_time = preg_replace("/\\.[0-9]{0,2}/", "", $module['total_time']);
     $global_time = addScormTime($global_time, $total_time);
 } elseif ($module['contentType'] == CTLABEL_ || $module['contentType'] == CTEXERCISE_ || $module['contentType'] == CTDOCUMENT_) {
     $session_time = $module['session_time'];
     $total_time = $module['total_time'];
 } else {
     // if no progression has been recorded for this module
     // leave
Beispiel #18
0
     continue;
 }
 $cmdDirName = $entry['path'];
 if (!$entry['visible']) {
     $style = ' class="not_visible"';
 } else {
     $style = '';
 }
 if ($is_dir) {
     $img_href = icon('fa-folder-o');
     $file_url = $base_url . "openDir={$cmdDirName}";
     $link_title = q($entry['filename']);
     $dload_msg = $langDownloadDir;
     $link_href = "<a href='{$file_url}'>{$link_title}</a>";
 } else {
     $img_href = icon(choose_image('.' . $entry['format']));
     $file_url = file_url($cmdDirName, $entry['filename']);
     if ($entry['extra_path']) {
         $cdpath = common_doc_path($entry['extra_path']);
         if ($cdpath) {
             if ($can_upload) {
                 if ($common_doc_visible) {
                     $link_title_extra .= '&nbsp;' . icon('common', $langCommonDocLink);
                 } else {
                     $link_title_extra .= '&nbsp;' . icon('common-invisible', $langCommonDocLinkInvisible);
                     $style = ' class="invisible"';
                 }
             }
         } else {
             // External file URL
             $file_url = $entry['extra_path'];
Beispiel #19
0
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// Date in the past
if ($cmd == 'getFileList') {
    $it = new DirectoryIterator($pathSys . $relPath);
    /*
     * Output
     */
    $out = "\n" . '<ul id="files">' . "\n";
    if (!empty($relPath)) {
        $parentPath = dirname($relPath);
        $out .= '<li>' . "\n" . '<a href="#" onclick="setFileList(\'' . $parentPath . '\')">' . '<img src="' . get_icon_url('parent') . '" />' . '..' . '</a>' . '</li>' . "\n";
    }
    // directories
    foreach ($it as $file) {
        if ($file->isDir() && !$file->isDot()) {
            // get relative path from allowed root (document/img or platform/document) to target
            $relativePath = str_replace(realpath($pathSys), '', realpath($file->getPathname()));
            $out .= '<li>' . "\n" . '<a href="#" class="selectFolder" onclick="setFileList(\'' . str_replace('\\', '/', $relativePath) . '\')">' . '<img src="' . get_icon_url('folder') . '" />' . claro_htmlspecialchars($file->getFileName()) . '</a>' . '</li>' . "\n";
        }
    }
    // then the files
    foreach ($it as $file) {
        if ($file->isFile() && is_image($file->getFileName())) {
            $path = '/' . $relPath . $file->getFileName();
            $url = claro_get_file_download_url($path);
            $out .= '<li>' . "\n" . '<a href="#" onclick="selectImage(\'' . $url . '\')">' . '<img src="' . get_icon_url(choose_image($file->getFileName())) . '" />' . claro_htmlspecialchars($file->getFileName()) . '</a>' . '</li>' . "\n";
        }
    }
    $out .= '</ul>' . "\n";
    echo claro_utf8_encode($out);
}
EOF;
        $tool_content .= "\n  <tr>";
        $tool_content .= "\n    <th width='50'>&nbsp;</th>";
        $tool_content .= "\n    <th width='10%'><div align='center'><b>{$langType}</b></div></th>";
        $tool_content .= "\n    <th><div align='left'><b>{$langName}</b></div></th>";
        $tool_content .= "\n    <th width='15%'><div align='center'><b>{$langSize}</b></div></th>";
        $tool_content .= "\n    <th width='15%'><div align='center'><b>{$langDate}</b></div></th>";
        $tool_content .= "\n  </tr>";
        foreach ($fileinfo as $entry) {
            if ($entry['is_dir']) {
                // do not handle directories
                continue;
            }
            $cmdDirName = $entry['path'];
            $copyright_icon = '';
            $image = choose_image('.' . $entry['format']);
            $size = format_file_size($entry['size']);
            $date = nice_format($entry['date'], true, true);
            if ($entry['visible']) {
                $style = '';
            } else {
                $style = ' class="invisible"';
            }
            if (empty($entry['title'])) {
                $link_text = $entry['filename'];
            } else {
                $link_text = $entry['title'];
            }
            if ($entry['copyrighted']) {
                $link_text .= " <img src='../document/img/copyrighted.png' />";
            }
function fileManageDisplayFile(&$fileManage, $uid, $is_adminOfCourse, $lock, $language, $webDir)
{
    //Aadido por Fernando Acero Martin
    include "{$webDir}/miguel/lang/spanish/trad4all.inc.php";
    include "{$webDir}/miguel/lang/{$language}/trad4all.inc.php";
    include "{$webDir}/miguel/lang/spanish/document.inc.php";
    include "{$webDir}/miguel/lang/{$language}/document.inc.php";
    $lFileListCount = count($fileManage->fileList);
    for ($i = 0; $i < $lFileListCount; $i++) {
        $cmdFileName = $fileManage->fileList[$i]['id'];
        $image = choose_image($fileManage->fileList[$i]['titre']);
        $size = format_file_size($fileManage->fileList[$i]['size']);
        $date = format_date($fileManage->fileList[$i]['date']);
        $pathFileName = format_url($GLOBALS[currentCourseID] . '/' . $fileManage->modName . $fileManage->fileList[$i]['path']);
        $dspFileName = htmlentities($fileManage->fileList[$i]['titre']);
        $commentFile = $fileManage->fileList[$i]['comment'];
        $visibilityStatus = $fileManage->fileList[$i]['visibility'];
        if ($fileManage->modName != 'document') {
            $lockStatus = $fileManage->fileList[$i]['lock'];
            $UIDFile = $fileManage->fileList[$i]['uid'];
            $GIDFile = $fileManage->fileList[$i]['gid'];
        } else {
            $lockStatus = 1;
        }
        //Indetec: Elige el estilo de la tupla en función d la visibilidad y el bloqueo.
        if ($visibilityStatus == 'i') {
            $style = " class=\"invisible\"";
            //Si no somos administradores o dueños y es una tupla invisible pasamos a la siguiente
            if (!$is_adminOfCourse && $uid != $UIDFile && $GIDFile != $fileManage->gid) {
                continue;
            }
        } else {
            $style = "";
        }
        echo "<tr align=\"center\"{$style}>\n";
        echo "<td align=\"left\">\n";
        echo "<a href=\"" . $GLOBALS[urlServer] . $pathFileName . "\" {$style} target=\"top\">\n";
        echo "<img src=\"" . $GLOBALS[urlServer] . "/miguel/image/filemanager/{$image}\" border=\"0\" hspace=\"5\" alt=\"\">\n";
        echo $dspFileName . "\n";
        echo "</a>\n";
        /*** size ***/
        echo "<td><small>{$size}</small></td>\n";
        /*** date ***/
        echo "<td><small>{$date}</small></td>\n";
        if (isset($uid)) {
            /*** delete command ***/
            //Indetec: Solo puede borrar si no está bloqueado y es el dueño o es el administrador del curso(profesor).
            if ($lockStatus == 1 && ($GIDFile == $fileManage->gid || $UIDFile == $uid || $is_adminOfCourse)) {
                echo "<td><a href=\"" . $_SERVER[PHP_SELF] . "?delete={$cmdFileName}\" onClick=\"return confirmation('" . addslashes($dspFileName) . "');\"><img src=\"" . $GLOBALS[urlServer] . "/miguel/image/filemanager/delete.png\" border=\"0\" alt=\"{$langDelete}\" title=\"{$langToolTipDelete}\"></a></td>\n";
            } else {
                echo "<td></td>";
            }
            if ($lockStatus == 1 && $is_adminOfCourse) {
                echo "<td><a href=\"" . $_SERVER[PHP_SELF] . "?move={$cmdFileName}\"><img src=\"" . $GLOBALS[urlServer] . "/miguel/image/filemanager/move.png\" border=\"0\" alt=\"{$langMove}\" title=\"{$langToolTipMove}\"></a></td>\n";
            } else {
                echo "</td><td>";
            }
            //Indetec: En caso de no estar bloqueado y ser dueño o ser profesor
            if ($lockStatus == 1 && ($GIDFile == $fileManage->gid || $UIDFile == $uid || $is_adminOfCourse)) {
                /*** rename command ***/
                echo "<td><a href=\"" . $_SERVER[PHP_SELF] . "?rename={$cmdFileName}\"><img src=\"" . $GLOBALS[urlServer] . "/miguel/image/filemanager/rename.png\" border=\"0\" alt=\"{$langRename}\" title=\"{$langToolTipRename}\"></a></td>\n";
                /*** comment command ***/
                echo "<td><a href=\"" . $_SERVER[PHP_SELF] . "?comment={$cmdFileName}\"><img src=\"" . $GLOBALS[urlServer] . "/miguel/image/filemanager/comment.png\" border=\"0\" alt=\"{$langComment}\" title=\"{$langToolTipComment}\"></a></td>\n";
            } else {
                echo "<td><td>";
            }
            if ($is_adminOfCourse) {
                // if theache
                /*** visibility command ***/
                if ($visibilityStatus == "i") {
                    echo "<td><a href=\"" . $_SERVER[PHP_SELF] . "?mkVisibl={$cmdFileName}\"><img src=\"" . $GLOBALS[urlServer] . "/miguel/image/filemanager/invisible.png\" border=\"0\" alt=\"{$langVisible}\" title=\"{$langToolTipVisible}\"></a>\n</td>\n";
                } else {
                    echo "<td><a href=\"" . $_SERVER[PHP_SELF] . "?mkInvisibl={$cmdFileName}\"><img src=\"" . $GLOBALS[urlServer] . "/miguel/image/filemanager/visible.png\" border=\"0\" alt=\"{$langInvisible}\" title=\"{$langToolTipInvisible}\"></a></td>\n";
                }
                /*** Indetec: Lock command ***/
                if ($lock) {
                    if ($lockStatus == 1) {
                        echo "<td><a href=\"" . $_SERVER[PHP_SELF] . "?mkUnLock={$cmdFileName}\"><img src=\"" . $GLOBALS[urlServer] . "/miguel/image/filemanager/lock.png\" border=\"0\" alt=\"{$langLock}\" title=\"{$langToolTipUnlock}\"></a>\n</td>\n";
                    } else {
                        echo "<td><a href=\"" . $_SERVER[PHP_SELF] . "?mkLock=" . $cmdFileName . "\"><img src=\"" . $GLOBALS[urlServer] . "/miguel/image/filemanager/unlock.png\" border=\"0\" alt=\"{$langUnlock}\" title=\"{$langToolTipLock}\"></a></td>\n";
                    }
                }
            } else {
                echo "<td><td>";
            }
        } else {
            echo "<td colspan=\"5\"></td>";
        }
        echo "</tr>\n";
        /*** comments ***/
        if ($commentFile != '') {
            $commentFile = htmlentities($commentFile);
            $commentFile = nl2br($commentFile);
            echo "<tr align=\"left\">\n";
            echo "<td colspan=\"8\">\n";
            echo "<div class=\"comment\">";
            echo $commentFile;
            echo "</div>\n";
            echo "</td>\n";
            echo "</tr>\n";
        }
    }
}