From 80e0f88b56ca7e306d415604c608d8bc09496e21 Mon Sep 17 00:00:00 2001 From: Alex AUVOLAT Date: Thu, 21 Jun 2012 17:12:06 +0200 Subject: Changes. But minor. Mostly usability changes. --- lib/file/editinfo.php | 6 +++++- lib/file/folder.php | 3 ++- lib/file/index.php | 6 +++--- lib/file/upload.php | 3 ++- tpl/file/folder.php | 22 +++++++++++++++++++--- tpl/file/index.php | 10 +++++----- tpl/file/upload-ok.php | 11 ++++++++--- 7 files changed, 44 insertions(+), 17 deletions(-) diff --git a/lib/file/editinfo.php b/lib/file/editinfo.php index eea9f35..500a7fc 100644 --- a/lib/file/editinfo.php +++ b/lib/file/editinfo.php @@ -30,7 +30,11 @@ if (isset($_POST['name']) && isset($_POST['comment']) && isset($_POST['folder']) } else { sql("UPDATE files SET name = '" . escs($name) . "', comment='" . escs($comment). "', comment_html = '" . escs($comment_html) . "', folder = $folder WHERE id = $id"); - header("Location: file"); + if ($folder == 0) { + header("Location: file"); + } else { + header("Location: folder-file-$folder"); + } die(); } } diff --git a/lib/file/folder.php b/lib/file/folder.php index 15e8625..f3beedd 100644 --- a/lib/file/folder.php +++ b/lib/file/folder.php @@ -33,7 +33,8 @@ $title = $fld["name"]; $files = array(); $fileq = sql("SELECT files.id AS id, files.name AS name, files.extension AS extension, files.upl_date AS upl_date, ". - "files.comment_html AS comment_html FROM files WHERE files.folder = $fldid"); + "files.comment_html AS comment_html FROM files WHERE files.folder = $fldid ". + "ORDER BY " . get_filter('order') . " " . get_filter('way')); while ($img = mysql_fetch_assoc($fileq)) $files[] = $img; $s = sql("SELECT id, name FROM folders WHERE owner = " . $fld['owner'] . ($fld['owner'] == $user['id'] ? '' : " AND public != 0"). " ORDER BY name ASC"); diff --git a/lib/file/index.php b/lib/file/index.php index 34686c5..1a60a79 100644 --- a/lib/file/index.php +++ b/lib/file/index.php @@ -6,7 +6,7 @@ $filters = array ( "order" => array ( "name" => "title", "upl_date" => "date uploaded", - "folder_name" => "folder", + //"folder_name" => "folder", ), "way" => $ord_ways, ); @@ -15,13 +15,13 @@ $fdefaults = array ( "way" => "DESC", ); -$title = "Image upload"; +$title = "File upload"; $files = array(); $fileq = sql("SELECT files.id AS id, files.name AS name, files.extension AS extension, files.upl_date AS upl_date, ". "files.comment_html AS comment_html, folders.id AS folder_id, folders.name AS folder_name ". " FROM files LEFT JOIN folders ON folders.id = files.folder ". - "WHERE files.owner = " . $user['id'] . + "WHERE files.folder = 0 AND files.owner = " . $user['id'] . " ORDER BY " . get_filter('order') . " " . get_filter('way')); while ($img = mysql_fetch_assoc($fileq)) $files[] = $img; diff --git a/lib/file/upload.php b/lib/file/upload.php index 4b5299d..21fa065 100644 --- a/lib/file/upload.php +++ b/lib/file/upload.php @@ -7,6 +7,7 @@ require("lib/conf/file.php"); if (isset($_FILES['file']) && isset($_POST['name'])) { $name = esca($_POST['name']); + $folder = (isset($_POST['folder']) ? intval($_POST['folder']) : 0); if ($name == "") $name = $_FILES['file']['name']; if ($_FILES['file']['error'] != 0) { $error = "Sorry, an error occurred while uploading your file. Try with a smaller one."; @@ -15,7 +16,7 @@ if (isset($_FILES['file']) && isset($_POST['name'])) { $origname = strtolower(basename($_FILES['file']['name'])); $type = preg_replace("#^.+\.([a-z0-9]+)$#", "$1", $origname); - sql("INSERT INTO files(owner, extension, name, upl_date) VALUES(" . $user['id'] . ", '$type', '" . escs($name) . "', NOW())"); + sql("INSERT INTO files(owner, folder, extension, name, upl_date) VALUES(" . $user['id'] . ", $folder, '$type', '" . escs($name) . "', NOW())"); $id = mysql_insert_id(); $filen = $savedir . $id . "." . $type; if (!copy($_FILES['file']['tmp_name'], $filen)) { diff --git a/tpl/file/folder.php b/tpl/file/folder.php index d7ebd73..61b4ed3 100644 --- a/tpl/file/folder.php +++ b/tpl/file/folder.php @@ -12,7 +12,7 @@ if (count($files) == 0) { echo '
This folder has no files.
'; } else { echo ''; - echo ''; + echo '
InfoDate
'; foreach ($files as $fl) { $min = $baseurl . $fl['id'] . "-min." . $fl['extension']; $flf = $baseurl . $fl['id'] . "." . $fl['extension']; @@ -24,17 +24,32 @@ if (count($files) == 0) { } echo ''; echo ''; - echo ''; } echo '
InfoDate
' . $fl['name'] . ''; + echo '
MD: ' . (has_mini($fl['extension']) ? '!' : '') . '['.$fl['name'].']('.$flf.')'; echo '
' . $fl['comment_html'] . '
'; echo '
' . $fl['upl_date'] . '
'; + echo '
' . $fl['upl_date']; if ($can_edit) echo '
delete'; - if ($can_edit) echo '
edit info'; + if ($can_edit) echo ' | edit'; echo '
'; } echo '
'; + +if ($is_owner) { + ?> +

Upload a file

+
+If you upload an image, a px preview will be created.

+Title :
+
+ +
+

+ Your folders'; } else { @@ -49,6 +64,7 @@ foreach ($folders as $f) { } } if ($is_owner) { + echo '
  • [files in no folder]
  • '; echo '
  • [+] New folder
  • '; } echo ''; diff --git a/tpl/file/index.php b/tpl/file/index.php index dc8cb52..abc340a 100644 --- a/tpl/file/index.php +++ b/tpl/file/index.php @@ -2,11 +2,11 @@ require("tpl/general/top.php"); if (count($files) == 0) { - echo '
    You have uploaded no files yet.
    '; + echo '

    You have no files that are uploaded and not put in a folder.

    '; } else { - echo '

    You have uploaded ' . count($files) .' files.

    '; + echo '

    You have ' . count($files) .' files uploaded in no folder. Select a folder to view the files it contains.

    '; echo ''; - echo ''; + echo '
    InfoDate
    '; foreach ($files as $fl) { $min = $baseurl . $fl['id'] . "-min." . $fl['extension']; $flf = $baseurl . $fl['id'] . "." . $fl['extension']; @@ -26,9 +26,9 @@ if (count($files) == 0) { /*echo 'Miniature:' . $min . '
    '; echo 'Image:' . $flf . '
    '; */ echo ''; - echo ''; } echo '
    InfoDate
    ' . $fl['upl_date'] . '
    '; + echo '
    ' . $fl['upl_date'] . ''; if ($can_delete) echo '
    delete'; - if ($can_rename) echo '
    edit info'; + if ($can_rename) echo ' | edit'; echo '
    '; diff --git a/tpl/file/upload-ok.php b/tpl/file/upload-ok.php index a0edee1..1d6559f 100644 --- a/tpl/file/upload-ok.php +++ b/tpl/file/upload-ok.php @@ -10,10 +10,15 @@ $imgurl = $baseurl . $id . "." . $type; Markdown code : ]()

    - Back to upload form + back to upload form = $apps['file']['index']) - echo ' - back to list of uploaded files'; + if ($user['priv'] >= $apps['file']['index']) { + echo ' | back to list of uploaded files'; + if ($folder != 0) { + echo ' | go to folder'; + } + echo ' | edit file info'; + } ?>