Exemplo n.º 1
0
        return url(array('q' => false, 'f' => $file->path()));
    }), new TableField('Type', 'type'), new TableFieldFormat('Size', 'size', 'format_bytes'), new TableField('MIME', 'mime'), new TableField('Permissions', 'perms'));
    $rows = array();
    foreach (explode("\n", $out) as $row) {
        if (!empty($row)) {
            $rows[] = new TableRow(new FileModel($row), $fields);
        }
    }
    $middle = render_str('foobar/table', compact('fields', 'rows'));
} else {
    $file = new FileModel($f);
    if (is_dir($f)) {
        $fields = array(new TableFieldIcon(), new TableFieldLink('Name', 'basename', function (FileModel $file) {
            return url(array('q' => false, 'f' => $file->path()));
        }), new TableField('Type', 'type'), new TableFieldFormat('Size', 'size', 'format_bytes'), new TableField('MIME', 'mime'), new TableField('Owner', 'owner'), new TableField('Group', 'group'), new TableField('Permissions', 'perms'));
        $rows = $file->rows();
        $middle = render_str('foobar/table', array('fields' => $fields, 'rows' => new TableRowGenerator($rows, $fields)));
    } else {
        switch ($file->mime()) {
            case 'audio/mpeg':
                if (begins($file->realpath(), $_SERVER['DOCUMENT_ROOT'])) {
                    $middle = render_str('foobar/audio', array('src' => replace_prefix($file->realpath(), $_SERVER['DOCUMENT_ROOT'], '/')));
                } else {
                    $middle = render_str('foobar/audio', array('src' => 'image.php?' . http_build_query(array('f' => $file->realpath()))));
                }
                break;
            case 'video/mp4':
                if (begins($file->realpath(), $_SERVER['DOCUMENT_ROOT'])) {
                    $middle = render_str('foobar/video', array('src' => replace_prefix($file->realpath(), $_SERVER['DOCUMENT_ROOT'], '/')));
                } else {
                    $middle = render_str('foobar/video', array('src' => 'image.php?' . http_build_query(array('f' => $file->realpath()))));