From af700ea27703bbec5aa1078a84f9fd44c0260322 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 26 May 2009 21:20:04 -0400 Subject: Let's you upload a file with a notice and have it shown with other attachments. --- lib/noticelist.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index 50a95cfcb..420272515 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -206,6 +206,7 @@ class NoticeListItem extends Widget return 'shownotice' !== $this->out->args['action']; } +/* function attachmentCount($discriminant = true) { $file_oembed = new File_oembed; $query = "select count(*) as c from file_oembed join file_to_post on file_oembed.file_id = file_to_post.file_id where post_id=" . $this->notice->id; @@ -213,11 +214,16 @@ class NoticeListItem extends Widget $file_oembed->fetch(); return intval($file_oembed->c); } +*/ + + function showWithAttachment() { + } function showNoticeInfo() { $this->out->elementStart('div', 'entry-content'); $this->showNoticeLink(); +// $this->showWithAttachment(); $this->showNoticeSource(); $this->showContext(); $this->out->elementEnd('div'); @@ -388,6 +394,11 @@ class NoticeListItem extends Widget $this->out->element('abbr', array('class' => 'published', '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'); -- cgit v1.2.3-54-g00ecf From b8de7935568e631bc99aec6120f2bc4090f50fec Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Fri, 29 May 2009 02:38:38 +0000 Subject: Changed ul to ol and added xoxo for notice lists. --- actions/conversation.php | 10 +++++----- actions/shownotice.php | 4 ++-- lib/noticelist.php | 4 ++-- lib/noticesection.php | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) (limited to 'lib/noticelist.php') diff --git a/actions/conversation.php b/actions/conversation.php index ef189016a..0d7cb9a87 100644 --- a/actions/conversation.php +++ b/actions/conversation.php @@ -179,14 +179,14 @@ class ConversationTree extends NoticeList $this->out->elementStart('div', array('id' =>'notices_primary')); $this->out->element('h2', null, _('Notices')); - $this->out->elementStart('ul', array('class' => 'notices')); + $this->out->elementStart('ol', array('class' => 'notices xoxo')); if (array_key_exists('root', $this->tree)) { $rootid = $this->tree['root'][0]; $this->showNoticePlus($rootid); } - $this->out->elementEnd('ul'); + $this->out->elementEnd('ol'); $this->out->elementEnd('div'); return $cnt; @@ -215,13 +215,13 @@ class ConversationTree extends NoticeList if (array_key_exists($id, $this->tree)) { $children = $this->tree[$id]; - $this->out->elementStart('ul', array('class' => 'notices')); + $this->out->elementStart('ol', array('class' => 'notices')); foreach ($children as $child) { $this->showNoticePlus($child); } - $this->out->elementEnd('ul'); + $this->out->elementEnd('ol'); } $this->out->elementEnd('li'); @@ -295,4 +295,4 @@ class ConversationTreeItem extends NoticeListItem { return; } -} \ No newline at end of file +} diff --git a/actions/shownotice.php b/actions/shownotice.php index 2c469c9de..34c8a8e94 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -208,10 +208,10 @@ class ShownoticeAction extends Action function showContent() { - $this->elementStart('ul', array('class' => 'notices')); + $this->elementStart('ol', array('class' => 'notices xoxo')); $nli = new NoticeListItem($this->notice, $this); $nli->show(); - $this->elementEnd('ul'); + $this->elementEnd('ol'); } /** diff --git a/lib/noticelist.php b/lib/noticelist.php index 50a95cfcb..0e80a9778 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -86,7 +86,7 @@ class NoticeList extends Widget { $this->out->elementStart('div', array('id' =>'notices_primary')); $this->out->element('h2', null, _('Notices')); - $this->out->elementStart('ul', array('class' => 'notices')); + $this->out->elementStart('ol', array('class' => 'notices xoxo')); $cnt = 0; @@ -101,7 +101,7 @@ class NoticeList extends Widget $item->show(); } - $this->out->elementEnd('ul'); + $this->out->elementEnd('ol'); $this->out->elementEnd('div'); return $cnt; diff --git a/lib/noticesection.php b/lib/noticesection.php index 37aafdaf6..ca1432686 100644 --- a/lib/noticesection.php +++ b/lib/noticesection.php @@ -52,12 +52,12 @@ class NoticeSection extends Section { $notices = $this->getNotices(); $cnt = 0; - $this->out->elementStart('ul', 'notices'); + $this->out->elementStart('ol', 'notices xoxo'); while ($notices->fetch() && ++$cnt <= NOTICES_PER_SECTION) { $this->showNotice($notices); } - $this->out->elementEnd('ul'); + $this->out->elementEnd('ol'); return ($cnt > NOTICES_PER_SECTION); } -- cgit v1.2.3-54-g00ecf From 27af3c67a2a9ea856aa2de041a986d452cce3025 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 9 Jun 2009 15:18:12 -0400 Subject: Improve file upload and attachment interface. --- classes/Notice.php | 12 ++++++++++++ lib/common.php | 1 + lib/noticelist.php | 8 ++++---- 3 files changed, 17 insertions(+), 4 deletions(-) (limited to 'lib/noticelist.php') diff --git a/classes/Notice.php b/classes/Notice.php index 1b5c0ab0a..0b1017e12 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -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); diff --git a/lib/common.php b/lib/common.php index ceb50337c..5aafdfe0e 100644 --- a/lib/common.php +++ b/lib/common.php @@ -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', diff --git a/lib/noticelist.php b/lib/noticelist.php index 5513e317e..9ace341d8 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -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'); -- cgit v1.2.3-54-g00ecf