]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Improve file upload and attachment interface.
authorRobin Millette <millette@controlyourself.ca>
Tue, 9 Jun 2009 19:18:12 +0000 (15:18 -0400)
committerRobin Millette <millette@controlyourself.ca>
Tue, 9 Jun 2009 19:18:12 +0000 (15:18 -0400)
classes/Notice.php
lib/common.php
lib/noticelist.php

index 1b5c0ab0a55afdc53592b860ec71ca414fa615a5..0b1017e126d95e0da7dd79c102a19e2474ed333c 100644 (file)
@@ -277,6 +277,18 @@ class Notice extends Memcached_DataObject
         return true;
     }
 
+    function getUploadedAttachment() {
+        $post = clone $this;
+        $query = 'select file.url as uploaded from file join file_to_post on file.id = file_id where post_id=' . $post->escape($post->id) . ' and url like "%/notice/%/file"';
+        $post->query($query);
+        $post->fetch();
+        $ret = $post->uploaded;
+//        var_dump($post);
+        $post->free();
+//        die();
+        return $ret;
+    }
+
     function hasAttachments() {
         $post = clone $this;
         $query = "select count(file_id) as n_attachments from file join file_to_post on (file_id = file.id) join notice on (post_id = notice.id) where post_id = " . $post->escape($post->id);
index ceb50337ccf193232a86972836f19fef4a2cd8f4..5aafdfe0ee9568e6936833ab7d979f1037f0eaf5 100644 (file)
@@ -188,6 +188,7 @@ $config =
             'application/vnd.oasis.opendocument.formula-template',
             'application/vnd.oasis.opendocument.text-master',
             'application/vnd.oasis.opendocument.text-web',
+            'application/x-zip',
             'application/zip',
             'text/plain',
             'video/mpeg',
index 5513e317e0406fff6b8396444eaf892778b298be..9ace341d8018b632103583bf88641ed1896ed806 100644 (file)
@@ -364,6 +364,10 @@ class NoticeListItem extends Widget
             // versions (>> 0.4.x)
             $this->out->raw(common_render_content($this->notice->content, $this->notice));
         }
+        $uploaded = $this->notice->getUploadedAttachment();
+        if ($uploaded) {
+            $this->out->element('a', array('href' => $uploaded, 'class' => 'attachment'), $uploaded);
+        }
         $this->out->elementEnd('p');
     }
 
@@ -395,10 +399,6 @@ class NoticeListItem extends Widget
                                           'title' => $dt),
                             common_date_string($this->notice->created));
 
-        $f2p = File_to_post::staticGet('post_id', $this->notice->id);
-        if (!empty($f2p)) {
-            $this->out->text(_(' (with attachments) '));
-        }
         $this->out->elementEnd('a');
         $this->out->elementEnd('dd');
         $this->out->elementEnd('dl');