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/attachmentlist.php | 6 +----- lib/noticelist.php | 55 +++++++++++++++++++++++--------------------------- lib/router.php | 15 +++++++++++--- 3 files changed, 38 insertions(+), 38 deletions(-) (limited to 'lib') diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 9485fe3d6..1be7b2fee 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -191,7 +191,7 @@ class AttachmentListItem extends Widget } function linkAttr() { - return array('class' => 'attachment', 'href' => common_local_url('attachment', array('attachment' => $this->attachment->id))); + return array('class' => 'attachment', 'href' => $this->attachment->url, 'id' => 'attachment-' . $this->attachment->id); } function showLink() { @@ -200,10 +200,6 @@ class AttachmentListItem extends Widget $this->out->elementStart('h4'); $this->out->element('a', $attr, $text); - if ($this->attachment->url !== $this->title()) - $this->out->element('span', null, " ({$this->attachment->url})"); - - $this->out->elementEnd('h4'); } 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'); } diff --git a/lib/router.php b/lib/router.php index 70ee0f3fb..39c005609 100644 --- a/lib/router.php +++ b/lib/router.php @@ -151,26 +151,35 @@ class Router $m->connect('search/notice/rss?q=:q', array('action' => 'noticesearchrss'), array('q' => '.+')); +/* + $m->connect('attachment/ajax_by_url/*url', + array('action' => 'attachment_ajax')); +*/ $m->connect('attachment/:attachment/ajax', array('action' => 'attachment_ajax'), - array('notice' => '[0-9]+')); + array('attachment' => '[0-9]+')); +/* + TODO + not used right now, will revisit later $m->connect('attachment/:attachment', array('action' => 'attachment'), - array('notice' => '[0-9]+')); - + array('attachment' => '[0-9]+')); +*/ // notice $m->connect('notice/new', array('action' => 'newnotice')); $m->connect('notice/new?replyto=:replyto', array('action' => 'newnotice'), array('replyto' => '[A-Za-z0-9_-]+')); +/* $m->connect('notice/:notice/attachments/ajax', array('action' => 'attachments_ajax'), array('notice' => '[0-9]+')); $m->connect('notice/:notice/attachments', array('action' => 'attachments'), array('notice' => '[0-9]+')); +*/ $m->connect('notice/:notice', array('action' => 'shownotice'), array('notice' => '[0-9]+')); -- 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') 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') 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 84edf12791dc3d44625b156cda6296f1f74f8a9d Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 25 May 2009 11:13:13 -0400 Subject: Display thumbnail on hover over links in notices when appropriate. --- js/util.js | 13 +++++++++++++ lib/attachmentlist.php | 4 ++-- lib/router.php | 4 ++++ lib/util.php | 12 +++++++++++- theme/base/css/display.css | 8 ++++++++ 5 files changed, 38 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/js/util.js b/js/util.js index b6848abaa..9ee2a1963 100644 --- a/js/util.js +++ b/js/util.js @@ -25,6 +25,19 @@ $(document).ready(function(){ //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'); + $('a.thumbnail').hover(function() { + anchor = $(this); + $.get('/attachment/' + ($(this).attr('id').substring('attachment'.length + 1)) + '/thumbnail', null, function(data) { + anchor.append(data); + $('#thumbnail').fadeIn('def'); + }); + }, + function() { + setTimeout(function() { + $('#thumbnail').fadeOut('slow', function() {$(this).remove();}); + }, 500); + } + ); // count character on keyup function counter(event){ diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 1be7b2fee..52aa5d9ee 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -171,7 +171,7 @@ class AttachmentListItem extends Widget } function linkTitle() { - return 'Our page for ' . $this->title(); + return $this->title(); } /** @@ -256,7 +256,7 @@ class Attachment extends AttachmentListItem } function linkTitle() { - return 'Direct link to ' . $this->title(); + return $this->attachment->url; } function showRepresentation() { diff --git a/lib/router.php b/lib/router.php index 39c005609..d1e2970c5 100644 --- a/lib/router.php +++ b/lib/router.php @@ -159,6 +159,10 @@ class Router array('action' => 'attachment_ajax'), array('attachment' => '[0-9]+')); + $m->connect('attachment/:attachment/thumbnail', + array('action' => 'attachment_thumbnail'), + array('attachment' => '[0-9]+')); + /* TODO not used right now, will revisit later diff --git a/lib/util.php b/lib/util.php index 4a55cbfe5..d56f44f7b 100644 --- a/lib/util.php +++ b/lib/util.php @@ -503,8 +503,18 @@ function common_linkify($url) { $file = new File; $file->query($query); $file->fetch(); + if (!empty($file->file_id)) { - $attrs['class'] = 'attachment'; + $query = "select file_thumbnail.file_id as file_id from file join file_thumbnail on file.id = file_thumbnail.file_id where file.url='$longurl'"; + $file2 = new File; + $file2->query($query); + $file2->fetch(); + + if (empty($file2->file_id)) { + $attrs['class'] = 'attachment'; + } else { + $attrs['class'] = 'attachment thumbnail'; + } $attrs['id'] = "attachment-{$file->file_id}"; } return XMLStringer::estring('a', $attrs, $display); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 8f72460a8..71a434c54 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -1205,3 +1205,11 @@ display:none; .guide { clear:both; } + +#thumbnail { +position:absolute; +z-index: 999; +display: none; +left: 100px; +} + -- cgit v1.2.3-54-g00ecf From 594454ced3d02ceb766bdbdce1dbfa871abec464 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 25 May 2009 15:38:50 -0400 Subject: Single anchor to include thumbnail and title for attachment --- lib/attachmentlist.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/attachmentlist.php b/lib/attachmentlist.php index 52aa5d9ee..2a0114b12 100644 --- a/lib/attachmentlist.php +++ b/lib/attachmentlist.php @@ -198,23 +198,22 @@ class AttachmentListItem extends Widget $attr = $this->linkAttr(); $text = $this->linkTitle(); $this->out->elementStart('h4'); - $this->out->element('a', $attr, $text); - + $this->out->elementStart('a', $attr); + $this->out->element('span', null, $text); + $this->showRepresentation(); + $this->out->elementEnd('a'); $this->out->elementEnd('h4'); } function showNoticeAttachment() { $this->showLink(); - $this->showRepresentation(); } function showRepresentation() { $thumbnail = File_thumbnail::staticGet('file_id', $this->attachment->id); if (!empty($thumbnail)) { - $this->out->elementStart('a', $this->linkAttr()/*'href' => $this->linkTo()*/); $this->out->element('img', array('alt' => 'nothing to say', 'src' => $thumbnail->url, 'width' => $thumbnail->width, 'height' => $thumbnail->height)); - $this->out->elementEnd('a'); } } -- cgit v1.2.3-54-g00ecf From 64d0767654d93de81a0779f04eb992c574bbdece Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 25 May 2009 19:42:03 +0000 Subject: Removed more cruft from old attachment/attachements pages --- actions/tag.php | 2 -- lib/router.php | 22 +--------------------- 2 files changed, 1 insertion(+), 23 deletions(-) (limited to 'lib') diff --git a/actions/tag.php b/actions/tag.php index e71ec06a8..e9351d241 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -49,8 +49,6 @@ class TagAction extends Action { $pop = new PopularNoticeSection($this); $pop->show(); -// $freqatt = new FrequentAttachmentSection($this); -// $freqatt->show(); } function title() diff --git a/lib/router.php b/lib/router.php index d1e2970c5..fc119821b 100644 --- a/lib/router.php +++ b/lib/router.php @@ -151,10 +151,6 @@ class Router $m->connect('search/notice/rss?q=:q', array('action' => 'noticesearchrss'), array('q' => '.+')); -/* - $m->connect('attachment/ajax_by_url/*url', - array('action' => 'attachment_ajax')); -*/ $m->connect('attachment/:attachment/ajax', array('action' => 'attachment_ajax'), array('attachment' => '[0-9]+')); @@ -163,27 +159,11 @@ class Router array('action' => 'attachment_thumbnail'), array('attachment' => '[0-9]+')); -/* - TODO - not used right now, will revisit later - $m->connect('attachment/:attachment', - array('action' => 'attachment'), - array('attachment' => '[0-9]+')); -*/ - // notice - $m->connect('notice/new', array('action' => 'newnotice')); $m->connect('notice/new?replyto=:replyto', array('action' => 'newnotice'), array('replyto' => '[A-Za-z0-9_-]+')); -/* - $m->connect('notice/:notice/attachments/ajax', - array('action' => 'attachments_ajax'), - array('notice' => '[0-9]+')); - $m->connect('notice/:notice/attachments', - array('action' => 'attachments'), - array('notice' => '[0-9]+')); -*/ + $m->connect('notice/:notice', array('action' => 'shownotice'), array('notice' => '[0-9]+')); -- 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') 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 From a598dcccba21daa6decefb7fb38882c1e77904eb Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Mon, 25 May 2009 19:58:31 +0000 Subject: Really removing the old files, thanks git! --- actions/attachments.php | 290 -------------------------------------- actions/attachments_ajax.php | 115 --------------- lib/attachmentsection.php | 80 ----------- lib/frequentattachmentsection.php | 66 --------- 4 files changed, 551 deletions(-) delete mode 100644 actions/attachments.php delete mode 100644 actions/attachments_ajax.php delete mode 100644 lib/attachmentsection.php delete mode 100644 lib/frequentattachmentsection.php (limited to 'lib') diff --git a/actions/attachments.php b/actions/attachments.php deleted file mode 100644 index d3c90fec2..000000000 --- a/actions/attachments.php +++ /dev/null @@ -1,290 +0,0 @@ -. - * - * @category Personal - * @package Laconica - * @author Evan Prodromou - * @copyright 2008-2009 Control Yourself, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -if (!defined('LACONICA')) { - exit(1); -} - -require_once INSTALLDIR.'/lib/attachmentlist.php'; - -/** - * Show notice attachments - * - * @category Personal - * @package Laconica - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -class AttachmentsAction extends Action -{ - /** - * Notice object to show - */ - - var $notice = null; - - /** - * Profile of the notice object - */ - - var $profile = null; - - /** - * Avatar of the profile of the notice object - */ - - var $avatar = null; - - /** - * Is this action read-only? - * - * @return boolean true - */ - - function isReadOnly($args) - { - return true; - } - - /** - * Last-modified date for page - * - * When was the content of this page last modified? Based on notice, - * profile, avatar. - * - * @return int last-modified date as unix timestamp - */ - - function lastModified() - { - return max(strtotime($this->notice->created), - strtotime($this->profile->modified), - ($this->avatar) ? strtotime($this->avatar->modified) : 0); - } - - /** - * An entity tag for this page - * - * Shows the ETag for the page, based on the notice ID and timestamps - * for the notice, profile, and avatar. It's weak, since we change - * the date text "one hour ago", etc. - * - * @return string etag - */ - - function etag() - { - $avtime = ($this->avatar) ? - strtotime($this->avatar->modified) : 0; - - return 'W/"' . implode(':', array($this->arg('action'), - common_language(), - $this->notice->id, - strtotime($this->notice->created), - strtotime($this->profile->modified), - $avtime)) . '"'; - } - - /** - * Title of the page - * - * @return string title of the page - */ - - function title() - { - return sprintf(_('%1$s\'s status on %2$s'), - $this->profile->nickname, - common_exact_date($this->notice->created)); - } - - - /** - * Load attributes based on database arguments - * - * Loads all the DB stuff - * - * @param array $args $_REQUEST array - * - * @return success flag - */ - - function prepare($args) - { - parent::prepare($args); - - $id = $this->arg('notice'); - - $this->notice = Notice::staticGet($id); - - if (!$this->notice) { - $this->clientError(_('No such notice.'), 404); - return false; - } - - -/* -// STOP if there are no attachments -// maybe even redirect if there's a single one -// RYM FIXME TODO - $this->clientError(_('No such attachment.'), 404); - return false; - -*/ - - - - - $this->profile = $this->notice->getProfile(); - - if (!$this->profile) { - $this->serverError(_('Notice has no profile'), 500); - return false; - } - - $this->avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); - return true; - } - - - - /** - * Handle input - * - * Only handles get, so just show the page. - * - * @param array $args $_REQUEST data (unused) - * - * @return void - */ - - function handle($args) - { - parent::handle($args); - - if ($this->notice->is_local == 0) { - if (!empty($this->notice->url)) { - common_redirect($this->notice->url, 301); - } else if (!empty($this->notice->uri) && preg_match('/^https?:/', $this->notice->uri)) { - common_redirect($this->notice->uri, 301); - } - } else { - $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) { - common_redirect(common_local_url('attachment', array('attachment' => $file->id)), 301); - } else { - $this->showPage(); - } - } - } - - /** - * Don't show local navigation - * - * @return void - */ - - function showLocalNavBlock() - { - } - - /** - * Fill the content area of the page - * - * Shows a single notice list item. - * - * @return void - */ - - function showContent() - { - $al = new AttachmentList($this->notice, $this); - $cnt = $al->show(); - } - - /** - * Don't show page notice - * - * @return void - */ - - function showPageNoticeBlock() - { - } - - /** - * Don't show aside - * - * @return void - */ - - function showAside() { - } - - /** - * Extra content - * - * We show the microid(s) for the author, if any. - * - * @return void - */ - - function extraHead() - { - $user = User::staticGet($this->profile->id); - - if (!$user) { - return; - } - - if ($user->emailmicroid && $user->email && $this->notice->uri) { - $id = new Microid('mailto:'. $user->email, - $this->notice->uri); - $this->element('meta', array('name' => 'microid', - 'content' => $id->toString())); - } - - if ($user->jabbermicroid && $user->jabber && $this->notice->uri) { - $id = new Microid('xmpp:', $user->jabber, - $this->notice->uri); - $this->element('meta', array('name' => 'microid', - 'content' => $id->toString())); - } - } -} - diff --git a/actions/attachments_ajax.php b/actions/attachments_ajax.php deleted file mode 100644 index 402d8b5e7..000000000 --- a/actions/attachments_ajax.php +++ /dev/null @@ -1,115 +0,0 @@ -. - * - * @category Personal - * @package Laconica - * @author Evan Prodromou - * @copyright 2008-2009 Control Yourself, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -if (!defined('LACONICA')) { - exit(1); -} - -//require_once INSTALLDIR.'/lib/personalgroupnav.php'; -//require_once INSTALLDIR.'/lib/feedlist.php'; -require_once INSTALLDIR.'/actions/attachments.php'; - -/** - * Show notice attachments - * - * @category Personal - * @package Laconica - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -class Attachments_ajaxAction extends AttachmentsAction -{ - function showContent() - { - } - - /** - * Fill the content area of the page - * - * Shows a single notice list item. - * - * @return void - */ - - function showContentBlock() - { - $al = new AttachmentList($this->notice, $this); - $cnt = $al->show(); - } - - /** - * Extra content - * - * We show the microid(s) for the author, if any. - * - * @return void - */ - - function extraHead() - { - } - - - /** - * Show page, a template method. - * - * @return nothing - */ - function showPage() - { - if (Event::handle('StartShowBody', array($this))) { - $this->showCore(); - Event::handle('EndShowBody', array($this)); - } - } - - /** - * Show core. - * - * Shows local navigation, content block and aside. - * - * @return nothing - */ - function showCore() - { - $this->elementStart('div', array('id' => 'core')); - if (Event::handle('StartShowContentBlock', array($this))) { - $this->showContentBlock(); - Event::handle('EndShowContentBlock', array($this)); - } - $this->elementEnd('div'); - } - - - - -} - diff --git a/lib/attachmentsection.php b/lib/attachmentsection.php deleted file mode 100644 index 20e620b9b..000000000 --- a/lib/attachmentsection.php +++ /dev/null @@ -1,80 +0,0 @@ -. - * - * @category Widget - * @package Laconica - * @author Evan Prodromou - * @copyright 2009 Control Yourself, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -if (!defined('LACONICA')) { - exit(1); -} - -define('ATTACHMENTS_PER_SECTION', 6); - -/** - * Base class for sections showing lists of attachments - * - * These are the widgets that show interesting data about a person - * group, or site. - * - * @category Widget - * @package Laconica - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -class AttachmentSection extends Section -{ - function showContent() - { - $attachments = $this->getAttachments(); - - $cnt = 0; - - $this->out->elementStart('ul', 'attachments'); - - while ($attachments->fetch() && ++$cnt <= ATTACHMENTS_PER_SECTION) { - $this->showAttachment($attachments); - } - - $this->out->elementEnd('ul'); - - return ($cnt > ATTACHMENTS_PER_SECTION); - } - - function getAttachments() - { - return null; - } - - function showAttachment($attachment) - { - $this->out->elementStart('li'); - $this->out->element('a', array('class' => 'attachment', 'href' => common_local_url('attachment', array('attachment' => $attachment->file_id))), "Attachment tagged {$attachment->c} times"); - $this->out->elementEnd('li'); - } -} - diff --git a/lib/frequentattachmentsection.php b/lib/frequentattachmentsection.php deleted file mode 100644 index 0ce0d1871..000000000 --- a/lib/frequentattachmentsection.php +++ /dev/null @@ -1,66 +0,0 @@ -. - * - * @category Widget - * @package Laconica - * @author Evan Prodromou - * @copyright 2009 Control Yourself, Inc. - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -if (!defined('LACONICA')) { - exit(1); -} - -/** - * FIXME - * - * These are the widgets that show interesting data about a person - * group, or site. - * - * @category Widget - * @package Laconica - * @author Evan Prodromou - * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ - */ - -class FrequentAttachmentSection extends AttachmentSection -{ - function getAttachments() { - $notice_tag = new Notice_tag; - $query = 'select file_id, count(file_id) as c from notice_tag join file_to_post on post_id = notice_id where tag="' . $notice_tag->escape($this->out->tag) . '" group by file_id order by c desc'; - $notice_tag->query($query); - return $notice_tag; - } - - function title() - { - return sprintf(_('Attachments frequently tagged with %s'), $this->out->tag); - } - - function divId() - { - return 'frequent_attachments'; - } -} - -- cgit v1.2.3-54-g00ecf From 0e8358bd2335bfc71ac5b2ee93e866fa5c571c89 Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 26 May 2009 02:34:36 +0000 Subject: Updated stylesheet paths for facebook app --- lib/facebookaction.php | 4 ---- theme/base/css/facebookapp.css | 2 -- 2 files changed, 6 deletions(-) (limited to 'lib') diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 043a078cd..00db79400 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -98,10 +98,6 @@ class FacebookAction extends Action // Add a timestamp to the file so Facebook cache wont ignore our changes $ts = filemtime(INSTALLDIR.'/theme/base/css/display.css'); - $this->element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => theme_path('css/display.css', 'base') . '?ts=' . $ts)); - $theme = common_config('site', 'theme'); $ts = filemtime(INSTALLDIR. '/theme/' . $theme .'/css/display.css'); diff --git a/theme/base/css/facebookapp.css b/theme/base/css/facebookapp.css index 9f269b96f..e6b1c9ee5 100644 --- a/theme/base/css/facebookapp.css +++ b/theme/base/css/facebookapp.css @@ -1,5 +1,3 @@ -@import url("../../identica/css/display.css"); - * { font-size:14px; font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif; -- cgit v1.2.3-54-g00ecf From c93031c2aa49b8a044e896ca1e07f5f4f429308e Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Tue, 26 May 2009 03:34:00 +0000 Subject: Reusing base stylesheet (instead of hoping for FB to import it) in FB app. --- lib/facebookaction.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib') diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 00db79400..637a6284d 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -97,6 +97,10 @@ class FacebookAction extends Action { // Add a timestamp to the file so Facebook cache wont ignore our changes $ts = filemtime(INSTALLDIR.'/theme/base/css/display.css'); + + $this->element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => theme_path('css/display.css', 'base') . '?ts=' . $ts)); $theme = common_config('site', 'theme'); -- cgit v1.2.3-54-g00ecf