Ejemplo n.º 1
0
/**
 * Get an html visual list of files and subdirs
 * @author Nicola Asuni
 * @param $dir (string) the starting directory path
 * @param $selected (string) the selected file
 * @param $params (string) additional parameters to add on links
 * @return html table
 */
function F_getDirVisualTable($dir, $selected = '', $params = '')
{
    global $l;
    require_once '../config/tce_config.php';
    $imgformats = array('gif', 'jpg', 'jpeg', 'png', 'svg');
    $allowed_extensions = unserialize(K_ALLOWED_UPLOAD_EXTENSIONS);
    $out = '';
    // html string to be returned
    $data = F_getDirFiles($dir);
    // dirs
    foreach ($data['dirs'] as $file) {
        $info = F_getFileInfo($file);
        $current_dir = urlencode($dir . $info['basename'] . '/');
        $out .= '<table style="float:left;border:none;margin:1px;padding:0;width:158px;background-color:#007fff;">';
        $out .= '<tr style="height:16px;font-family:monospace;font-size:12px;font-weight:bold;color:white;"><th>';
        $filename = $info['basename'];
        if (strlen($filename) > 20) {
            $filename = substr($filename, 0, 20) . '...';
        }
        $out .= $filename;
        $out .= '</th></tr>';
        $out .= '<tr style="height:160px;"><td style="text-align:center;vertical-align:middle;background-color:white;">';
        $out .= '<a href="' . $_SERVER['SCRIPT_NAME'] . '?d=' . $current_dir . '&amp;v=0' . $params . '" title="' . $l['w_change_dir'] . ' : ' . $info['basename'] . '" style="text-decoration:underline;"><img src="' . K_PATH_IMAGES . 'dir.png" width="50" height="50" alt="' . $l['w_change_dir'] . ' : ' . $info['basename'] . '" style="border:none;" /></a>';
        $out .= '</td></tr>';
        $out .= '</table>';
    }
    // files
    $current_dir = urlencode($dir);
    foreach ($data['files'] as $file) {
        $info = F_getFileInfo($file);
        if (isset($info['extension']) and in_array(strtolower($info['extension']), $allowed_extensions) and substr($info['basename'], 0, 6) != 'latex_') {
            $current_file = urlencode($dir . $info['basename']);
            if ($info['basename'] == $selected) {
                $bgcolor = '#009900';
            } else {
                $bgcolor = '#333333';
            }
            if (in_array(strtolower($info['extension']), $imgformats)) {
                $w = 150;
                $h = 150;
                $imgicon = F_objects_replacement($info['tcename'], $info['extension'], 0, 0, $l['w_preview'], $w, $h);
            } else {
                $imgicon = '<img src="' . K_PATH_IMAGES . 'file.png" width="39" height="50" alt="' . $l['w_select'] . ' : ' . $info['basename'] . ' (' . F_formatFileSize($info['size']) . ')' . '" style="border:none;" />';
            }
            $out .= '<table style="float:left;border:none;margin:1px;padding:0;width:158px;background-color:' . $bgcolor . ';">';
            $out .= '<tr style="height:16px;font-family:monospace;font-size:12px;color:white;"><th>';
            $filename = $info['basename'];
            if (strlen($filename) > 20) {
                $filename = substr(substr($filename, 0, -(strlen($info['extension']) + 1)), 0, 15) . '&rarr;.' . $info['extension'];
            }
            $out .= $filename;
            $out .= '</th></tr>';
            $out .= '<tr style="height:160px;"><td style="text-align:center;vertical-align:middle;background-color:white;">';
            $out .= '<a href="' . $_SERVER['SCRIPT_NAME'] . '?d=' . $current_dir . '&amp;f=' . urlencode($current_file) . '&amp;v=0' . $params . '" title="' . $l['w_select'] . ' : ' . $info['basename'] . ' (' . F_formatFileSize($info['size']) . ')' . '">' . $imgicon . '</a>';
            $out .= '</td></tr>';
            $out .= '</table>';
        }
    }
    $out .= '<br style="clear:both;" />';
    return $out;
}
Ejemplo n.º 2
0
/**
 * Callback function for preg_replace_callback.
 * Returns replacement code by MIME type.
 * @param $matches (string) array containing matches: $matches[0] is the complete match, $matches[1] the match for the first subpattern enclosed in '(...)' and so on
 * @return string replacement string by file extension
 */
function F_objects_callback($matches)
{
    $width = 0;
    $height = 0;
    $alt = '';
    if (isset($matches[3]) and $matches[3] > 0) {
        $width = $matches[3];
    }
    if (isset($matches[4]) and $matches[4] > 0) {
        $height = $matches[4];
    }
    if (isset($matches[5]) and !empty($matches[5])) {
        $alt = F_tcecodeToTitle($matches[5]);
    }
    return F_objects_replacement($matches[1], $matches[2], $width, $height, $alt);
}
Ejemplo n.º 3
0
echo '<div class="contentbox">' . K_NEWLINE;
echo '<form action="' . $_SERVER['SCRIPT_NAME'] . '" method="post" enctype="multipart/form-data" id="form_filemanager">' . K_NEWLINE;
echo '<div>' . K_NEWLINE;
echo '<input type="hidden" name="frm" id="frm" value="' . $callingform . '" />' . K_NEWLINE;
echo '<input type="hidden" name="fld" id="fld" value="' . $callingfield . '" />' . K_NEWLINE;
// current dir
echo '<input type="hidden" name="d" id="d" value="' . $dir . '" />' . K_NEWLINE;
echo '<fieldset>' . K_NEWLINE;
echo '<legend title="' . $l['w_action'] . '">' . $l['w_action'] . '</legend>' . K_NEWLINE;
if (!empty($file)) {
    // file mode
    // preview
    $filedata = F_getFileInfo($file);
    $w = 500;
    $h = 250;
    echo F_objects_replacement($filedata['tcename'], $filedata['extension'], 0, 0, $l['w_preview'], $w, $h);
    echo '<br />' . K_NEWLINE;
    // display basic info
    echo '<span style="font-size:80%;color:#333333;">' . $w . ' x ' . $h . ' px ( ' . F_formatFileSize($filedata['size']) . ' ) ' . $filedata['lastmod'] . '</span>';
    echo '<br />' . K_NEWLINE;
    // action buttons
    echo '<input type="hidden" name="file" id="file" value="' . $file . '" />' . K_NEWLINE;
    echo '<input type="hidden" name="tcefile" id="tcefile" value="' . $filedata['tcefile'] . '" />' . K_NEWLINE;
    echo '<input type="text" name="newname" id="newname" value="' . basename($file) . '" size="30" maxlength="255" title="' . $l['w_name'] . '" />' . K_NEWLINE;
    if ($_SESSION['session_user_level'] >= K_AUTH_RENAME_MEDIAFILE) {
        F_submit_button('rename', $l['w_rename'], $l['w_rename']);
    }
    if ($_SESSION['session_user_level'] >= K_AUTH_DELETE_MEDIAFILE) {
        F_submit_button('delete', $l['w_delete'], $l['w_delete']);
    }
    // description fields