Exemplo n.º 1
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;
}