From b5ac6e31f2f148164860aeabec6899b75d7292ec Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Sun, 24 May 2009 04:43:34 -0400 Subject: Rearranged attachment info to only appear on each applicable notice page and thru an ajax popup. --- lib/noticelist.php | 55 +++++++++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 30 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index a52132171..e3361fc99 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -34,6 +34,7 @@ if (!defined('LACONICA')) { require_once INSTALLDIR.'/lib/favorform.php'; require_once INSTALLDIR.'/lib/disfavorform.php'; +require_once INSTALLDIR.'/lib/attachmentlist.php'; /** * widget for displaying a list of notices @@ -179,9 +180,10 @@ class NoticeListItem extends Widget { $this->showStart(); $this->showNotice(); - $this->showNoticeAttachments(); + $this->showNoticeAttachmentsIcon(); $this->showNoticeInfo(); $this->showNoticeOptions(); + $this->showNoticeAttachments(); $this->showEnd(); } @@ -193,45 +195,38 @@ class NoticeListItem extends Widget $this->out->elementEnd('div'); } - function showNoticeAttachments() - { + function showNoticeAttachments() { + if ($this->isUsedInList()) { + return; + } + $al = new AttachmentList($this->notice, $this->out); + $al->show(); + } + + function isUsedInList() { + return 'shownotice' !== $this->out->args['action']; + } + + function attachmentCount() { $f2p = new File_to_post; $f2p->post_id = $this->notice->id; $file = new File; $file->joinAdd($f2p); $file->selectAdd(); $file->selectAdd('file.id as id'); - $count = $file->find(true); - if (!$count) return; - if (1 === $count) { - $href = common_local_url('attachment', array('attachment' => $file->id)); - $att_class = 'attachment'; - } else { - $href = common_local_url('attachments', array('notice' => $this->notice->id)); - $att_class = 'attachments'; - } + return $file->find(true); + } - $clip = theme_path('images/icons/clip', 'base'); - if ('shownotice' === $this->out->args['action']) { - $height = '96px'; - $width = '83%'; - $width_att = '15%'; - $clip .= '-big.png'; - $top = '70px'; - } else { - $height = '48px'; - $width = '90%'; - $width_att = '8%'; - $clip .= '.png'; - $top = '20px'; + function showNoticeAttachmentsIcon() + { + if (!($this->isUsedInList() && ($count = $this->attachmentCount()))) { + return; } -if(0) - $this->out->elementStart('div', 'entry-attachments'); -else - $this->out->elementStart('p', array('class' => 'entry-attachments', 'style' => "float: right; width: $width_att; background: url($clip) no-repeat; text-align: right; height: $height;")); - $this->out->element('a', array('class' => $att_class, 'style' => "text-decoration: none; padding-top: $top; display: block; height: $height;", 'href' => $href, 'title' => "# of attachments: $count"), $count === 1 ? '' : $count); + $href = common_local_url('shownotice', array('notice' => $this->notice->id)) . '#attachments'; + $this->out->elementStart('p', 'entry-attachments'); + $this->out->element('a', array('href' => $href, 'title' => "# of attachments: $count"), $count === 1 ? '' : $count); $this->out->elementEnd('p'); } -- cgit v1.2.3-54-g00ecf From bd70caace84758e6655f8db4957049492834a6c6 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Sun, 24 May 2009 18:06:19 -0400 Subject: Only show number of attachments if > 1 --- lib/noticelist.php | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'lib/noticelist.php') diff --git a/lib/noticelist.php b/lib/noticelist.php index e3361fc99..51b8987fe 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -207,14 +207,12 @@ class NoticeListItem extends Widget return 'shownotice' !== $this->out->args['action']; } - function attachmentCount() { - $f2p = new File_to_post; - $f2p->post_id = $this->notice->id; - $file = new File; - $file->joinAdd($f2p); - $file->selectAdd(); - $file->selectAdd('file.id as id'); - return $file->find(true); + 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; + $file_oembed->query($query); + $file_oembed->fetch(); + return intval($file_oembed->c); } function showNoticeAttachmentsIcon() @@ -224,7 +222,6 @@ class NoticeListItem extends Widget } $href = common_local_url('shownotice', array('notice' => $this->notice->id)) . '#attachments'; - $this->out->elementStart('p', 'entry-attachments'); $this->out->element('a', array('href' => $href, 'title' => "# of attachments: $count"), $count === 1 ? '' : $count); $this->out->elementEnd('p'); -- cgit v1.2.3-54-g00ecf From 5f3acc252738e408ea2447b7541eae66c1e9e09a Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Sun, 24 May 2009 21:13:42 -0400 Subject: Removed big clip and replaced with smaller inline one next to each URL (in a notice) that's actually an attachment. Overlay (popup) on click. --- js/util.js | 6 +++++- lib/noticelist.php | 1 - lib/util.php | 11 +++++++++++ theme/base/images/icons/clip-inline.png | Bin 0 -> 1646 bytes 4 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 theme/base/images/icons/clip-inline.png (limited to 'lib/noticelist.php') diff --git a/js/util.js b/js/util.js index 6511c0380..b6848abaa 100644 --- a/js/util.js +++ b/js/util.js @@ -20,7 +20,11 @@ $(document).ready(function(){ // attachments and attachment pages not used at the moment except for attachment_ajax version // $('.attachments').click(function() {$().jOverlay({zIndex:999, success:function(html) {$('.attachment').click(function() {$().jOverlay({url:$(this).attr('href') + '/ajax'}); return false; }); // }, url:$(this).attr('href') + '/ajax'}); return false; }); - $('.attachment').click(function() {$().jOverlay({url:'../attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); + + //FIXME + //need to link to proper url depending on site config (path name and theme, for instance) + $('a.attachment').click(function() {$().jOverlay({url:'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); + $('.entry-title a.attachment').append(' Attachment'); // count character on keyup function counter(event){ diff --git a/lib/noticelist.php b/lib/noticelist.php index 51b8987fe..ae1438892 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -180,7 +180,6 @@ class NoticeListItem extends Widget { $this->showStart(); $this->showNotice(); - $this->showNoticeAttachmentsIcon(); $this->showNoticeInfo(); $this->showNoticeOptions(); $this->showNoticeAttachments(); diff --git a/lib/util.php b/lib/util.php index fbef8764a..4a55cbfe5 100644 --- a/lib/util.php +++ b/lib/util.php @@ -496,6 +496,17 @@ function common_linkify($url) { } $attrs = array('href' => $longurl, 'rel' => 'external'); + +// if this URL is an attachment, then we set class='attachment' and id='attahcment-ID' +// where ID is the id of the attachment for the given URL. + $query = "select file_oembed.file_id as file_id from file join file_oembed on file.id = file_oembed.file_id where file.url='$longurl'"; + $file = new File; + $file->query($query); + $file->fetch(); + if (!empty($file->file_id)) { + $attrs['class'] = 'attachment'; + $attrs['id'] = "attachment-{$file->file_id}"; + } return XMLStringer::estring('a', $attrs, $display); } diff --git a/theme/base/images/icons/clip-inline.png b/theme/base/images/icons/clip-inline.png new file mode 100644 index 000000000..870f8b2e8 Binary files /dev/null and b/theme/base/images/icons/clip-inline.png differ -- cgit v1.2.3-54-g00ecf From 01dad5729827870d87f87118c336dcf2acc4af32 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Mon, 25 May 2009 15:53:19 -0400 Subject: Markup cleanup for attachments --- actions/attachment.php | 2 -- actions/attachment_ajax.php | 2 +- js/util.js | 6 ------ lib/attachmentlist.php | 17 +++++++---------- lib/noticelist.php | 14 +------------- theme/base/css/display.css | 3 +++ 6 files changed, 12 insertions(+), 32 deletions(-) (limited to 'lib/noticelist.php') diff --git a/actions/attachment.php b/actions/attachment.php index c51c75120..16ee723d9 100644 --- a/actions/attachment.php +++ b/actions/attachment.php @@ -176,10 +176,8 @@ class AttachmentAction extends Action function showContent() { - $this->elementStart('ul', array('class' => 'attachments')); $ali = new Attachment($this->attachment, $this); $cnt = $ali->show(); - $this->elementEnd('ul'); } /** diff --git a/actions/attachment_ajax.php b/actions/attachment_ajax.php index 6930dc112..3d83393c5 100644 --- a/actions/attachment_ajax.php +++ b/actions/attachment_ajax.php @@ -67,7 +67,7 @@ class Attachment_ajaxAction extends AttachmentAction */ function showCore() { - $this->elementStart('div', array('id' => 'ajaxcore')); + $this->elementStart('div', array('id' => 'core')); if (Event::handle('StartShowContentBlock', array($this))) { $this->showContentBlock(); Event::handle('EndShowContentBlock', array($this)); diff --git a/js/util.js b/js/util.js index ffaedc690..cba6f822e 100644 --- a/js/util.js +++ b/js/util.js @@ -17,12 +17,6 @@ */ $(document).ready(function(){ -// attachments and attachment pages not used at the moment except for attachment_ajax version -// $('.attachments').click(function() {$().jOverlay({zIndex:999, success:function(html) {$('.attachment').click(function() {$().jOverlay({url:$(this).attr('href') + '/ajax'}); return false; }); -// }, url:$(this).attr('href') + '/ajax'}); return false; }); - - //FIXME - //need to link to proper url depending on site config (path name and theme, for instance) $('a.attachment').click(function() {$().jOverlay({url: $('address .url')[0].href+'/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/ajax'}); return false; }); $('a.thumbnail').hover( function() { diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 2a0114b12..d0478bad3 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -80,9 +80,9 @@ class AttachmentList extends Widget function show() { -// $this->out->elementStart('div', array('id' =>'attachments_primary')); - $this->out->elementStart('div', array('id' =>'content')); - $this->out->element('h2', null, _('Attachments')); + $this->out->elementStart('dl', array('id' =>'attachment')); + $this->out->element('dt', null, _('Attachments')); + $this->out->elementStart('dd'); $this->out->elementStart('ul', array('class' => 'attachments')); $atts = new File; @@ -92,8 +92,9 @@ class AttachmentList extends Widget $item->show(); } + $this->out->elementEnd('dd'); $this->out->elementEnd('ul'); - $this->out->elementEnd('div'); + $this->out->elementEnd('dl'); return count($att); } @@ -195,14 +196,10 @@ class AttachmentListItem extends Widget } function showLink() { - $attr = $this->linkAttr(); - $text = $this->linkTitle(); - $this->out->elementStart('h4'); - $this->out->elementStart('a', $attr); - $this->out->element('span', null, $text); + $this->out->elementStart('a', $this->linkAttr()); + $this->out->element('span', null, $this->linkTitle()); $this->showRepresentation(); $this->out->elementEnd('a'); - $this->out->elementEnd('h4'); } function showNoticeAttachment() diff --git a/lib/noticelist.php b/lib/noticelist.php index ae1438892..50a95cfcb 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -180,9 +180,9 @@ class NoticeListItem extends Widget { $this->showStart(); $this->showNotice(); + $this->showNoticeAttachments(); $this->showNoticeInfo(); $this->showNoticeOptions(); - $this->showNoticeAttachments(); $this->showEnd(); } @@ -214,18 +214,6 @@ class NoticeListItem extends Widget return intval($file_oembed->c); } - function showNoticeAttachmentsIcon() - { - if (!($this->isUsedInList() && ($count = $this->attachmentCount()))) { - return; - } - - $href = common_local_url('shownotice', array('notice' => $this->notice->id)) . '#attachments'; - $this->out->elementStart('p', 'entry-attachments'); - $this->out->element('a', array('href' => $href, 'title' => "# of attachments: $count"), $count === 1 ? '' : $count); - $this->out->elementEnd('p'); - } - function showNoticeInfo() { $this->out->elementStart('div', 'entry-content'); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 74f369142..aa76910f0 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -861,6 +861,9 @@ top:11px; left:0; z-index:99; } +#shownotice .notice .attachment img { +position:static; +} .notice-options { -- cgit v1.2.3-54-g00ecf