From 89197210cf706683c8ab22deedc43724fa1fe235 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 21 Feb 2009 19:04:27 +0100 Subject: Fixes #1067: Avatar stretched on authorize remote subscription page. The img tag used a wrong class which had a width: 100% applied. --- actions/userauthorization.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/userauthorization.php b/actions/userauthorization.php index ed17ceec9..0dc1841d4 100644 --- a/actions/userauthorization.php +++ b/actions/userauthorization.php @@ -105,7 +105,7 @@ class UserauthorizationAction extends Action $this->elementStart('div', 'profile'); if ($avatar) { $this->element('img', array('src' => $avatar, - 'class' => 'avatar profile', + 'class' => 'avatar', 'width' => AVATAR_PROFILE_SIZE, 'height' => AVATAR_PROFILE_SIZE, 'alt' => $nickname)); -- cgit v1.2.3-54-g00ecf From 616fd16bc528ce78d7fc1fa8a6ad5a67f10ae5eb Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 21 Feb 2009 19:43:18 +0100 Subject: Auth_Yadis_Yadis::PlainHTTPFetcher expects plain arrays, not hashes. --- actions/finishremotesubscribe.php | 2 +- actions/remotesubscribe.php | 3 +-- lib/omb.php | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) (limited to 'actions') diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php index 76db887de..acfacbdc1 100644 --- a/actions/finishremotesubscribe.php +++ b/actions/finishremotesubscribe.php @@ -283,7 +283,7 @@ class FinishremotesubscribeAction extends Action $fetcher = Auth_Yadis_Yadis::getHTTPFetcher(); $result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata(), - array('User-Agent' => 'Laconica/' . LACONICA_VERSION)); + array('User-Agent: Laconica/' . LACONICA_VERSION)); common_debug('got result: "'.print_r($result,true).'"', __FILE__); diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php index f727a63b8..7ea7acd6d 100644 --- a/actions/remotesubscribe.php +++ b/actions/remotesubscribe.php @@ -321,8 +321,7 @@ class RemotesubscribeAction extends Action $result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata(), - array('User-Agent' => 'Laconica/' . LACONICA_VERSION)); - + array('User-Agent: Laconica/' . LACONICA_VERSION)); if ($result->status != 200) { return null; } diff --git a/lib/omb.php b/lib/omb.php index 29e14c75f..befcf4666 100644 --- a/lib/omb.php +++ b/lib/omb.php @@ -206,7 +206,7 @@ function omb_post_notice_keys($notice, $postnoticeurl, $tk, $secret) $result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata(), - array('User-Agent' => 'Laconica/' . LACONICA_VERSION)); + array('User-Agent: Laconica/' . LACONICA_VERSION)); common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__); @@ -291,7 +291,7 @@ function omb_update_profile($profile, $remote_profile, $subscription) common_debug('postdata = '.$req->to_postdata(), __FILE__); $result = $fetcher->post($req->get_normalized_http_url(), $req->to_postdata(), - array('User-Agent' => 'Laconica/' . LACONICA_VERSION)); + array('User-Agent: Laconica/' . LACONICA_VERSION)); common_debug('Got HTTP result "'.print_r($result,true).'"', __FILE__); -- cgit v1.2.3-54-g00ecf From d4b6e7266ad80add5ff29c947cfad4bd5dbd3c8a Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 21 Feb 2009 22:41:24 +0100 Subject: Correctly handle avatars at updateProfile --- actions/updateprofile.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/updateprofile.php b/actions/updateprofile.php index 898c53543..4751a04ff 100644 --- a/actions/updateprofile.php +++ b/actions/updateprofile.php @@ -162,7 +162,13 @@ class UpdateprofileAction extends Action if ($avatar) { $temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar'); copy($avatar, $temp_filename); - if (!$profile->setOriginal($temp_filename)) { + $imagefile = new ImageFile($profile->id, $temp_filename); + $filename = Avatar::filename($profile->id, + image_type_to_extension($imagefile->type), + null, + common_timestamp()); + rename($temp_filename, Avatar::path($filename)); + if (!$profile->setOriginal($filename)) { $this->serverError(_('Could not save avatar info'), 500); return false; } -- cgit v1.2.3-54-g00ecf From a90a8da5c3c445b11e1e2bf0d0530eb48fa146c0 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sat, 21 Feb 2009 22:50:59 +0100 Subject: Broadcast profile via OMB after avatar change. --- actions/avatarsettings.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'actions') diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php index f38a44a24..6545d9489 100644 --- a/actions/avatarsettings.php +++ b/actions/avatarsettings.php @@ -324,13 +324,12 @@ class AvatarsettingsAction extends AccountSettingsAction return; } - // If image is not being cropped assume pos & dimentions of original + // If image is not being cropped assume pos & dimensions of original. $dest_x = $this->arg('avatar_crop_x') ? $this->arg('avatar_crop_x'):0; $dest_y = $this->arg('avatar_crop_y') ? $this->arg('avatar_crop_y'):0; $dest_w = $this->arg('avatar_crop_w') ? $this->arg('avatar_crop_w'):$filedata['width']; $dest_h = $this->arg('avatar_crop_h') ? $this->arg('avatar_crop_h'):$filedata['height']; - $size = min($dest_w, $dest_h); - $size = ($size > MAX_ORIGINAL) ? MAX_ORIGINAL:$size; + $size = min($dest_w, $dest_h, MAX_ORIGINAL); $user = common_current_user(); $profile = $user->getProfile(); @@ -343,6 +342,7 @@ class AvatarsettingsAction extends AccountSettingsAction unset($_SESSION['FILEDATA']); $this->mode = 'upload'; $this->showForm(_('Avatar updated.'), true); + common_broadcast_profile($profile); } else { $this->showForm(_('Failed updating avatar.')); } -- cgit v1.2.3-54-g00ecf From 210647a56c0ee917ec5bb7d4753ad2603d28d7c4 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 22 Feb 2009 13:32:14 +0100 Subject: Fix replyto parameter in newnotice --- actions/newnotice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/newnotice.php b/actions/newnotice.php index 9face9644..9f44d2516 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -253,7 +253,7 @@ class NewnoticeAction extends Action } } - $notice_form = new NoticeForm($this, $content); + $notice_form = new NoticeForm($this, '', $content); $notice_form->show(); } -- cgit v1.2.3-54-g00ecf From d005b370712943eed3edae2ff82d38dfa3d42a92 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 22 Feb 2009 13:38:16 +0100 Subject: Fixes #1241: in-reply-to links were broken due to copy and paste error (Variable name was wrong). --- actions/noticesearch.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/noticesearch.php b/actions/noticesearch.php index dc58d7528..0bbaa0256 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -201,7 +201,7 @@ class NoticesearchAction extends SearchAction if ($notice->reply_to) { $replyurl = common_local_url('shownotice', - array('notice' => $this->notice->reply_to)); + array('notice' => $notice->reply_to)); $this->elementStart('dl', 'response'); $this->element('dt', null, _('To')); $this->elementStart('dd'); -- cgit v1.2.3-54-g00ecf From bdb8c12d975846ce128619e672b8064b8f5f890a Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Sun, 22 Feb 2009 14:02:17 +0100 Subject: Completely refactored noticesearch list, now using subclassing for highlighting. Fixes #1240 and probably other bugs. --- actions/noticesearch.php | 146 ++++++++++++----------------------------------- 1 file changed, 38 insertions(+), 108 deletions(-) (limited to 'actions') diff --git a/actions/noticesearch.php b/actions/noticesearch.php index 0bbaa0256..83e59dd9a 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -113,123 +113,58 @@ class NoticesearchAction extends SearchAction } else { $cnt = $notice->find(); } - if ($cnt > 0) { - $terms = preg_split('/[\s,]+/', $q); - $this->elementStart('ul', array('class' => 'notices')); - for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) { - if ($notice->fetch()) { - $this->showNotice($notice, $terms); - } else { - // shouldn't happen! - break; - } - } - $this->elementEnd('ul'); - } else { + if ($cnt === 0) { $this->element('p', 'error', _('No results')); + return; } + $terms = preg_split('/[\s,]+/', $q); + $nl = new SearchNoticeList($notice, $this, $terms); + + $cnt = $nl->show(); - $this->pagination($page > 1, $cnt > NOTICES_PER_PAGE, - $page, 'noticesearch', array('q' => $q)); + $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, + $this->page, 'noticesearch', array('q' => $q)); } + function isReadOnly() + { + return true; + } +} - /** - * Show notice - * - * @param class $notice notice - * @param array $terms terms to highlight - * - * @return void - * - * @todo refactor and combine with StreamAction::showNotice() - */ - function showNotice($notice, $terms) +class SearchNoticeList extends NoticeList { + function __construct($notice, $out=null, $terms) { - $profile = $notice->getProfile(); - if (!$profile) { - common_log_db_error($notice, 'SELECT', __FILE__); - $this->serverError(_('Notice without matching profile')); - return; - } - // XXX: RDFa - $this->elementStart('li', array('class' => 'hentry notice', - 'id' => 'notice-' . $notice->id)); + parent::__construct($notice, $out); + $this->terms = $terms; + } - $this->elementStart('div', 'entry-title'); - $this->elementStart('span', 'vcard author'); - $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE); - $this->elementStart('a', array('href' => $profile->profileurl, - 'class' => 'url')); - $this->element('img', array('src' => ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_STREAM_SIZE), - 'class' => 'avatar photo', - 'width' => AVATAR_STREAM_SIZE, - 'height' => AVATAR_STREAM_SIZE, - 'alt' => - ($profile->fullname) ? $profile->fullname : - $profile->nickname)); - $this->element('span', 'nickname fn', $profile->nickname); - $this->elementEnd('a'); - $this->elementEnd('span'); + function newListItem($notice) + { + return new SearchNoticeListItem($notice, $this->out, $this->terms); + } +} +class SearchNoticeListItem extends NoticeListItem { + function __construct($notice, $out=null, $terms) + { + parent::__construct($notice, $out); + $this->terms = $terms; + } + + function showContent() + { // FIXME: URL, image, video, audio - $this->elementStart('p', array('class' => 'entry-content')); - if ($notice->rendered) { - $this->raw($this->highlight($notice->rendered, $terms)); + $this->out->elementStart('p', array('class' => 'entry-content')); + if ($this->notice->rendered) { + $this->out->raw($this->highlight($this->notice->rendered, $this->terms)); } else { // XXX: may be some uncooked notices in the DB, // we cook them right now. This should probably disappear in future // versions (>> 0.4.x) - $this->raw($this->highlight(common_render_content($notice->content, $notice), $terms)); + $this->out->raw($this->highlight(common_render_content($this->notice->content, $this->notice), $this->terms)); } - $this->elementEnd('p'); - $this->elementEnd('div'); + $this->out->elementEnd('p'); - $noticeurl = common_local_url('shownotice', array('notice' => $notice->id)); - $this->elementStart('div', 'entry-content'); - $this->elementStart('dl', 'timestamp'); - $this->element('dt', null, _('Published')); - $this->elementStart('dd', null); - $this->elementStart('a', array('rel' => 'bookmark', - 'href' => $noticeurl)); - $dt = common_date_iso8601($notice->created); - $this->element('abbr', array('class' => 'published', - 'title' => $dt), - common_date_string($notice->created)); - $this->elementEnd('a'); - $this->elementEnd('dd'); - $this->elementEnd('dl'); - - if ($notice->reply_to) { - $replyurl = common_local_url('shownotice', - array('notice' => $notice->reply_to)); - $this->elementStart('dl', 'response'); - $this->element('dt', null, _('To')); - $this->elementStart('dd'); - $this->element('a', array('href' => $replyurl, - 'rel' => 'in-reply-to'), - _('in reply to')); - $this->elementEnd('dd'); - $this->elementEnd('dl'); - } - $this->elementEnd('div'); - - $this->elementStart('div', 'notice-options'); - - $reply_url = common_local_url('newnotice', - array('replyto' => $profile->nickname)); - - $this->elementStart('dl', 'notice_reply'); - $this->element('dt', null, _('Reply to this notice')); - $this->elementStart('dd'); - $this->elementStart('a', array('href' => $reply_url, - 'title' => _('Reply to this notice'))); - $this->text(_('Reply')); - $this->element('span', 'notice_id', $notice->id); - $this->elementEnd('a'); - $this->elementEnd('dd'); - $this->elementEnd('dl'); - $this->elementEnd('div'); - $this->elementEnd('li'); } /** @@ -242,7 +177,7 @@ class NoticesearchAction extends SearchAction */ function highlight($text, $terms) { - /* Highligh serach terms */ + /* Highligh search terms */ $pattern = '/('.implode('|', array_map('htmlspecialchars', $terms)).')/i'; $result = preg_replace($pattern, '\\1', $text); @@ -253,10 +188,5 @@ class NoticesearchAction extends SearchAction } while ($count); return $result; } - - function isReadOnly() - { - return true; - } } -- cgit v1.2.3-54-g00ecf