From 0093b035c12bf21c88f57e4f0931b0abce214f43 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Tue, 13 Jan 2009 23:48:05 -0500 Subject: Modify public stream to use new UI framework I modified public.php to use the new UI framework. Since the Action class isn't functional yet, I don't know if it works. I took some of the functionality, like the public tabs nav and the feeds list, and made them widgets. I also moved the navigation from common_navigation() to a method of Action. --- actions/public.php | 197 +++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 144 insertions(+), 53 deletions(-) (limited to 'actions') diff --git a/actions/public.php b/actions/public.php index 039e885e6..e00f8efba 100644 --- a/actions/public.php +++ b/actions/public.php @@ -1,9 +1,12 @@ . + * + * @category Public + * @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); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/stream.php'); +/** + * Action for displaying the public stream + * + * @category Public + * @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/ + * + * @see PublicrssAction + * @see PublicxrdsAction + */ -class PublicAction extends StreamAction +class PublicAction extends Action { + /** + * page of the stream we're on; default = 1 + */ - function handle($args) - { - parent::handle($args); + var $page = null; - $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + /** + * Read and validate arguments + * + * @param array $args URL parameters + * + * @return boolean success value + */ - header('X-XRDS-Location: '. common_local_url('publicxrds')); + function prepare($args) + { + parent::prepare($args); + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + return true; + } - common_show_header(_('Public timeline'), - array($this, 'show_header'), null, - array($this, 'show_top')); + /** + * handle request + * + * Show the public stream, using recipe method showPage() + * + * @param array $args arguments, mostly unused + * + * @return void + */ - # XXX: Public sidebar here? + function handle($args) + { + parent::handle($args); - $this->show_notices($page); + header('X-XRDS-Location: '. common_local_url('publicxrds')); - common_show_footer(); + $this->showPage(); } - function show_top() + /** + * Title of the page + * + * @return page title, including page number if over 1 + */ + + function title() { - if (common_logged_in()) { - common_notice_form('public'); + if ($this->page > 1) { + return sprintf(_('Public timeline, page %d'), $this->page); } else { - $instr = $this->get_instructions(); - $output = common_markup_to_html($instr); - common_element_start('div', 'instructions'); - common_raw($output); - common_element_end('div'); + return _('Public timeline'); } - - $this->public_views_menu(); - - $this->show_feeds_list(array(0=>array('href'=>common_local_url('publicrss'), - 'type' => 'rss', - 'version' => 'RSS 1.0', - 'item' => 'publicrss'), - 1=>array('href'=>common_local_url('publicatom'), - 'type' => 'atom', - 'version' => 'Atom 1.0', - 'item' => 'publicatom'))); } - function get_instructions() - { - return _('This is %%site.name%%, a [micro-blogging](http://en.wikipedia.org/wiki/Micro-blogging) service ' . - 'based on the Free Software [Laconica](http://laconi.ca/) tool. ' . - '[Join now](%%action.register%%) to share notices about yourself with friends, family, and colleagues! ([Read more](%%doc.help%%))'); - } + /** + * Output elements for RSS and Atom feeds + * + * @return void + */ - function show_header() + function showFeeds() { - common_element('link', array('rel' => 'alternate', + $this->element('link', array('rel' => 'alternate', 'href' => common_local_url('publicrss'), 'type' => 'application/rss+xml', 'title' => _('Public Stream Feed'))); - # for client side of OpenID authentication - common_element('meta', array('http-equiv' => 'X-XRDS-Location', + } + + /** + * Extra head elements + * + * We include a element linking to the publicxrds page, for OpenID + * client-side authentication. + * + * @return void + */ + + function extraHead() + { + // for client side of OpenID authentication + $this->element('meta', array('http-equiv' => 'X-XRDS-Location', 'content' => common_local_url('publicxrds'))); } - function show_notices($page) + /** + * Show tabset for this page + * + * Uses the PublicGroupNav widget + * + * @return void + * @see PublicGroupNav + */ + + function showLocalNav() { + $nav = new PublicGroupNav($this); + $nav->show(); + } + + /** + * Fill the content area + * + * Shows a list of the notices in the public stream, with some pagination + * controls. + * + * @return void + */ - $cnt = 0; - $notice = Notice::publicStream(($page-1)*NOTICES_PER_PAGE, + function showContent() + { + $notice = Notice::publicStream(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); if (!$notice) { @@ -97,9 +165,32 @@ class PublicAction extends StreamAction return; } - $cnt = $this->show_notice_list($notice); + $nl = new NoticeList($notice); + + $cnt = $nl->show(); - common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, - $page, 'public'); + $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, + $this->page, 'public'); + } + + /** + * Makes a list of exported feeds for this page + * + * @return void + * + * @todo I18N + */ + + function showExportData() + { + $fl = new FeedList($this); + $fl->show(array(0 => array('href' => common_local_url('publicrss'), + 'type' => 'rss', + 'version' => 'RSS 1.0', + 'item' => 'publicrss'), + 1 => array('href' => common_local_url('publicatom'), + 'type' => 'atom', + 'version' => 'Atom 1.0', + 'item' => 'publicatom'))); } } -- cgit v1.2.3-54-g00ecf From 3bb7ea79c023cc7260e456b6e1f17526494e5424 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Thu, 15 Jan 2009 11:29:45 -0800 Subject: Twitter bridge: verify creds was taking user ID from the status instead of the user object, and failing if user hadn't ever posted on Twitter. --- actions/twittersettings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/twittersettings.php b/actions/twittersettings.php index 9e7e4cae8..62262e021 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -354,7 +354,7 @@ class TwittersettingsAction extends SettingsAction return false; } - $twitter_id = $user->status->id; + $twitter_id = $user->id; if ($twitter_id) { return $twitter_id; -- cgit v1.2.3-54-g00ecf From b32a47807e7ed2dba86d76fe37d780e345f2b89a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 20:13:11 +0000 Subject: Include PublicGroupNav in publicaction --- actions/public.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'actions') diff --git a/actions/public.php b/actions/public.php index e00f8efba..b13678bf0 100644 --- a/actions/public.php +++ b/actions/public.php @@ -31,6 +31,8 @@ if (!defined('LACONICA')) { exit(1); } +require_once INSTALLDIR.'/lib/publicgroupnav.php'; + /** * Action for displaying the public stream * -- cgit v1.2.3-54-g00ecf From 082db2ad7d6005859bdb70b1b37d3945c49f03bd Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 20:19:32 +0000 Subject: A little further with notice lists --- actions/public.php | 3 +- lib/noticelist.php | 108 +++++++++++++++++++++++++++-------------------------- 2 files changed, 57 insertions(+), 54 deletions(-) (limited to 'actions') diff --git a/actions/public.php b/actions/public.php index b13678bf0..76e922dff 100644 --- a/actions/public.php +++ b/actions/public.php @@ -32,6 +32,7 @@ if (!defined('LACONICA')) { } require_once INSTALLDIR.'/lib/publicgroupnav.php'; +require_once INSTALLDIR.'/lib/noticelist.php'; /** * Action for displaying the public stream @@ -167,7 +168,7 @@ class PublicAction extends Action return; } - $nl = new NoticeList($notice); + $nl = new NoticeList($notice, $this); $cnt = $nl->show(); diff --git a/lib/noticelist.php b/lib/noticelist.php index be3128b4b..fb3e66f9f 100644 --- a/lib/noticelist.php +++ b/lib/noticelist.php @@ -50,7 +50,7 @@ if (!defined('LACONICA')) { * @see ProfileNoticeList */ -class NoticeList +class NoticeList extends Widget { /** the current stream of notices being displayed. */ @@ -62,8 +62,9 @@ class NoticeList * @param Notice $notice stream of notices from DB_DataObject */ - function __construct($notice) + function __construct($notice, $out=null) { + parent::__construct($out); $this->notice = $notice; } @@ -78,7 +79,7 @@ class NoticeList function show() { - common_element_start('ul', array('id' => 'notices')); + $this->out->elementStart('ul', array('id' => 'notices')); $cnt = 0; @@ -93,7 +94,7 @@ class NoticeList $item->show(); } - common_element_end('ul'); + $this->out->elementEnd('ul'); return $cnt; } @@ -111,7 +112,7 @@ class NoticeList function newListItem($notice) { - return new NoticeListItem($notice); + return new NoticeListItem($notice, $this->out); } } @@ -133,7 +134,7 @@ class NoticeList * @see ProfileNoticeListItem */ -class NoticeListItem +class NoticeListItem extends Widget { /** The notice this item will show. */ @@ -151,8 +152,9 @@ class NoticeListItem * @param Notice $notice The notice we'll display */ - function __construct($notice) + function __construct($notice, $out=null) { + parent::__construct($out); $this->notice = $notice; $this->profile = $notice->getProfile(); } @@ -177,28 +179,28 @@ class NoticeListItem function showNotice() { - $this->elementStart('div', 'entry-title'); + $this->out->elementStart('div', 'entry-title'); $this->showAuthor(); $this->showContent(); - $this->elementEnd('div'); + $this->out->elementEnd('div'); } function showNoticeInfo() { - $this->elementStart('div', 'entry-content'); + $this->out->elementStart('div', 'entry-content'); $this->showNoticeLink(); $this->showNoticeSource(); $this->showReplyTo(); - $this->elementEnd('div'); + $this->out->elementEnd('div'); } function showNoticeOptions() { - $this->elementStart('div', 'notice-options'); + $this->out->elementStart('div', 'notice-options'); $this->showFaveForm(); $this->showReplyLink(); $this->showDeleteLink(); - $this->elementEnd('div'); + $this->out->elementEnd('div'); } @@ -212,7 +214,7 @@ class NoticeListItem { // XXX: RDFa // TODO: add notice_type class e.g., notice_video, notice_image - common_element_start('li', array('class' => 'hentry notice', + $this->out->elementStart('li', array('class' => 'hentry notice', 'id' => 'notice-' . $this->notice->id)); } @@ -244,13 +246,13 @@ class NoticeListItem function showAuthor() { - $this->elementStart('span', 'vcard author'); - $this->elementStart('a', array('href' => $this->profile->profileurl, + $this->out->elementStart('span', 'vcard author'); + $this->out->elementStart('a', array('href' => $this->profile->profileurl, 'class' => 'url')); $this->showAvatar(); $this->showNickname(); - $this->elementEnd('a'); - $this->elementEnd('span'); + $this->out->elementEnd('a'); + $this->out->elementEnd('span'); } /** @@ -266,7 +268,7 @@ class NoticeListItem { $avatar = $this->profile->getAvatar(AVATAR_STREAM_SIZE); - $this->element('img', array('src' => ($avatar) ? + $this->out->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE), 'class' => 'avatar photo', @@ -288,7 +290,7 @@ class NoticeListItem function showNickname() { - $this->element('span', array('class' => 'nickname fn'), + $this->out->element('span', array('class' => 'nickname fn'), $this->profile->nickname); } @@ -305,16 +307,16 @@ class NoticeListItem function showContent() { // FIXME: URL, image, video, audio - common_element_start('p', array('class' => 'entry-content')); + $this->out->elementStart('p', array('class' => 'entry-content')); if ($this->notice->rendered) { - common_raw($this->notice->rendered); + $this->out->raw($this->notice->rendered); } 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) - common_raw(common_render_content($this->notice->content, $this->notice)); + $this->out->raw(common_render_content($this->notice->content, $this->notice)); } - common_element_end('p'); + $this->out->elementEnd('p'); } /** @@ -335,18 +337,18 @@ class NoticeListItem preg_match('/^http/', $this->notice->uri)) { $noticeurl = $this->notice->uri; } - $this->elementStart('dl', 'timestamp'); - $this->element('dt', _('Published')); - $this->elementStart('dd', null); - $this->element('a', array('rel' => 'bookmark', + $this->out->elementStart('dl', 'timestamp'); + $this->out->element('dt', _('Published')); + $this->out->elementStart('dd', null); + $this->out->element('a', array('rel' => 'bookmark', 'href' => $noticeurl)); $dt = common_date_iso8601($this->notice->created); - $this->element('abbr', array('class' => 'published', + $this->out->element('abbr', array('class' => 'published', 'title' => $dt), common_date_string($this->notice->created)); - $this->elementEnd('a'); - $this->elementEnd('dd'); - $this->elementEnd('dl'); + $this->out->elementEnd('a'); + $this->out->elementEnd('dd'); + $this->out->elementEnd('dl'); } /** @@ -361,8 +363,8 @@ class NoticeListItem function showNoticeSource() { if ($this->notice->source) { - $this->elementStart('dl', 'device'); - $this->element('dt', null, _('From')); + $this->out->elementStart('dl', 'device'); + $this->out->element('dt', null, _('From')); $source_name = _($this->notice->source); switch ($this->notice->source) { case 'web': @@ -370,22 +372,22 @@ class NoticeListItem case 'mail': case 'omb': case 'api': - $this->element('dd', 'noticesource', $source_name); + $this->out->element('dd', 'noticesource', $source_name); break; default: $ns = Notice_source::staticGet($this->notice->source); if ($ns) { - $this->elementStart('dd', null); - $this->element('a', array('href' => $ns->url, + $this->out->elementStart('dd', null); + $this->out->element('a', array('href' => $ns->url, 'rel' => 'external'), $ns->name); - $this->elementEnd('dd'); + $this->out->elementEnd('dd'); } else { - $this->element('dd', 'noticesource', $source_name); + $this->out->element('dd', 'noticesource', $source_name); } break; } - $this->elementEnd('dl'); + $this->out->elementEnd('dl'); } } @@ -403,14 +405,14 @@ class NoticeListItem if ($this->notice->reply_to) { $replyurl = common_local_url('shownotice', array('notice' => $this->notice->reply_to)); - $this->elementStart('dl', 'response'); - $this->element('dt', null, _('To')); - $this->elementStart('dd'); - $this->element('a', array('href' => $replyurl, + $this->out->elementStart('dl', 'response'); + $this->out->element('dt', null, _('To')); + $this->out->elementStart('dd'); + $this->out->element('a', array('href' => $replyurl, 'rel' => 'in-reply-to'), _('in reply to')); - $this->elementEnd('dd'); - $this->elementEnd('dl'); + $this->out->elementEnd('dd'); + $this->out->elementEnd('dl'); } } @@ -431,13 +433,13 @@ class NoticeListItem $reply_js = 'return doreply("'.$this->profile->nickname.'",'.$this->notice->id.');'; - common_element_start('a', + $this->out->elementStart('a', array('href' => $reply_url, 'onclick' => $reply_js, 'title' => _('reply'), 'class' => 'replybutton')); - common_raw(' →'); - common_element_end('a'); + $this->out->raw(' →'); + $this->out->elementEnd('a'); } /** @@ -452,11 +454,11 @@ class NoticeListItem if ($user && $this->notice->profile_id == $user->id) { $deleteurl = common_local_url('deletenotice', array('notice' => $this->notice->id)); - common_element_start('a', array('class' => 'deletenotice', + $this->out->elementStart('a', array('class' => 'deletenotice', 'href' => $deleteurl, 'title' => _('delete'))); - common_raw(' ×'); - common_element_end('a'); + $this->out->raw(' ×'); + $this->out->elementEnd('a'); } } @@ -470,6 +472,6 @@ class NoticeListItem function showEnd() { - common_element_end('li'); + $this->out->elementEnd('li'); } } -- cgit v1.2.3-54-g00ecf From 37350e873d7d0d3350c4286a0c7d028ffe49825a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 20:22:14 +0000 Subject: Make the feedlist work -- kinda --- actions/public.php | 1 + lib/feedlist.php | 13 +++++++------ 2 files changed, 8 insertions(+), 6 deletions(-) (limited to 'actions') diff --git a/actions/public.php b/actions/public.php index 76e922dff..62071eccc 100644 --- a/actions/public.php +++ b/actions/public.php @@ -33,6 +33,7 @@ if (!defined('LACONICA')) { require_once INSTALLDIR.'/lib/publicgroupnav.php'; require_once INSTALLDIR.'/lib/noticelist.php'; +require_once INSTALLDIR.'/lib/feedlist.php'; /** * Action for displaying the public stream diff --git a/lib/feedlist.php b/lib/feedlist.php index 0ff88cb25..9bc77ca15 100644 --- a/lib/feedlist.php +++ b/lib/feedlist.php @@ -47,13 +47,14 @@ if (!defined('LACONICA')) { * @see Action::showExportList() */ -class FeedList +class FeedList extends Widget { - var $out = null; - - function __construct($out=null) + var $action = null; + + function __construct($action=null) { - $this->out = $out; + parent::__construct($action); + $this->action = $action; } function show($feeds) @@ -72,7 +73,7 @@ class FeedList function feedItem($feed) { - $nickname = $this->trimmed('nickname'); + $nickname = $this->action->trimmed('nickname'); switch($feed['item']) { case 'notices': default: -- cgit v1.2.3-54-g00ecf From 4cee28ace9ece31acc89277903a8924a0747ac95 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 22:17:18 +0000 Subject: section for export data --- actions/public.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'actions') diff --git a/actions/public.php b/actions/public.php index 62071eccc..5a11cece1 100644 --- a/actions/public.php +++ b/actions/public.php @@ -187,6 +187,7 @@ class PublicAction extends Action function showExportData() { + $this->elementStart('div', array('id' => 'exportdata', 'class' => 'section')); $fl = new FeedList($this); $fl->show(array(0 => array('href' => common_local_url('publicrss'), 'type' => 'rss', @@ -196,5 +197,6 @@ class PublicAction extends Action 'type' => 'atom', 'version' => 'Atom 1.0', 'item' => 'publicatom'))); + $this->elementEnd('div'); } } -- cgit v1.2.3-54-g00ecf From 10a4d9ea1e7a930354c8005fb1f418f12d33013b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 22:23:40 +0000 Subject: Revert "section for export data" This reverts commit 4cee28ace9ece31acc89277903a8924a0747ac95. --- actions/public.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'actions') diff --git a/actions/public.php b/actions/public.php index 5a11cece1..62071eccc 100644 --- a/actions/public.php +++ b/actions/public.php @@ -187,7 +187,6 @@ class PublicAction extends Action function showExportData() { - $this->elementStart('div', array('id' => 'exportdata', 'class' => 'section')); $fl = new FeedList($this); $fl->show(array(0 => array('href' => common_local_url('publicrss'), 'type' => 'rss', @@ -197,6 +196,5 @@ class PublicAction extends Action 'type' => 'atom', 'version' => 'Atom 1.0', 'item' => 'publicatom'))); - $this->elementEnd('div'); } } -- cgit v1.2.3-54-g00ecf From eaa81d25fa7bd954132ce7f901fae69b0d46ec1a Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 22:57:15 +0000 Subject: Convert all actions to use new UI functions I did a massive search-and-replace to get all the action subclasses to use the new output function (common_element() -> $this->element(), etc.) There's still a lot to do, but it's a first step --- actions/all.php | 2 +- actions/api.php | 8 +- actions/block.php | 16 ++-- actions/confirmaddress.php | 2 +- actions/deletenotice.php | 18 ++--- actions/deleteprofile.php | 40 +++++----- actions/disfavor.php | 12 +-- actions/doc.php | 2 +- actions/emailsettings.php | 72 ++++++++--------- actions/facebookhome.php | 2 +- actions/facebookinvite.php | 38 ++++----- actions/facebooksettings.php | 40 +++++----- actions/favor.php | 12 +-- actions/favorited.php | 10 +-- actions/featured.php | 6 +- actions/finishaddopenid.php | 2 +- actions/finishopenidlogin.php | 42 +++++----- actions/foaf.php | 72 ++++++++--------- actions/imsettings.php | 48 ++++++------ actions/invite.php | 46 +++++------ actions/login.php | 54 ++++++++----- actions/newmessage.php | 2 +- actions/newnotice.php | 28 +++---- actions/noticesearch.php | 48 ++++++------ actions/nudge.php | 12 +-- actions/openidlogin.php | 20 ++--- actions/openidsettings.php | 48 ++++++------ actions/opensearch.php | 24 +++--- actions/othersettings.php | 40 +++++----- actions/peoplesearch.php | 2 +- actions/peopletag.php | 10 +-- actions/profilesettings.php | 90 ++++++++++----------- actions/publicxrds.php | 24 +++--- actions/recoverpassword.php | 36 ++++----- actions/register.php | 58 +++++++------- actions/remotesubscribe.php | 20 ++--- actions/replies.php | 2 +- actions/showfavorites.php | 2 +- actions/shownotice.php | 8 +- actions/showstream.php | 156 ++++++++++++++++++------------------- actions/smssettings.php | 86 ++++++++++---------- actions/subscribe.php | 12 +-- actions/subscriptions.php | 14 ++-- actions/tag.php | 16 ++-- actions/tagother.php | 54 ++++++------- actions/twitapidirect_messages.php | 28 +++---- actions/twitapifriendships.php | 2 +- actions/twitapihelp.php | 2 +- actions/twitapilaconica.php | 12 +-- actions/twitapistatuses.php | 4 +- actions/twittersettings.php | 64 +++++++-------- actions/unsubscribe.php | 12 +-- actions/userauthorization.php | 44 +++++------ actions/xrds.php | 36 ++++----- lib/action.php | 23 +++--- 55 files changed, 801 insertions(+), 782 deletions(-) (limited to 'actions') diff --git a/actions/all.php b/actions/all.php index 526ac5f40..a8a74fb33 100644 --- a/actions/all.php +++ b/actions/all.php @@ -57,7 +57,7 @@ class AllAction extends StreamAction function show_header($user) { - common_element('link', array('rel' => 'alternate', + $this->element('link', array('rel' => 'alternate', 'href' => common_local_url('allrss', array('nickname' => $user->nickname)), 'type' => 'application/rss+xml', diff --git a/actions/api.php b/actions/api.php index 7a0759831..9cbf9a468 100644 --- a/actions/api.php +++ b/actions/api.php @@ -159,10 +159,10 @@ class ApiAction extends Action if ($this->content_type == 'xml') { header('Content-Type: application/xml; charset=utf-8'); common_start_xml(); - common_element_start('hash'); - common_element('error', null, $msg); - common_element('request', null, $_SERVER['REQUEST_URI']); - common_element_end('hash'); + $this->elementStart('hash'); + $this->element('error', null, $msg); + $this->element('request', null, $_SERVER['REQUEST_URI']); + $this->elementEnd('hash'); common_end_xml(); } else if ($this->content_type == 'json') { header('Content-Type: application/json; charset=utf-8'); diff --git a/actions/block.php b/actions/block.php index c1ff7c044..f8f6f24fd 100644 --- a/actions/block.php +++ b/actions/block.php @@ -81,34 +81,34 @@ class BlockAction extends Action common_show_header(_('Block user')); - common_element('p', null, + $this->element('p', null, _('Are you sure you want to block this user? '. 'Afterwards, they will be unsubscribed from you, '. 'unable to subscribe to you in the future, and '. 'you will not be notified of any @-replies from them.')); - common_element_start('form', array('id' => 'block-' . $id, + $this->elementStart('form', array('id' => 'block-' . $id, 'method' => 'post', 'class' => 'block', 'action' => common_local_url('block'))); - common_hidden('token', common_session_token()); + $this->hidden('token', common_session_token()); - common_element('input', array('id' => 'blockto-' . $id, + $this->element('input', array('id' => 'blockto-' . $id, 'name' => 'blockto', 'type' => 'hidden', 'value' => $id)); foreach ($this->args as $k => $v) { if (substr($k, 0, 9) == 'returnto-') { - common_hidden($k, $v); + $this->hidden($k, $v); } } - common_submit('no', _('No')); - common_submit('yes', _('Yes')); + $this->submit('no', _('No')); + $this->submit('yes', _('Yes')); - common_element_end('form'); + $this->elementEnd('form'); common_show_footer(); } diff --git a/actions/confirmaddress.php b/actions/confirmaddress.php index 1d5c53ff2..31a157768 100644 --- a/actions/confirmaddress.php +++ b/actions/confirmaddress.php @@ -90,7 +90,7 @@ class ConfirmaddressAction extends Action $cur->query('COMMIT'); common_show_header(_('Confirm Address')); - common_element('p', null, + $this->element('p', null, sprintf(_('The address "%s" has been confirmed for your account.'), $cur->$type)); common_show_footer(); } diff --git a/actions/deletenotice.php b/actions/deletenotice.php index e9b4b3254..bae0eac1b 100644 --- a/actions/deletenotice.php +++ b/actions/deletenotice.php @@ -51,24 +51,24 @@ class DeletenoticeAction extends DeleteAction common_show_header($this->get_title(), array($this, 'show_header'), $error, array($this, 'show_top')); - common_element_start('form', array('id' => 'notice_delete_form', + $this->elementStart('form', array('id' => 'notice_delete_form', 'method' => 'post', 'action' => common_local_url('deletenotice'))); - common_hidden('token', common_session_token()); - common_hidden('notice', $this->trimmed('notice')); - common_element_start('p'); - common_element('span', array('id' => 'confirmation_text'), _('Are you sure you want to delete this notice?')); + $this->hidden('token', common_session_token()); + $this->hidden('notice', $this->trimmed('notice')); + $this->elementStart('p'); + $this->element('span', array('id' => 'confirmation_text'), _('Are you sure you want to delete this notice?')); - common_element('input', array('id' => 'submit_no', + $this->element('input', array('id' => 'submit_no', 'name' => 'submit', 'type' => 'submit', 'value' => _('No'))); - common_element('input', array('id' => 'submit_yes', + $this->element('input', array('id' => 'submit_yes', 'name' => 'submit', 'type' => 'submit', 'value' => _('Yes'))); - common_element_end('p'); - common_element_end('form'); + $this->elementEnd('p'); + $this->elementEnd('form'); common_show_footer(); } diff --git a/actions/deleteprofile.php b/actions/deleteprofile.php index e12fe131a..ef4687d5f 100644 --- a/actions/deleteprofile.php +++ b/actions/deleteprofile.php @@ -49,15 +49,15 @@ class DeleteprofileAction extends Action function show_feeds_list($feeds) { - common_element_start('div', array('class' => 'feedsdel')); - common_element('p', null, 'Feeds:'); - common_element_start('ul', array('class' => 'xoxo')); + $this->elementStart('div', array('class' => 'feedsdel')); + $this->element('p', null, 'Feeds:'); + $this->elementStart('ul', array('class' => 'xoxo')); foreach ($feeds as $key => $value) { $this->common_feed_item($feeds[$key]); } - common_element_end('ul'); - common_element_end('div'); + $this->elementEnd('ul'); + $this->elementEnd('div'); } //TODO move to common.php (and retrace its origin) @@ -81,19 +81,19 @@ class DeleteprofileAction extends Action $feed['textContent'] = "FOAF"; break; } - common_element_start('li'); - common_element('a', array('href' => $feed['href'], + $this->elementStart('li'); + $this->element('a', array('href' => $feed['href'], 'class' => $feed_classname, 'type' => $feed_mimetype, 'title' => $feed_title), $feed['textContent']); - common_element_end('li'); + $this->elementEnd('li'); } function show_form($msg=null, $success=false) { $this->form_header(_('Delete my account'), $msg, $success); - common_element('h2', null, _('Delete my account confirmation')); + $this->element('h2', null, _('Delete my account confirmation')); $this->show_confirm_delete_form(); common_show_footer(); } @@ -105,13 +105,13 @@ class DeleteprofileAction extends Action $notices->profile_id = $user->id; $notice_count = (int) $notices->count(); - common_element_start('form', array('method' => 'POST', + $this->elementStart('form', array('method' => 'POST', 'id' => 'delete', 'action' => common_local_url('deleteprofile'))); - common_hidden('token', common_session_token()); - common_element('p', null, "Last chance to copy your notices and contacts by saving the two links below before deleting your account. Be careful, this operation cannot be undone."); + $this->hidden('token', common_session_token()); + $this->element('p', null, "Last chance to copy your notices and contacts by saving the two links below before deleting your account. Be careful, this operation cannot be undone."); $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('limit' => $notice_count, 'nickname' => $user->nickname)), 'type' => 'rss', @@ -122,10 +122,10 @@ class DeleteprofileAction extends Action 'version' => 'FOAF', 'item' => 'foaf'))); - common_checkbox('confirmation', _('Check if you are sure you want to delete your account.')); + $this->checkbox('confirmation', _('Check if you are sure you want to delete your account.')); - common_submit('deleteaccount', _('Delete my account')); - common_element_end('form'); + $this->submit('deleteaccount', _('Delete my account')); + $this->elementEnd('form'); } function handle_post() @@ -238,9 +238,9 @@ class DeleteprofileAction extends Action } else { $inst = $this->get_instructions(); $output = common_markup_to_html($inst); - common_element_start('div', 'instructions'); - common_raw($output); - common_element_end('div'); + $this->elementStart('div', 'instructions'); + $this->raw($output); + $this->elementEnd('div'); } $this->settings_menu(); } @@ -272,7 +272,7 @@ class DeleteprofileAction extends Action _('Other options'))); $action = $this->trimmed('action'); - common_element_start('ul', array('id' => 'nav_views')); + $this->elementStart('ul', array('id' => 'nav_views')); foreach ($menu as $menuaction => $menudesc) { if ($menuaction == 'imsettings' && !common_config('xmpp', 'enabled')) { @@ -283,7 +283,7 @@ class DeleteprofileAction extends Action $menudesc[1], $action == $menuaction); } - common_element_end('ul'); + $this->elementEnd('ul'); } } diff --git a/actions/disfavor.php b/actions/disfavor.php index 74aae86cc..9a27f34b1 100644 --- a/actions/disfavor.php +++ b/actions/disfavor.php @@ -70,13 +70,13 @@ class DisfavorAction extends Action if ($this->boolean('ajax')) { common_start_html('text/xml;charset=utf-8', true); - common_element_start('head'); - common_element('title', null, _('Add to favorites')); - common_element_end('head'); - common_element_start('body'); + $this->elementStart('head'); + $this->element('title', null, _('Add to favorites')); + $this->elementEnd('head'); + $this->elementStart('body'); common_favor_form($notice); - common_element_end('body'); - common_element_end('html'); + $this->elementEnd('body'); + $this->elementEnd('html'); } else { common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname))); diff --git a/actions/doc.php b/actions/doc.php index 856025e66..98da31267 100644 --- a/actions/doc.php +++ b/actions/doc.php @@ -34,7 +34,7 @@ class DocAction extends Action $c = file_get_contents($filename); $output = common_markup_to_html($c); common_show_header(_(ucfirst($title))); - common_raw($output); + $this->raw($output); common_show_footer(); } } diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 3fa8ce296..39f186bff 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -33,83 +33,83 @@ class EmailsettingsAction extends SettingsAction { $user = common_current_user(); $this->form_header(_('Email Settings'), $msg, $success); - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'id' => 'emailsettings', 'action' => common_local_url('emailsettings'))); - common_hidden('token', common_session_token()); + $this->hidden('token', common_session_token()); - common_element('h2', null, _('Address')); + $this->element('h2', null, _('Address')); if ($user->email) { - common_element_start('p'); - common_element('span', 'address confirmed', $user->email); - common_element('span', 'input_instructions', + $this->elementStart('p'); + $this->element('span', 'address confirmed', $user->email); + $this->element('span', 'input_instructions', _('Current confirmed email address.')); - common_hidden('email', $user->email); - common_element_end('p'); - common_submit('remove', _('Remove')); + $this->hidden('email', $user->email); + $this->elementEnd('p'); + $this->submit('remove', _('Remove')); } else { $confirm = $this->get_confirmation(); if ($confirm) { - common_element_start('p'); - common_element('span', 'address unconfirmed', $confirm->address); - common_element('span', 'input_instructions', + $this->elementStart('p'); + $this->element('span', 'address unconfirmed', $confirm->address); + $this->element('span', 'input_instructions', _('Awaiting confirmation on this address. Check your inbox (and spam box!) for a message with further instructions.')); - common_hidden('email', $confirm->address); - common_element_end('p'); - common_submit('cancel', _('Cancel')); + $this->hidden('email', $confirm->address); + $this->elementEnd('p'); + $this->submit('cancel', _('Cancel')); } else { - common_input('email', _('Email Address'), + $this->input('email', _('Email Address'), ($this->arg('email')) ? $this->arg('email') : null, _('Email address, like "UserName@example.org"')); - common_submit('add', _('Add')); + $this->submit('add', _('Add')); } } if ($user->email) { - common_element('h2', null, _('Incoming email')); + $this->element('h2', null, _('Incoming email')); if ($user->incomingemail) { - common_element_start('p'); - common_element('span', 'address', $user->incomingemail); - common_element('span', 'input_instructions', + $this->elementStart('p'); + $this->element('span', 'address', $user->incomingemail); + $this->element('span', 'input_instructions', _('Send email to this address to post new notices.')); - common_element_end('p'); - common_submit('removeincoming', _('Remove')); + $this->elementEnd('p'); + $this->submit('removeincoming', _('Remove')); } - common_element_start('p'); - common_element('span', 'input_instructions', + $this->elementStart('p'); + $this->element('span', 'input_instructions', _('Make a new email address for posting to; cancels the old one.')); - common_element_end('p'); - common_submit('newincoming', _('New')); + $this->elementEnd('p'); + $this->submit('newincoming', _('New')); } - common_element('h2', null, _('Preferences')); + $this->element('h2', null, _('Preferences')); - common_checkbox('emailnotifysub', + $this->checkbox('emailnotifysub', _('Send me notices of new subscriptions through email.'), $user->emailnotifysub); - common_checkbox('emailnotifyfav', + $this->checkbox('emailnotifyfav', _('Send me email when someone adds my notice as a favorite.'), $user->emailnotifyfav); - common_checkbox('emailnotifymsg', + $this->checkbox('emailnotifymsg', _('Send me email when someone sends me a private message.'), $user->emailnotifymsg); - common_checkbox('emailnotifynudge', + $this->checkbox('emailnotifynudge', _('Allow friends to nudge me and send me an email.'), $user->emailnotifynudge); - common_checkbox('emailpost', + $this->checkbox('emailpost', _('I want to post notices by email.'), $user->emailpost); - common_checkbox('emailmicroid', + $this->checkbox('emailmicroid', _('Publish a MicroID for my email address.'), $user->emailmicroid); - common_submit('save', _('Save')); + $this->submit('save', _('Save')); - common_element_end('form'); + $this->elementEnd('form'); common_show_footer(); } diff --git a/actions/facebookhome.php b/actions/facebookhome.php index f72f08a34..d2ac7617d 100644 --- a/actions/facebookhome.php +++ b/actions/facebookhome.php @@ -105,7 +105,7 @@ class FacebookhomeAction extends FacebookAction $this->show_header('Home'); if ($msg) { - common_element('fb:success', array('message' => $msg)); + $this->element('fb:success', array('message' => $msg)); } echo $this->show_notices($user); diff --git a/actions/facebookinvite.php b/actions/facebookinvite.php index fe0c5e493..103d5a568 100644 --- a/actions/facebookinvite.php +++ b/actions/facebookinvite.php @@ -43,22 +43,22 @@ class FacebookinviteAction extends FacebookAction $this->show_header('Invite'); - common_element('h2', null, _('Thanks for inviting your friends to use Identi.ca!')); - common_element('p', null, _('Invitations have been sent to the following users:')); + $this->element('h2', null, _('Thanks for inviting your friends to use Identi.ca!')); + $this->element('p', null, _('Invitations have been sent to the following users:')); $friend_ids = $_POST['ids']; // Hmm... $this->arg('ids') doesn't seem to work - common_element_start("ul"); + $this->elementStart("ul"); foreach ($friend_ids as $friend) { - common_element_start('li'); - common_element('fb:profile-pic', array('uid' => $friend)); - common_element('fb:name', array('uid' => $friend, + $this->elementStart('li'); + $this->element('fb:profile-pic', array('uid' => $friend)); + $this->element('fb:name', array('uid' => $friend, 'capitalize' => 'true')); - common_element_end('li'); + $this->elementEnd('li'); } - common_element_end("ul"); + $this->elementEnd("ul"); $this->show_footer(); } @@ -77,32 +77,32 @@ class FacebookinviteAction extends FacebookAction $content = _('You have been invited to Identi.ca!') . htmlentities(''); - common_element_start('fb:request-form', array('action' => 'invite.php', + $this->elementStart('fb:request-form', array('action' => 'invite.php', 'method' => 'post', 'invite' => 'true', 'type' => 'Identi.ca', 'content' => $content)); - common_hidden('invite', 'true'); + $this->hidden('invite', 'true'); $actiontext = 'Invite your friends to use Identi.ca.'; - common_element('fb:multi-friend-selector', array('showborder' => 'false', + $this->element('fb:multi-friend-selector', array('showborder' => 'false', 'actiontext' => $actiontext, 'exclude_ids' => implode(',', $exclude_ids), 'bypass' => 'cancel')); - common_element_end('fb:request-form'); + $this->elementEnd('fb:request-form'); - common_element('h2', null, _('Friends already using Identi.ca:')); - common_element_start("ul"); + $this->element('h2', null, _('Friends already using Identi.ca:')); + $this->elementStart("ul"); foreach ($exclude_ids as $friend) { - common_element_start('li'); - common_element('fb:profile-pic', array('uid' => $friend)); - common_element('fb:name', array('uid' => $friend, + $this->elementStart('li'); + $this->element('fb:profile-pic', array('uid' => $friend)); + $this->element('fb:name', array('uid' => $friend, 'capitalize' => 'true')); - common_element_end('li'); + $this->elementEnd('li'); } - common_element_end("ul"); + $this->elementEnd("ul"); $this->show_footer(); diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php index ab04ad82b..8b071353a 100644 --- a/actions/facebooksettings.php +++ b/actions/facebooksettings.php @@ -68,43 +68,43 @@ class FacebooksettingsAction extends FacebookAction $this->show_header('Settings', $msg, $success); - common_element_start('fb:if-section-not-added', array('section' => 'profile')); - common_element('h2', null, _('Add an Identi.ca box to my profile')); - common_element_start('p'); - common_element('fb:add-section-button', array('section' => 'profile')); - common_element_end('p'); - - common_element_end('fb:if-section-not-added'); - common_element_start('p'); - common_element_start('fb:prompt-permission', array('perms' => 'status_update')); - common_element('h2', null, _('Allow Identi.ca to update my Facebook status')); - common_element_end('fb:prompt-permission'); - common_element_end('p'); + $this->elementStart('fb:if-section-not-added', array('section' => 'profile')); + $this->element('h2', null, _('Add an Identi.ca box to my profile')); + $this->elementStart('p'); + $this->element('fb:add-section-button', array('section' => 'profile')); + $this->elementEnd('p'); + + $this->elementEnd('fb:if-section-not-added'); + $this->elementStart('p'); + $this->elementStart('fb:prompt-permission', array('perms' => 'status_update')); + $this->element('h2', null, _('Allow Identi.ca to update my Facebook status')); + $this->elementEnd('fb:prompt-permission'); + $this->elementEnd('p'); if ($facebook->api_client->users_hasAppPermission('status_update')) { - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'id' => 'facebook_settings')); - common_element('h2', null, _('Sync preferences')); + $this->element('h2', null, _('Sync preferences')); - common_checkbox('noticesync', _('Automatically update my Facebook status with my notices.'), + $this->checkbox('noticesync', _('Automatically update my Facebook status with my notices.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND) : true); - common_checkbox('replysync', _('Send local "@" replies to Facebook.'), + $this->checkbox('replysync', _('Send local "@" replies to Facebook.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true); - // function common_input($id, $label, $value=null,$instructions=null) + // function $this->input($id, $label, $value=null,$instructions=null) $prefix = $facebook->api_client->data_getUserPreference(1); - common_input('prefix', _('Prefix'), + $this->input('prefix', _('Prefix'), ($prefix) ? $prefix : null, _('A string to prefix notices with.')); - common_submit('save', _('Save')); + $this->submit('save', _('Save')); - common_element_end('form'); + $this->elementEnd('form'); } diff --git a/actions/favor.php b/actions/favor.php index 8103f8181..1dfef9bbb 100644 --- a/actions/favor.php +++ b/actions/favor.php @@ -69,13 +69,13 @@ class FavorAction extends Action if ($this->boolean('ajax')) { common_start_html('text/xml;charset=utf-8', true); - common_element_start('head'); - common_element('title', null, _('Disfavor favorite')); - common_element_end('head'); - common_element_start('body'); + $this->elementStart('head'); + $this->element('title', null, _('Disfavor favorite')); + $this->elementEnd('head'); + $this->elementStart('body'); common_disfavor_form($notice); - common_element_end('body'); - common_element_end('html'); + $this->elementEnd('body'); + $this->elementEnd('html'); } else { common_redirect(common_local_url('showfavorites', array('nickname' => $user->nickname))); diff --git a/actions/favorited.php b/actions/favorited.php index 71a9e026e..936905732 100644 --- a/actions/favorited.php +++ b/actions/favorited.php @@ -43,9 +43,9 @@ class FavoritedAction extends StreamAction { $instr = $this->get_instructions(); $output = common_markup_to_html($instr); - common_element_start('div', 'instructions'); - common_raw($output); - common_element_end('div'); + $this->elementStart('div', 'instructions'); + $this->raw($output); + $this->elementEnd('div'); $this->public_views_menu(); } @@ -81,7 +81,7 @@ class FavoritedAction extends StreamAction $notice = new Notice; $notice->query(sprintf($qry, common_config('popular', 'dropoff'))); - common_element_start('ul', array('id' => 'notices')); + $this->elementStart('ul', array('id' => 'notices')); $cnt = 0; @@ -96,7 +96,7 @@ class FavoritedAction extends StreamAction $item->show(); } - common_element_end('ul'); + $this->elementEnd('ul'); common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, $page, 'favorited'); diff --git a/actions/featured.php b/actions/featured.php index 2bf8b0b81..035622691 100644 --- a/actions/featured.php +++ b/actions/featured.php @@ -44,9 +44,9 @@ class FeaturedAction extends StreamAction { $instr = $this->get_instructions(); $output = common_markup_to_html($instr); - common_element_start('div', 'instructions'); - common_raw($output); - common_element_end('div'); + $this->elementStart('div', 'instructions'); + $this->raw($output); + $this->elementEnd('div'); $this->public_views_menu(); } diff --git a/actions/finishaddopenid.php b/actions/finishaddopenid.php index 0ce1680aa..7de631712 100644 --- a/actions/finishaddopenid.php +++ b/actions/finishaddopenid.php @@ -101,7 +101,7 @@ class FinishaddopenidAction extends Action function message($msg) { common_show_header(_('OpenID Login')); - common_element('p', null, $msg); + $this->element('p', null, $msg); common_show_footer(); } } diff --git a/actions/finishopenidlogin.php b/actions/finishopenidlogin.php index bdb8516a3..112429002 100644 --- a/actions/finishopenidlogin.php +++ b/actions/finishopenidlogin.php @@ -57,10 +57,10 @@ class FinishopenidloginAction extends Action function show_top($error=null) { if ($error) { - common_element('div', array('class' => 'error'), $error); + $this->element('div', array('class' => 'error'), $error); } else { global $config; - common_element('div', 'instructions', + $this->element('div', 'instructions', sprintf(_('This is the first time you\'ve logged into %s so we must connect your OpenID to a local account. You can either create a new account, or connect with your existing account, if you have one.'), $config['site']['name'])); } } @@ -70,36 +70,36 @@ class FinishopenidloginAction extends Action common_show_header(_('OpenID Account Setup'), null, $error, array($this, 'show_top')); - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'id' => 'account_connect', 'action' => common_local_url('finishopenidlogin'))); - common_hidden('token', common_session_token()); - common_element('h2', null, + $this->hidden('token', common_session_token()); + $this->element('h2', null, _('Create new account')); - common_element('p', null, + $this->element('p', null, _('Create a new user with this nickname.')); - common_input('newname', _('New nickname'), + $this->input('newname', _('New nickname'), ($username) ? $username : '', _('1-64 lowercase letters or numbers, no punctuation or spaces')); - common_element_start('p'); - common_element('input', array('type' => 'checkbox', + $this->elementStart('p'); + $this->element('input', array('type' => 'checkbox', 'id' => 'license', 'name' => 'license', 'value' => 'true')); - common_text(_('My text and files are available under ')); - common_element('a', array(href => common_config('license', 'url')), + $this->text(_('My text and files are available under ')); + $this->element('a', array(href => common_config('license', 'url')), common_config('license', 'title')); - common_text(_(' except this private data: password, email address, IM address, phone number.')); - common_element_end('p'); - common_submit('create', _('Create')); - common_element('h2', null, + $this->text(_(' except this private data: password, email address, IM address, phone number.')); + $this->elementEnd('p'); + $this->submit('create', _('Create')); + $this->element('h2', null, _('Connect existing account')); - common_element('p', null, + $this->element('p', null, _('If you already have an account, login with your username and password to connect it to your OpenID.')); - common_input('nickname', _('Existing nickname')); - common_password('password', _('Password')); - common_submit('connect', _('Connect')); - common_element_end('form'); + $this->input('nickname', _('Existing nickname')); + $this->password('password', _('Password')); + $this->submit('connect', _('Connect')); + $this->elementEnd('form'); common_show_footer(); } @@ -154,7 +154,7 @@ class FinishopenidloginAction extends Action function message($msg) { common_show_header(_('OpenID Login')); - common_element('p', null, $msg); + $this->element('p', null, $msg); common_show_footer(); } diff --git a/actions/foaf.php b/actions/foaf.php index 30e98960c..6f73ce505 100644 --- a/actions/foaf.php +++ b/actions/foaf.php @@ -54,7 +54,7 @@ class FoafAction extends Action header('Content-Type: application/rdf+xml'); common_start_xml(); - common_element_start('rdf:RDF', array('xmlns:rdf' => + $this->elementStart('rdf:RDF', array('xmlns:rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#', 'xmlns:rdfs' => 'http://www.w3.org/2000/01/rdf-schema#', @@ -67,25 +67,25 @@ class FoafAction extends Action $this->show_ppd('', $user->uri); # XXX: might not be a person - common_element_start('Person', array('rdf:about' => + $this->elementStart('Person', array('rdf:about' => $user->uri)); - common_element('mbox_sha1sum', null, sha1('mailto:' . $user->email)); + $this->element('mbox_sha1sum', null, sha1('mailto:' . $user->email)); if ($profile->fullname) { - common_element('name', null, $profile->fullname); + $this->element('name', null, $profile->fullname); } if ($profile->homepage) { - common_element('homepage', array('rdf:resource' => $profile->homepage)); + $this->element('homepage', array('rdf:resource' => $profile->homepage)); } if ($profile->bio) { - common_element('rdfs:comment', null, $profile->bio); + $this->element('rdfs:comment', null, $profile->bio); } # XXX: more structured location data if ($profile->location) { - common_element_start('based_near'); - common_element_start('geo:SpatialThing'); - common_element('name', null, $profile->location); - common_element_end('geo:SpatialThing'); - common_element_end('based_near'); + $this->elementStart('based_near'); + $this->elementStart('geo:SpatialThing'); + $this->element('name', null, $profile->location); + $this->elementEnd('geo:SpatialThing'); + $this->elementEnd('based_near'); } $this->show_microblogging_account($profile, common_root_url()); @@ -93,18 +93,18 @@ class FoafAction extends Action $avatar = $profile->getOriginalAvatar(); if ($avatar) { - common_element_start('img'); - common_element_start('Image', array('rdf:about' => $avatar->url)); + $this->elementStart('img'); + $this->elementStart('Image', array('rdf:about' => $avatar->url)); foreach (array(AVATAR_PROFILE_SIZE, AVATAR_STREAM_SIZE, AVATAR_MINI_SIZE) as $size) { $scaled = $profile->getAvatar($size); if (!$scaled->original) { # sometimes the original has one of our scaled sizes - common_element_start('thumbnail'); - common_element('Image', array('rdf:about' => $scaled->url)); - common_element_end('thumbnail'); + $this->elementStart('thumbnail'); + $this->element('Image', array('rdf:about' => $scaled->url)); + $this->elementEnd('thumbnail'); } } - common_element_end('Image'); - common_element_end('img'); + $this->elementEnd('Image'); + $this->elementEnd('img'); } # Get people user is subscribed to @@ -126,7 +126,7 @@ class FoafAction extends Action common_debug('Got a bad subscription: '.print_r($sub,true)); continue; } - common_element('knows', array('rdf:resource' => $other->uri)); + $this->element('knows', array('rdf:resource' => $other->uri)); $person[$other->uri] = array(LISTENEE, $other); } } @@ -156,7 +156,7 @@ class FoafAction extends Action } } - common_element_end('Person'); + $this->elementEnd('Person'); foreach ($person as $uri => $p) { $foaf_url = null; @@ -164,44 +164,44 @@ class FoafAction extends Action $foaf_url = common_local_url('foaf', array('nickname' => $p[1]->nickname)); } $profile = Profile::staticGet($p[1]->id); - common_element_start('Person', array('rdf:about' => $uri)); + $this->elementStart('Person', array('rdf:about' => $uri)); if ($p[0] == LISTENER || $p[0] == BOTH) { - common_element('knows', array('rdf:resource' => $user->uri)); + $this->element('knows', array('rdf:resource' => $user->uri)); } $this->show_microblogging_account($profile, ($p[1] instanceof User) ? common_root_url() : null); if ($foaf_url) { - common_element('rdfs:seeAlso', array('rdf:resource' => $foaf_url)); + $this->element('rdfs:seeAlso', array('rdf:resource' => $foaf_url)); } - common_element_end('Person'); + $this->elementEnd('Person'); if ($foaf_url) { $this->show_ppd($foaf_url, $uri); } } - common_element_end('rdf:RDF'); + $this->elementEnd('rdf:RDF'); } function show_ppd($foaf_url, $person_uri) { - common_element_start('PersonalProfileDocument', array('rdf:about' => $foaf_url)); - common_element('maker', array('rdf:resource' => $person_uri)); - common_element('primaryTopic', array('rdf:resource' => $person_uri)); - common_element_end('PersonalProfileDocument'); + $this->elementStart('PersonalProfileDocument', array('rdf:about' => $foaf_url)); + $this->element('maker', array('rdf:resource' => $person_uri)); + $this->element('primaryTopic', array('rdf:resource' => $person_uri)); + $this->elementEnd('PersonalProfileDocument'); } function show_microblogging_account($profile, $service=null) { # Their account - common_element_start('holdsAccount'); - common_element_start('OnlineAccount'); + $this->elementStart('holdsAccount'); + $this->elementStart('OnlineAccount'); if ($service) { - common_element('accountServiceHomepage', array('rdf:resource' => + $this->element('accountServiceHomepage', array('rdf:resource' => $service)); } - common_element('accountName', null, $profile->nickname); - common_element('homepage', array('rdf:resource' => $profile->profileurl)); - common_element_end('OnlineAccount'); - common_element_end('holdsAccount'); + $this->element('accountName', null, $profile->nickname); + $this->element('homepage', array('rdf:resource' => $profile->profileurl)); + $this->elementEnd('OnlineAccount'); + $this->elementEnd('holdsAccount'); } } diff --git a/actions/imsettings.php b/actions/imsettings.php index 8ecf200ec..693f49efa 100644 --- a/actions/imsettings.php +++ b/actions/imsettings.php @@ -34,57 +34,57 @@ class ImsettingsAction extends SettingsAction { $user = common_current_user(); $this->form_header(_('IM Settings'), $msg, $success); - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'id' => 'imsettings', 'action' => common_local_url('imsettings'))); - common_hidden('token', common_session_token()); + $this->hidden('token', common_session_token()); - common_element('h2', null, _('Address')); + $this->element('h2', null, _('Address')); if ($user->jabber) { - common_element_start('p'); - common_element('span', 'address confirmed', $user->jabber); - common_element('span', 'input_instructions', + $this->elementStart('p'); + $this->element('span', 'address confirmed', $user->jabber); + $this->element('span', 'input_instructions', _('Current confirmed Jabber/GTalk address.')); - common_hidden('jabber', $user->jabber); - common_element_end('p'); - common_submit('remove', _('Remove')); + $this->hidden('jabber', $user->jabber); + $this->elementEnd('p'); + $this->submit('remove', _('Remove')); } else { $confirm = $this->get_confirmation(); if ($confirm) { - common_element_start('p'); - common_element('span', 'address unconfirmed', $confirm->address); - common_element('span', 'input_instructions', + $this->elementStart('p'); + $this->element('span', 'address unconfirmed', $confirm->address); + $this->element('span', 'input_instructions', sprintf(_('Awaiting confirmation on this address. Check your Jabber/GTalk account for a message with further instructions. (Did you add %s to your buddy list?)'), jabber_daemon_address())); - common_hidden('jabber', $confirm->address); - common_element_end('p'); - common_submit('cancel', _('Cancel')); + $this->hidden('jabber', $confirm->address); + $this->elementEnd('p'); + $this->submit('cancel', _('Cancel')); } else { - common_input('jabber', _('IM Address'), + $this->input('jabber', _('IM Address'), ($this->arg('jabber')) ? $this->arg('jabber') : null, sprintf(_('Jabber or GTalk address, like "UserName@example.org". First, make sure to add %s to your buddy list in your IM client or on GTalk.'), jabber_daemon_address())); - common_submit('add', _('Add')); + $this->submit('add', _('Add')); } } - common_element('h2', null, _('Preferences')); + $this->element('h2', null, _('Preferences')); - common_checkbox('jabbernotify', + $this->checkbox('jabbernotify', _('Send me notices through Jabber/GTalk.'), $user->jabbernotify); - common_checkbox('updatefrompresence', + $this->checkbox('updatefrompresence', _('Post a notice when my Jabber/GTalk status changes.'), $user->updatefrompresence); - common_checkbox('jabberreplies', + $this->checkbox('jabberreplies', _('Send me replies through Jabber/GTalk from people I\'m not subscribed to.'), $user->jabberreplies); - common_checkbox('jabbermicroid', + $this->checkbox('jabbermicroid', _('Publish a MicroID for my Jabber/GTalk address.'), $user->jabbermicroid); - common_submit('save', _('Save')); + $this->submit('save', _('Save')); - common_element_end('form'); + $this->elementEnd('form'); common_show_footer(); } diff --git a/actions/invite.php b/actions/invite.php index 80e022a3d..15233602e 100644 --- a/actions/invite.php +++ b/actions/invite.php @@ -89,29 +89,29 @@ class InviteAction extends Action common_show_header(_('Invitation(s) sent')); if ($already) { - common_element('p', null, _('You are already subscribed to these users:')); - common_element_start('ul'); + $this->element('p', null, _('You are already subscribed to these users:')); + $this->elementStart('ul'); foreach ($already as $other) { - common_element('li', null, sprintf(_('%s (%s)'), $other->nickname, $other->email)); + $this->element('li', null, sprintf(_('%s (%s)'), $other->nickname, $other->email)); } - common_element_end('ul'); + $this->elementEnd('ul'); } if ($subbed) { - common_element('p', null, _('These people are already users and you were automatically subscribed to them:')); - common_element_start('ul'); + $this->element('p', null, _('These people are already users and you were automatically subscribed to them:')); + $this->elementStart('ul'); foreach ($subbed as $other) { - common_element('li', null, sprintf(_('%s (%s)'), $other->nickname, $other->email)); + $this->element('li', null, sprintf(_('%s (%s)'), $other->nickname, $other->email)); } - common_element_end('ul'); + $this->elementEnd('ul'); } if ($sent) { - common_element('p', null, _('Invitation(s) sent to the following people:')); - common_element_start('ul'); + $this->element('p', null, _('Invitation(s) sent to the following people:')); + $this->elementStart('ul'); foreach ($sent as $other) { - common_element('li', null, $other); + $this->element('li', null, $other); } - common_element_end('ul'); - common_element('p', null, _('You will be notified when your invitees accept the invitation and register on the site. Thanks for growing the community!')); + $this->elementEnd('ul'); + $this->element('p', null, _('You will be notified when your invitees accept the invitation and register on the site. Thanks for growing the community!')); } common_show_footer(); } @@ -119,12 +119,12 @@ class InviteAction extends Action function show_top($error=null) { if ($error) { - common_element('p', 'error', $error); + $this->element('p', 'error', $error); } else { - common_element_start('div', 'instructions'); - common_element('p', null, + $this->elementStart('div', 'instructions'); + $this->element('p', null, _('Use this form to invite your friends and colleagues to use this service.')); - common_element_end('div'); + $this->elementEnd('div'); } } @@ -135,22 +135,22 @@ class InviteAction extends Action common_show_header(_('Invite new users'), null, $error, array($this, 'show_top')); - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'id' => 'invite', 'action' => common_local_url('invite'))); - common_hidden('token', common_session_token()); + $this->hidden('token', common_session_token()); - common_textarea('addresses', _('Email addresses'), + $this->textarea('addresses', _('Email addresses'), $this->trimmed('addresses'), _('Addresses of friends to invite (one per line)')); - common_textarea('personal', _('Personal message'), + $this->textarea('personal', _('Personal message'), $this->trimmed('personal'), _('Optionally add a personal message to the invitation.')); - common_submit('send', _('Send')); + $this->submit('send', _('Send')); - common_element_end('form'); + $this->elementEnd('form'); common_show_footer(); } diff --git a/actions/login.php b/actions/login.php index 8600d44fd..fd98e656d 100644 --- a/actions/login.php +++ b/actions/login.php @@ -106,22 +106,45 @@ class LoginAction extends Action function show_form($error=null) { - common_show_header(_('Login'), null, $error, array($this, 'show_top')); - common_element_start('form', array('method' => 'post', + $this->error = $error; + $this->showPage(); + } + + function title() + { + return _('Login'); + } + + function showPageNotice() + { + if ($this->error) { + $this->element('p', 'error', $this->error); + } else { + $instr = $this->get_instructions(); + $output = common_markup_to_html($instr); + $this->elementStart('div', 'instructions'); + $this->raw($output); + $this->elementEnd('div'); + } + } + + function showContent() + { + $this->elementStart('form', array('method' => 'post', 'id' => 'login', 'action' => common_local_url('login'))); - common_input('nickname', _('Nickname')); - common_password('password', _('Password')); - common_checkbox('rememberme', _('Remember me'), false, + $this->input('nickname', _('Nickname')); + $this->password('password', _('Password')); + $this->checkbox('rememberme', _('Remember me'), false, _('Automatically login in the future; ' . 'not for shared computers!')); - common_submit('submit', _('Login')); - common_hidden('token', common_session_token()); - common_element_end('form'); - common_element_start('p'); - common_element('a', array('href' => common_local_url('recoverpassword')), + $this->submit('submit', _('Login')); + $this->hidden('token', common_session_token()); + $this->elementEnd('form'); + $this->elementStart('p'); + $this->element('a', array('href' => common_local_url('recoverpassword')), _('Lost or forgotten password?')); - common_element_end('p'); + $this->elementEnd('p'); common_show_footer(); } @@ -146,14 +169,5 @@ class LoginAction extends Action function show_top($error=null) { - if ($error) { - common_element('p', 'error', $error); - } else { - $instr = $this->get_instructions(); - $output = common_markup_to_html($instr); - common_element_start('div', 'instructions'); - common_raw($output); - common_element_end('div'); - } } } diff --git a/actions/newmessage.php b/actions/newmessage.php index 27fa9d518..6221b67e9 100644 --- a/actions/newmessage.php +++ b/actions/newmessage.php @@ -127,7 +127,7 @@ class NewmessageAction extends Action array($this, 'show_top')); if ($msg) { - common_element('p', array('id'=>'error'), $msg); + $this->element('p', array('id'=>'error'), $msg); } common_show_footer(); diff --git a/actions/newnotice.php b/actions/newnotice.php index c412e893d..89792d95a 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -92,13 +92,13 @@ class NewnoticeAction extends Action if ($this->boolean('ajax')) { common_start_html('text/xml;charset=utf-8', true); - common_element_start('head'); - common_element('title', null, _('Notice posted')); - common_element_end('head'); - common_element_start('body'); + $this->elementStart('head'); + $this->element('title', null, _('Notice posted')); + $this->elementEnd('head'); + $this->elementStart('body'); $this->show_notice($notice); - common_element_end('body'); - common_element_end('html'); + $this->elementEnd('body'); + $this->elementEnd('html'); } else { $returnto = $this->trimmed('returnto'); @@ -116,13 +116,13 @@ class NewnoticeAction extends Action function ajax_error_msg($msg) { common_start_html('text/xml;charset=utf-8', true); - common_element_start('head'); - common_element('title', null, _('Ajax Error')); - common_element_end('head'); - common_element_start('body'); - common_element('p', array('id' => 'error'), $msg); - common_element_end('body'); - common_element_end('html'); + $this->elementStart('head'); + $this->element('title', null, _('Ajax Error')); + $this->elementEnd('head'); + $this->elementStart('body'); + $this->element('p', array('id' => 'error'), $msg); + $this->elementEnd('body'); + $this->elementEnd('html'); } function show_top($content=null) @@ -147,7 +147,7 @@ class NewnoticeAction extends Action common_show_header(_('New notice'), null, $content, array($this, 'show_top')); if ($msg) { - common_element('p', array('id' => 'error'), $msg); + $this->element('p', array('id' => 'error'), $msg); } common_show_footer(); } diff --git a/actions/noticesearch.php b/actions/noticesearch.php index b36fc8ad2..d998b9da8 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -58,7 +58,7 @@ class NoticesearchAction extends SearchAction } if ($cnt > 0) { $terms = preg_split('/[\s,]+/', $q); - common_element_start('ul', array('id' => 'notices')); + $this->elementStart('ul', array('id' => 'notices')); for ($i = 0; $i < min($cnt, NOTICES_PER_PAGE); $i++) { if ($notice->fetch()) { $this->show_notice($notice, $terms); @@ -67,9 +67,9 @@ class NoticesearchAction extends SearchAction break; } } - common_element_end('ul'); + $this->elementEnd('ul'); } else { - common_element('p', 'error', _('No results')); + $this->element('p', 'error', _('No results')); } common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, @@ -82,7 +82,7 @@ class NoticesearchAction extends SearchAction $q = $arr[0]; } if ($q) { - common_element('link', array('rel' => 'alternate', + $this->element('link', array('rel' => 'alternate', 'href' => common_local_url('noticesearchrss', array('q' => $q)), 'type' => 'application/rss+xml', @@ -101,58 +101,58 @@ class NoticesearchAction extends SearchAction return; } # XXX: RDFa - common_element_start('li', array('class' => 'notice_single', + $this->elementStart('li', array('class' => 'notice_single', 'id' => 'notice-' . $notice->id)); $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE); - common_element_start('a', array('href' => $profile->profileurl)); - common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE), + $this->elementStart('a', array('href' => $profile->profileurl)); + $this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE), 'class' => 'avatar stream', 'width' => AVATAR_STREAM_SIZE, 'height' => AVATAR_STREAM_SIZE, 'alt' => ($profile->fullname) ? $profile->fullname : $profile->nickname)); - common_element_end('a'); - common_element('a', array('href' => $profile->profileurl, + $this->elementEnd('a'); + $this->element('a', array('href' => $profile->profileurl, 'class' => 'nickname'), $profile->nickname); # FIXME: URL, image, video, audio - common_element_start('p', array('class' => 'content')); + $this->elementStart('p', array('class' => 'content')); if ($notice->rendered) { - common_raw($this->highlight($notice->rendered, $terms)); + $this->raw($this->highlight($notice->rendered, $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) - common_raw($this->highlight(common_render_content($notice->content, $notice), $terms)); + $this->raw($this->highlight(common_render_content($notice->content, $notice), $terms)); } - common_element_end('p'); + $this->elementEnd('p'); $noticeurl = common_local_url('shownotice', array('notice' => $notice->id)); - common_element_start('p', 'time'); - common_element('a', array('class' => 'permalink', + $this->elementStart('p', 'time'); + $this->element('a', array('class' => 'permalink', 'href' => $noticeurl, 'title' => common_exact_date($notice->created)), common_date_string($notice->created)); if ($notice->reply_to) { $replyurl = common_local_url('shownotice', array('notice' => $notice->reply_to)); - common_text(' ('); - common_element('a', array('class' => 'inreplyto', + $this->text(' ('); + $this->element('a', array('class' => 'inreplyto', 'href' => $replyurl), _('in reply to...')); - common_text(')'); + $this->text(')'); } - common_element_start('a', + $this->elementStart('a', array('href' => common_local_url('newnotice', array('replyto' => $profile->nickname)), 'onclick' => 'doreply("'.$profile->nickname.'"); return false', 'title' => _('reply'), 'class' => 'replybutton')); - common_hidden('posttoken', common_session_token()); + $this->hidden('posttoken', common_session_token()); - common_raw('→'); - common_element_end('a'); - common_element_end('p'); - common_element_end('li'); + $this->raw('→'); + $this->elementEnd('a'); + $this->elementEnd('p'); + $this->elementEnd('li'); } function highlight($text, $terms) diff --git a/actions/nudge.php b/actions/nudge.php index a6480a582..de930e462 100644 --- a/actions/nudge.php +++ b/actions/nudge.php @@ -59,13 +59,13 @@ class NudgeAction extends Action if ($this->boolean('ajax')) { common_start_html('text/xml;charset=utf-8', true); - common_element_start('head'); - common_element('title', null, _('Nudge sent')); - common_element_end('head'); - common_element_start('body'); + $this->elementStart('head'); + $this->element('title', null, _('Nudge sent')); + $this->elementEnd('head'); + $this->elementStart('body'); common_nudge_response(); - common_element_end('body'); - common_element_end('html'); + $this->elementEnd('body'); + $this->elementEnd('html'); } else { // display a confirmation to the user common_redirect(common_local_url('showstream', diff --git a/actions/openidlogin.php b/actions/openidlogin.php index 09679e372..82791af34 100644 --- a/actions/openidlogin.php +++ b/actions/openidlogin.php @@ -66,13 +66,13 @@ class OpenidloginAction extends Action function show_top($error=null) { if ($error) { - common_element('div', array('class' => 'error'), $error); + $this->element('div', array('class' => 'error'), $error); } else { $instr = $this->get_instructions(); $output = common_markup_to_html($instr); - common_element_start('div', 'instructions'); - common_raw($output); - common_element_end('div'); + $this->elementStart('div', 'instructions'); + $this->raw($output); + $this->elementEnd('div'); } } @@ -80,18 +80,18 @@ class OpenidloginAction extends Action { common_show_header(_('OpenID Login'), null, $error, array($this, 'show_top')); $formaction = common_local_url('openidlogin'); - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'id' => 'openidlogin', 'action' => $formaction)); - common_hidden('token', common_session_token()); - common_input('openid_url', _('OpenID URL'), + $this->hidden('token', common_session_token()); + $this->input('openid_url', _('OpenID URL'), $openid_url, _('Your OpenID URL')); - common_checkbox('rememberme', _('Remember me'), false, + $this->checkbox('rememberme', _('Remember me'), false, _('Automatically login in the future; ' . 'not for shared computers!')); - common_submit('submit', _('Login')); - common_element_end('form'); + $this->submit('submit', _('Login')); + $this->elementEnd('form'); common_show_footer(); } } diff --git a/actions/openidsettings.php b/actions/openidsettings.php index 039236048..9265b5ea6 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -39,28 +39,28 @@ class OpenidsettingsAction extends SettingsAction $this->form_header(_('OpenID settings'), $msg, $success); - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'id' => 'openidadd', 'action' => common_local_url('openidsettings'))); - common_hidden('token', common_session_token()); - common_element('h2', null, _('Add OpenID')); - common_element('p', null, + $this->hidden('token', common_session_token()); + $this->element('h2', null, _('Add OpenID')); + $this->element('p', null, _('If you want to add an OpenID to your account, ' . 'enter it in the box below and click "Add".')); - common_element_start('p'); - common_element('label', array('for' => 'openid_url'), + $this->elementStart('p'); + $this->element('label', array('for' => 'openid_url'), _('OpenID URL')); - common_element('input', array('name' => 'openid_url', + $this->element('input', array('name' => 'openid_url', 'type' => 'text', 'id' => 'openid_url')); - common_element('input', array('type' => 'submit', + $this->element('input', array('type' => 'submit', 'id' => 'add', 'name' => 'add', 'class' => 'submit', 'value' => _('Add'))); - common_element_end('p'); - common_element_end('form'); + $this->elementEnd('p'); + $this->elementEnd('form'); $oid = new User_openid(); $oid->user_id = $user->id; @@ -69,48 +69,48 @@ class OpenidsettingsAction extends SettingsAction if ($cnt > 0) { - common_element('h2', null, _('Remove OpenID')); + $this->element('h2', null, _('Remove OpenID')); if ($cnt == 1 && !$user->password) { - common_element('p', null, + $this->element('p', null, _('Removing your only OpenID would make it impossible to log in! ' . 'If you need to remove it, add another OpenID first.')); if ($oid->fetch()) { - common_element_start('p'); - common_element('a', array('href' => $oid->canonical), + $this->elementStart('p'); + $this->element('a', array('href' => $oid->canonical), $oid->display); - common_element_end('p'); + $this->elementEnd('p'); } } else { - common_element('p', null, + $this->element('p', null, _('You can remove an OpenID from your account '. 'by clicking the button marked "Remove".')); $idx = 0; while ($oid->fetch()) { - common_element_start('form', array('method' => 'POST', + $this->elementStart('form', array('method' => 'POST', 'id' => 'openiddelete' . $idx, 'action' => common_local_url('openidsettings'))); - common_element_start('p'); - common_hidden('token', common_session_token()); - common_element('a', array('href' => $oid->canonical), + $this->elementStart('p'); + $this->hidden('token', common_session_token()); + $this->element('a', array('href' => $oid->canonical), $oid->display); - common_element('input', array('type' => 'hidden', + $this->element('input', array('type' => 'hidden', 'id' => 'openid_url'.$idx, 'name' => 'openid_url', 'value' => $oid->canonical)); - common_element('input', array('type' => 'submit', + $this->element('input', array('type' => 'submit', 'id' => 'remove'.$idx, 'name' => 'remove', 'class' => 'submit', 'value' => _('Remove'))); - common_element_end('p'); - common_element_end('form'); + $this->elementEnd('p'); + $this->elementEnd('form'); $idx++; } } diff --git a/actions/opensearch.php b/actions/opensearch.php index 96691fa6f..6e6e794e9 100644 --- a/actions/opensearch.php +++ b/actions/opensearch.php @@ -41,21 +41,21 @@ class OpensearchAction extends Action header('Content-Type: text/html'); common_start_xml(); - common_element_start('OpenSearchDescription', array('xmlns' => 'http://a9.com/-/spec/opensearch/1.1/')); + $this->elementStart('OpenSearchDescription', array('xmlns' => 'http://a9.com/-/spec/opensearch/1.1/')); $short_name = common_config('site', 'name').' '.$short_name; - common_element('ShortName', null, $short_name); - common_element('Contact', null, common_config('site', 'email')); - common_element('Url', array('type' => 'text/html', 'method' => 'get', + $this->element('ShortName', null, $short_name); + $this->element('Contact', null, common_config('site', 'email')); + $this->element('Url', array('type' => 'text/html', 'method' => 'get', 'template' => str_replace('---', '{searchTerms}', common_local_url($type, array('q' => '---'))))); - common_element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/vnd.microsoft.icon'), common_path('favicon.ico')); - common_element('Image', array('height' => 50, 'width' => 50, 'type' => 'image/png'), theme_path('logo.png')); - common_element('AdultContent', null, 'false'); - common_element('Language', null, common_language()); - common_element('OutputEncoding', null, 'UTF-8'); - common_element('InputEncoding', null, 'UTF-8'); - - common_element_end('OpenSearchDescription'); + $this->element('Image', array('height' => 16, 'width' => 16, 'type' => 'image/vnd.microsoft.icon'), common_path('favicon.ico')); + $this->element('Image', array('height' => 50, 'width' => 50, 'type' => 'image/png'), theme_path('logo.png')); + $this->element('AdultContent', null, 'false'); + $this->element('Language', null, common_language()); + $this->element('OutputEncoding', null, 'UTF-8'); + $this->element('InputEncoding', null, 'UTF-8'); + + $this->elementEnd('OpenSearchDescription'); common_end_xml(); } } diff --git a/actions/othersettings.php b/actions/othersettings.php index c2f08934c..97cbd0094 100644 --- a/actions/othersettings.php +++ b/actions/othersettings.php @@ -35,12 +35,12 @@ class OthersettingsAction extends SettingsAction $this->form_header(_('Other Settings'), $msg, $success); - common_element('h2', null, _('URL Auto-shortening')); - common_element_start('form', array('method' => 'post', + $this->element('h2', null, _('URL Auto-shortening')); + $this->elementStart('form', array('method' => 'post', 'id' => 'othersettings', 'action' => common_local_url('othersettings'))); - common_hidden('token', common_session_token()); + $this->hidden('token', common_session_token()); $services = array( '' => 'None', @@ -54,13 +54,13 @@ class OthersettingsAction extends SettingsAction 'metamark.net' => 'metamark.net' ); - common_dropdown('urlshorteningservice', _('Service'), $services, _('Automatic shortening service to use.'), false, $user->urlshorteningservice); + $this->dropdown('urlshorteningservice', _('Service'), $services, _('Automatic shortening service to use.'), false, $user->urlshorteningservice); - common_submit('save', _('Save')); + $this->submit('save', _('Save')); - common_element_end('form'); + $this->elementEnd('form'); -// common_element('h2', null, _('Delete my account')); +// $this->element('h2', null, _('Delete my account')); // $this->show_delete_form(); common_show_footer(); @@ -68,15 +68,15 @@ class OthersettingsAction extends SettingsAction function show_feeds_list($feeds) { - common_element_start('div', array('class' => 'feedsdel')); - common_element('p', null, 'Feeds:'); - common_element_start('ul', array('class' => 'xoxo')); + $this->elementStart('div', array('class' => 'feedsdel')); + $this->element('p', null, 'Feeds:'); + $this->elementStart('ul', array('class' => 'xoxo')); foreach ($feeds as $key => $value) { $this->common_feed_item($feeds[$key]); } - common_element_end('ul'); - common_element_end('div'); + $this->elementEnd('ul'); + $this->elementEnd('div'); } //TODO move to common.php (and retrace its origin) @@ -100,13 +100,13 @@ class OthersettingsAction extends SettingsAction $feed['textContent'] = "FOAF"; break; } - common_element_start('li'); - common_element('a', array('href' => $feed['href'], + $this->elementStart('li'); + $this->element('a', array('href' => $feed['href'], 'class' => $feed_classname, 'type' => $feed_mimetype, 'title' => $feed_title), $feed['textContent']); - common_element_end('li'); + $this->elementEnd('li'); } // function show_delete_form() { @@ -115,13 +115,13 @@ class OthersettingsAction extends SettingsAction // $notices->profile_id = $user->id; // $notice_count = (int) $notices->count(); // -// common_element_start('form', array('method' => 'POST', +// $this->elementStart('form', array('method' => 'POST', // 'id' => 'delete', // 'action' => // common_local_url('deleteprofile'))); // -// common_hidden('token', common_session_token()); -// common_element('p', null, "You can copy your notices and contacts by saving the two links below before deleting your account. Be careful, this operation cannot be undone."); +// $this->hidden('token', common_session_token()); +// $this->element('p', null, "You can copy your notices and contacts by saving the two links below before deleting your account. Be careful, this operation cannot be undone."); // // $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('limit' => $notice_count, 'nickname' => $user->nickname)), // 'type' => 'rss', @@ -132,8 +132,8 @@ class OthersettingsAction extends SettingsAction // 'version' => 'FOAF', // 'item' => 'foaf'))); // -// common_submit('deleteaccount', _('Delete my account')); -// common_element_end('form'); +// $this->submit('deleteaccount', _('Delete my account')); +// $this->elementEnd('form'); // } function handle_post() diff --git a/actions/peoplesearch.php b/actions/peoplesearch.php index 0d0fae4e5..2b13b0812 100644 --- a/actions/peoplesearch.php +++ b/actions/peoplesearch.php @@ -60,7 +60,7 @@ class PeoplesearchAction extends SearchAction $results = new PeopleSearchResults($profile, $terms); $results->show_list(); } else { - common_element('p', 'error', _('No results')); + $this->element('p', 'error', _('No results')); } $profile->free(); diff --git a/actions/peopletag.php b/actions/peopletag.php index 13a0b7a41..2680638d7 100644 --- a/actions/peopletag.php +++ b/actions/peopletag.php @@ -90,11 +90,11 @@ class PeopletagAction extends Action { $instr = sprintf(_('These are users who have tagged themselves "%s" ' . 'to show a common interest, characteristic, hobby or job.'), $tag); - common_element_start('div', 'instructions'); - common_element_start('p'); - common_text($instr); - common_element_end('p'); - common_element_end('div'); + $this->elementStart('div', 'instructions'); + $this->elementStart('p'); + $this->text($instr); + $this->elementEnd('p'); + $this->elementEnd('div'); } function get_title() diff --git a/actions/profilesettings.php b/actions/profilesettings.php index d861919b9..ef45fc1d9 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -34,11 +34,11 @@ class ProfilesettingsAction extends SettingsAction { $this->form_header(_('Profile settings'), $msg, $success); $this->show_settings_form(); - common_element('h2', null, _('Avatar')); + $this->element('h2', null, _('Avatar')); $this->show_avatar_form(); - common_element('h2', null, _('Change password')); + $this->element('h2', null, _('Change password')); $this->show_password_form(); -// common_element('h2', null, _('Delete my account')); +// $this->element('h2', null, _('Delete my account')); // $this->show_delete_form(); common_show_footer(); } @@ -74,46 +74,46 @@ class ProfilesettingsAction extends SettingsAction $user = common_current_user(); $profile = $user->getProfile(); - common_element_start('form', array('method' => 'POST', + $this->elementStart('form', array('method' => 'POST', 'id' => 'profilesettings', 'action' => common_local_url('profilesettings'))); - common_hidden('token', common_session_token()); + $this->hidden('token', common_session_token()); # too much common patterns here... abstractable? - common_input('nickname', _('Nickname'), + $this->input('nickname', _('Nickname'), ($this->arg('nickname')) ? $this->arg('nickname') : $profile->nickname, _('1-64 lowercase letters or numbers, no punctuation or spaces')); - common_input('fullname', _('Full name'), + $this->input('fullname', _('Full name'), ($this->arg('fullname')) ? $this->arg('fullname') : $profile->fullname); - common_input('homepage', _('Homepage'), + $this->input('homepage', _('Homepage'), ($this->arg('homepage')) ? $this->arg('homepage') : $profile->homepage, _('URL of your homepage, blog, or profile on another site')); - common_textarea('bio', _('Bio'), + $this->textarea('bio', _('Bio'), ($this->arg('bio')) ? $this->arg('bio') : $profile->bio, _('Describe yourself and your interests in 140 chars')); - common_input('location', _('Location'), + $this->input('location', _('Location'), ($this->arg('location')) ? $this->arg('location') : $profile->location, _('Where you are, like "City, State (or Region), Country"')); - common_input('tags', _('Tags'), + $this->input('tags', _('Tags'), ($this->arg('tags')) ? $this->arg('tags') : implode(' ', $user->getSelfTags()), _('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated')); $language = common_language(); - common_dropdown('language', _('Language'), get_nice_language_list(), _('Preferred language'), true, $language); + $this->dropdown('language', _('Language'), get_nice_language_list(), _('Preferred language'), true, $language); $timezone = common_timezone(); $timezones = array(); foreach(DateTimeZone::listIdentifiers() as $k => $v) { $timezones[$v] = $v; } - common_dropdown('timezone', _('Timezone'), $timezones, _('What timezone are you normally in?'), true, $timezone); + $this->dropdown('timezone', _('Timezone'), $timezones, _('What timezone are you normally in?'), true, $timezone); - common_checkbox('autosubscribe', _('Automatically subscribe to whoever subscribes to me (best for non-humans)'), + $this->checkbox('autosubscribe', _('Automatically subscribe to whoever subscribes to me (best for non-humans)'), ($this->arg('autosubscribe')) ? $this->boolean('autosubscribe') : $user->autosubscribe); - common_submit('save', _('Save')); + $this->submit('save', _('Save')); - common_element_end('form'); + $this->elementEnd('form'); } @@ -132,62 +132,62 @@ class ProfilesettingsAction extends SettingsAction $original = $profile->getOriginalAvatar(); - common_element_start('form', array('enctype' => 'multipart/form-data', + $this->elementStart('form', array('enctype' => 'multipart/form-data', 'method' => 'POST', 'id' => 'avatar', 'action' => common_local_url('profilesettings'))); - common_hidden('token', common_session_token()); + $this->hidden('token', common_session_token()); if ($original) { - common_element_start('div', array('id'=>'avatar_original', 'class'=>'avatar_view')); - common_element('h3', null, _("Original:")); - common_element_start('div', array('id'=>'avatar_original_view')); - common_element('img', array('src' => $original->url, + $this->elementStart('div', array('id'=>'avatar_original', 'class'=>'avatar_view')); + $this->element('h3', null, _("Original:")); + $this->elementStart('div', array('id'=>'avatar_original_view')); + $this->element('img', array('src' => $original->url, 'class' => 'avatar original', 'width' => $original->width, 'height' => $original->height, 'alt' => $user->nickname)); - common_element_end('div'); - common_element_end('div'); + $this->elementEnd('div'); + $this->elementEnd('div'); } $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); if ($avatar) { - common_element_start('div', array('id'=>'avatar_preview', 'class'=>'avatar_view')); - common_element('h3', null, _("Preview:")); - common_element_start('div', array('id'=>'avatar_preview_view')); - common_element('img', array('src' => $original->url,//$avatar->url, + $this->elementStart('div', array('id'=>'avatar_preview', 'class'=>'avatar_view')); + $this->element('h3', null, _("Preview:")); + $this->elementStart('div', array('id'=>'avatar_preview_view')); + $this->element('img', array('src' => $original->url,//$avatar->url, 'class' => 'avatar profile', 'width' => AVATAR_PROFILE_SIZE, 'height' => AVATAR_PROFILE_SIZE, 'alt' => $user->nickname)); - common_element_end('div'); - common_element_end('div'); + $this->elementEnd('div'); + $this->elementEnd('div'); foreach(array('avatar_crop_x', 'avatar_crop_y', 'avatar_crop_w', 'avatar_crop_h') as $crop_info) { - common_element('input', array('name' => $crop_info, + $this->element('input', array('name' => $crop_info, 'type' => 'hidden', 'id' => $crop_info)); } - common_submit('crop', _('Crop')); + $this->submit('crop', _('Crop')); } - common_element('input', array('name' => 'MAX_FILE_SIZE', + $this->element('input', array('name' => 'MAX_FILE_SIZE', 'type' => 'hidden', 'id' => 'MAX_FILE_SIZE', 'value' => MAX_AVATAR_SIZE)); - common_element_start('p'); + $this->elementStart('p'); - common_element('input', array('name' => 'avatarfile', + $this->element('input', array('name' => 'avatarfile', 'type' => 'file', 'id' => 'avatarfile')); - common_element_end('p'); + $this->elementEnd('p'); - common_submit('upload', _('Upload')); - common_element_end('form'); + $this->submit('upload', _('Upload')); + $this->elementEnd('form'); } @@ -195,23 +195,23 @@ class ProfilesettingsAction extends SettingsAction { $user = common_current_user(); - common_element_start('form', array('method' => 'POST', + $this->elementStart('form', array('method' => 'POST', 'id' => 'password', 'action' => common_local_url('profilesettings'))); - common_hidden('token', common_session_token()); + $this->hidden('token', common_session_token()); # Users who logged in with OpenID won't have a pwd if ($user->password) { - common_password('oldpassword', _('Old password')); + $this->password('oldpassword', _('Old password')); } - common_password('newpassword', _('New password'), + $this->password('newpassword', _('New password'), _('6 or more characters')); - common_password('confirm', _('Confirm'), + $this->password('confirm', _('Confirm'), _('same as password above')); - common_submit('changepass', _('Change')); - common_element_end('form'); + $this->submit('changepass', _('Change')); + $this->elementEnd('form'); } function save_profile() diff --git a/actions/publicxrds.php b/actions/publicxrds.php index 3d731d79f..f66e34533 100644 --- a/actions/publicxrds.php +++ b/actions/publicxrds.php @@ -39,45 +39,45 @@ class PublicxrdsAction extends Action header('Content-Type: application/xrds+xml'); common_start_xml(); - common_element_start('XRDS', array('xmlns' => 'xri://$xrds')); + $this->elementStart('XRDS', array('xmlns' => 'xri://$xrds')); - common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', + $this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', 'xmlns:simple' => 'http://xrds-simple.net/core/1.0', 'version' => '2.0')); - common_element('Type', null, 'xri://$xrds*simple'); + $this->element('Type', null, 'xri://$xrds*simple'); foreach (array('finishopenidlogin', 'finishaddopenid', 'finishimmediate') as $finish) { $this->show_service(Auth_OpenID_RP_RETURN_TO_URL_TYPE, common_local_url($finish)); } - common_element_end('XRD'); + $this->elementEnd('XRD'); - common_element_end('XRDS'); + $this->elementEnd('XRDS'); common_end_xml(); } function show_service($type, $uri, $params=null, $sigs=null, $localId=null) { - common_element_start('Service'); + $this->elementStart('Service'); if ($uri) { - common_element('URI', null, $uri); + $this->element('URI', null, $uri); } - common_element('Type', null, $type); + $this->element('Type', null, $type); if ($params) { foreach ($params as $param) { - common_element('Type', null, $param); + $this->element('Type', null, $param); } } if ($sigs) { foreach ($sigs as $sig) { - common_element('Type', null, $sig); + $this->element('Type', null, $sig); } } if ($localId) { - common_element('LocalID', null, $localId); + $this->element('LocalID', null, $localId); } - common_element_end('Service'); + $this->elementEnd('Service'); } } \ No newline at end of file diff --git a/actions/recoverpassword.php b/actions/recoverpassword.php index bb6ef81d6..3e6ecfb1f 100644 --- a/actions/recoverpassword.php +++ b/actions/recoverpassword.php @@ -141,24 +141,24 @@ class RecoverpasswordAction extends Action function show_top($msg=null) { if ($msg) { - common_element('div', 'error', $msg); + $this->element('div', 'error', $msg); } else { - common_element_start('div', 'instructions'); - common_element('p', null, + $this->elementStart('div', 'instructions'); + $this->element('p', null, _('If you\'ve forgotten or lost your' . ' password, you can get a new one sent to' . ' the email address you have stored ' . ' in your account.')); - common_element_end('div'); + $this->elementEnd('div'); } } function show_password_top($msg=null) { if ($msg) { - common_element('div', 'error', $msg); + $this->element('div', 'error', $msg); } else { - common_element('div', 'instructions', + $this->element('div', 'instructions', _('You\'ve been identified. Enter a ' . ' new password below. ')); } @@ -170,15 +170,15 @@ class RecoverpasswordAction extends Action common_show_header(_('Recover password'), null, $msg, array($this, 'show_top')); - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'id' => 'recoverpassword', 'action' => common_local_url('recoverpassword'))); - common_input('nicknameoremail', _('Nickname or email'), + $this->input('nicknameoremail', _('Nickname or email'), $this->trimmed('nicknameoremail'), _('Your nickname on this server, ' . 'or your registered email address.')); - common_submit('recover', _('Recover')); - common_element_end('form'); + $this->submit('recover', _('Recover')); + $this->elementEnd('form'); common_show_footer(); } @@ -188,16 +188,16 @@ class RecoverpasswordAction extends Action common_show_header(_('Reset password'), null, $msg, array($this, 'show_password_top')); - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'id' => 'recoverpassword', 'action' => common_local_url('recoverpassword'))); - common_hidden('token', common_session_token()); - common_password('newpassword', _('New password'), + $this->hidden('token', common_session_token()); + $this->password('newpassword', _('New password'), _('6 or more characters, and don\'t forget it!')); - common_password('confirm', _('Confirm'), + $this->password('confirm', _('Confirm'), _('Same as password above')); - common_submit('reset', _('Reset')); - common_element_end('form'); + $this->submit('reset', _('Reset')); + $this->elementEnd('form'); common_show_footer(); } @@ -278,7 +278,7 @@ class RecoverpasswordAction extends Action mail_to_user($user, _('Password recovery requested'), $body, $confirm->address); common_show_header(_('Password recovery requested')); - common_element('p', null, + $this->element('p', null, _('Instructions for recovering your password ' . 'have been sent to the email address registered to your ' . 'account.')); @@ -336,7 +336,7 @@ class RecoverpasswordAction extends Action common_real_login(true); common_show_header(_('Password saved.')); - common_element('p', null, _('New password successfully saved. ' . + $this->element('p', null, _('New password successfully saved. ' . 'You are now logged in.')); common_show_footer(); } diff --git a/actions/register.php b/actions/register.php index c479816ef..bac179687 100644 --- a/actions/register.php +++ b/actions/register.php @@ -155,16 +155,16 @@ class RegisterAction extends Action function show_top($error=null) { if ($error) { - common_element('p', 'error', $error); + $this->element('p', 'error', $error); } else { $instr = common_markup_to_html(_('With this form you can create a new account. ' . 'You can then post notices and link up to friends and colleagues. '. '(Have an [OpenID](http://openid.net/)? ' . 'Try our [OpenID registration](%%action.openidlogin%%)!)')); - common_element_start('div', 'instructions'); - common_raw($instr); - common_element_end('div'); + $this->elementStart('div', 'instructions'); + $this->raw($instr); + $this->elementEnd('div'); } } @@ -184,45 +184,45 @@ class RegisterAction extends Action } common_show_header(_('Register'), null, $error, array($this, 'show_top')); - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'id' => 'login', 'action' => common_local_url('register'))); - common_hidden('token', common_session_token()); + $this->hidden('token', common_session_token()); if ($code) { - common_hidden('code', $code); + $this->hidden('code', $code); } - common_input('nickname', _('Nickname'), $this->trimmed('nickname'), + $this->input('nickname', _('Nickname'), $this->trimmed('nickname'), _('1-64 lowercase letters or numbers, no punctuation or spaces. Required.')); - common_password('password', _('Password'), + $this->password('password', _('Password'), _('6 or more characters. Required.')); - common_password('confirm', _('Confirm'), + $this->password('confirm', _('Confirm'), _('Same as password above. Required.')); if ($invite && $invite->address_type == 'email') { - common_input('email', _('Email'), $invite->address, + $this->input('email', _('Email'), $invite->address, _('Used only for updates, announcements, and password recovery')); } else { - common_input('email', _('Email'), $this->trimmed('email'), + $this->input('email', _('Email'), $this->trimmed('email'), _('Used only for updates, announcements, and password recovery')); } - common_input('fullname', _('Full name'), + $this->input('fullname', _('Full name'), $this->trimmed('fullname'), _('Longer name, preferably your "real" name')); - common_input('homepage', _('Homepage'), + $this->input('homepage', _('Homepage'), $this->trimmed('homepage'), _('URL of your homepage, blog, or profile on another site')); - common_textarea('bio', _('Bio'), + $this->textarea('bio', _('Bio'), $this->trimmed('bio'), _('Describe yourself and your interests in 140 chars')); - common_input('location', _('Location'), + $this->input('location', _('Location'), $this->trimmed('location'), _('Where you are, like "City, State (or Region), Country"')); - common_checkbox('rememberme', _('Remember me'), + $this->checkbox('rememberme', _('Remember me'), $this->boolean('rememberme'), _('Automatically login in the future; not for shared computers!')); - common_element_start('p'); + $this->elementStart('p'); $attrs = array('type' => 'checkbox', 'id' => 'license', 'name' => 'license', @@ -230,14 +230,14 @@ class RegisterAction extends Action if ($this->boolean('license')) { $attrs['checked'] = 'checked'; } - common_element('input', $attrs); - common_text(_('My text and files are available under ')); - common_element('a', array('href' => $config['license']['url']), + $this->element('input', $attrs); + $this->text(_('My text and files are available under ')); + $this->element('a', array('href' => $config['license']['url']), $config['license']['title']); - common_text(_(' except this private data: password, email address, IM address, phone number.')); - common_element_end('p'); - common_submit('submit', _('Register')); - common_element_end('form'); + $this->text(_(' except this private data: password, email address, IM address, phone number.')); + $this->elementEnd('p'); + $this->submit('submit', _('Register')); + $this->elementEnd('form'); common_show_footer(); } @@ -245,7 +245,7 @@ class RegisterAction extends Action { $nickname = $this->arg('nickname'); common_show_header(_('Registration successful')); - common_element_start('div', 'success'); + $this->elementStart('div', 'success'); $instr = sprintf(_('Congratulations, %s! And welcome to %%%%site.name%%%%. From here, you may want to...'. "\n\n" . '* Go to [your profile](%s) and post your first message.' . "\n" . '* Add a [Jabber/GTalk address](%%%%action.imsettings%%%%) so you can send notices through instant messages.' . "\n" . @@ -254,14 +254,14 @@ class RegisterAction extends Action '* Read over the [online docs](%%%%doc.help%%%%) for features you may have missed. ' . "\n\n" . 'Thanks for signing up and we hope you enjoy using this service.'), $nickname, common_local_url('showstream', array('nickname' => $nickname))); - common_raw(common_markup_to_html($instr)); + $this->raw(common_markup_to_html($instr)); $have_email = $this->trimmed('email'); if ($have_email) { $emailinstr = _('(You should receive a message by email momentarily, with ' . 'instructions on how to confirm your email address.)'); - common_raw(common_markup_to_html($emailinstr)); + $this->raw(common_markup_to_html($emailinstr)); } - common_element_end('div'); + $this->elementEnd('div'); common_show_footer(); } diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php index a9494772e..b9e29d645 100644 --- a/actions/remotesubscribe.php +++ b/actions/remotesubscribe.php @@ -61,13 +61,13 @@ class RemotesubscribeAction extends Action function show_top($err=null) { if ($err) { - common_element('div', 'error', $err); + $this->element('div', 'error', $err); } else { $instructions = $this->get_instructions(); $output = common_markup_to_html($instructions); - common_element_start('div', 'instructions'); - common_raw($output); - common_element_end('p'); + $this->elementStart('div', 'instructions'); + $this->raw($output); + $this->elementEnd('p'); } } @@ -79,15 +79,15 @@ class RemotesubscribeAction extends Action array($this, 'show_top')); # id = remotesubscribe conflicts with the # button on profile page - common_element_start('form', array('id' => 'remsub', 'method' => 'post', + $this->elementStart('form', array('id' => 'remsub', 'method' => 'post', 'action' => common_local_url('remotesubscribe'))); - common_hidden('token', common_session_token()); - common_input('nickname', _('User nickname'), $nickname, + $this->hidden('token', common_session_token()); + $this->input('nickname', _('User nickname'), $nickname, _('Nickname of the user you want to follow')); - common_input('profile_url', _('Profile URL'), $profile, + $this->input('profile_url', _('Profile URL'), $profile, _('URL of your profile on another compatible microblogging service')); - common_submit('submit', _('Subscribe')); - common_element_end('form'); + $this->submit('submit', _('Subscribe')); + $this->elementEnd('form'); common_show_footer(); } diff --git a/actions/replies.php b/actions/replies.php index eceeb4d65..878550888 100644 --- a/actions/replies.php +++ b/actions/replies.php @@ -62,7 +62,7 @@ class RepliesAction extends StreamAction function show_header($user) { - common_element('link', array('rel' => 'alternate', + $this->element('link', array('rel' => 'alternate', 'href' => common_local_url('repliesrss', array('nickname' => $user->nickname)), 'type' => 'application/rss+xml', diff --git a/actions/showfavorites.php b/actions/showfavorites.php index f4344833d..1dec3ba5b 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -57,7 +57,7 @@ class ShowfavoritesAction extends StreamAction function show_header($user) { - common_element('link', array('rel' => 'alternate', + $this->element('link', array('rel' => 'alternate', 'href' => common_local_url('favoritesrss', array('nickname' => $user->nickname)), 'type' => 'application/rss+xml', diff --git a/actions/shownotice.php b/actions/shownotice.php index 2df09cb3f..c519af0ba 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -81,10 +81,10 @@ class ShownoticeAction extends StreamAction array($this, 'show_header'), null, array($this, 'show_top')); - common_element_start('ul', array('id' => 'notices')); + $this->elementStart('ul', array('id' => 'notices')); $nli = new NoticeListItem($this->notice); $nli->show(); - common_element_end('ul'); + $this->elementEnd('ul'); common_show_footer(); } @@ -99,12 +99,12 @@ class ShownoticeAction extends StreamAction } if ($user->emailmicroid && $user->email && $this->notice->uri) { - common_element('meta', array('name' => 'microid', + $this->element('meta', array('name' => 'microid', 'content' => "mailto+http:sha1:" . sha1(sha1('mailto:' . $user->email) . sha1($this->notice->uri)))); } if ($user->jabbermicroid && $user->jabber && $this->notice->uri) { - common_element('meta', array('name' => 'microid', + $this->element('meta', array('name' => 'microid', 'content' => "xmpp+http:sha1:" . sha1(sha1('xmpp:' . $user->jabber) . sha1($this->notice->uri)))); } } diff --git a/actions/showstream.php b/actions/showstream.php index e4e5d96d1..9a59f7ae4 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -106,53 +106,53 @@ class ShowstreamAction extends StreamAction function show_header($user) { # Feeds - common_element('link', array('rel' => 'alternate', + $this->element('link', array('rel' => 'alternate', 'href' => common_local_url('api', array('apiaction' => 'statuses', 'method' => 'user_timeline.rss', 'argument' => $user->nickname)), 'type' => 'application/rss+xml', 'title' => sprintf(_('Notice feed for %s'), $user->nickname))); - common_element('link', array('rel' => 'alternate feed', + $this->element('link', array('rel' => 'alternate feed', 'href' => common_local_url('api', array('apiaction' => 'statuses', 'method' => 'user_timeline.atom', 'argument' => $user->nickname)), 'type' => 'application/atom+xml', 'title' => sprintf(_('Notice feed for %s'), $user->nickname))); - common_element('link', array('rel' => 'alternate', + $this->element('link', array('rel' => 'alternate', 'href' => common_local_url('userrss', array('nickname' => $user->nickname)), 'type' => 'application/rdf+xml', 'title' => sprintf(_('Notice feed for %s'), $user->nickname))); # FOAF - common_element('link', array('rel' => 'meta', + $this->element('link', array('rel' => 'meta', 'href' => common_local_url('foaf', array('nickname' => $user->nickname)), 'type' => 'application/rdf+xml', 'title' => 'FOAF')); # for remote subscriptions etc. - common_element('meta', array('http-equiv' => 'X-XRDS-Location', + $this->element('meta', array('http-equiv' => 'X-XRDS-Location', 'content' => common_local_url('xrds', array('nickname' => $user->nickname)))); $profile = $user->getProfile(); if ($profile->bio) { - common_element('meta', array('name' => 'description', + $this->element('meta', array('name' => 'description', 'content' => $profile->bio)); } if ($user->emailmicroid && $user->email && $profile->profileurl) { - common_element('meta', array('name' => 'microid', + $this->element('meta', array('name' => 'microid', 'content' => "mailto+http:sha1:" . sha1(sha1('mailto:' . $user->email) . sha1($profile->profileurl)))); } if ($user->jabbermicroid && $user->jabber && $profile->profileurl) { - common_element('meta', array('name' => 'microid', + $this->element('meta', array('name' => 'microid', 'content' => "xmpp+http:sha1:" . sha1(sha1('xmpp:' . $user->jabber) . sha1($profile->profileurl)))); } # See https://wiki.mozilla.org/Microsummaries - common_element('link', array('rel' => 'microsummary', + $this->element('link', array('rel' => 'microsummary', 'href' => common_local_url('microsummary', array('nickname' => $profile->nickname)))); } @@ -165,7 +165,7 @@ class ShowstreamAction extends StreamAction function show_profile($profile) { - common_element_start('div', array('id' => 'profile', 'class' => 'vcard')); + $this->elementStart('div', array('id' => 'profile', 'class' => 'vcard')); $this->show_personal($profile); @@ -175,23 +175,23 @@ class ShowstreamAction extends StreamAction $this->show_subscriptions($profile); - common_element_end('div'); + $this->elementEnd('div'); } function show_personal($profile) { $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); - common_element_start('div', array('id' => 'profile_avatar')); - common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE), + $this->elementStart('div', array('id' => 'profile_avatar')); + $this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE), 'class' => 'avatar profile photo', 'width' => AVATAR_PROFILE_SIZE, 'height' => AVATAR_PROFILE_SIZE, 'alt' => $profile->nickname)); - common_element_start('ul', array('id' => 'profile_actions')); + $this->elementStart('ul', array('id' => 'profile_actions')); - common_element_start('li', array('id' => 'profile_subscribe')); + $this->elementStart('li', array('id' => 'profile_subscribe')); $cur = common_current_user(); if ($cur) { if ($cur->id != $profile->id) { @@ -204,14 +204,14 @@ class ShowstreamAction extends StreamAction } else { $this->show_remote_subscribe_link($profile); } - common_element_end('li'); + $this->elementEnd('li'); $user = User::staticGet('id', $profile->id); common_profile_new_message_nudge($cur, $user, $profile); if ($cur && $cur->id != $profile->id) { $blocked = $cur->hasBlocked($profile); - common_element_start('li', array('id' => 'profile_block')); + $this->elementStart('li', array('id' => 'profile_block')); if ($blocked) { common_unblock_form($profile, array('action' => 'showstream', 'nickname' => $profile->nickname)); @@ -219,62 +219,62 @@ class ShowstreamAction extends StreamAction common_block_form($profile, array('action' => 'showstream', 'nickname' => $profile->nickname)); } - common_element_end('li'); + $this->elementEnd('li'); } - common_element_end('ul'); + $this->elementEnd('ul'); - common_element_end('div'); + $this->elementEnd('div'); - common_element_start('div', array('id' => 'profile_information')); + $this->elementStart('div', array('id' => 'profile_information')); if ($profile->fullname) { - common_element('h1', array('class' => 'fn'), $profile->fullname . ' (' . $profile->nickname . ')'); + $this->element('h1', array('class' => 'fn'), $profile->fullname . ' (' . $profile->nickname . ')'); } else { - common_element('h1', array('class' => 'fn nickname'), $profile->nickname); + $this->element('h1', array('class' => 'fn nickname'), $profile->nickname); } if ($profile->location) { - common_element('p', 'location', $profile->location); + $this->element('p', 'location', $profile->location); } if ($profile->bio) { - common_element('p', 'description note', $profile->bio); + $this->element('p', 'description note', $profile->bio); } if ($profile->homepage) { - common_element_start('p', 'website'); - common_element('a', array('href' => $profile->homepage, + $this->elementStart('p', 'website'); + $this->element('a', array('href' => $profile->homepage, 'rel' => 'me', 'class' => 'url'), $profile->homepage); - common_element_end('p'); + $this->elementEnd('p'); } $this->show_statistics($profile); - common_element_end('div'); + $this->elementEnd('div'); } function show_remote_subscribe_link($profile) { $url = common_local_url('remotesubscribe', array('nickname' => $profile->nickname)); - common_element('a', array('href' => $url, + $this->element('a', array('href' => $url, 'id' => 'remotesubscribe'), _('Subscribe')); } function show_unsubscribe_form($profile) { - common_element_start('form', array('id' => 'unsubscribe', 'method' => 'post', + $this->elementStart('form', array('id' => 'unsubscribe', 'method' => 'post', 'action' => common_local_url('unsubscribe'))); - common_hidden('token', common_session_token()); - common_element('input', array('id' => 'unsubscribeto', + $this->hidden('token', common_session_token()); + $this->element('input', array('id' => 'unsubscribeto', 'name' => 'unsubscribeto', 'type' => 'hidden', 'value' => $profile->nickname)); - common_element('input', array('type' => 'submit', + $this->element('input', array('type' => 'submit', 'class' => 'submit', 'value' => _('Unsubscribe'))); - common_element_end('form'); + $this->elementEnd('form'); } function show_subscriptions($profile) @@ -293,13 +293,13 @@ class ShowstreamAction extends StreamAction $subs_count = $subs->find(); - common_element_start('div', array('id' => 'subscriptions')); + $this->elementStart('div', array('id' => 'subscriptions')); - common_element('h2', null, _('Subscriptions')); + $this->element('h2', null, _('Subscriptions')); if ($subs_count > 0) { - common_element_start('ul', array('id' => 'subscriptions_avatars')); + $this->elementStart('ul', array('id' => 'subscriptions_avatars')); for ($i = 0; $i < min($subs_count, SUBSCRIPTIONS); $i++) { @@ -315,39 +315,39 @@ class ShowstreamAction extends StreamAction continue; } - common_element_start('li', 'vcard'); - common_element_start('a', array('title' => ($other->fullname) ? + $this->elementStart('li', 'vcard'); + $this->elementStart('a', array('title' => ($other->fullname) ? $other->fullname : $other->nickname, 'href' => $other->profileurl, 'rel' => 'contact', 'class' => 'subscription fn url')); $avatar = $other->getAvatar(AVATAR_MINI_SIZE); - common_element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_MINI_SIZE)), + $this->element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_MINI_SIZE)), 'width' => AVATAR_MINI_SIZE, 'height' => AVATAR_MINI_SIZE, 'class' => 'avatar mini photo', 'alt' => ($other->fullname) ? $other->fullname : $other->nickname)); - common_element_end('a'); - common_element_end('li'); + $this->elementEnd('a'); + $this->elementEnd('li'); } - common_element_end('ul'); + $this->elementEnd('ul'); } if ($subs_count > SUBSCRIPTIONS) { - common_element_start('p', array('id' => 'subscriptions_viewall')); + $this->elementStart('p', array('id' => 'subscriptions_viewall')); - common_element('a', array('href' => common_local_url('subscriptions', + $this->element('a', array('href' => common_local_url('subscriptions', array('nickname' => $profile->nickname)), 'class' => 'moresubscriptions'), _('All subscriptions')); - common_element_end('p'); + $this->elementEnd('p'); } - common_element_end('div'); + $this->elementEnd('div'); } function show_statistics($profile) @@ -366,49 +366,49 @@ class ShowstreamAction extends StreamAction $notices->profile_id = $profile->id; $notice_count = (int) $notices->count(); - common_element_start('div', 'statistics'); - common_element('h2', 'statistics', _('Statistics')); + $this->elementStart('div', 'statistics'); + $this->element('h2', 'statistics', _('Statistics')); # Other stats...? - common_element_start('dl', 'statistics'); - common_element('dt', 'membersince', _('Member since')); - common_element('dd', 'membersince', date('j M Y', + $this->elementStart('dl', 'statistics'); + $this->element('dt', 'membersince', _('Member since')); + $this->element('dd', 'membersince', date('j M Y', strtotime($profile->created))); - common_element_start('dt', 'subscriptions'); - common_element('a', array('href' => common_local_url('subscriptions', + $this->elementStart('dt', 'subscriptions'); + $this->element('a', array('href' => common_local_url('subscriptions', array('nickname' => $profile->nickname))), _('Subscriptions')); - common_element_end('dt'); - common_element('dd', 'subscriptions', (is_int($subs_count)) ? $subs_count : '0'); - common_element_start('dt', 'subscribers'); - common_element('a', array('href' => common_local_url('subscribers', + $this->elementEnd('dt'); + $this->element('dd', 'subscriptions', (is_int($subs_count)) ? $subs_count : '0'); + $this->elementStart('dt', 'subscribers'); + $this->element('a', array('href' => common_local_url('subscribers', array('nickname' => $profile->nickname))), _('Subscribers')); - common_element_end('dt'); - common_element('dd', 'subscribers', (is_int($subbed_count)) ? $subbed_count : '0'); - common_element('dt', 'notices', _('Notices')); - common_element('dd', 'notices', (is_int($notice_count)) ? $notice_count : '0'); + $this->elementEnd('dt'); + $this->element('dd', 'subscribers', (is_int($subbed_count)) ? $subbed_count : '0'); + $this->element('dt', 'notices', _('Notices')); + $this->element('dd', 'notices', (is_int($notice_count)) ? $notice_count : '0'); # XXX: link these to something - common_element('dt', 'tags', _('Tags')); - common_element_start('dd', 'tags'); + $this->element('dt', 'tags', _('Tags')); + $this->elementStart('dd', 'tags'); $tags = Profile_tag::getTags($profile->id, $profile->id); - common_element_start('ul', 'tags xoxo'); + $this->elementStart('ul', 'tags xoxo'); foreach ($tags as $tag) { - common_element_start('li'); - common_element('a', array('rel' => 'bookmark tag', + $this->elementStart('li'); + $this->element('a', array('rel' => 'bookmark tag', 'href' => common_local_url('peopletag', array('tag' => $tag))), $tag); - common_element_end('li'); + $this->elementEnd('li'); } - common_element_end('ul'); - common_element_end('dd'); + $this->elementEnd('ul'); + $this->elementEnd('dd'); - common_element_end('dl'); + $this->elementEnd('dl'); - common_element_end('div'); + $this->elementEnd('div'); } function show_notices($user) @@ -428,22 +428,22 @@ class ShowstreamAction extends StreamAction function show_last_notice($profile) { - common_element('h2', null, _('Currently')); + $this->element('h2', null, _('Currently')); $notice = $profile->getCurrentNotice(); if ($notice) { # FIXME: URL, image, video, audio - common_element_start('p', array('class' => 'notice_current')); + $this->elementStart('p', array('class' => 'notice_current')); if ($notice->rendered) { - common_raw($notice->rendered); + $this->raw($notice->rendered); } else { # XXX: may be some uncooked notices in the DB, # we cook them right now. This can probably disappear in future # versions (>> 0.4.x) - common_raw(common_render_content($notice->content, $notice)); + $this->raw(common_render_content($notice->content, $notice)); } - common_element_end('p'); + $this->elementEnd('p'); } } } diff --git a/actions/smssettings.php b/actions/smssettings.php index fad71135c..1be45d1ce 100644 --- a/actions/smssettings.php +++ b/actions/smssettings.php @@ -34,75 +34,75 @@ class SmssettingsAction extends EmailsettingsAction { $user = common_current_user(); $this->form_header(_('SMS Settings'), $msg, $success); - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'id' => 'smssettings', 'action' => common_local_url('smssettings'))); - common_hidden('token', common_session_token()); - common_element('h2', null, _('Address')); + $this->hidden('token', common_session_token()); + $this->element('h2', null, _('Address')); if ($user->sms) { - common_element_start('p'); + $this->elementStart('p'); $carrier = $user->getCarrier(); - common_element('span', 'address confirmed', $user->sms . ' (' . $carrier->name . ')'); - common_element('span', 'input_instructions', + $this->element('span', 'address confirmed', $user->sms . ' (' . $carrier->name . ')'); + $this->element('span', 'input_instructions', _('Current confirmed SMS-enabled phone number.')); - common_hidden('sms', $user->sms); - common_hidden('carrier', $user->carrier); - common_element_end('p'); - common_submit('remove', _('Remove')); + $this->hidden('sms', $user->sms); + $this->hidden('carrier', $user->carrier); + $this->elementEnd('p'); + $this->submit('remove', _('Remove')); } else { $confirm = $this->get_confirmation(); if ($confirm) { $carrier = Sms_carrier::staticGet($confirm->address_extra); - common_element_start('p'); - common_element('span', 'address unconfirmed', $confirm->address . ' (' . $carrier->name . ')'); - common_element('span', 'input_instructions', + $this->elementStart('p'); + $this->element('span', 'address unconfirmed', $confirm->address . ' (' . $carrier->name . ')'); + $this->element('span', 'input_instructions', _('Awaiting confirmation on this phone number.')); - common_hidden('sms', $confirm->address); - common_hidden('carrier', $confirm->address_extra); - common_element_end('p'); - common_submit('cancel', _('Cancel')); - common_input('code', _('Confirmation code'), null, + $this->hidden('sms', $confirm->address); + $this->hidden('carrier', $confirm->address_extra); + $this->elementEnd('p'); + $this->submit('cancel', _('Cancel')); + $this->input('code', _('Confirmation code'), null, _('Enter the code you received on your phone.')); - common_submit('confirm', _('Confirm')); + $this->submit('confirm', _('Confirm')); } else { - common_input('sms', _('SMS Phone number'), + $this->input('sms', _('SMS Phone number'), ($this->arg('sms')) ? $this->arg('sms') : null, _('Phone number, no punctuation or spaces, with area code')); $this->carrier_select(); - common_submit('add', _('Add')); + $this->submit('add', _('Add')); } } if ($user->sms) { - common_element('h2', null, _('Incoming email')); + $this->element('h2', null, _('Incoming email')); if ($user->incomingemail) { - common_element_start('p'); - common_element('span', 'address', $user->incomingemail); - common_element('span', 'input_instructions', + $this->elementStart('p'); + $this->element('span', 'address', $user->incomingemail); + $this->element('span', 'input_instructions', _('Send email to this address to post new notices.')); - common_element_end('p'); - common_submit('removeincoming', _('Remove')); + $this->elementEnd('p'); + $this->submit('removeincoming', _('Remove')); } - common_element_start('p'); - common_element('span', 'input_instructions', + $this->elementStart('p'); + $this->element('span', 'input_instructions', _('Make a new email address for posting to; cancels the old one.')); - common_element_end('p'); - common_submit('newincoming', _('New')); + $this->elementEnd('p'); + $this->submit('newincoming', _('New')); } - common_element('h2', null, _('Preferences')); + $this->element('h2', null, _('Preferences')); - common_checkbox('smsnotify', + $this->checkbox('smsnotify', _('Send me notices through SMS; I understand I may incur exorbitant charges from my carrier.'), $user->smsnotify); - common_submit('save', _('Save')); + $this->submit('save', _('Save')); - common_element_end('form'); + $this->elementEnd('form'); common_show_footer(); } @@ -307,19 +307,19 @@ class SmssettingsAction extends EmailsettingsAction $carrier = new Sms_carrier(); $cnt = $carrier->find(); - common_element_start('p'); - common_element('label', array('for' => 'carrier')); - common_element_start('select', array('name' => 'carrier', + $this->elementStart('p'); + $this->element('label', array('for' => 'carrier')); + $this->elementStart('select', array('name' => 'carrier', 'id' => 'carrier')); - common_element('option', array('value' => 0), + $this->element('option', array('value' => 0), _('Select a carrier')); while ($carrier->fetch()) { - common_element('option', array('value' => $carrier->id), + $this->element('option', array('value' => $carrier->id), $carrier->name); } - common_element_end('select'); - common_element_end('p'); - common_element('span', 'input_instructions', + $this->elementEnd('select'); + $this->elementEnd('p'); + $this->element('span', 'input_instructions', sprintf(_('Mobile carrier for your phone. '. 'If you know a carrier that accepts ' . 'SMS over email but isn\'t listed here, ' . diff --git a/actions/subscribe.php b/actions/subscribe.php index f33d1d207..99f9acc24 100644 --- a/actions/subscribe.php +++ b/actions/subscribe.php @@ -65,13 +65,13 @@ class SubscribeAction extends Action if ($this->boolean('ajax')) { common_start_html('text/xml;charset=utf-8', true); - common_element_start('head'); - common_element('title', null, _('Subscribed')); - common_element_end('head'); - common_element_start('body'); + $this->elementStart('head'); + $this->element('title', null, _('Subscribed')); + $this->elementEnd('head'); + $this->elementStart('body'); common_unsubscribe_form($other->getProfile()); - common_element_end('body'); - common_element_end('html'); + $this->elementEnd('body'); + $this->elementEnd('html'); } else { common_redirect(common_local_url('subscriptions', array('nickname' => $user->nickname))); diff --git a/actions/subscriptions.php b/actions/subscriptions.php index afe8fb260..7a87a144f 100644 --- a/actions/subscriptions.php +++ b/actions/subscriptions.php @@ -72,16 +72,16 @@ class SubscriptionsList extends ProfileList return; } - common_element_start('form', array('id' => 'subedit-' . $profile->id, + $this->elementStart('form', array('id' => 'subedit-' . $profile->id, 'method' => 'post', 'class' => 'subedit', 'action' => common_local_url('subedit'))); - common_hidden('token', common_session_token()); - common_hidden('profile', $profile->id); - common_checkbox('jabber', _('Jabber'), $sub->jabber); - common_checkbox('sms', _('SMS'), $sub->sms); - common_submit('save', _('Save')); - common_element_end('form'); + $this->hidden('token', common_session_token()); + $this->hidden('profile', $profile->id); + $this->checkbox('jabber', _('Jabber'), $sub->jabber); + $this->checkbox('sms', _('SMS'), $sub->sms); + $this->submit('save', _('Save')); + $this->elementEnd('form'); return; } } diff --git a/actions/tag.php b/actions/tag.php index 8a3f90c16..3096b75b3 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -51,7 +51,7 @@ class TagAction extends StreamAction function show_header($tag = false) { if ($tag) { - common_element('link', array('rel' => 'alternate', + $this->element('link', array('rel' => 'alternate', 'href' => common_local_url('tagrss', array('tag' => $tag)), 'type' => 'application/rss+xml', 'title' => sprintf(_('Feed for tag %s'), $tag))); @@ -68,9 +68,9 @@ class TagAction extends StreamAction if (!$tag) { $instr = $this->get_instructions(); $output = common_markup_to_html($instr); - common_element_start('div', 'instructions'); - common_raw($output); - common_element_end('div'); + $this->elementStart('div', 'instructions'); + $this->raw($output); + $this->elementEnd('div'); $this->public_views_menu(); } else { @@ -110,7 +110,7 @@ class TagAction extends StreamAction $cnt = $tags->find(); if ($cnt > 0) { - common_element_start('p', 'tagcloud'); + $this->elementStart('p', 'tagcloud'); $tw = array(); $sum = 0; @@ -125,7 +125,7 @@ class TagAction extends StreamAction $this->show_tag($tag, $weight, $weight/$sum); } - common_element_end('p'); + $this->elementEnd('p'); } } @@ -149,10 +149,10 @@ class TagAction extends StreamAction $cls = 'smallest'; } - common_element('a', array('class' => "$cls weight-$weight relative-$relative", + $this->element('a', array('class' => "$cls weight-$weight relative-$relative", 'href' => common_local_url('tag', array('tag' => $tag))), $tag); - common_text(' '); + $this->text(' '); } function show_notices($tag) diff --git a/actions/tagother.php b/actions/tagother.php index ff6788cc6..f0105ec8b 100644 --- a/actions/tagother.php +++ b/actions/tagother.php @@ -61,7 +61,7 @@ class TagotherAction extends Action $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); - common_element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE), + $this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE), 'class' => 'avatar stream', 'width' => AVATAR_PROFILE_SIZE, 'height' => AVATAR_PROFILE_SIZE, @@ -69,39 +69,39 @@ class TagotherAction extends Action ($profile->fullname) ? $profile->fullname : $profile->nickname)); - common_element('a', array('href' => $profile->profileurl, + $this->element('a', array('href' => $profile->profileurl, 'class' => 'external profile nickname'), $profile->nickname); if ($profile->fullname) { - common_element_start('div', 'fullname'); + $this->elementStart('div', 'fullname'); if ($profile->homepage) { - common_element('a', array('href' => $profile->homepage), + $this->element('a', array('href' => $profile->homepage), $profile->fullname); } else { - common_text($profile->fullname); + $this->text($profile->fullname); } - common_element_end('div'); + $this->elementEnd('div'); } if ($profile->location) { - common_element('div', 'location', $profile->location); + $this->element('div', 'location', $profile->location); } if ($profile->bio) { - common_element('div', 'bio', $profile->bio); + $this->element('div', 'bio', $profile->bio); } - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'id' => 'tag_user', 'name' => 'tagother', 'action' => $this->self_url())); - common_hidden('token', common_session_token()); - common_hidden('id', $profile->id); - common_input('tags', _('Tags'), + $this->hidden('token', common_session_token()); + $this->hidden('id', $profile->id); + $this->input('tags', _('Tags'), ($this->arg('tags')) ? $this->arg('tags') : implode(' ', Profile_tag::getTags($user->id, $profile->id)), _('Tags for this user (letters, numbers, -, ., and _), comma- or space- separated')); - common_submit('save', _('Save')); - common_element_end('form'); + $this->submit('save', _('Save')); + $this->elementEnd('form'); common_show_footer(); } @@ -162,20 +162,20 @@ class TagotherAction extends Action if ($this->boolean('ajax')) { common_start_html('text/xml'); - common_element_start('head'); - common_element('title', null, _('Tags')); - common_element_end('head'); - common_element_start('body'); - common_element_start('p', 'subtags'); + $this->elementStart('head'); + $this->element('title', null, _('Tags')); + $this->elementEnd('head'); + $this->elementStart('body'); + $this->elementStart('p', 'subtags'); foreach ($tags as $tag) { - common_element('a', array('href' => common_local_url($action, + $this->element('a', array('href' => common_local_url($action, array('nickname' => $user->nickname, 'tag' => $tag))), $tag); } - common_element_end('p'); - common_element_end('body'); - common_element_end('html'); + $this->elementEnd('p'); + $this->elementEnd('body'); + $this->elementEnd('html'); } else { common_redirect(common_local_url($action, array('nickname' => $user->nickname))); @@ -186,12 +186,12 @@ class TagotherAction extends Action { list($profile, $error) = $arr; if ($error) { - common_element('p', 'error', $error); + $this->element('p', 'error', $error); } else { - common_element_start('div', 'instructions'); - common_element('p', null, + $this->elementStart('div', 'instructions'); + $this->element('p', null, _('Use this form to add tags to your subscribers or subscriptions.')); - common_element_end('div'); + $this->elementEnd('div'); } } } diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php index e0731f66f..36d2a7e09 100644 --- a/actions/twitapidirect_messages.php +++ b/actions/twitapidirect_messages.php @@ -188,7 +188,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction { $this->init_document('xml'); - common_element_start('direct-messages', array('type' => 'array')); + $this->elementStart('direct-messages', array('type' => 'array')); if (is_array($messages)) { foreach ($message as $m) { @@ -202,7 +202,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction } } - common_element_end('direct-messages'); + $this->elementEnd('direct-messages'); $this->end_document('xml'); } @@ -236,13 +236,13 @@ class Twitapidirect_messagesAction extends TwitterapiAction $this->init_document('rss'); - common_element_start('channel'); - common_element('title', null, $title); + $this->elementStart('channel'); + $this->element('title', null, $title); - common_element('link', null, $link); - common_element('description', null, $subtitle); - common_element('language', null, 'en-us'); - common_element('ttl', null, '40'); + $this->element('link', null, $link); + $this->element('description', null, $subtitle); + $this->element('language', null, 'en-us'); + $this->element('ttl', null, '40'); if (is_array($message)) { foreach ($message as $m) { @@ -256,7 +256,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction } } - common_element_end('channel'); + $this->elementEnd('channel'); $this->end_twitter_rss(); } @@ -266,12 +266,12 @@ class Twitapidirect_messagesAction extends TwitterapiAction $this->init_document('atom'); - common_element('title', null, $title); + $this->element('title', null, $title); $siteserver = common_config('site', 'server'); - common_element('id', null, "tag:$siteserver,2008:DirectMessage"); - common_element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null); - common_element('updated', null, common_date_iso8601(strftime('%c'))); - common_element('subtitle', null, $subtitle); + $this->element('id', null, "tag:$siteserver,2008:DirectMessage"); + $this->element('link', array('href' => $link, 'rel' => 'alternate', 'type' => 'text/html'), null); + $this->element('updated', null, common_date_iso8601(strftime('%c'))); + $this->element('subtitle', null, $subtitle); if (is_array($message)) { foreach ($message as $m) { diff --git a/actions/twitapifriendships.php b/actions/twitapifriendships.php index ba4afe441..458ff48a5 100644 --- a/actions/twitapifriendships.php +++ b/actions/twitapifriendships.php @@ -142,7 +142,7 @@ class TwitapifriendshipsAction extends TwitterapiAction switch ($apidata['content-type']) { case 'xml': $this->init_document('xml'); - common_element('friends', null, $result); + $this->element('friends', null, $result); $this->end_document('xml'); break; case 'json': diff --git a/actions/twitapihelp.php b/actions/twitapihelp.php index 1b84cb11b..531c6e9d3 100644 --- a/actions/twitapihelp.php +++ b/actions/twitapihelp.php @@ -34,7 +34,7 @@ class TwitapihelpAction extends TwitterapiAction if ($apidata['content-type'] == 'xml') { $this->init_document('xml'); - common_element('ok', null, 'true'); + $this->element('ok', null, 'true'); $this->end_document('xml'); } elseif ($apidata['content-type'] == 'json') { $this->init_document('json'); diff --git a/actions/twitapilaconica.php b/actions/twitapilaconica.php index 722423fae..34c8f88fc 100644 --- a/actions/twitapilaconica.php +++ b/actions/twitapilaconica.php @@ -70,7 +70,7 @@ class TwitapilaconicaAction extends TwitterapiAction switch ($apidata['content-type']) { case 'xml': $this->init_document('xml'); - common_element('version', null, LACONICA_VERSION); + $this->element('version', null, LACONICA_VERSION); $this->end_document('xml'); break; case 'json': @@ -115,10 +115,10 @@ class TwitapilaconicaAction extends TwitterapiAction switch ($apidata['content-type']) { case 'xml': $this->init_document('xml'); - common_element_start('config'); + $this->elementStart('config'); // XXX: check that all sections and settings are legal XML elements foreach ($keys as $section => $settings) { - common_element_start($section); + $this->elementStart($section); foreach ($settings as $setting) { $value = common_config($section, $setting); if (is_array($value)) { @@ -128,11 +128,11 @@ class TwitapilaconicaAction extends TwitterapiAction } else if ($value === true) { $value = 'true'; } - common_element($setting, null, $value); + $this->element($setting, null, $value); } - common_element_end($section); + $this->elementEnd($section); } - common_element_end('config'); + $this->elementEnd('config'); $this->end_document('xml'); break; case 'json': diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php index e629d5cc4..8d175ecab 100644 --- a/actions/twitapistatuses.php +++ b/actions/twitapistatuses.php @@ -538,11 +538,11 @@ class TwitapistatusesAction extends TwitterapiAction { switch ($type) { case 'xml': - common_element_start('users', array('type' => 'array')); + $this->elementStart('users', array('type' => 'array')); foreach ($profiles as $profile) { $this->show_profile($profile); } - common_element_end('users'); + $this->elementEnd('users'); break; case 'json': $arrays = array(); diff --git a/actions/twittersettings.php b/actions/twittersettings.php index 9e7e4cae8..663688037 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -44,52 +44,52 @@ class TwittersettingsAction extends SettingsAction } $this->form_header(_('Twitter settings'), $msg, $success); - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'id' => 'twittersettings', 'action' => common_local_url('twittersettings'))); - common_hidden('token', common_session_token()); + $this->hidden('token', common_session_token()); - common_element('h2', null, _('Twitter Account')); + $this->element('h2', null, _('Twitter Account')); if ($fuser) { - common_element_start('p'); + $this->elementStart('p'); - common_element('span', 'twitter_user', $fuser->nickname); - common_element('a', array('href' => $fuser->uri), $fuser->uri); - common_element('span', 'input_instructions', + $this->element('span', 'twitter_user', $fuser->nickname); + $this->element('a', array('href' => $fuser->uri), $fuser->uri); + $this->element('span', 'input_instructions', _('Current verified Twitter account.')); - common_hidden('flink_foreign_id', $flink->foreign_id); - common_element_end('p'); - common_submit('remove', _('Remove')); + $this->hidden('flink_foreign_id', $flink->foreign_id); + $this->elementEnd('p'); + $this->submit('remove', _('Remove')); } else { - common_input('twitter_username', _('Twitter user name'), + $this->input('twitter_username', _('Twitter user name'), ($this->arg('twitter_username')) ? $this->arg('twitter_username') : $profile->nickname, _('No spaces, please.')); // hey, it's what Twitter says - common_password('twitter_password', _('Twitter password')); + $this->password('twitter_password', _('Twitter password')); } - common_element('h2', null, _('Preferences')); + $this->element('h2', null, _('Preferences')); - common_checkbox('noticesync', _('Automatically send my notices to Twitter.'), + $this->checkbox('noticesync', _('Automatically send my notices to Twitter.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND) : true); - common_checkbox('replysync', _('Send local "@" replies to Twitter.'), + $this->checkbox('replysync', _('Send local "@" replies to Twitter.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true); - common_checkbox('friendsync', _('Subscribe to my Twitter friends here.'), + $this->checkbox('friendsync', _('Subscribe to my Twitter friends here.'), ($flink) ? ($flink->friendsync & FOREIGN_FRIEND_RECV) : false); if ($flink) { - common_submit('save', _('Save')); + $this->submit('save', _('Save')); } else { - common_submit('add', _('Add')); + $this->submit('add', _('Add')); } $this->show_twitter_subscriptions(); - common_element_end('form'); + $this->elementEnd('form'); common_show_footer(); } @@ -131,9 +131,9 @@ class TwittersettingsAction extends SettingsAction if ($friends_count > 0) { - common_element('h3', null, _('Twitter Friends')); - common_element_start('div', array('id' => 'subscriptions')); - common_element_start('ul', array('id' => 'subscriptions_avatars')); + $this->element('h3', null, _('Twitter Friends')); + $this->elementStart('div', array('id' => 'subscriptions')); + $this->elementStart('ul', array('id' => 'subscriptions_avatars')); for ($i = 0; $i < min($friends_count, SUBSCRIPTIONS); $i++) { @@ -144,28 +144,28 @@ class TwittersettingsAction extends SettingsAction continue; } - common_element_start('li'); - common_element_start('a', array('title' => ($other->fullname) ? + $this->elementStart('li'); + $this->elementStart('a', array('title' => ($other->fullname) ? $other->fullname : $other->nickname, 'href' => $other->profileurl, 'rel' => 'contact', 'class' => 'subscription')); $avatar = $other->getAvatar(AVATAR_MINI_SIZE); - common_element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_MINI_SIZE)), + $this->element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_MINI_SIZE)), 'width' => AVATAR_MINI_SIZE, 'height' => AVATAR_MINI_SIZE, 'class' => 'avatar mini', 'alt' => ($other->fullname) ? $other->fullname : $other->nickname)); - common_element_end('a'); - common_element_end('li'); + $this->elementEnd('a'); + $this->elementEnd('li'); } - common_element_end('ul'); - common_element_end('div'); + $this->elementEnd('ul'); + $this->elementEnd('div'); } @@ -173,13 +173,13 @@ class TwittersettingsAction extends SettingsAction /* if ($subs_count > SUBSCRIPTIONS) { - common_element_start('p', array('id' => 'subscriptions_viewall')); + $this->elementStart('p', array('id' => 'subscriptions_viewall')); - common_element('a', array('href' => common_local_url('subscriptions', + $this->element('a', array('href' => common_local_url('subscriptions', array('nickname' => $profile->nickname)), 'class' => 'moresubscriptions'), _('All subscriptions')); - common_element_end('p'); + $this->elementEnd('p'); } */ diff --git a/actions/unsubscribe.php b/actions/unsubscribe.php index 1c2e13635..455c5e28e 100644 --- a/actions/unsubscribe.php +++ b/actions/unsubscribe.php @@ -67,13 +67,13 @@ class UnsubscribeAction extends Action if ($this->boolean('ajax')) { common_start_html('text/xml;charset=utf-8', true); - common_element_start('head'); - common_element('title', null, _('Unsubscribed')); - common_element_end('head'); - common_element_start('body'); + $this->elementStart('head'); + $this->element('title', null, _('Unsubscribed')); + $this->elementEnd('head'); + $this->elementStart('body'); common_subscribe_form($other); - common_element_end('body'); - common_element_end('html'); + $this->elementEnd('body'); + $this->elementEnd('html'); } else { common_redirect(common_local_url('subscriptions', array('nickname' => $user->nickname))); diff --git a/actions/userauthorization.php b/actions/userauthorization.php index 05efbc16c..196fae9ad 100644 --- a/actions/userauthorization.php +++ b/actions/userauthorization.php @@ -84,51 +84,51 @@ class UserauthorizationAction extends Action $avatar = $req->get_parameter('omb_listenee_avatar'); common_show_header(_('Authorize subscription')); - common_element('p', null, _('Please check these details to make sure '. + $this->element('p', null, _('Please check these details to make sure '. 'that you want to subscribe to this user\'s notices. '. 'If you didn\'t just ask to subscribe to someone\'s notices, '. 'click "Cancel".')); - common_element_start('div', 'profile'); + $this->elementStart('div', 'profile'); if ($avatar) { - common_element('img', array('src' => $avatar, + $this->element('img', array('src' => $avatar, 'class' => 'avatar profile', 'width' => AVATAR_PROFILE_SIZE, 'height' => AVATAR_PROFILE_SIZE, 'alt' => $nickname)); } - common_element('a', array('href' => $profile, + $this->element('a', array('href' => $profile, 'class' => 'external profile nickname'), $nickname); if ($fullname) { - common_element_start('div', 'fullname'); + $this->elementStart('div', 'fullname'); if ($homepage) { - common_element('a', array('href' => $homepage), + $this->element('a', array('href' => $homepage), $fullname); } else { - common_text($fullname); + $this->text($fullname); } - common_element_end('div'); + $this->elementEnd('div'); } if ($location) { - common_element('div', 'location', $location); + $this->element('div', 'location', $location); } if ($bio) { - common_element('div', 'bio', $bio); + $this->element('div', 'bio', $bio); } - common_element_start('div', 'license'); - common_element('a', array('href' => $license, + $this->elementStart('div', 'license'); + $this->element('a', array('href' => $license, 'class' => 'license'), $license); - common_element_end('div'); - common_element_end('div'); - common_element_start('form', array('method' => 'post', + $this->elementEnd('div'); + $this->elementEnd('div'); + $this->elementStart('form', array('method' => 'post', 'id' => 'userauthorization', 'name' => 'userauthorization', 'action' => common_local_url('userauthorization'))); - common_hidden('token', common_session_token()); - common_submit('accept', _('Accept')); - common_submit('reject', _('Reject')); - common_element_end('form'); + $this->hidden('token', common_session_token()); + $this->submit('accept', _('Accept')); + $this->submit('reject', _('Reject')); + $this->elementEnd('form'); common_show_footer(); } @@ -328,18 +328,18 @@ class UserauthorizationAction extends Action function show_accept_message($tok) { common_show_header(_('Subscription authorized')); - common_element('p', null, + $this->element('p', null, _('The subscription has been authorized, but no '. 'callback URL was passed. Check with the site\'s instructions for '. 'details on how to authorize the subscription. Your subscription token is:')); - common_element('blockquote', 'token', $tok); + $this->element('blockquote', 'token', $tok); common_show_footer(); } function show_reject_message($tok) { common_show_header(_('Subscription rejected')); - common_element('p', null, + $this->element('p', null, _('The subscription has been rejected, but no '. 'callback URL was passed. Check with the site\'s instructions for '. 'details on how to fully reject the subscription.')); diff --git a/actions/xrds.php b/actions/xrds.php index 7edc6aa39..9c51f1dd2 100644 --- a/actions/xrds.php +++ b/actions/xrds.php @@ -47,14 +47,14 @@ class XrdsAction extends Action header('Content-Type: application/xrds+xml'); common_start_xml(); - common_element_start('XRDS', array('xmlns' => 'xri://$xrds')); + $this->elementStart('XRDS', array('xmlns' => 'xri://$xrds')); - common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', + $this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', 'xml:id' => 'oauth', 'xmlns:simple' => 'http://xrds-simple.net/core/1.0', 'version' => '2.0')); - common_element('Type', null, 'xri://$xrds*simple'); + $this->element('Type', null, 'xri://$xrds*simple'); $this->show_service(OAUTH_ENDPOINT_REQUEST, common_local_url('requesttoken'), @@ -77,16 +77,16 @@ class XrdsAction extends Action array(OAUTH_AUTH_HEADER, OAUTH_POST_BODY), array(OAUTH_HMAC_SHA1)); - common_element_end('XRD'); + $this->elementEnd('XRD'); # XXX: decide whether to include user's ID/nickname in postNotice URL - common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', + $this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', 'xml:id' => 'omb', 'xmlns:simple' => 'http://xrds-simple.net/core/1.0', 'version' => '2.0')); - common_element('Type', null, 'xri://$xrds*simple'); + $this->element('Type', null, 'xri://$xrds*simple'); $this->show_service(OMB_ENDPOINT_POSTNOTICE, common_local_url('postnotice')); @@ -94,44 +94,44 @@ class XrdsAction extends Action $this->show_service(OMB_ENDPOINT_UPDATEPROFILE, common_local_url('updateprofile')); - common_element_end('XRD'); + $this->elementEnd('XRD'); - common_element_start('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', + $this->elementStart('XRD', array('xmlns' => 'xri://$xrd*($v*2.0)', 'version' => '2.0')); - common_element('Type', null, 'xri://$xrds*simple'); + $this->element('Type', null, 'xri://$xrds*simple'); $this->show_service(OAUTH_DISCOVERY, '#oauth'); $this->show_service(OMB_NAMESPACE, '#omb'); - common_element_end('XRD'); + $this->elementEnd('XRD'); - common_element_end('XRDS'); + $this->elementEnd('XRDS'); common_end_xml(); } function show_service($type, $uri, $params=null, $sigs=null, $localId=null) { - common_element_start('Service'); + $this->elementStart('Service'); if ($uri) { - common_element('URI', null, $uri); + $this->element('URI', null, $uri); } - common_element('Type', null, $type); + $this->element('Type', null, $type); if ($params) { foreach ($params as $param) { - common_element('Type', null, $param); + $this->element('Type', null, $param); } } if ($sigs) { foreach ($sigs as $sig) { - common_element('Type', null, $sig); + $this->element('Type', null, $sig); } } if ($localId) { - common_element('LocalID', null, $localId); + $this->element('LocalID', null, $localId); } - common_element_end('Service'); + $this->elementEnd('Service'); } } \ No newline at end of file diff --git a/lib/action.php b/lib/action.php index d5060758e..d02a1b709 100644 --- a/lib/action.php +++ b/lib/action.php @@ -314,7 +314,7 @@ class Action extends HTMLOutputter // lawsuit { $this->elementStart('div', array('id' => 'content')); $this->showPageTitle(); - $this->showPageNotice(); + $this->showPageNoticeBlock(); $this->elementStart('div', array('id' => 'content_inner')); // show the actual content (forms, lists, whatever) $this->showContent(); @@ -326,19 +326,24 @@ class Action extends HTMLOutputter // lawsuit $this->element('h1', NULL, $this->title()); } + function showPageNoticeBlock() + { + $this->elementStart('dl', array('id' => 'page_notice', + 'class' => 'system_notice')); + $this->element('dt', null, _('Page notice')); + $this->elementStart('dd', null); + $this->showPageNotice(); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + } + } + // SHOULD overload (unless there's not a notice) function showPageNotice() { - $this->elementStart('dl', array('id' => 'page_notice', - 'class' => 'system_notice')); - $this->element('dt', null, _('Page notice')); - $this->elementStart('dd', null); - // Output a bunch of paragraphs here - $this->elementEnd('dd'); - $this->elementEnd('dl'); } - + // MUST overload function showContent() -- cgit v1.2.3-54-g00ecf From 4b0cf99e56f965e10eeb8b8b19e7b405bda49eaf Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 23:03:38 +0000 Subject: Convert use of common_server_error and common_user_error to methods on Action --- actions/accesstoken.php | 2 +- actions/all.php | 4 ++-- actions/allrss.php | 2 +- actions/api.php | 4 ++-- actions/avatarbynickname.php | 10 ++++----- actions/block.php | 12 +++++------ actions/confirmaddress.php | 14 ++++++------ actions/deleteprofile.php | 2 +- actions/disfavor.php | 8 +++---- actions/doc.php | 2 +- actions/emailsettings.php | 12 +++++------ actions/facebookremove.php | 2 +- actions/favor.php | 8 +++---- actions/favoritesrss.php | 2 +- actions/finishaddopenid.php | 2 +- actions/finishopenidlogin.php | 12 +++++------ actions/finishremotesubscribe.php | 34 ++++++++++++++--------------- actions/foaf.php | 4 ++-- actions/imsettings.php | 8 +++---- actions/invite.php | 2 +- actions/login.php | 8 +++---- actions/logout.php | 2 +- actions/microsummary.php | 4 ++-- actions/newmessage.php | 10 ++++----- actions/newnotice.php | 4 ++-- actions/noticesearch.php | 2 +- actions/nudge.php | 6 +++--- actions/openidlogin.php | 2 +- actions/othersettings.php | 2 +- actions/peopletag.php | 2 +- actions/postnotice.php | 14 ++++++------ actions/profilesettings.php | 12 +++++------ actions/public.php | 2 +- actions/recoverpassword.php | 26 +++++++++++----------- actions/register.php | 10 ++++----- actions/remotesubscribe.php | 4 ++-- actions/replies.php | 4 ++-- actions/repliesrss.php | 2 +- actions/requesttoken.php | 2 +- actions/showfavorites.php | 6 +++--- actions/showmessage.php | 4 ++-- actions/shownotice.php | 6 +++--- actions/showstream.php | 4 ++-- actions/smssettings.php | 8 +++---- actions/subedit.php | 12 +++++------ actions/subscribe.php | 8 +++---- actions/tagother.php | 12 +++++------ actions/tagrss.php | 2 +- actions/twitapiaccount.php | 16 +++++++------- actions/twitapiblocks.php | 8 +++---- actions/twitapidirect_messages.php | 18 ++++++++-------- actions/twitapifavorites.php | 20 ++++++++--------- actions/twitapifriendships.php | 16 +++++++------- actions/twitapihelp.php | 4 ++-- actions/twitapilaconica.php | 6 +++--- actions/twitapinotifications.php | 4 ++-- actions/twitapistatuses.php | 44 +++++++++++++++++++------------------- actions/twitapiusers.php | 4 ++-- actions/twittersettings.php | 2 +- actions/unblock.php | 10 ++++----- actions/unsubscribe.php | 10 ++++----- actions/updateprofile.php | 36 +++++++++++++++---------------- actions/userauthorization.php | 12 +++++------ actions/userbyid.php | 4 ++-- actions/userrss.php | 4 ++-- actions/xrds.php | 2 +- lib/action.php | 4 ++-- 67 files changed, 275 insertions(+), 275 deletions(-) (limited to 'actions') diff --git a/actions/accesstoken.php b/actions/accesstoken.php index 072ce27eb..ad03b7019 100644 --- a/actions/accesstoken.php +++ b/actions/accesstoken.php @@ -38,7 +38,7 @@ class AccesstokenAction extends Action common_debug('printing the access token', __FILE__); print $token; } catch (OAuthException $e) { - common_server_error($e->getMessage()); + $this->serverError($e->getMessage()); } } } diff --git a/actions/all.php b/actions/all.php index a8a74fb33..4ad7f12ae 100644 --- a/actions/all.php +++ b/actions/all.php @@ -33,14 +33,14 @@ class AllAction extends StreamAction $user = User::staticGet('nickname', $nickname); if (!$user) { - $this->client_error(_('No such user.')); + $this->clientError(_('No such user.')); return; } $profile = $user->getProfile(); if (!$profile) { - common_server_error(_('User has no profile.')); + $this->serverError(_('User has no profile.')); return; } diff --git a/actions/allrss.php b/actions/allrss.php index 660afb9e2..56818d605 100644 --- a/actions/allrss.php +++ b/actions/allrss.php @@ -34,7 +34,7 @@ class AllrssAction extends Rss10Action $this->user = User::staticGet('nickname', $nickname); if (!$this->user) { - common_user_error(_('No such user.')); + $this->clientError(_('No such user.')); return false; } else { return true; diff --git a/actions/api.php b/actions/api.php index 9cbf9a468..64971774d 100644 --- a/actions/api.php +++ b/actions/api.php @@ -103,10 +103,10 @@ class ApiAction extends Action call_user_func(array($action_obj, $this->api_method), $_REQUEST, $apidata); } else { - common_user_error("API method not found!", $code=404); + $this->clientError("API method not found!", $code=404); } } else { - common_user_error("API method not found!", $code=404); + $this->clientError("API method not found!", $code=404); } } diff --git a/actions/avatarbynickname.php b/actions/avatarbynickname.php index 666f386f6..d2d078b61 100644 --- a/actions/avatarbynickname.php +++ b/actions/avatarbynickname.php @@ -26,28 +26,28 @@ class AvatarbynicknameAction extends Action parent::handle($args); $nickname = $this->trimmed('nickname'); if (!$nickname) { - $this->client_error(_('No nickname.')); + $this->clientError(_('No nickname.')); return; } $size = $this->trimmed('size'); if (!$size) { - $this->client_error(_('No size.')); + $this->clientError(_('No size.')); return; } $size = strtolower($size); if (!in_array($size, array('original', '96', '48', '24'))) { - $this->client_error(_('Invalid size.')); + $this->clientError(_('Invalid size.')); return; } $user = User::staticGet('nickname', $nickname); if (!$user) { - $this->client_error(_('No such user.')); + $this->clientError(_('No such user.')); return; } $profile = $user->getProfile(); if (!$profile) { - $this->client_error(_('User has no profile.')); + $this->clientError(_('User has no profile.')); return; } if ($size == 'original') { diff --git a/actions/block.php b/actions/block.php index f8f6f24fd..738cbfbf7 100644 --- a/actions/block.php +++ b/actions/block.php @@ -30,28 +30,28 @@ class BlockAction extends Action parent::prepare($args); if (!common_logged_in()) { - $this->client_error(_('Not logged in.')); + $this->clientError(_('Not logged in.')); return false; } $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->client_error(_('There was a problem with your session token. Try again, please.')); + $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } $id = $this->trimmed('blockto'); if (!$id) { - $this->client_error(_('No profile specified.')); + $this->clientError(_('No profile specified.')); return false; } $this->profile = Profile::staticGet('id', $id); if (!$this->profile) { - $this->client_error(_('No profile with that ID.')); + $this->clientError(_('No profile with that ID.')); return false; } @@ -119,14 +119,14 @@ class BlockAction extends Action $cur = common_current_user(); if ($cur->hasBlocked($this->profile)) { - $this->client_error(_('You have already blocked this user.')); + $this->clientError(_('You have already blocked this user.')); return; } $result = $cur->block($this->profile); if (!$result) { - $this->server_error(_('Failed to save block information.')); + $this->serverError(_('Failed to save block information.')); return; } diff --git a/actions/confirmaddress.php b/actions/confirmaddress.php index 31a157768..53410fbe6 100644 --- a/actions/confirmaddress.php +++ b/actions/confirmaddress.php @@ -32,26 +32,26 @@ class ConfirmaddressAction extends Action } $code = $this->trimmed('code'); if (!$code) { - $this->client_error(_('No confirmation code.')); + $this->clientError(_('No confirmation code.')); return; } $confirm = Confirm_address::staticGet('code', $code); if (!$confirm) { - $this->client_error(_('Confirmation code not found.')); + $this->clientError(_('Confirmation code not found.')); return; } $cur = common_current_user(); if ($cur->id != $confirm->user_id) { - $this->client_error(_('That confirmation code is not for you!')); + $this->clientError(_('That confirmation code is not for you!')); return; } $type = $confirm->address_type; if (!in_array($type, array('email', 'jabber', 'sms'))) { - $this->server_error(sprintf(_('Unrecognized address type %s'), $type)); + $this->serverError(sprintf(_('Unrecognized address type %s'), $type)); return; } if ($cur->$type == $confirm->address) { - $this->client_error(_('That address has already been confirmed.')); + $this->clientError(_('That address has already been confirmed.')); return; } @@ -71,7 +71,7 @@ class ConfirmaddressAction extends Action if (!$result) { common_log_db_error($cur, 'UPDATE', __FILE__); - $this->server_error(_('Couldn\'t update user.')); + $this->serverError(_('Couldn\'t update user.')); return; } @@ -83,7 +83,7 @@ class ConfirmaddressAction extends Action if (!$result) { common_log_db_error($confirm, 'DELETE', __FILE__); - $this->server_error(_('Couldn\'t delete email confirmation.')); + $this->serverError(_('Couldn\'t delete email confirmation.')); return; } diff --git a/actions/deleteprofile.php b/actions/deleteprofile.php index ef4687d5f..cc236f847 100644 --- a/actions/deleteprofile.php +++ b/actions/deleteprofile.php @@ -24,7 +24,7 @@ class DeleteprofileAction extends Action function handle($args) { parent::handle($args); - $this->server_error(_('Code not yet ready.')); + $this->serverError(_('Code not yet ready.')); return; if ('POST' === $_SERVER['REQUEST_METHOD']) { $this->handle_post(); diff --git a/actions/disfavor.php b/actions/disfavor.php index 9a27f34b1..fc36f7c75 100644 --- a/actions/disfavor.php +++ b/actions/disfavor.php @@ -28,7 +28,7 @@ class DisfavorAction extends Action parent::handle($args); if (!common_logged_in()) { - common_user_error(_('Not logged in.')); + $this->clientError(_('Not logged in.')); return; } @@ -46,7 +46,7 @@ class DisfavorAction extends Action $token = $this->trimmed('token-'.$notice->id); if (!$token || $token != common_session_token()) { - $this->client_error(_("There was a problem with your session token. Try again, please.")); + $this->clientError(_("There was a problem with your session token. Try again, please.")); return; } @@ -54,7 +54,7 @@ class DisfavorAction extends Action $fave->user_id = $this->id; $fave->notice_id = $notice->id; if (!$fave->find(true)) { - $this->client_error(_('This notice is not a favorite!')); + $this->clientError(_('This notice is not a favorite!')); return; } @@ -62,7 +62,7 @@ class DisfavorAction extends Action if (!$result) { common_log_db_error($fave, 'DELETE', __FILE__); - $this->server_error(_('Could not delete favorite.')); + $this->serverError(_('Could not delete favorite.')); return; } diff --git a/actions/doc.php b/actions/doc.php index 98da31267..3d14b25b8 100644 --- a/actions/doc.php +++ b/actions/doc.php @@ -28,7 +28,7 @@ class DocAction extends Action $title = $this->trimmed('title'); $filename = INSTALLDIR.'/doc/'.$title; if (!file_exists($filename)) { - common_user_error(_('No such document.')); + $this->clientError(_('No such document.')); return; } $c = file_get_contents($filename); diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 39f186bff..6210c07b4 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -182,7 +182,7 @@ class EmailsettingsAction extends SettingsAction if ($result === false) { common_log_db_error($user, 'UPDATE', __FILE__); - common_server_error(_('Couldn\'t update user.')); + $this->serverError(_('Couldn\'t update user.')); return; } @@ -232,7 +232,7 @@ class EmailsettingsAction extends SettingsAction if ($result === false) { common_log_db_error($confirm, 'INSERT', __FILE__); - common_server_error(_('Couldn\'t insert confirmation code.')); + $this->serverError(_('Couldn\'t insert confirmation code.')); return; } @@ -260,7 +260,7 @@ class EmailsettingsAction extends SettingsAction if (!$result) { common_log_db_error($confirm, 'DELETE', __FILE__); - $this->server_error(_('Couldn\'t delete email confirmation.')); + $this->serverError(_('Couldn\'t delete email confirmation.')); return; } @@ -286,7 +286,7 @@ class EmailsettingsAction extends SettingsAction $result = $user->updateKeys($original); if (!$result) { common_log_db_error($user, 'UPDATE', __FILE__); - common_server_error(_('Couldn\'t update user.')); + $this->serverError(_('Couldn\'t update user.')); return; } $user->query('COMMIT'); @@ -308,7 +308,7 @@ class EmailsettingsAction extends SettingsAction if (!$user->updateKeys($orig)) { common_log_db_error($user, 'UPDATE', __FILE__); - $this->server_error(_("Couldn't update user record.")); + $this->serverError(_("Couldn't update user record.")); } $this->show_form(_('Incoming email address removed.'), true); @@ -323,7 +323,7 @@ class EmailsettingsAction extends SettingsAction if (!$user->updateKeys($orig)) { common_log_db_error($user, 'UPDATE', __FILE__); - $this->server_error(_("Couldn't update user record.")); + $this->serverError(_("Couldn't update user record.")); } $this->show_form(_('New incoming email address added.'), true); diff --git a/actions/facebookremove.php b/actions/facebookremove.php index a200fefbf..d0a0dd951 100644 --- a/actions/facebookremove.php +++ b/actions/facebookremove.php @@ -53,7 +53,7 @@ class FacebookremoveAction extends FacebookAction if (!$result) { common_log_db_error($flink, 'DELETE', __FILE__); - common_server_error(_('Couldn\'t remove Facebook user.')); + $this->serverError(_('Couldn\'t remove Facebook user.')); return; } diff --git a/actions/favor.php b/actions/favor.php index 1dfef9bbb..8d751a7a9 100644 --- a/actions/favor.php +++ b/actions/favor.php @@ -29,7 +29,7 @@ class FavorAction extends Action parent::handle($args); if (!common_logged_in()) { - common_user_error(_('Not logged in.')); + $this->clientError(_('Not logged in.')); return; } @@ -48,19 +48,19 @@ class FavorAction extends Action $token = $this->trimmed('token-'.$notice->id); if (!$token || $token != common_session_token()) { - $this->client_error(_("There was a problem with your session token. Try again, please.")); + $this->clientError(_("There was a problem with your session token. Try again, please.")); return; } if ($user->hasFave($notice)) { - $this->client_error(_('This notice is already a favorite!')); + $this->clientError(_('This notice is already a favorite!')); return; } $fave = Fave::addNew($user, $notice); if (!$fave) { - $this->server_error(_('Could not create favorite.')); + $this->serverError(_('Could not create favorite.')); return; } diff --git a/actions/favoritesrss.php b/actions/favoritesrss.php index 8c7ce52bf..3f4ffc63a 100644 --- a/actions/favoritesrss.php +++ b/actions/favoritesrss.php @@ -34,7 +34,7 @@ class FavoritesrssAction extends Rss10Action $this->user = User::staticGet('nickname', $nickname); if (!$this->user) { - common_user_error(_('No such user.')); + $this->clientError(_('No such user.')); return false; } else { return true; diff --git a/actions/finishaddopenid.php b/actions/finishaddopenid.php index 7de631712..708e8d4bf 100644 --- a/actions/finishaddopenid.php +++ b/actions/finishaddopenid.php @@ -28,7 +28,7 @@ class FinishaddopenidAction extends Action { parent::handle($args); if (!common_logged_in()) { - common_user_error(_('Not logged in.')); + $this->clientError(_('Not logged in.')); } else { $this->try_login(); } diff --git a/actions/finishopenidlogin.php b/actions/finishopenidlogin.php index 112429002..bc33ac330 100644 --- a/actions/finishopenidlogin.php +++ b/actions/finishopenidlogin.php @@ -28,7 +28,7 @@ class FinishopenidloginAction extends Action { parent::handle($args); if (common_logged_in()) { - common_user_error(_('Already logged in.')); + $this->clientError(_('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { @@ -179,7 +179,7 @@ class FinishopenidloginAction extends Action # FIXME: save invite code before redirect, and check here if (common_config('site', 'closed') || common_config('site', 'inviteonly')) { - common_user_error(_('Registration not allowed.')); + $this->clientError(_('Registration not allowed.')); return; } @@ -205,7 +205,7 @@ class FinishopenidloginAction extends Action list($display, $canonical, $sreg) = $this->get_saved_values(); if (!$display || !$canonical) { - common_server_error(_('Stored OpenID not found.')); + $this->serverError(_('Stored OpenID not found.')); return; } @@ -214,7 +214,7 @@ class FinishopenidloginAction extends Action $other = oid_get_user($canonical); if ($other) { - common_server_error(_('Creating new account for OpenID that already has a user.')); + $this->serverError(_('Creating new account for OpenID that already has a user.')); return; } @@ -274,14 +274,14 @@ class FinishopenidloginAction extends Action list($display, $canonical, $sreg) = $this->get_saved_values(); if (!$display || !$canonical) { - common_server_error(_('Stored OpenID not found.')); + $this->serverError(_('Stored OpenID not found.')); return; } $result = oid_link_user($user->id, $canonical, $display); if (!$result) { - common_server_error(_('Error connecting user to OpenID.')); + $this->serverError(_('Error connecting user to OpenID.')); return; } diff --git a/actions/finishremotesubscribe.php b/actions/finishremotesubscribe.php index cee3a1818..f9094a50c 100644 --- a/actions/finishremotesubscribe.php +++ b/actions/finishremotesubscribe.php @@ -30,14 +30,14 @@ class FinishremotesubscribeAction extends Action parent::handle($args); if (common_logged_in()) { - common_user_error(_('You can use the local subscription!')); + $this->clientError(_('You can use the local subscription!')); return; } $omb = $_SESSION['oauth_authorization_request']; if (!$omb) { - common_user_error(_('Not expecting this response!')); + $this->clientError(_('Not expecting this response!')); return; } @@ -51,38 +51,38 @@ class FinishremotesubscribeAction extends Action # I think this is the success metric if ($token != $omb['token']) { - common_user_error(_('Not authorized.')); + $this->clientError(_('Not authorized.')); return; } $version = $req->get_parameter('omb_version'); if ($version != OMB_VERSION_01) { - common_user_error(_('Unknown version of OMB protocol.')); + $this->clientError(_('Unknown version of OMB protocol.')); return; } $nickname = $req->get_parameter('omb_listener_nickname'); if (!$nickname) { - common_user_error(_('No nickname provided by remote server.')); + $this->clientError(_('No nickname provided by remote server.')); return; } $profile_url = $req->get_parameter('omb_listener_profile'); if (!$profile_url) { - common_user_error(_('No profile URL returned by server.')); + $this->clientError(_('No profile URL returned by server.')); return; } if (!Validate::uri($profile_url, array('allowed_schemes' => array('http', 'https')))) { - common_user_error(_('Invalid profile URL returned by server.')); + $this->clientError(_('Invalid profile URL returned by server.')); return; } if ($profile_url == common_local_url('showstream', array('nickname' => $nickname))) { - common_user_error(_('You can use the local subscription!')); + $this->clientError(_('You can use the local subscription!')); return; } @@ -91,14 +91,14 @@ class FinishremotesubscribeAction extends Action $user = User::staticGet('nickname', $omb['listenee']); if (!$user) { - common_user_error(_('User being listened to doesn\'t exist.')); + $this->clientError(_('User being listened to doesn\'t exist.')); return; } $other = User::staticGet('uri', $omb['listener']); if ($other) { - common_user_error(_('You can use the local subscription!')); + $this->clientError(_('You can use the local subscription!')); return; } @@ -111,7 +111,7 @@ class FinishremotesubscribeAction extends Action list($newtok, $newsecret) = $this->access_token($omb); if (!$newtok || !$newsecret) { - common_user_error(_('Couldn\'t convert request tokens to access tokens.')); + $this->clientError(_('Couldn\'t convert request tokens to access tokens.')); return; } @@ -155,7 +155,7 @@ class FinishremotesubscribeAction extends Action $profile->created = DB_DataObject_Cast::dateTime(); # current time $id = $profile->insert(); if (!$id) { - common_server_error(_('Error inserting new profile')); + $this->serverError(_('Error inserting new profile')); return; } $remote->id = $id; @@ -163,7 +163,7 @@ class FinishremotesubscribeAction extends Action if ($avatar_url) { if (!$this->add_avatar($profile, $avatar_url)) { - common_server_error(_('Error inserting avatar')); + $this->serverError(_('Error inserting avatar')); return; } } @@ -173,19 +173,19 @@ class FinishremotesubscribeAction extends Action if ($exists) { if (!$remote->update($orig_remote)) { - common_server_error(_('Error updating remote profile')); + $this->serverError(_('Error updating remote profile')); return; } } else { $remote->created = DB_DataObject_Cast::dateTime(); # current time if (!$remote->insert()) { - common_server_error(_('Error inserting remote profile')); + $this->serverError(_('Error inserting remote profile')); return; } } if ($user->hasBlocked($profile)) { - $this->client_error(_('That user has blocked you from subscribing.')); + $this->clientError(_('That user has blocked you from subscribing.')); return; } @@ -215,7 +215,7 @@ class FinishremotesubscribeAction extends Action if (!$result) { common_log_db_error($sub, ($sub_exists) ? 'UPDATE' : 'INSERT', __FILE__); - common_user_error(_('Couldn\'t insert new subscription.')); + $this->clientError(_('Couldn\'t insert new subscription.')); return; } diff --git a/actions/foaf.php b/actions/foaf.php index 6f73ce505..a0f8a1ff3 100644 --- a/actions/foaf.php +++ b/actions/foaf.php @@ -40,14 +40,14 @@ class FoafAction extends Action $user = User::staticGet('nickname', $nickname); if (!$user) { - common_user_error(_('No such user.'), 404); + $this->clientError(_('No such user.'), 404); return; } $profile = $user->getProfile(); if (!$profile) { - common_server_error(_('User has no profile.'), 500); + $this->serverError(_('User has no profile.'), 500); return; } diff --git a/actions/imsettings.php b/actions/imsettings.php index 693f49efa..14df3451a 100644 --- a/actions/imsettings.php +++ b/actions/imsettings.php @@ -149,7 +149,7 @@ class ImsettingsAction extends SettingsAction if ($result === false) { common_log_db_error($user, 'UPDATE', __FILE__); - common_server_error(_('Couldn\'t update user.')); + $this->serverError(_('Couldn\'t update user.')); return; } @@ -199,7 +199,7 @@ class ImsettingsAction extends SettingsAction if ($result === false) { common_log_db_error($confirm, 'INSERT', __FILE__); - common_server_error(_('Couldn\'t insert confirmation code.')); + $this->serverError(_('Couldn\'t insert confirmation code.')); return; } @@ -231,7 +231,7 @@ class ImsettingsAction extends SettingsAction if (!$result) { common_log_db_error($confirm, 'DELETE', __FILE__); - $this->server_error(_('Couldn\'t delete email confirmation.')); + $this->serverError(_('Couldn\'t delete email confirmation.')); return; } @@ -257,7 +257,7 @@ class ImsettingsAction extends SettingsAction $result = $user->updateKeys($original); if (!$result) { common_log_db_error($user, 'UPDATE', __FILE__); - common_server_error(_('Couldn\'t update user.')); + $this->serverError(_('Couldn\'t update user.')); return; } $user->query('COMMIT'); diff --git a/actions/invite.php b/actions/invite.php index 15233602e..879264deb 100644 --- a/actions/invite.php +++ b/actions/invite.php @@ -31,7 +31,7 @@ class InviteAction extends Action { parent::handle($args); if (!common_logged_in()) { - $this->client_error(sprintf(_('You must be logged in to invite other users to use %s'), + $this->clientError(sprintf(_('You must be logged in to invite other users to use %s'), common_config('site', 'name'))); return; } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { diff --git a/actions/login.php b/actions/login.php index fd98e656d..060d16ad6 100644 --- a/actions/login.php +++ b/actions/login.php @@ -31,7 +31,7 @@ class LoginAction extends Action { parent::handle($args); if (common_is_real_login()) { - common_user_error(_('Already logged in.')); + $this->clientError(_('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->check_login(); } else { @@ -46,7 +46,7 @@ class LoginAction extends Action # CSRF protection - token set in common_notice_form() $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->client_error(_('There was a problem with your session token. Try again, please.')); + $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } @@ -55,7 +55,7 @@ class LoginAction extends Action if (common_check_user($nickname, $password)) { # success! if (!common_set_user($nickname)) { - common_server_error(_('Error setting user.')); + $this->serverError(_('Error setting user.')); return; } common_real_login(true); @@ -81,7 +81,7 @@ class LoginAction extends Action # success! if (!common_set_user($user)) { - common_server_error(_('Error setting user.')); + $this->serverError(_('Error setting user.')); return; } diff --git a/actions/logout.php b/actions/logout.php index 201378730..3001f3613 100644 --- a/actions/logout.php +++ b/actions/logout.php @@ -33,7 +33,7 @@ class LogoutAction extends Action { parent::handle($args); if (!common_logged_in()) { - common_user_error(_('Not logged in.')); + $this->clientError(_('Not logged in.')); } else { common_set_user(null); common_real_login(false); # not logged in diff --git a/actions/microsummary.php b/actions/microsummary.php index 13ddc4e3e..b46c5bee5 100644 --- a/actions/microsummary.php +++ b/actions/microsummary.php @@ -31,14 +31,14 @@ class MicrosummaryAction extends Action $user = User::staticGet('nickname', $nickname); if (!$user) { - $this->client_error(_('No such user'), 404); + $this->clientError(_('No such user'), 404); return; } $notice = $user->getCurrentNotice(); if (!$notice) { - $this->client_error(_('No current status'), 404); + $this->clientError(_('No current status'), 404); } header('Content-Type: text/plain'); diff --git a/actions/newmessage.php b/actions/newmessage.php index 6221b67e9..510a5f8f3 100644 --- a/actions/newmessage.php +++ b/actions/newmessage.php @@ -27,7 +27,7 @@ class NewmessageAction extends Action parent::handle($args); if (!common_logged_in()) { - $this->client_error(_('Not logged in.'), 403); + $this->clientError(_('Not logged in.'), 403); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->save_new_message(); } else { @@ -71,10 +71,10 @@ class NewmessageAction extends Action $this->show_form(_('No recipient specified.')); return; } else if (!$user->mutuallySubscribed($other)) { - $this->client_error(_('You can\'t send a message to this user.'), 404); + $this->clientError(_('You can\'t send a message to this user.'), 404); return; } else if ($user->id == $other->id) { - $this->client_error(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'), 403); + $this->clientError(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'), 403); return; } @@ -113,12 +113,12 @@ class NewmessageAction extends Action $other = User::staticGet('id', $to); if (!$other) { - $this->client_error(_('No such user'), 404); + $this->clientError(_('No such user'), 404); return; } if (!$user->mutuallySubscribed($other)) { - $this->client_error(_('You can\'t send a message to this user.'), 404); + $this->clientError(_('You can\'t send a message to this user.'), 404); return; } diff --git a/actions/newnotice.php b/actions/newnotice.php index 89792d95a..cb02854a1 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -29,13 +29,13 @@ class NewnoticeAction extends Action parent::handle($args); if (!common_logged_in()) { - common_user_error(_('Not logged in.')); + $this->clientError(_('Not logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { # CSRF protection - token set in common_notice_form() $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->client_error(_('There was a problem with your session token. Try again, please.')); + $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } diff --git a/actions/noticesearch.php b/actions/noticesearch.php index d998b9da8..336e39bd3 100644 --- a/actions/noticesearch.php +++ b/actions/noticesearch.php @@ -97,7 +97,7 @@ class NoticesearchAction extends SearchAction $profile = $notice->getProfile(); if (!$profile) { common_log_db_error($notice, 'SELECT', __FILE__); - $this->server_error(_('Notice without matching profile')); + $this->serverError(_('Notice without matching profile')); return; } # XXX: RDFa diff --git a/actions/nudge.php b/actions/nudge.php index de930e462..49223d431 100644 --- a/actions/nudge.php +++ b/actions/nudge.php @@ -29,7 +29,7 @@ class NudgeAction extends Action parent::handle($args); if (!common_logged_in()) { - $this->client_error(_('Not logged in.')); + $this->clientError(_('Not logged in.')); return; } @@ -46,12 +46,12 @@ class NudgeAction extends Action $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->client_error(_('There was a problem with your session token. Try again, please.')); + $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } if (!$other->email || !$other->emailnotifynudge) { - $this->client_error(_('This user doesn\'t allow nudges or hasn\'t confirmed or set his email yet.')); + $this->clientError(_('This user doesn\'t allow nudges or hasn\'t confirmed or set his email yet.')); return; } diff --git a/actions/openidlogin.php b/actions/openidlogin.php index 82791af34..d1989e0de 100644 --- a/actions/openidlogin.php +++ b/actions/openidlogin.php @@ -28,7 +28,7 @@ class OpenidloginAction extends Action { parent::handle($args); if (common_logged_in()) { - common_user_error(_('Already logged in.')); + $this->clientError(_('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $openid_url = $this->trimmed('openid_url'); diff --git a/actions/othersettings.php b/actions/othersettings.php index 97cbd0094..51f6f8197 100644 --- a/actions/othersettings.php +++ b/actions/othersettings.php @@ -177,7 +177,7 @@ class OthersettingsAction extends SettingsAction if ($result === false) { common_log_db_error($user, 'UPDATE', __FILE__); - common_server_error(_('Couldn\'t update user.')); + $this->serverError(_('Couldn\'t update user.')); return; } diff --git a/actions/peopletag.php b/actions/peopletag.php index 2680638d7..7bcfcb93e 100644 --- a/actions/peopletag.php +++ b/actions/peopletag.php @@ -32,7 +32,7 @@ class PeopletagAction extends Action $tag = $this->trimmed('tag'); if (!common_valid_profile_tag($tag)) { - $this->client_error(sprintf(_('Not a valid people tag: %s'), $tag)); + $this->clientError(sprintf(_('Not a valid people tag: %s'), $tag)); return; } diff --git a/actions/postnotice.php b/actions/postnotice.php index dec62a678..0b4735296 100644 --- a/actions/postnotice.php +++ b/actions/postnotice.php @@ -36,7 +36,7 @@ class PostnoticeAction extends Action print "omb_version=".OMB_VERSION_01; } } catch (OAuthException $e) { - common_server_error($e->getMessage()); + $this->serverError($e->getMessage()); return; } } @@ -45,36 +45,36 @@ class PostnoticeAction extends Action { $version = $req->get_parameter('omb_version'); if ($version != OMB_VERSION_01) { - common_user_error(_('Unsupported OMB version'), 400); + $this->clientError(_('Unsupported OMB version'), 400); return false; } # First, check to see $listenee = $req->get_parameter('omb_listenee'); $remote_profile = Remote_profile::staticGet('uri', $listenee); if (!$remote_profile) { - common_user_error(_('Profile unknown'), 403); + $this->clientError(_('Profile unknown'), 403); return false; } $sub = Subscription::staticGet('token', $token->key); if (!$sub) { - common_user_error(_('No such subscription'), 403); + $this->clientError(_('No such subscription'), 403); return false; } $content = $req->get_parameter('omb_notice_content'); $content_shortened = common_shorten_links($content); if (mb_strlen($content_shortened) > 140) { - common_user_error(_('Invalid notice content'), 400); + $this->clientError(_('Invalid notice content'), 400); return false; } $notice_uri = $req->get_parameter('omb_notice'); if (!Validate::uri($notice_uri) && !common_valid_tag($notice_uri)) { - common_user_error(_('Invalid notice uri'), 400); + $this->clientError(_('Invalid notice uri'), 400); return false; } $notice_url = $req->get_parameter('omb_notice_url'); if ($notice_url && !common_valid_http_url($notice_url)) { - common_user_error(_('Invalid notice url'), 400); + $this->clientError(_('Invalid notice url'), 400); return false; } $notice = Notice::staticGet('uri', $notice_uri); diff --git a/actions/profilesettings.php b/actions/profilesettings.php index ef45fc1d9..6ad3f2ef5 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -125,7 +125,7 @@ class ProfilesettingsAction extends SettingsAction if (!$profile) { common_log_db_error($user, 'SELECT', __FILE__); - $this->server_error(_('User without matching profile')); + $this->serverError(_('User without matching profile')); return; } @@ -298,7 +298,7 @@ class ProfilesettingsAction extends SettingsAction if ($result === false) { common_log_db_error($user, 'UPDATE', __FILE__); - common_server_error(_('Couldn\'t update user.')); + $this->serverError(_('Couldn\'t update user.')); return; } else { # Re-initialize language environment if it changed @@ -318,7 +318,7 @@ class ProfilesettingsAction extends SettingsAction if ($result === false) { common_log_db_error($user, 'UPDATE', __FILE__); - common_server_error(_('Couldn\'t update user for autosubscribe.')); + $this->serverError(_('Couldn\'t update user for autosubscribe.')); return; } } @@ -341,7 +341,7 @@ class ProfilesettingsAction extends SettingsAction if (!$result) { common_log_db_error($profile, 'UPDATE', __FILE__); - common_server_error(_('Couldn\'t save profile.')); + $this->serverError(_('Couldn\'t save profile.')); return; } @@ -350,7 +350,7 @@ class ProfilesettingsAction extends SettingsAction $result = $user->setSelfTags($tags); if (!$result) { - common_server_error(_('Couldn\'t save tags.')); + $this->serverError(_('Couldn\'t save tags.')); return; } @@ -475,7 +475,7 @@ class ProfilesettingsAction extends SettingsAction } if (!$user->update($original)) { - common_server_error(_('Can\'t save new password.')); + $this->serverError(_('Can\'t save new password.')); return; } diff --git a/actions/public.php b/actions/public.php index 62071eccc..0ceeef98e 100644 --- a/actions/public.php +++ b/actions/public.php @@ -165,7 +165,7 @@ class PublicAction extends Action NOTICES_PER_PAGE + 1); if (!$notice) { - $this->server_error(_('Could not retrieve public stream.')); + $this->serverError(_('Could not retrieve public stream.')); return; } diff --git a/actions/recoverpassword.php b/actions/recoverpassword.php index 3e6ecfb1f..3d839e751 100644 --- a/actions/recoverpassword.php +++ b/actions/recoverpassword.php @@ -30,7 +30,7 @@ class RecoverpasswordAction extends Action { parent::handle($args); if (common_logged_in()) { - $this->client_error(_('You are already logged in!')); + $this->clientError(_('You are already logged in!')); return; } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($this->arg('recover')) { @@ -38,7 +38,7 @@ class RecoverpasswordAction extends Action } else if ($this->arg('reset')) { $this->reset_password(); } else { - $this->client_error(_('Unexpected form submission.')); + $this->clientError(_('Unexpected form submission.')); } } else { if ($this->trimmed('code')) { @@ -56,18 +56,18 @@ class RecoverpasswordAction extends Action $confirm = Confirm_address::staticGet('code', $code); if (!$confirm) { - $this->client_error(_('No such recovery code.')); + $this->clientError(_('No such recovery code.')); return; } if ($confirm->address_type != 'recover') { - $this->client_error(_('Not a recovery code.')); + $this->clientError(_('Not a recovery code.')); return; } $user = User::staticGet($confirm->user_id); if (!$user) { - $this->server_error(_('Recovery code for unknown user.')); + $this->serverError(_('Recovery code for unknown user.')); return; } @@ -80,7 +80,7 @@ class RecoverpasswordAction extends Action if (!$result) { common_log_db_error($confirm, 'DELETE', __FILE__); - common_server_error(_('Error with confirmation code.')); + $this->serverError(_('Error with confirmation code.')); return; } @@ -91,7 +91,7 @@ class RecoverpasswordAction extends Action common_log(LOG_WARNING, 'Attempted redemption on recovery code ' . 'that is ' . $touched . ' seconds old. '); - $this->client_error(_('This confirmation code is too old. ' . + $this->clientError(_('This confirmation code is too old. ' . 'Please start again.')); return; } @@ -105,7 +105,7 @@ class RecoverpasswordAction extends Action $result = $user->updateKeys($orig); if (!$result) { common_log_db_error($user, 'UPDATE', __FILE__); - $this->server_error(_('Could not update user with confirmed email address.')); + $this->serverError(_('Could not update user with confirmed email address.')); return; } } @@ -240,7 +240,7 @@ class RecoverpasswordAction extends Action } if (!$user->email && !$confirm_email) { - $this->client_error(_('No registered email address for that user.')); + $this->clientError(_('No registered email address for that user.')); return; } @@ -254,7 +254,7 @@ class RecoverpasswordAction extends Action if (!$confirm->insert()) { common_log_db_error($confirm, 'INSERT', __FILE__); - $this->server_error(_('Error saving address confirmation.')); + $this->serverError(_('Error saving address confirmation.')); return; } @@ -298,7 +298,7 @@ class RecoverpasswordAction extends Action $user = $this->get_temp_user(); if (!$user) { - $this->client_error(_('Unexpected password reset.')); + $this->clientError(_('Unexpected password reset.')); return; } @@ -322,14 +322,14 @@ class RecoverpasswordAction extends Action if (!$user->update($original)) { common_log_db_error($user, 'UPDATE', __FILE__); - common_server_error(_('Can\'t save new password.')); + $this->serverError(_('Can\'t save new password.')); return; } $this->clear_temp_user(); if (!common_set_user($user->nickname)) { - common_server_error(_('Error setting user.')); + $this->serverError(_('Error setting user.')); return; } diff --git a/actions/register.php b/actions/register.php index bac179687..b4d0d43fb 100644 --- a/actions/register.php +++ b/actions/register.php @@ -26,9 +26,9 @@ class RegisterAction extends Action parent::handle($args); if (common_config('site', 'closed')) { - common_user_error(_('Registration not allowed.')); + $this->clientError(_('Registration not allowed.')); } else if (common_logged_in()) { - common_user_error(_('Already logged in.')); + $this->clientError(_('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { $this->try_register(); } else { @@ -65,7 +65,7 @@ class RegisterAction extends Action } if (common_config('site', 'inviteonly') && !($code && $invite)) { - $this->client_error(_('Sorry, only invited people can register.')); + $this->clientError(_('Sorry, only invited people can register.')); return; } @@ -115,7 +115,7 @@ class RegisterAction extends Action } # success! if (!common_set_user($user)) { - common_server_error(_('Error setting user.')); + $this->serverError(_('Error setting user.')); return; } # this is a real login @@ -179,7 +179,7 @@ class RegisterAction extends Action } if (common_config('site', 'inviteonly') && !($code && $invite)) { - $this->client_error(_('Sorry, only invited people can register.')); + $this->clientError(_('Sorry, only invited people can register.')); return; } diff --git a/actions/remotesubscribe.php b/actions/remotesubscribe.php index b9e29d645..32e9bf3d3 100644 --- a/actions/remotesubscribe.php +++ b/actions/remotesubscribe.php @@ -30,7 +30,7 @@ class RemotesubscribeAction extends Action parent::handle($args); if (common_logged_in()) { - common_user_error(_('You can use the local subscription!')); + $this->clientError(_('You can use the local subscription!')); return; } @@ -342,7 +342,7 @@ class RemotesubscribeAction extends Action $profile = $user->getProfile(); if (!$profile) { common_log_db_error($user, 'SELECT', __FILE__); - $this->server_error(_('User without matching profile')); + $this->serverError(_('User without matching profile')); return; } diff --git a/actions/replies.php b/actions/replies.php index 878550888..84fd894ff 100644 --- a/actions/replies.php +++ b/actions/replies.php @@ -40,7 +40,7 @@ class RepliesAction extends StreamAction $profile = $user->getProfile(); if (!$profile) { - common_server_error(_('User has no profile.')); + $this->serverError(_('User has no profile.')); return; } @@ -57,7 +57,7 @@ class RepliesAction extends StreamAction function no_such_user() { - common_user_error(_('No such user.')); + $this->clientError(_('No such user.')); } function show_header($user) diff --git a/actions/repliesrss.php b/actions/repliesrss.php index 5f85f8d2e..43be133a4 100644 --- a/actions/repliesrss.php +++ b/actions/repliesrss.php @@ -34,7 +34,7 @@ class RepliesrssAction extends Rss10Action $this->user = User::staticGet('nickname', $nickname); if (!$this->user) { - common_user_error(_('No such user.')); + $this->clientError(_('No such user.')); return false; } else { return true; diff --git a/actions/requesttoken.php b/actions/requesttoken.php index a74548739..378db4403 100644 --- a/actions/requesttoken.php +++ b/actions/requesttoken.php @@ -39,7 +39,7 @@ class RequesttokenAction extends Action $token = $server->fetch_request_token($req); print $token; } catch (OAuthException $e) { - common_server_error($e->getMessage()); + $this->serverError($e->getMessage()); } } } diff --git a/actions/showfavorites.php b/actions/showfavorites.php index 1dec3ba5b..caa823893 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -33,14 +33,14 @@ class ShowfavoritesAction extends StreamAction $user = User::staticGet('nickname', $nickname); if (!$user) { - $this->client_error(_('No such user.')); + $this->clientError(_('No such user.')); return; } $profile = $user->getProfile(); if (!$profile) { - common_server_error(_('User has no profile.')); + $this->serverError(_('User has no profile.')); return; } @@ -90,7 +90,7 @@ class ShowfavoritesAction extends StreamAction $notice = $user->favoriteNotices(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); if (!$notice) { - $this->server_error(_('Could not retrieve favorite notices.')); + $this->serverError(_('Could not retrieve favorite notices.')); return; } diff --git a/actions/showmessage.php b/actions/showmessage.php index 25330a568..d13e9f671 100644 --- a/actions/showmessage.php +++ b/actions/showmessage.php @@ -32,7 +32,7 @@ class ShowmessageAction extends MailboxAction $message = $this->get_message(); if (!$message) { - $this->client_error(_('No such message.'), 404); + $this->clientError(_('No such message.'), 404); return; } @@ -41,7 +41,7 @@ class ShowmessageAction extends MailboxAction if ($cur && ($cur->id == $message->from_profile || $cur->id == $message->to_profile)) { $this->show_page($cur, 1); } else { - $this->client_error(_('Only the sender and recipient may read this message.'), 403); + $this->clientError(_('Only the sender and recipient may read this message.'), 403); return; } } diff --git a/actions/shownotice.php b/actions/shownotice.php index c519af0ba..82d4bd270 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -37,14 +37,14 @@ class ShownoticeAction extends StreamAction $this->notice = Notice::staticGet($id); if (!$this->notice) { - $this->client_error(_('No such notice.'), 404); + $this->clientError(_('No such notice.'), 404); return false; } $this->profile = $this->notice->getProfile(); if (!$this->profile) { - $this->server_error(_('Notice has no profile'), 500); + $this->serverError(_('Notice has no profile'), 500); return false; } @@ -119,6 +119,6 @@ class ShownoticeAction extends StreamAction function no_such_notice() { - common_user_error(_('No such notice.')); + $this->clientError(_('No such notice.')); } } diff --git a/actions/showstream.php b/actions/showstream.php index 9a59f7ae4..ed38c67f9 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -56,7 +56,7 @@ class ShowstreamAction extends StreamAction $profile = $user->getProfile(); if (!$profile) { - common_server_error(_('User has no profile.')); + $this->serverError(_('User has no profile.')); return; } @@ -159,7 +159,7 @@ class ShowstreamAction extends StreamAction function no_such_user() { - $this->client_error(_('No such user.'), 404); + $this->clientError(_('No such user.'), 404); } function show_profile($profile) diff --git a/actions/smssettings.php b/actions/smssettings.php index 1be45d1ce..c5879e4d9 100644 --- a/actions/smssettings.php +++ b/actions/smssettings.php @@ -168,7 +168,7 @@ class SmssettingsAction extends EmailsettingsAction if ($result === false) { common_log_db_error($user, 'UPDATE', __FILE__); - common_server_error(_('Couldn\'t update user.')); + $this->serverError(_('Couldn\'t update user.')); return; } @@ -218,7 +218,7 @@ class SmssettingsAction extends EmailsettingsAction if ($result === false) { common_log_db_error($confirm, 'INSERT', __FILE__); - common_server_error(_('Couldn\'t insert confirmation code.')); + $this->serverError(_('Couldn\'t insert confirmation code.')); return; } @@ -254,7 +254,7 @@ class SmssettingsAction extends EmailsettingsAction if (!$result) { common_log_db_error($confirm, 'DELETE', __FILE__); - $this->server_error(_('Couldn\'t delete email confirmation.')); + $this->serverError(_('Couldn\'t delete email confirmation.')); return; } @@ -283,7 +283,7 @@ class SmssettingsAction extends EmailsettingsAction $result = $user->updateKeys($original); if (!$result) { common_log_db_error($user, 'UPDATE', __FILE__); - common_server_error(_('Couldn\'t update user.')); + $this->serverError(_('Couldn\'t update user.')); return; } $user->query('COMMIT'); diff --git a/actions/subedit.php b/actions/subedit.php index 1142b7a03..e22384869 100644 --- a/actions/subedit.php +++ b/actions/subedit.php @@ -30,28 +30,28 @@ class SubeditAction extends Action parent::prepare($args); if (!common_logged_in()) { - $this->client_error(_('Not logged in.')); + $this->clientError(_('Not logged in.')); return false; } $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->client_error(_('There was a problem with your session token. Try again, please.')); + $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } $id = $this->trimmed('profile'); if (!$id) { - $this->client_error(_('No profile specified.')); + $this->clientError(_('No profile specified.')); return false; } $this->profile = Profile::staticGet('id', $id); if (!$this->profile) { - $this->client_error(_('No profile with that ID.')); + $this->clientError(_('No profile with that ID.')); return false; } @@ -68,7 +68,7 @@ class SubeditAction extends Action 'subscribed' => $this->profile->id)); if (!$sub) { - $this->client_error(_('You are not subscribed to that profile.')); + $this->clientError(_('You are not subscribed to that profile.')); return false; } @@ -81,7 +81,7 @@ class SubeditAction extends Action if (!$result) { common_log_db_error($sub, 'UPDATE', __FILE__); - $this->server_error(_('Could not save subscription.')); + $this->serverError(_('Could not save subscription.')); return false; } diff --git a/actions/subscribe.php b/actions/subscribe.php index 99f9acc24..b6f03f0f1 100644 --- a/actions/subscribe.php +++ b/actions/subscribe.php @@ -27,7 +27,7 @@ class SubscribeAction extends Action parent::handle($args); if (!common_logged_in()) { - common_user_error(_('Not logged in.')); + $this->clientError(_('Not logged in.')); return; } @@ -43,7 +43,7 @@ class SubscribeAction extends Action $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->client_error(_('There was a problem with your session token. Try again, please.')); + $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } @@ -52,14 +52,14 @@ class SubscribeAction extends Action $other = User::staticGet('id', $other_id); if (!$other) { - $this->client_error(_('Not a local user.')); + $this->clientError(_('Not a local user.')); return; } $result = subs_subscribe_to($user, $other); if($result != true) { - common_user_error($result); + $this->clientError($result); return; } diff --git a/actions/tagother.php b/actions/tagother.php index f0105ec8b..e11e3a00d 100644 --- a/actions/tagother.php +++ b/actions/tagother.php @@ -30,7 +30,7 @@ class TagotherAction extends Action parent::handle($args); if (!common_logged_in()) { - $this->client_error(_('Not logged in'), 403); + $this->clientError(_('Not logged in'), 403); return; } @@ -39,12 +39,12 @@ class TagotherAction extends Action } else { $id = $this->trimmed('id'); if (!$id) { - $this->client_error(_('No id argument.')); + $this->clientError(_('No id argument.')); return; } $profile = Profile::staticGet('id', $id); if (!$profile) { - $this->client_error(_('No profile with that ID.')); + $this->clientError(_('No profile with that ID.')); return; } $this->show_form($profile); @@ -121,7 +121,7 @@ class TagotherAction extends Action $profile = Profile::staticGet('id', $id); if (!$profile) { - $this->client_error(_('No such profile.')); + $this->clientError(_('No such profile.')); return; } @@ -147,14 +147,14 @@ class TagotherAction extends Action !Subscription::pkeyGet(array('subscriber' => $profile->id, 'subscribed' => $user->id))) { - $this->client_error(_('You can only tag people you are subscribed to or who are subscribed to you.')); + $this->clientError(_('You can only tag people you are subscribed to or who are subscribed to you.')); return; } $result = Profile_tag::setTags($user->id, $profile->id, $tags); if (!$result) { - $this->client_error(_('Could not save tags.')); + $this->clientError(_('Could not save tags.')); return; } diff --git a/actions/tagrss.php b/actions/tagrss.php index 912d71413..b0227ab39 100644 --- a/actions/tagrss.php +++ b/actions/tagrss.php @@ -32,7 +32,7 @@ class TagrssAction extends Rss10Action $this->tag = Notice_tag::staticGet('tag', $tag); if (!$this->tag) { - common_user_error(_('No such tag.')); + $this->clientError(_('No such tag.')); return false; } else { return true; diff --git a/actions/twitapiaccount.php b/actions/twitapiaccount.php index 79e1ed990..e51a29a2d 100644 --- a/actions/twitapiaccount.php +++ b/actions/twitapiaccount.php @@ -29,7 +29,7 @@ class TwitapiaccountAction extends TwitterapiAction parent::handle($args); if (!in_array($apidata['content-type'], array('xml', 'json'))) { - common_user_error(_('API method not found!'), $code = 404); + $this->clientError(_('API method not found!'), $code = 404); return; } @@ -39,7 +39,7 @@ class TwitapiaccountAction extends TwitterapiAction function end_session($args, $apidata) { parent::handle($args); - common_server_error(_('API method under construction.'), $code=501); + $this->serverError(_('API method under construction.'), $code=501); } function update_location($args, $apidata) @@ -47,7 +47,7 @@ class TwitapiaccountAction extends TwitterapiAction parent::handle($args); if ($_SERVER['REQUEST_METHOD'] != 'POST') { - $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']); + $this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']); return; } @@ -56,7 +56,7 @@ class TwitapiaccountAction extends TwitterapiAction if (!is_null($location) && strlen($location) > 255) { // XXX: But Twitter just truncates and runs with it. -- Zach - $this->client_error(_('That\'s too long. Max notice size is 255 chars.'), 406, $apidate['content-type']); + $this->clientError(_('That\'s too long. Max notice size is 255 chars.'), 406, $apidate['content-type']); return; } @@ -64,7 +64,7 @@ class TwitapiaccountAction extends TwitterapiAction $profile = $user->getProfile(); if (!$profile) { - common_server_error(_('User has no profile.')); + $this->serverError(_('User has no profile.')); return; } @@ -75,7 +75,7 @@ class TwitapiaccountAction extends TwitterapiAction if (!$result) { common_log_db_error($profile, 'UPDATE', __FILE__); - common_server_error(_('Couldn\'t save profile.')); + $this->serverError(_('Couldn\'t save profile.')); return; } @@ -91,12 +91,12 @@ class TwitapiaccountAction extends TwitterapiAction function update_delivery_device($args, $apidata) { parent::handle($args); - common_server_error(_('API method under construction.'), $code=501); + $this->serverError(_('API method under construction.'), $code=501); } function rate_limit_status($args, $apidata) { parent::handle($args); - common_server_error(_('API method under construction.'), $code=501); + $this->serverError(_('API method under construction.'), $code=501); } } \ No newline at end of file diff --git a/actions/twitapiblocks.php b/actions/twitapiblocks.php index 5d64f2f7d..8135adef3 100644 --- a/actions/twitapiblocks.php +++ b/actions/twitapiblocks.php @@ -32,7 +32,7 @@ class TwitapiblocksAction extends TwitterapiAction $blockee = $this->get_user($apidata['api_arg'], $apidata); if (!$blockee) { - $this->client_error('Not Found', 404, $apidata['content-type']); + $this->clientError('Not Found', 404, $apidata['content-type']); return; } @@ -44,7 +44,7 @@ class TwitapiblocksAction extends TwitterapiAction $this->show_profile($blockee, $type); $this->end_document($type); } else { - common_server_error(_('Block user failed.')); + $this->serverError(_('Block user failed.')); } } @@ -54,7 +54,7 @@ class TwitapiblocksAction extends TwitterapiAction $blockee = $this->get_user($apidata['api_arg'], $apidata); if (!$blockee) { - $this->client_error('Not Found', 404, $apidata['content-type']); + $this->clientError('Not Found', 404, $apidata['content-type']); return; } @@ -66,7 +66,7 @@ class TwitapiblocksAction extends TwitterapiAction $this->show_profile($blockee, $type); $this->end_document($type); } else { - common_server_error(_('Unblock user failed.')); + $this->serverError(_('Unblock user failed.')); } } } \ No newline at end of file diff --git a/actions/twitapidirect_messages.php b/actions/twitapidirect_messages.php index 36d2a7e09..db55e8cd0 100644 --- a/actions/twitapidirect_messages.php +++ b/actions/twitapidirect_messages.php @@ -108,7 +108,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction $this->show_json_dmsgs($message); break; default: - common_user_error(_('API method not found!'), $code = 404); + $this->clientError(_('API method not found!'), $code = 404); } } @@ -119,7 +119,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction parent::handle($args); if ($_SERVER['REQUEST_METHOD'] != 'POST') { - $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']); + $this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']); return; } @@ -134,11 +134,11 @@ class Twitapidirect_messagesAction extends TwitterapiAction $content = $this->trimmed('text'); if (!$content) { - $this->client_error(_('No message text!'), $code = 406, $apidata['content-type']); + $this->clientError(_('No message text!'), $code = 406, $apidata['content-type']); } else { $content_shortened = common_shorten_links($content); if (mb_strlen($content_shortened) > 140) { - $this->client_error(_('That\'s too long. Max message size is 140 chars.'), + $this->clientError(_('That\'s too long. Max message size is 140 chars.'), $code = 406, $apidata['content-type']); return; } @@ -147,15 +147,15 @@ class Twitapidirect_messagesAction extends TwitterapiAction $other = $this->get_user($this->trimmed('user')); if (!$other) { - $this->client_error(_('Recipient user not found.'), $code = 403, $apidata['content-type']); + $this->clientError(_('Recipient user not found.'), $code = 403, $apidata['content-type']); return; } else if (!$user->mutuallySubscribed($other)) { - $this->client_error(_('Can\'t send direct messages to users who aren\'t your friend.'), + $this->clientError(_('Can\'t send direct messages to users who aren\'t your friend.'), $code = 403, $apidata['content-type']); return; } else if ($user->id == $other->id) { // Sending msgs to yourself is allowed by Twitter - $this->client_error(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'), + $this->clientError(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'), $code = 403, $apidata['content-type']); return; } @@ -164,7 +164,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction html_entity_decode($content, ENT_NOQUOTES, 'UTF-8'), $source); if (is_string($message)) { - $this->server_error($message); + $this->serverError($message); return; } @@ -181,7 +181,7 @@ class Twitapidirect_messagesAction extends TwitterapiAction function destroy($args, $apidata) { parent::handle($args); - common_server_error(_('API method under construction.'), $code=501); + $this->serverError(_('API method under construction.'), $code=501); } function show_xml_dmsgs($message) diff --git a/actions/twitapifavorites.php b/actions/twitapifavorites.php index 55e04732f..737b7229f 100644 --- a/actions/twitapifavorites.php +++ b/actions/twitapifavorites.php @@ -32,14 +32,14 @@ class TwitapifavoritesAction extends TwitterapiAction $user = $this->get_user($apidata['api_arg'], $apidata); if (!$user) { - $this->client_error('Not Found', 404, $apidata['content-type']); + $this->clientError('Not Found', 404, $apidata['content-type']); return; } $profile = $user->getProfile(); if (!$profile) { - common_server_error(_('User has no profile.')); + $this->serverError(_('User has no profile.')); return; } @@ -56,7 +56,7 @@ class TwitapifavoritesAction extends TwitterapiAction $notice = $user->favoriteNotices((($page-1)*20), $count); if (!$notice) { - common_server_error(_('Could not retrieve favorite notices.')); + $this->serverError(_('Could not retrieve favorite notices.')); return; } @@ -82,7 +82,7 @@ class TwitapifavoritesAction extends TwitterapiAction $this->show_json_timeline($notice); break; default: - common_user_error(_('API method not found!'), $code = 404); + $this->clientError(_('API method not found!'), $code = 404); } } @@ -94,12 +94,12 @@ class TwitapifavoritesAction extends TwitterapiAction // Check for RESTfulness if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) { // XXX: Twitter just prints the err msg, no XML / JSON. - $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']); + $this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']); return; } if (!in_array($apidata['content-type'], array('xml', 'json'))) { - common_user_error(_('API method not found!'), $code = 404); + $this->clientError(_('API method not found!'), $code = 404); return; } @@ -109,20 +109,20 @@ class TwitapifavoritesAction extends TwitterapiAction $notice = Notice::staticGet($notice_id); if (!$notice) { - $this->client_error(_('No status found with that ID.'), 404, $apidata['content-type']); + $this->clientError(_('No status found with that ID.'), 404, $apidata['content-type']); return; } // XXX: Twitter lets you fave things repeatedly via api. if ($user->hasFave($notice)) { - $this->client_error(_('This notice is already a favorite!'), 403, $apidata['content-type']); + $this->clientError(_('This notice is already a favorite!'), 403, $apidata['content-type']); return; } $fave = Fave::addNew($user, $notice); if (!$fave) { - common_server_error(_('Could not create favorite.')); + $this->serverError(_('Could not create favorite.')); return; } @@ -140,7 +140,7 @@ class TwitapifavoritesAction extends TwitterapiAction function destroy($args, $apidata) { parent::handle($args); - common_server_error(_('API method under construction.'), $code=501); + $this->serverError(_('API method under construction.'), $code=501); } // XXX: these two funcs swiped from faves. Maybe put in util.php, or some common base class? diff --git a/actions/twitapifriendships.php b/actions/twitapifriendships.php index 458ff48a5..c50c5e84a 100644 --- a/actions/twitapifriendships.php +++ b/actions/twitapifriendships.php @@ -29,7 +29,7 @@ class TwitapifriendshipsAction extends TwitterapiAction parent::handle($args); if ($_SERVER['REQUEST_METHOD'] != 'POST') { - $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']); + $this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']); return; } @@ -38,7 +38,7 @@ class TwitapifriendshipsAction extends TwitterapiAction $other = $this->get_user($id); if (!$other) { - $this->client_error(_('Could not follow user: User not found.'), 403, $apidata['content-type']); + $this->clientError(_('Could not follow user: User not found.'), 403, $apidata['content-type']); return; } @@ -46,7 +46,7 @@ class TwitapifriendshipsAction extends TwitterapiAction if ($user->isSubscribed($other)) { $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname); - $this->client_error($errmsg, 403, $apidata['content-type']); + $this->clientError($errmsg, 403, $apidata['content-type']); return; } @@ -62,7 +62,7 @@ class TwitapifriendshipsAction extends TwitterapiAction if (!$result) { $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $other->nickname); - $this->client_error($errmsg, 400, $apidata['content-type']); + $this->clientError($errmsg, 400, $apidata['content-type']); return; } @@ -82,7 +82,7 @@ class TwitapifriendshipsAction extends TwitterapiAction parent::handle($args); if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) { - $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']); + $this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']); return; } @@ -102,7 +102,7 @@ class TwitapifriendshipsAction extends TwitterapiAction $sub->delete(); $sub->query('COMMIT'); } else { - $this->client_error(_('You are not friends with the specified user.'), 403, $apidata['content-type']); + $this->clientError(_('You are not friends with the specified user.'), 403, $apidata['content-type']); return; } @@ -118,7 +118,7 @@ class TwitapifriendshipsAction extends TwitterapiAction parent::handle($args); if (!in_array($apidata['content-type'], array('xml', 'json'))) { - common_user_error(_('API method not found!'), $code = 404); + $this->clientError(_('API method not found!'), $code = 404); return; } @@ -129,7 +129,7 @@ class TwitapifriendshipsAction extends TwitterapiAction $user_b = $this->get_user($user_b_id); if (!$user_a || !$user_b) { - $this->client_error(_('Two user ids or screen_names must be supplied.'), 400, $apidata['content-type']); + $this->clientError(_('Two user ids or screen_names must be supplied.'), 400, $apidata['content-type']); return; } diff --git a/actions/twitapihelp.php b/actions/twitapihelp.php index 531c6e9d3..db5892baf 100644 --- a/actions/twitapihelp.php +++ b/actions/twitapihelp.php @@ -41,7 +41,7 @@ class TwitapihelpAction extends TwitterapiAction print '"ok"'; $this->end_document('json'); } else { - common_user_error(_('API method not found!'), $code=404); + $this->clientError(_('API method not found!'), $code=404); } } @@ -49,7 +49,7 @@ class TwitapihelpAction extends TwitterapiAction function downtime_schedule($args, $apidata) { parent::handle($args); - common_server_error(_('API method under construction.'), $code=501); + $this->serverError(_('API method under construction.'), $code=501); } } \ No newline at end of file diff --git a/actions/twitapilaconica.php b/actions/twitapilaconica.php index 34c8f88fc..8cd7a64b9 100644 --- a/actions/twitapilaconica.php +++ b/actions/twitapilaconica.php @@ -79,7 +79,7 @@ class TwitapilaconicaAction extends TwitterapiAction $this->end_document('json'); break; default: - $this->client_error(_('API method not found!'), $code=404); + $this->clientError(_('API method not found!'), $code=404); } } @@ -148,7 +148,7 @@ class TwitapilaconicaAction extends TwitterapiAction $this->end_document('json'); break; default: - $this->client_error(_('API method not found!'), $code=404); + $this->clientError(_('API method not found!'), $code=404); } } @@ -169,6 +169,6 @@ class TwitapilaconicaAction extends TwitterapiAction function wadl($args, $apidata) { parent::handle($args); - common_server_error(_('API method under construction.'), 501); + $this->serverError(_('API method under construction.'), 501); } } diff --git a/actions/twitapinotifications.php b/actions/twitapinotifications.php index a19d652c3..411971af1 100644 --- a/actions/twitapinotifications.php +++ b/actions/twitapinotifications.php @@ -28,13 +28,13 @@ class TwitapinotificationsAction extends TwitterapiAction function follow($args, $apidata) { parent::handle($args); - common_server_error(_('API method under construction.'), $code=501); + $this->serverError(_('API method under construction.'), $code=501); } function leave($args, $apidata) { parent::handle($args); - common_server_error(_('API method under construction.'), $code=501); + $this->serverError(_('API method under construction.'), $code=501); } } \ No newline at end of file diff --git a/actions/twitapistatuses.php b/actions/twitapistatuses.php index 8d175ecab..a35f4b12e 100644 --- a/actions/twitapistatuses.php +++ b/actions/twitapistatuses.php @@ -76,12 +76,12 @@ class TwitapistatusesAction extends TwitterapiAction $this->show_json_timeline($notice); break; default: - common_user_error(_('API method not found!'), $code = 404); + $this->clientError(_('API method not found!'), $code = 404); break; } } else { - common_server_error(_('Couldn\'t find any statuses.'), $code = 503); + $this->serverError(_('Couldn\'t find any statuses.'), $code = 503); } } @@ -144,7 +144,7 @@ class TwitapistatusesAction extends TwitterapiAction $this->show_json_timeline($notice); break; default: - common_user_error(_('API method not found!'), $code = 404); + $this->clientError(_('API method not found!'), $code = 404); } } @@ -157,14 +157,14 @@ class TwitapistatusesAction extends TwitterapiAction $user = $this->get_user($apidata['api_arg'], $apidata); if (!$user) { - $this->client_error('Not Found', 404, $apidata['content-type']); + $this->clientError('Not Found', 404, $apidata['content-type']); return; } $profile = $user->getProfile(); if (!$profile) { - common_server_error(_('User has no profile.')); + $this->serverError(_('User has no profile.')); return; } @@ -225,7 +225,7 @@ class TwitapistatusesAction extends TwitterapiAction $this->show_json_timeline($notice); break; default: - common_user_error(_('API method not found!'), $code = 404); + $this->clientError(_('API method not found!'), $code = 404); } } @@ -236,12 +236,12 @@ class TwitapistatusesAction extends TwitterapiAction parent::handle($args); if (!in_array($apidata['content-type'], array('xml', 'json'))) { - common_user_error(_('API method not found!'), $code = 404); + $this->clientError(_('API method not found!'), $code = 404); return; } if ($_SERVER['REQUEST_METHOD'] != 'POST') { - $this->client_error(_('This method requires a POST.'), 400, $apidata['content-type']); + $this->clientError(_('This method requires a POST.'), 400, $apidata['content-type']); return; } @@ -273,7 +273,7 @@ class TwitapistatusesAction extends TwitterapiAction // as "truncated." Sending this error may screw up some clients // that assume Twitter will truncate for them. Should we just // truncate too? -- Zach - $this->client_error(_('That\'s too long. Max notice size is 140 chars.'), $code = 406, $apidata['content-type']); + $this->clientError(_('That\'s too long. Max notice size is 140 chars.'), $code = 406, $apidata['content-type']); return; } @@ -306,7 +306,7 @@ class TwitapistatusesAction extends TwitterapiAction if ($reply) { $reply_to = $in_reply_to_status_id; } else { - $this->client_error(_('Not found'), $code = 404, $apidata['content-type']); + $this->clientError(_('Not found'), $code = 404, $apidata['content-type']); return; } } @@ -315,7 +315,7 @@ class TwitapistatusesAction extends TwitterapiAction $source, 1, $reply_to); if (is_string($notice)) { - $this->server_error($notice); + $this->serverError($notice); return; } @@ -389,7 +389,7 @@ class TwitapistatusesAction extends TwitterapiAction $this->show_json_timeline($notices); break; default: - common_user_error(_('API method not found!'), $code = 404); + $this->clientError(_('API method not found!'), $code = 404); } } @@ -399,7 +399,7 @@ class TwitapistatusesAction extends TwitterapiAction parent::handle($args); if (!in_array($apidata['content-type'], array('xml', 'json'))) { - common_user_error(_('API method not found!'), $code = 404); + $this->clientError(_('API method not found!'), $code = 404); return; } @@ -415,7 +415,7 @@ class TwitapistatusesAction extends TwitterapiAction } } else { // XXX: Twitter just sets a 404 header and doens't bother to return an err msg - $this->client_error(_('No status with that ID found.'), 404, $apidata['content-type']); + $this->clientError(_('No status with that ID found.'), 404, $apidata['content-type']); } } @@ -426,14 +426,14 @@ class TwitapistatusesAction extends TwitterapiAction parent::handle($args); if (!in_array($apidata['content-type'], array('xml', 'json'))) { - common_user_error(_('API method not found!'), $code = 404); + $this->clientError(_('API method not found!'), $code = 404); return; } // Check for RESTfulness if (!in_array($_SERVER['REQUEST_METHOD'], array('POST', 'DELETE'))) { // XXX: Twitter just prints the err msg, no XML / JSON. - $this->client_error(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']); + $this->clientError(_('This method requires a POST or DELETE.'), 400, $apidata['content-type']); return; } @@ -443,7 +443,7 @@ class TwitapistatusesAction extends TwitterapiAction $notice = Notice::staticGet($notice_id); if (!$notice) { - $this->client_error(_('No status found with that ID.'), 404, $apidata['content-type']); + $this->clientError(_('No status found with that ID.'), 404, $apidata['content-type']); return; } @@ -460,7 +460,7 @@ class TwitapistatusesAction extends TwitterapiAction $this->show_single_json_status($notice); } } else { - $this->client_error(_('You may not delete another user\'s status.'), 403, $apidata['content-type']); + $this->clientError(_('You may not delete another user\'s status.'), 403, $apidata['content-type']); } } @@ -487,7 +487,7 @@ class TwitapistatusesAction extends TwitterapiAction $user = $this->get_user($apidata['api_arg'], $apidata); if (!$user) { - $this->client_error('Not Found', 404, $apidata['content-type']); + $this->clientError('Not Found', 404, $apidata['content-type']); return; } @@ -500,7 +500,7 @@ class TwitapistatusesAction extends TwitterapiAction $profile = $user->getProfile(); if (!$profile) { - common_server_error(_('User has no profile.')); + $this->serverError(_('User has no profile.')); return; } @@ -552,14 +552,14 @@ class TwitapistatusesAction extends TwitterapiAction print json_encode($arrays); break; default: - $this->client_error(_('unsupported file type')); + $this->clientError(_('unsupported file type')); } } function featured($args, $apidata) { parent::handle($args); - common_server_error(_('API method under construction.'), $code=501); + $this->serverError(_('API method under construction.'), $code=501); } function supported($cmd) diff --git a/actions/twitapiusers.php b/actions/twitapiusers.php index 409986985..ed2417561 100644 --- a/actions/twitapiusers.php +++ b/actions/twitapiusers.php @@ -29,7 +29,7 @@ class TwitapiusersAction extends TwitterapiAction parent::handle($args); if (!in_array($apidata['content-type'], array('xml', 'json'))) { - common_user_error(_('API method not found!'), $code = 404); + $this->clientError(_('API method not found!'), $code = 404); return; } @@ -44,7 +44,7 @@ class TwitapiusersAction extends TwitterapiAction if (!$user) { // XXX: Twitter returns a random(?) user instead of throwing and err! -- Zach - $this->client_error(_('Not found.'), 404, $apidata['content-type']); + $this->clientError(_('Not found.'), 404, $apidata['content-type']); return; } diff --git a/actions/twittersettings.php b/actions/twittersettings.php index 663688037..9c879c965 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -285,7 +285,7 @@ class TwittersettingsAction extends SettingsAction if (!$result) { common_log_db_error($flink, 'DELETE', __FILE__); - common_server_error(_('Couldn\'t remove Twitter user.')); + $this->serverError(_('Couldn\'t remove Twitter user.')); return; } diff --git a/actions/unblock.php b/actions/unblock.php index 112304f71..59270f882 100644 --- a/actions/unblock.php +++ b/actions/unblock.php @@ -30,28 +30,28 @@ class UnblockAction extends Action parent::prepare($args); if (!common_logged_in()) { - $this->client_error(_('Not logged in.')); + $this->clientError(_('Not logged in.')); return false; } $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->client_error(_('There was a problem with your session token. Try again, please.')); + $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } $id = $this->trimmed('unblockto'); if (!$id) { - $this->client_error(_('No profile specified.')); + $this->clientError(_('No profile specified.')); return false; } $this->profile = Profile::staticGet('id', $id); if (!$this->profile) { - $this->client_error(_('No profile with that ID.')); + $this->clientError(_('No profile with that ID.')); return false; } @@ -74,7 +74,7 @@ class UnblockAction extends Action $result = $cur->unblock($this->profile); if (!$result) { - $this->server_error(_('Error removing the block.')); + $this->serverError(_('Error removing the block.')); return; } diff --git a/actions/unsubscribe.php b/actions/unsubscribe.php index 455c5e28e..32511a4b4 100644 --- a/actions/unsubscribe.php +++ b/actions/unsubscribe.php @@ -24,7 +24,7 @@ class UnsubscribeAction extends Action { parent::handle($args); if (!common_logged_in()) { - common_user_error(_('Not logged in.')); + $this->clientError(_('Not logged in.')); return; } @@ -40,28 +40,28 @@ class UnsubscribeAction extends Action $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->client_error(_('There was a problem with your session token. Try again, please.')); + $this->clientError(_('There was a problem with your session token. Try again, please.')); return; } $other_id = $this->arg('unsubscribeto'); if (!$other_id) { - $this->client_error(_('No profile id in request.')); + $this->clientError(_('No profile id in request.')); return; } $other = Profile::staticGet('id', $other_id); if (!$other_id) { - $this->client_error(_('No profile with that id.')); + $this->clientError(_('No profile with that id.')); return; } $result = subs_unsubscribe_to($user, $other); if ($result != true) { - common_user_error($result); + $this->clientError($result); return; } diff --git a/actions/updateprofile.php b/actions/updateprofile.php index abb034c81..c79112dac 100644 --- a/actions/updateprofile.php +++ b/actions/updateprofile.php @@ -37,7 +37,7 @@ class UpdateprofileAction extends Action print "omb_version=".OMB_VERSION_01; } } catch (OAuthException $e) { - $this->server_error($e->getMessage()); + $this->serverError($e->getMessage()); return; } } @@ -46,14 +46,14 @@ class UpdateprofileAction extends Action { $version = $req->get_parameter('omb_version'); if ($version != OMB_VERSION_01) { - $this->client_error(_('Unsupported OMB version'), 400); + $this->clientError(_('Unsupported OMB version'), 400); return false; } # First, check to see if listenee exists $listenee = $req->get_parameter('omb_listenee'); $remote = Remote_profile::staticGet('uri', $listenee); if (!$remote) { - $this->client_error(_('Profile unknown'), 404); + $this->clientError(_('Profile unknown'), 404); return false; } # Second, check to see if they should be able to post updates! @@ -64,72 +64,72 @@ class UpdateprofileAction extends Action $sub->subscribed = $remote->id; $sub->token = $token->key; if (!$sub->find(true)) { - $this->client_error(_('You did not send us that profile'), 403); + $this->clientError(_('You did not send us that profile'), 403); return false; } $profile = Profile::staticGet('id', $remote->id); if (!$profile) { # This one is our fault - $this->server_error(_('Remote profile with no matching profile'), 500); + $this->serverError(_('Remote profile with no matching profile'), 500); return false; } $nickname = $req->get_parameter('omb_listenee_nickname'); if ($nickname && !Validate::string($nickname, array('min_length' => 1, 'max_length' => 64, 'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) { - $this->client_error(_('Nickname must have only lowercase letters and numbers and no spaces.')); + $this->clientError(_('Nickname must have only lowercase letters and numbers and no spaces.')); return false; } $license = $req->get_parameter('omb_listenee_license'); if ($license && !common_valid_http_url($license)) { - $this->client_error(sprintf(_("Invalid license URL '%s'"), $license)); + $this->clientError(sprintf(_("Invalid license URL '%s'"), $license)); return false; } $profile_url = $req->get_parameter('omb_listenee_profile'); if ($profile_url && !common_valid_http_url($profile_url)) { - $this->client_error(sprintf(_("Invalid profile URL '%s'."), $profile_url)); + $this->clientError(sprintf(_("Invalid profile URL '%s'."), $profile_url)); return false; } # optional stuff $fullname = $req->get_parameter('omb_listenee_fullname'); if ($fullname && strlen($fullname) > 255) { - $this->client_error(_("Full name is too long (max 255 chars).")); + $this->clientError(_("Full name is too long (max 255 chars).")); return false; } $homepage = $req->get_parameter('omb_listenee_homepage'); if ($homepage && (!common_valid_http_url($homepage) || strlen($homepage) > 255)) { - $this->client_error(sprintf(_("Invalid homepage '%s'"), $homepage)); + $this->clientError(sprintf(_("Invalid homepage '%s'"), $homepage)); return false; } $bio = $req->get_parameter('omb_listenee_bio'); if ($bio && strlen($bio) > 140) { - $this->client_error(_("Bio is too long (max 140 chars).")); + $this->clientError(_("Bio is too long (max 140 chars).")); return false; } $location = $req->get_parameter('omb_listenee_location'); if ($location && strlen($location) > 255) { - $this->client_error(_("Location is too long (max 255 chars).")); + $this->clientError(_("Location is too long (max 255 chars).")); return false; } $avatar = $req->get_parameter('omb_listenee_avatar'); if ($avatar) { if (!common_valid_http_url($avatar) || strlen($avatar) > 255) { - $this->client_error(sprintf(_("Invalid avatar URL '%s'"), $avatar)); + $this->clientError(sprintf(_("Invalid avatar URL '%s'"), $avatar)); return false; } $size = @getimagesize($avatar); if (!$size) { - $this->client_error(sprintf(_("Can't read avatar URL '%s'"), $avatar)); + $this->clientError(sprintf(_("Can't read avatar URL '%s'"), $avatar)); return false; } if ($size[0] != AVATAR_PROFILE_SIZE || $size[1] != AVATAR_PROFILE_SIZE) { - $this->client_error(sprintf(_("Wrong size image at '%s'"), $avatar)); + $this->clientError(sprintf(_("Wrong size image at '%s'"), $avatar)); return false; } if (!in_array($size[2], array(IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_PNG))) { - $this->client_error(sprintf(_("Wrong image type for '%s'"), $avatar)); + $this->clientError(sprintf(_("Wrong image type for '%s'"), $avatar)); return false; } } @@ -156,14 +156,14 @@ class UpdateprofileAction extends Action } if (!$profile->update($orig_profile)) { - $this->server_error(_('Could not save new profile info'), 500); + $this->serverError(_('Could not save new profile info'), 500); return false; } else { if ($avatar) { $temp_filename = tempnam(sys_get_temp_dir(), 'listenee_avatar'); copy($avatar, $temp_filename); if (!$profile->setOriginal($temp_filename)) { - $this->server_error(_('Could not save avatar info'), 500); + $this->serverError(_('Could not save avatar info'), 500); return false; } } diff --git a/actions/userauthorization.php b/actions/userauthorization.php index 196fae9ad..838458932 100644 --- a/actions/userauthorization.php +++ b/actions/userauthorization.php @@ -54,7 +54,7 @@ class UserauthorizationAction extends Action common_debug('getting new request', __FILE__); $req = $this->get_new_request(); if (!$req) { - $this->client_error(_('No request found!')); + $this->clientError(_('No request found!')); } common_debug('validating request', __FILE__); # XXX: only validate new requests, since nonce is one-time use @@ -64,7 +64,7 @@ class UserauthorizationAction extends Action $this->show_form($req); } catch (OAuthException $e) { $this->clear_request(); - $this->client_error($e->getMessage()); + $this->clientError($e->getMessage()); return; } @@ -137,7 +137,7 @@ class UserauthorizationAction extends Action $req = $this->get_stored_request(); if (!$req) { - common_user_error(_('No authorization request!')); + $this->clientError(_('No authorization request!')); return; } @@ -145,10 +145,10 @@ class UserauthorizationAction extends Action if ($this->arg('accept')) { if (!$this->authorize_token($req)) { - $this->client_error(_('Error authorizing token')); + $this->clientError(_('Error authorizing token')); } if (!$this->save_remote_profile($req)) { - $this->client_error(_('Error saving remote profile')); + $this->clientError(_('Error saving remote profile')); } if (!$callback) { $this->show_accept_message($req->get_parameter('oauth_token')); @@ -160,7 +160,7 @@ class UserauthorizationAction extends Action $profile = $user->getProfile(); if (!$profile) { common_log_db_error($user, 'SELECT', __FILE__); - $this->server_error(_('User without matching profile')); + $this->serverError(_('User without matching profile')); return; } $params['omb_listener_nickname'] = $user->nickname; diff --git a/actions/userbyid.php b/actions/userbyid.php index d57ed21a5..3ff2c9c41 100644 --- a/actions/userbyid.php +++ b/actions/userbyid.php @@ -32,11 +32,11 @@ class UserbyidAction extends Action parent::handle($args); $id = $this->trimmed('id'); if (!$id) { - $this->client_error(_('No id.')); + $this->clientError(_('No id.')); } $user =& User::staticGet($id); if (!$user) { - $this->client_error(_('No such user.')); + $this->clientError(_('No such user.')); } // support redirecting to FOAF rdf/xml if the agent prefers it diff --git a/actions/userrss.php b/actions/userrss.php index 1e9fe121f..d14fc523e 100644 --- a/actions/userrss.php +++ b/actions/userrss.php @@ -34,7 +34,7 @@ class UserrssAction extends Rss10Action $this->user = User::staticGet('nickname', $nickname); if (!$this->user) { - common_user_error(_('No such user.')); + $this->clientError(_('No such user.')); return false; } else { return true; @@ -78,7 +78,7 @@ class UserrssAction extends Rss10Action $profile = $user->getProfile(); if (!$profile) { common_log_db_error($user, 'SELECT', __FILE__); - $this->server_error(_('User without matching profile')); + $this->serverError(_('User without matching profile')); return null; } $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); diff --git a/actions/xrds.php b/actions/xrds.php index 9c51f1dd2..7cb2cd210 100644 --- a/actions/xrds.php +++ b/actions/xrds.php @@ -35,7 +35,7 @@ class XrdsAction extends Action $nickname = $this->trimmed('nickname'); $user = User::staticGet('nickname', $nickname); if (!$user) { - common_user_error(_('No such user.')); + $this->clientError(_('No such user.')); return; } $this->show_xrds($user); diff --git a/lib/action.php b/lib/action.php index d02a1b709..207be3c82 100644 --- a/lib/action.php +++ b/lib/action.php @@ -529,14 +529,14 @@ class Action extends HTMLOutputter // lawsuit } } - function server_error($msg, $code=500) + function serverError($msg, $code=500) { $action = $this->trimmed('action'); common_debug("Server error '$code' on '$action': $msg", __FILE__); common_server_error($msg, $code); } - function client_error($msg, $code=400) + function clientError($msg, $code=400) { $action = $this->trimmed('action'); common_debug("User error '$code' on '$action': $msg", __FILE__); -- cgit v1.2.3-54-g00ecf From 8d9fb7711f32f7b7c0676641dd0c2b9343a5666f Mon Sep 17 00:00:00 2001 From: sarven Date: Thu, 15 Jan 2009 23:05:36 +0000 Subject: Unnecessary wrapper --- actions/login.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'actions') diff --git a/actions/login.php b/actions/login.php index fd98e656d..f43de31ff 100644 --- a/actions/login.php +++ b/actions/login.php @@ -122,9 +122,7 @@ class LoginAction extends Action } else { $instr = $this->get_instructions(); $output = common_markup_to_html($instr); - $this->elementStart('div', 'instructions'); $this->raw($output); - $this->elementEnd('div'); } } -- cgit v1.2.3-54-g00ecf From ba9f1f603b5d832d8dd2f2b910ddf90bf32181b8 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 23:09:16 +0000 Subject: All actions now use isReadOnly() --- actions/api.php | 2 +- actions/foaf.php | 2 +- actions/invite.php | 2 +- actions/login.php | 21 ++++++++------------- actions/logout.php | 2 +- actions/publicxrds.php | 2 +- actions/requesttoken.php | 2 +- actions/sup.php | 2 +- actions/userbyid.php | 2 +- actions/xrds.php | 2 +- 10 files changed, 17 insertions(+), 22 deletions(-) (limited to 'actions') diff --git a/actions/api.php b/actions/api.php index 64971774d..47c119605 100644 --- a/actions/api.php +++ b/actions/api.php @@ -174,7 +174,7 @@ class ApiAction extends Action } } - function is_readonly() + function isReadOnly() { # NOTE: before handle(), can't use $this->arg $apiaction = $_REQUEST['apiaction']; diff --git a/actions/foaf.php b/actions/foaf.php index a0f8a1ff3..9fa321d4a 100644 --- a/actions/foaf.php +++ b/actions/foaf.php @@ -26,7 +26,7 @@ define('BOTH', 0); class FoafAction extends Action { - function is_readonly() + function isReadOnly() { return true; } diff --git a/actions/invite.php b/actions/invite.php index 879264deb..95d96bcde 100644 --- a/actions/invite.php +++ b/actions/invite.php @@ -22,7 +22,7 @@ if (!defined('LACONICA')) { exit(1); } class InviteAction extends Action { - function is_readonly() + function isReadOnly() { return false; } diff --git a/actions/login.php b/actions/login.php index 060d16ad6..cd337bd39 100644 --- a/actions/login.php +++ b/actions/login.php @@ -22,7 +22,7 @@ if (!defined('LACONICA')) { exit(1); } class LoginAction extends Action { - function is_readonly() + function isReadOnly() { return true; } @@ -33,13 +33,13 @@ class LoginAction extends Action if (common_is_real_login()) { $this->clientError(_('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { - $this->check_login(); + $this->checkLogin(); } else { - $this->show_form(); + $this->showForm(); } } - function check_login() + function checkLogin() { # XXX: login throttle @@ -75,7 +75,7 @@ class LoginAction extends Action } common_redirect($url); } else { - $this->show_form(_('Incorrect username or password.')); + $this->showForm(_('Incorrect username or password.')); return; } @@ -104,7 +104,7 @@ class LoginAction extends Action common_redirect($url); } - function show_form($error=null) + function showForm($error=null) { $this->error = $error; $this->showPage(); @@ -120,7 +120,7 @@ class LoginAction extends Action if ($this->error) { $this->element('p', 'error', $this->error); } else { - $instr = $this->get_instructions(); + $instr = $this->getInstructions(); $output = common_markup_to_html($instr); $this->elementStart('div', 'instructions'); $this->raw($output); @@ -145,10 +145,9 @@ class LoginAction extends Action $this->element('a', array('href' => common_local_url('recoverpassword')), _('Lost or forgotten password?')); $this->elementEnd('p'); - common_show_footer(); } - function get_instructions() + function getInstructions() { if (common_logged_in() && !common_is_real_login() && @@ -166,8 +165,4 @@ class LoginAction extends Action 'try [OpenID](%%action.openidlogin%%). '); } } - - function show_top($error=null) - { - } } diff --git a/actions/logout.php b/actions/logout.php index 3001f3613..86d6270ab 100644 --- a/actions/logout.php +++ b/actions/logout.php @@ -24,7 +24,7 @@ require_once(INSTALLDIR.'/lib/openid.php'); class LogoutAction extends Action { - function is_readonly() + function isReadOnly() { return true; } diff --git a/actions/publicxrds.php b/actions/publicxrds.php index f66e34533..e765fb1c9 100644 --- a/actions/publicxrds.php +++ b/actions/publicxrds.php @@ -26,7 +26,7 @@ require_once(INSTALLDIR.'/lib/openid.php'); class PublicxrdsAction extends Action { - function is_readonly() + function isReadOnly() { return true; } diff --git a/actions/requesttoken.php b/actions/requesttoken.php index 378db4403..5058deedb 100644 --- a/actions/requesttoken.php +++ b/actions/requesttoken.php @@ -24,7 +24,7 @@ require_once(INSTALLDIR.'/lib/omb.php'); class RequesttokenAction extends Action { - function is_readonly() + function isReadOnly() { return false; } diff --git a/actions/sup.php b/actions/sup.php index 6a1897585..38e2e2e59 100644 --- a/actions/sup.php +++ b/actions/sup.php @@ -79,7 +79,7 @@ class SupAction extends Action return $updates; } - function is_readonly() + function isReadOnly() { return true; } diff --git a/actions/userbyid.php b/actions/userbyid.php index 3ff2c9c41..4bb896c38 100644 --- a/actions/userbyid.php +++ b/actions/userbyid.php @@ -22,7 +22,7 @@ if (!defined('LACONICA')) { exit(1); } class UserbyidAction extends Action { - function is_readonly() + function isReadOnly() { return true; } diff --git a/actions/xrds.php b/actions/xrds.php index 7cb2cd210..14cb9d503 100644 --- a/actions/xrds.php +++ b/actions/xrds.php @@ -24,7 +24,7 @@ require_once(INSTALLDIR.'/lib/omb.php'); class XrdsAction extends Action { - function is_readonly() + function isReadOnly() { return true; } -- cgit v1.2.3-54-g00ecf From e20309315f1be64f93ceda2e02918bc6358eaca9 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 23:17:04 +0000 Subject: Correct error var in login --- actions/login.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/login.php b/actions/login.php index cd337bd39..1044142a3 100644 --- a/actions/login.php +++ b/actions/login.php @@ -21,7 +21,8 @@ if (!defined('LACONICA')) { exit(1); } class LoginAction extends Action { - + var $error = null; + function isReadOnly() { return true; -- cgit v1.2.3-54-g00ecf From c73ed29cb7977de759379249d0932f5fa62b179b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Thu, 15 Jan 2009 23:46:22 +0000 Subject: Some work to make the all action work --- actions/all.php | 120 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 63 insertions(+), 57 deletions(-) (limited to 'actions') diff --git a/actions/all.php b/actions/all.php index 4ad7f12ae..548d7a103 100644 --- a/actions/all.php +++ b/actions/all.php @@ -19,80 +19,86 @@ if (!defined('LACONICA')) { exit(1); } -require_once(INSTALLDIR.'/actions/showstream.php'); +require_once INSTALLDIR.'/lib/personalgroupnav.php'; +require_once INSTALLDIR.'/lib/noticelist.php'; +require_once INSTALLDIR.'/lib/feedlist.php'; -class AllAction extends StreamAction +class AllAction extends Action { - + var $user = null; + var $page = null; + + function isReadOnly() + { + return true; + } + + function prepare($args) + { + parent::prepare($args); + $nickname = common_canonical_nickname($this->arg('nickname')); + $this->user = User::staticGet('nickname', $nickname); + $this->page = $this->trimmed('page'); + if (!$this->page) { + $this->page = 1; + } + return true; + } + function handle($args) { - parent::handle($args); - - $nickname = common_canonical_nickname($this->arg('nickname')); - $user = User::staticGet('nickname', $nickname); - - if (!$user) { + + if (!$this->user) { $this->clientError(_('No such user.')); return; } - - $profile = $user->getProfile(); - - if (!$profile) { - $this->serverError(_('User has no profile.')); - return; - } - - # Looks like we're good; show the header - - common_show_header(sprintf(_("%s and friends"), $profile->nickname), - array($this, 'show_header'), $user, - array($this, 'show_top')); - - $this->show_notices($user); - - common_show_footer(); + + $this->showPage(); } - - function show_header($user) + + function title() + { + if ($this->page > 1) { + return sprintf(_("%s and friends, page %d"), $this->user->nickname, $this->page); + } else { + return sprintf(_("%s and friends"), $this->user->nickname); + } + } + + function showFeeds() { $this->element('link', array('rel' => 'alternate', 'href' => common_local_url('allrss', array('nickname' => - $user->nickname)), + $this->user->nickname)), 'type' => 'application/rss+xml', - 'title' => sprintf(_('Feed for friends of %s'), $user->nickname))); + 'title' => sprintf(_('Feed for friends of %s'), $this->user->nickname))); } - - function show_top($user) + + function showLocalNav() { - $cur = common_current_user(); - - if ($cur && $cur->id == $user->id) { - common_notice_form('all'); - } - - $this->views_menu(); - - $this->show_feeds_list(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $user->nickname)), - 'type' => 'rss', - 'version' => 'RSS 1.0', - 'item' => 'allrss'))); + $nav = new PersonalGroupNav($this); + $nav->show(); } - function show_notices($user) + function showExportData() { - - $page = $this->trimmed('page'); - if (!$page) { - $page = 1; - } - - $notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); - - $cnt = $this->show_notice_list($notice); - - common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, - $page, 'all', array('nickname' => $user->nickname)); + $fl = new FeedList($this); + $fl->show(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $this->user->nickname)), + 'type' => 'rss', + 'version' => 'RSS 1.0', + 'item' => 'allrss'))); + } + + function showContent() + { + $notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); + + $nl = new NoticeList($notice, $this); + + $cnt = $nl->show(); + + $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, + $this->page, 'all', array('nickname' => $this->user->nickname)); } } -- cgit v1.2.3-54-g00ecf From 877327a18e15d768df3bda658ce9dded116399fa Mon Sep 17 00:00:00 2001 From: sarven Date: Fri, 16 Jan 2009 17:02:46 +0000 Subject: Update to XHR post notice --- actions/newnotice.php | 2 +- js/util.js | 57 +++++++++++++++++++++++++++++---------------------- lib/action.php | 4 ++++ 3 files changed, 38 insertions(+), 25 deletions(-) (limited to 'actions') diff --git a/actions/newnotice.php b/actions/newnotice.php index cb02854a1..b6ed87f81 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -91,7 +91,7 @@ class NewnoticeAction extends Action common_broadcast_notice($notice); if ($this->boolean('ajax')) { - common_start_html('text/xml;charset=utf-8', true); + $this->startHTML('text/xml;charset=utf-8', true); $this->elementStart('head'); $this->element('title', null, _('Notice posted')); $this->elementEnd('head'); diff --git a/js/util.js b/js/util.js index 38a958968..c43af2333 100644 --- a/js/util.js +++ b/js/util.js @@ -20,21 +20,21 @@ $(document).ready(function(){ // count character on keyup function counter(event){ var maxLength = 140; - var currentLength = $("#status_textarea").val().length; + var currentLength = $("#notice_data-text").val().length; var remaining = maxLength - currentLength; var counter = $("#counter"); counter.text(remaining); if (remaining <= 0) { - $("#status_form").addClass("response_error"); + $("#form_notice").addClass("response_error"); } else { - $("#status_form").removeClass("response_error"); + $("#form_notice").removeClass("response_error"); } } function submitonreturn(event) { if (event.keyCode == 13) { - $("#status_form").submit(); + $("#form_notice").submit(); event.preventDefault(); event.stopPropagation(); return false; @@ -42,15 +42,15 @@ $(document).ready(function(){ return true; } - if ($("#status_textarea").length) { - $("#status_textarea").bind("keyup", counter); - $("#status_textarea").bind("keydown", submitonreturn); + if ($("#notice_data-text").length) { + $("#notice_data-text").bind("keyup", counter); + $("#notice_data-text").bind("keydown", submitonreturn); // run once in case there's something in there counter(); // set the focus - $("#status_textarea").focus(); + $("#notice_data-text").focus(); } // XXX: refactor this code @@ -136,12 +136,12 @@ $(document).ready(function(){ var PostNotice = { dataType: 'xml', - beforeSubmit: function(formData, jqForm, options) { if ($("#status_textarea").get(0).value.length == 0) { - $("#status_form").addClass("response_error"); + beforeSubmit: function(formData, jqForm, options) { if ($("#notice_data-text").get(0).value.length == 0) { + $("#form_notice").addClass("warning"); return false; } - $("#status_form input[type=submit]").attr("disabled", "disabled"); - $("#status_form input[type=submit]").addClass("disabled"); + $("#notice_action-submit").attr("disabled", "disabled"); + $("#notice_action-submit").addClass("disabled"); return true; }, success: function(xml) { if ($("#error", xml).length > 0 || $("#command_result", xml).length > 0) { @@ -150,28 +150,37 @@ $(document).ready(function(){ alert(result); } else { - $("#notices").prepend(document._importNode($("li", xml).get(0), true)); - $("#status_textarea").val(""); + $("#notices_primary .notices").prepend(document._importNode($("li", xml).get(0), true)); + $("#notice_data-text").val(""); counter(); - $(".notice_single:first").css({display:"none"}); - $(".notice_single:first").fadeIn(2500); + $("#notices_primary .notice:first").css({display:"none"}); + $("#notices_primary .notice:first").fadeIn(2500); } - $("#status_form input[type=submit]").removeAttr("disabled"); - $("#status_form input[type=submit]").removeClass("disabled"); + $("#notice_action-submit").removeAttr("disabled"); + $("#notice_action-submit").removeClass("disabled"); } }; - $("#status_form").ajaxForm(PostNotice); - $("#status_form").each(addAjaxHidden); + $("#form_notice").ajaxForm(PostNotice); + $("#form_notice").each(addAjaxHidden); + + $(".notice").hover( + function () { + $(this).addClass('hover'); + }, + function () { + $(this).removeClass('hover'); + } + ); }); function doreply(nick,id) { rgx_username = /^[0-9a-zA-Z\-_.]*$/; if (nick.match(rgx_username)) { replyto = "@" + nick + " "; - if ($("#status_textarea").length) { - $("#status_textarea").val(replyto); - $("form#status_form input#inreplyto").val(id); - $("#status_textarea").focus(); + if ($("#notice_data-text").length) { + $("#notice_data-text").val(replyto); + $("form#form_notice input#inreplyto").val(id); + $("#notice_data-text").focus(); return false; } } diff --git a/lib/action.php b/lib/action.php index 94be04b52..129a4b24b 100644 --- a/lib/action.php +++ b/lib/action.php @@ -126,6 +126,10 @@ class Action extends HTMLOutputter // lawsuit 'type' => 'text/css', 'href' => theme_path('css/display.css', 'base') . '?version=' . LACONICA_VERSION, 'media' => 'screen, projection, tv')); + $this->element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => theme_path('css/thickbox.css', 'base') . '?version=' . LACONICA_VERSION, + 'media' => 'screen, projection, tv')); $this->element('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => theme_path('css/display.css', null) . '?version=' . LACONICA_VERSION, -- cgit v1.2.3-54-g00ecf From aedf9942b4fbc9fdc8c65e3bbafc4cff0a32cb2d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 16 Jan 2009 20:00:52 +0000 Subject: Convert emailsettings to use new framework --- actions/emailsettings.php | 304 +++++++++++++++++++++++++++++++++------------- 1 file changed, 218 insertions(+), 86 deletions(-) (limited to 'actions') diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 6210c07b4..4cd63a9d3 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -1,9 +1,12 @@ . + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @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); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/settingsaction.php'); +require_once INSTALLDIR.'/lib/settingsaction.php'; + +/** + * Settings for email + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + * + * @see Widget + */ class EmailsettingsAction extends SettingsAction { + /** + * Title of the page + * + * @return string Title of the page + */ - function get_instructions() + function title() + { + return _('Email Settings'); + } + + /** + * Instructions for use + * + * @return instructions for use + */ + + function getInstructions() { return _('Manage how you get email from %%site.name%%.'); } - function show_form($msg=null, $success=false) + /** + * Content area of the page + * + * Shows a form for adding and removing email addresses and setting + * email preferences. + * + * @return void + */ + + function showContent() { $user = common_current_user(); - $this->form_header(_('Email Settings'), $msg, $success); + $this->elementStart('form', array('method' => 'post', - 'id' => 'emailsettings', - 'action' => - common_local_url('emailsettings'))); + 'id' => 'emailsettings', + 'action' => + common_local_url('emailsettings'))); + $this->hidden('token', common_session_token()); $this->element('h2', null, _('Address')); @@ -50,12 +102,14 @@ class EmailsettingsAction extends SettingsAction $this->elementEnd('p'); $this->submit('remove', _('Remove')); } else { - $confirm = $this->get_confirmation(); + $confirm = $this->getConfirmation(); if ($confirm) { $this->elementStart('p'); $this->element('span', 'address unconfirmed', $confirm->address); $this->element('span', 'input_instructions', - _('Awaiting confirmation on this address. Check your inbox (and spam box!) for a message with further instructions.')); + _('Awaiting confirmation on this address. '. + 'Check your inbox (and spam box!) for a message '. + 'with further instructions.')); $this->hidden('email', $confirm->address); $this->elementEnd('p'); $this->submit('cancel', _('Cancel')); @@ -69,7 +123,7 @@ class EmailsettingsAction extends SettingsAction if ($user->email) { $this->element('h2', null, _('Incoming email')); - + if ($user->incomingemail) { $this->elementStart('p'); $this->element('span', 'address', $user->incomingemail); @@ -78,21 +132,23 @@ class EmailsettingsAction extends SettingsAction $this->elementEnd('p'); $this->submit('removeincoming', _('Remove')); } - + $this->elementStart('p'); $this->element('span', 'input_instructions', - _('Make a new email address for posting to; cancels the old one.')); + _('Make a new email address for posting to; '. + 'cancels the old one.')); $this->elementEnd('p'); $this->submit('newincoming', _('New')); } - + $this->element('h2', null, _('Preferences')); $this->checkbox('emailnotifysub', _('Send me notices of new subscriptions through email.'), $user->emailnotifysub); $this->checkbox('emailnotifyfav', - _('Send me email when someone adds my notice as a favorite.'), + _('Send me email when someone '. + 'adds my notice as a favorite.'), $user->emailnotifyfav); $this->checkbox('emailnotifymsg', _('Send me email when someone sends me a private message.'), @@ -108,17 +164,25 @@ class EmailsettingsAction extends SettingsAction $user->emailmicroid); $this->submit('save', _('Save')); - + $this->elementEnd('form'); - common_show_footer(); } - function get_confirmation() + /** + * Gets any existing email address confirmations we're waiting for + * + * @return Confirm_address Email address confirmation for user, or null + */ + + function getConfirmation() { $user = common_current_user(); + $confirm = new Confirm_address(); - $confirm->user_id = $user->id; + + $confirm->user_id = $user->id; $confirm->address_type = 'email'; + if ($confirm->find(true)) { return $confirm; } else { @@ -126,57 +190,72 @@ class EmailsettingsAction extends SettingsAction } } - function handle_post() + /** + * Handle posts + * + * Since there are a lot of different options on the page, we + * figure out what we're supposed to do based on which button was + * pushed + * + * @return void + */ + + function handlePost() { - - # CSRF protection + // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); + $this->show_form(_('There was a problem with your session token. '. + 'Try again, please.')); return; } if ($this->arg('save')) { - $this->save_preferences(); + $this->savePreferences(); } else if ($this->arg('add')) { - $this->add_address(); + $this->addAddress(); } else if ($this->arg('cancel')) { - $this->cancel_confirmation(); + $this->cancelConfirmation(); } else if ($this->arg('remove')) { - $this->remove_address(); + $this->removeAddress(); } else if ($this->arg('removeincoming')) { - $this->remove_incoming(); + $this->removeIncoming(); } else if ($this->arg('newincoming')) { - $this->new_incoming(); + $this->newIncoming(); } else { - $this->show_form(_('Unexpected form submission.')); + $this->showForm(_('Unexpected form submission.')); } } - function save_preferences() - { + /** + * Save email preferences + * + * @return void + */ - $emailnotifysub = $this->boolean('emailnotifysub'); - $emailnotifyfav = $this->boolean('emailnotifyfav'); - $emailnotifymsg = $this->boolean('emailnotifymsg'); + function savePreferences() + { + $emailnotifysub = $this->boolean('emailnotifysub'); + $emailnotifyfav = $this->boolean('emailnotifyfav'); + $emailnotifymsg = $this->boolean('emailnotifymsg'); $emailnotifynudge = $this->boolean('emailnotifynudge'); - $emailmicroid = $this->boolean('emailmicroid'); - $emailpost = $this->boolean('emailpost'); + $emailmicroid = $this->boolean('emailmicroid'); + $emailpost = $this->boolean('emailpost'); $user = common_current_user(); - assert(!is_null($user)); # should already be checked + assert(!is_null($user)); // should already be checked $user->query('BEGIN'); $original = clone($user); - $user->emailnotifysub = $emailnotifysub; - $user->emailnotifyfav = $emailnotifyfav; - $user->emailnotifymsg = $emailnotifymsg; + $user->emailnotifysub = $emailnotifysub; + $user->emailnotifyfav = $emailnotifyfav; + $user->emailnotifymsg = $emailnotifymsg; $user->emailnotifynudge = $emailnotifynudge; - $user->emailmicroid = $emailmicroid; - $user->emailpost = $emailpost; + $user->emailmicroid = $emailmicroid; + $user->emailpost = $emailpost; $result = $user->update($original); @@ -188,45 +267,52 @@ class EmailsettingsAction extends SettingsAction $user->query('COMMIT'); - $this->show_form(_('Preferences saved.'), true); + $this->showForm(_('Preferences saved.'), true); } - function add_address() - { + /** + * Add the address passed in by the user + * + * @return void + */ + function addAddress() + { $user = common_current_user(); $email = $this->trimmed('email'); - # Some validation + // Some validation if (!$email) { - $this->show_form(_('No email address.')); + $this->showForm(_('No email address.')); return; } $email = common_canonical_email($email); if (!$email) { - $this->show_form(_('Cannot normalize that email address')); + $this->showForm(_('Cannot normalize that email address')); return; } if (!Validate::email($email, true)) { - $this->show_form(_('Not a valid email address')); + $this->showForm(_('Not a valid email address')); return; } else if ($user->email == $email) { - $this->show_form(_('That is already your email address.')); + $this->showForm(_('That is already your email address.')); return; - } else if ($this->email_exists($email)) { - $this->show_form(_('That email address already belongs to another user.')); + } else if ($this->emailExists($email)) { + $this->showForm(_('That email address already belongs '. + 'to another user.')); return; } - $confirm = new Confirm_address(); - $confirm->address = $email; - $confirm->address_type = 'email'; - $confirm->user_id = $user->id; - $confirm->code = common_confirmation_code(64); + $confirm = new Confirm_address(); + + $confirm->address = $email; + $confirm->address_type = 'email'; + $confirm->user_id = $user->id; + $confirm->code = common_confirmation_code(64); $result = $confirm->insert(); @@ -238,21 +324,31 @@ class EmailsettingsAction extends SettingsAction mail_confirm_address($user, $confirm->code, $user->nickname, $email); - $msg = _('A confirmation code was sent to the email address you added. Check your inbox (and spam box!) for the code and instructions on how to use it.'); + $msg = _('A confirmation code was sent to the email address you added. '. + 'Check your inbox (and spam box!) for the code and instructions '. + 'on how to use it.'); - $this->show_form($msg, true); + $this->showForm($msg, true); } - function cancel_confirmation() + /** + * Handle a request to cancel email confirmation + * + * @return void + */ + + function cancelConfirmation() { $email = $this->arg('email'); - $confirm = $this->get_confirmation(); + + $confirm = $this->getConfirmation(); + if (!$confirm) { - $this->show_form(_('No pending confirmation to cancel.')); + $this->showForm(_('No pending confirmation to cancel.')); return; } if ($confirm->address != $email) { - $this->show_form(_('That is the wrong IM address.')); + $this->showForm(_('That is the wrong IM address.')); return; } @@ -264,26 +360,36 @@ class EmailsettingsAction extends SettingsAction return; } - $this->show_form(_('Confirmation cancelled.'), true); + $this->showForm(_('Confirmation cancelled.'), true); } - function remove_address() - { + /** + * Handle a request to remove an address from the user's account + * + * @return void + */ + function removeAddress() + { $user = common_current_user(); + $email = $this->arg('email'); - # Maybe an old tab open...? + // Maybe an old tab open...? if ($user->email != $email) { - $this->show_form(_('That is not your email address.')); + $this->showForm(_('That is not your email address.')); return; } $user->query('BEGIN'); + $original = clone($user); + $user->email = null; + $result = $user->updateKeys($original); + if (!$result) { common_log_db_error($user, 'UPDATE', __FILE__); $this->serverError(_('Couldn\'t update user.')); @@ -291,48 +397,74 @@ class EmailsettingsAction extends SettingsAction } $user->query('COMMIT'); - $this->show_form(_('The address was removed.'), true); + $this->showForm(_('The address was removed.'), true); } - function remove_incoming() + /** + * Handle a request to remove an incoming email address + * + * @return void + */ + + function removeIncoming() { $user = common_current_user(); - + if (!$user->incomingemail) { - $this->show_form(_('No incoming email address.')); + $this->showForm(_('No incoming email address.')); return; } - + $orig = clone($user); + $user->incomingemail = null; if (!$user->updateKeys($orig)) { common_log_db_error($user, 'UPDATE', __FILE__); $this->serverError(_("Couldn't update user record.")); } - - $this->show_form(_('Incoming email address removed.'), true); + + $this->showForm(_('Incoming email address removed.'), true); } - function new_incoming() + /** + * Generate a new incoming email address + * + * @return void + */ + + function newIncoming() { $user = common_current_user(); - + $orig = clone($user); + $user->incomingemail = mail_new_incoming_address(); - + if (!$user->updateKeys($orig)) { common_log_db_error($user, 'UPDATE', __FILE__); $this->serverError(_("Couldn't update user record.")); } - $this->show_form(_('New incoming email address added.'), true); + $this->showForm(_('New incoming email address added.'), true); } - - function email_exists($email) + + /** + * Does another user already have this email address? + * + * Email addresses are unique for users. + * + * @param string $email Address to check + * + * @return boolean Whether the email already exists. + */ + + function emailExists($email) { $user = common_current_user(); + $other = User::staticGet('email', $email); + if (!$other) { return false; } else { -- cgit v1.2.3-54-g00ecf From 2c9759c3b329eff455b3998d748292d581635f90 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Fri, 16 Jan 2009 20:19:49 +0000 Subject: trac750 Don't accidentally show login form after user logs in --- actions/facebookhome.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'actions') diff --git a/actions/facebookhome.php b/actions/facebookhome.php index f72f08a34..b780b8cc3 100644 --- a/actions/facebookhome.php +++ b/actions/facebookhome.php @@ -71,15 +71,16 @@ class FacebookhomeAction extends FacebookAction // XXX: Do some error handling here $this->setDefaults(); - $this->showHome($flink, _('You can now use Identi.ca from Facebook!')); - + return; + } else { $msg = _('Incorrect username or password.'); } } $this->showLoginForm($msg); + } function setDefaults() -- cgit v1.2.3-54-g00ecf From 2f99a257a0d8bd773ea96249b13b134fcfbc99cd Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 16 Jan 2009 20:25:46 +0000 Subject: Make the OpenID settings work with new framework --- actions/finishaddopenid.php | 112 ++++++++++++++++++++++++++++----- actions/openidsettings.php | 147 ++++++++++++++++++++++++++++++++------------ 2 files changed, 202 insertions(+), 57 deletions(-) (limited to 'actions') diff --git a/actions/finishaddopenid.php b/actions/finishaddopenid.php index 708e8d4bf..8f10505cf 100644 --- a/actions/finishaddopenid.php +++ b/actions/finishaddopenid.php @@ -1,9 +1,12 @@ . + * + * @category Settings + * @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); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/openid.php'); +require_once INSTALLDIR.'/lib/openid.php'; + +/** + * Complete adding an OpenID + * + * Handle the return from an OpenID verification + * + * @category Settings + * @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 FinishaddopenidAction extends Action { + var $msg = null; + + /** + * Handle the redirect back from OpenID confirmation + * + * Check to see if the user's logged in, and then try + * to use the OpenID login system. + * + * @param array $args $_REQUEST arguments + * + * @return void + */ function handle($args) { @@ -30,13 +66,20 @@ class FinishaddopenidAction extends Action if (!common_logged_in()) { $this->clientError(_('Not logged in.')); } else { - $this->try_login(); + $this->tryLogin(); } } - - function try_login() - { + /** + * Try to log in using OpenID + * + * Check the OpenID for validity; potentially store it. + * + * @return void + */ + + function tryLogin() + { $consumer =& oid_consumer(); $response = $consumer->complete(common_local_url('finishaddopenid')); @@ -46,10 +89,11 @@ class FinishaddopenidAction extends Action return; } else if ($response->status == Auth_OpenID_FAILURE) { // Authentication failed; display the error message. - $this->message(sprintf(_('OpenID authentication failed: %s'), $response->message)); + $this->message(sprintf(_('OpenID authentication failed: %s'), + $response->message)); } else if ($response->status == Auth_OpenID_SUCCESS) { - $display = $response->getDisplayIdentifier(); + $display = $response->getDisplayIdentifier(); $canonical = ($response->endpoint && $response->endpoint->canonicalID) ? $response->endpoint->canonicalID : $display; @@ -60,6 +104,7 @@ class FinishaddopenidAction extends Action } $cur =& common_current_user(); + $other = oid_get_user($canonical); if ($other) { @@ -71,7 +116,7 @@ class FinishaddopenidAction extends Action return; } - # start a transaction + // start a transaction $cur->query('BEGIN'); @@ -88,7 +133,7 @@ class FinishaddopenidAction extends Action } } - # success! + // success! $cur->query('COMMIT'); @@ -98,10 +143,43 @@ class FinishaddopenidAction extends Action } } + /** + * Show a failure message + * + * Something went wrong. Save the message, and show the page. + * + * @param string $msg Error message to show + * + * @return void + */ + function message($msg) { - common_show_header(_('OpenID Login')); - $this->element('p', null, $msg); - common_show_footer(); + $this->message = $msg; + $this->showPage(); + } + + /** + * Title of the page + * + * @return string title + */ + + function title() + { + return _('OpenID Login'); + } + + /** + * Show error message + * + * @return void + */ + + function showPageNotice() + { + if ($this->message) { + $this->element('p', 'error', $this->message); + } } } diff --git a/actions/openidsettings.php b/actions/openidsettings.php index 9265b5ea6..a21a9869e 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -1,9 +1,12 @@ . + * + * @category Settings + * @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); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/settingsaction.php'); -require_once(INSTALLDIR.'/lib/openid.php'); +require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/openid.php'; + +/** + * Settings for OpenID + * + * Lets users add, edit and delete OpenIDs from their account + * + * @category Settings + * @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 OpenidsettingsAction extends SettingsAction { + /** + * Title of the page + * + * @return string Page title + */ - function get_instructions() + function title() { - return _('[OpenID](%%doc.openid%%) lets you log into many sites ' . - ' with the same user account. '. - ' Manage your associated OpenIDs from here.'); + return _('OpenID settings'); } - function show_form($msg=null, $success=false) + /** + * Instructions for use + * + * @return string Instructions for use + */ + + function getInstructions() { + return _('[OpenID](%%doc.openid%%) lets you log into many sites ' . + ' with the same user account. '. + ' Manage your associated OpenIDs from here.'); + } - $user = common_current_user(); + /** + * Show the form for OpenID management + * + * We have one form with a few different submit buttons to do different things. + * + * @return void + */ - $this->form_header(_('OpenID settings'), $msg, $success); + function showContent() + { + $user = common_current_user(); $this->elementStart('form', array('method' => 'post', - 'id' => 'openidadd', - 'action' => - common_local_url('openidsettings'))); + 'id' => 'openidadd', + 'action' => + common_local_url('openidsettings'))); $this->hidden('token', common_session_token()); $this->element('h2', null, _('Add OpenID')); $this->element('p', null, _('If you want to add an OpenID to your account, ' . - 'enter it in the box below and click "Add".')); + 'enter it in the box below and click "Add".')); $this->elementStart('p'); $this->element('label', array('for' => 'openid_url'), _('OpenID URL')); @@ -63,6 +108,7 @@ class OpenidsettingsAction extends SettingsAction $this->elementEnd('form'); $oid = new User_openid(); + $oid->user_id = $user->id; $cnt = $oid->find(); @@ -74,8 +120,10 @@ class OpenidsettingsAction extends SettingsAction if ($cnt == 1 && !$user->password) { $this->element('p', null, - _('Removing your only OpenID would make it impossible to log in! ' . - 'If you need to remove it, add another OpenID first.')); + _('Removing your only OpenID '. + 'would make it impossible to log in! ' . + 'If you need to remove it, '. + 'add another OpenID first.')); if ($oid->fetch()) { $this->elementStart('p'); @@ -88,14 +136,15 @@ class OpenidsettingsAction extends SettingsAction $this->element('p', null, _('You can remove an OpenID from your account '. - 'by clicking the button marked "Remove".')); + 'by clicking the button marked "Remove".')); $idx = 0; while ($oid->fetch()) { - $this->elementStart('form', array('method' => 'POST', - 'id' => 'openiddelete' . $idx, - 'action' => - common_local_url('openidsettings'))); + $this->elementStart('form', + array('method' => 'POST', + 'id' => 'openiddelete' . $idx, + 'action' => + common_local_url('openidsettings'))); $this->elementStart('p'); $this->hidden('token', common_session_token()); $this->element('a', array('href' => $oid->canonical), @@ -115,47 +164,65 @@ class OpenidsettingsAction extends SettingsAction } } } - - common_show_footer(); } - function handle_post() + /** + * Handle a POST request + * + * Muxes to different sub-functions based on which button was pushed + * + * @return void + */ + + function handlePost() { - # CSRF protection + // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); + $this->showForm(_('There was a problem with your session token. '. + 'Try again, please.')); return; } if ($this->arg('add')) { - $result = oid_authenticate($this->trimmed('openid_url'), 'finishaddopenid'); - if (is_string($result)) { # error message - $this->show_form($result); + $result = oid_authenticate($this->trimmed('openid_url'), + 'finishaddopenid'); + if (is_string($result)) { // error message + $this->showForm($result); } } else if ($this->arg('remove')) { - $this->remove_openid(); + $this->removeOpenid(); } else { - $this->show_form(_('Something weird happened.')); + $this->showForm(_('Something weird happened.')); } } - function remove_openid() - { + /** + * Handles a request to remove an OpenID from the user's account + * + * Validates input and, if everything is OK, deletes the OpenID. + * Reloads the form with a success or error notification. + * + * @return void + */ + function removeOpenid() + { $openid_url = $this->trimmed('openid_url'); + $oid = User_openid::staticGet('canonical', $openid_url); + if (!$oid) { - $this->show_form(_('No such OpenID.')); + $this->showForm(_('No such OpenID.')); return; } $cur = common_current_user(); if (!$cur || $oid->user_id != $cur->id) { - $this->show_form(_('That OpenID does not belong to you.')); + $this->showForm(_('That OpenID does not belong to you.')); return; } $oid->delete(); - $this->show_form(_('OpenID removed.'), true); + $this->showForm(_('OpenID removed.'), true); return; } } -- cgit v1.2.3-54-g00ecf From c0a5ade1e7a9ed7a501c8db74213e203449d861d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 16 Jan 2009 20:56:39 +0000 Subject: SMS settings updated to new framework --- actions/smssettings.php | 332 ++++++++++++++++++++++++++++++++++-------------- 1 file changed, 234 insertions(+), 98 deletions(-) (limited to 'actions') diff --git a/actions/smssettings.php b/actions/smssettings.php index c5879e4d9..f214997ec 100644 --- a/actions/smssettings.php +++ b/actions/smssettings.php @@ -1,9 +1,12 @@ . + * + * @category Settings + * @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); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/settingsaction.php'); -require_once(INSTALLDIR.'/actions/emailsettings.php'); +require_once INSTALLDIR.'/lib/settingsaction.php'; + +/** + * Settings for SMS + * + * @category Settings + * @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/ + * + * @see SettingsAction + */ -class SmssettingsAction extends EmailsettingsAction +class SmssettingsAction extends SettingsAction { + /** + * Title of the page + * + * @return string Title of the page + */ - function get_instructions() + function title() + { + return _('SMS Settings'); + } + + /** + * Instructions for use + * + * @return instructions for use + */ + + function getInstructions() { return _('You can receive SMS messages through email from %%site.name%%.'); } - function show_form($msg=null, $success=false) + /** + * Content area of the page + * + * Shows a form for adding and removing SMS phone numbers and setting + * SMS preferences. + * + * @return void + */ + + function showContent() { $user = common_current_user(); - $this->form_header(_('SMS Settings'), $msg, $success); + $this->elementStart('form', array('method' => 'post', - 'id' => 'smssettings', - 'action' => - common_local_url('smssettings'))); + 'id' => 'smssettings', + 'action' => + common_local_url('smssettings'))); + $this->hidden('token', common_session_token()); $this->element('h2', null, _('Address')); if ($user->sms) { $this->elementStart('p'); $carrier = $user->getCarrier(); - $this->element('span', 'address confirmed', $user->sms . ' (' . $carrier->name . ')'); + $this->element('span', 'address confirmed', + $user->sms . ' (' . $carrier->name . ')'); $this->element('span', 'input_instructions', _('Current confirmed SMS-enabled phone number.')); $this->hidden('sms', $user->sms); @@ -52,11 +102,12 @@ class SmssettingsAction extends EmailsettingsAction $this->elementEnd('p'); $this->submit('remove', _('Remove')); } else { - $confirm = $this->get_confirmation(); + $confirm = $this->getConfirmation(); if ($confirm) { $carrier = Sms_carrier::staticGet($confirm->address_extra); $this->elementStart('p'); - $this->element('span', 'address unconfirmed', $confirm->address . ' (' . $carrier->name . ')'); + $this->element('span', 'address unconfirmed', + $confirm->address . ' (' . $carrier->name . ')'); $this->element('span', 'input_instructions', _('Awaiting confirmation on this phone number.')); $this->hidden('sms', $confirm->address); @@ -69,15 +120,16 @@ class SmssettingsAction extends EmailsettingsAction } else { $this->input('sms', _('SMS Phone number'), ($this->arg('sms')) ? $this->arg('sms') : null, - _('Phone number, no punctuation or spaces, with area code')); - $this->carrier_select(); + _('Phone number, no punctuation or spaces, '. + 'with area code')); + $this->carrierSelect(); $this->submit('add', _('Add')); } } if ($user->sms) { $this->element('h2', null, _('Incoming email')); - + if ($user->incomingemail) { $this->elementStart('p'); $this->element('span', 'address', $user->incomingemail); @@ -86,32 +138,45 @@ class SmssettingsAction extends EmailsettingsAction $this->elementEnd('p'); $this->submit('removeincoming', _('Remove')); } - + $this->elementStart('p'); $this->element('span', 'input_instructions', - _('Make a new email address for posting to; cancels the old one.')); + _('Make a new email address for posting to; '. + 'cancels the old one.')); $this->elementEnd('p'); $this->submit('newincoming', _('New')); } - + $this->element('h2', null, _('Preferences')); - + $this->checkbox('smsnotify', - _('Send me notices through SMS; I understand I may incur exorbitant charges from my carrier.'), + _('Send me notices through SMS; '. + 'I understand I may incur '. + 'exorbitant charges from my carrier.'), $user->smsnotify); - + $this->submit('save', _('Save')); - + $this->elementEnd('form'); - common_show_footer(); } - function get_confirmation() + /** + * Get a pending confirmation, if any, for this user + * + * @return void + * + * @todo very similar to EmailsettingsAction::getConfirmation(); refactor? + */ + + function getConfirmation() { $user = common_current_user(); + $confirm = new Confirm_address(); - $confirm->user_id = $user->id; + + $confirm->user_id = $user->id; $confirm->address_type = 'sms'; + if ($confirm->find(true)) { return $confirm; } else { @@ -119,44 +184,62 @@ class SmssettingsAction extends EmailsettingsAction } } - function handle_post() + /** + * Handle posts to this form + * + * Based on the button that was pressed, muxes out to other functions + * to do the actual task requested. + * + * All sub-functions reload the form with a message -- success or failure. + * + * @return void + */ + + function handlePost() { - - # CSRF protection + // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); + $this->showForm(_('There was a problem with your session token. '. + 'Try again, please.')); return; } if ($this->arg('save')) { - $this->save_preferences(); + $this->savePreferences(); } else if ($this->arg('add')) { - $this->add_address(); + $this->addAddress(); } else if ($this->arg('cancel')) { - $this->cancel_confirmation(); + $this->cancelConfirmation(); } else if ($this->arg('remove')) { - $this->remove_address(); + $this->removeAddress(); } else if ($this->arg('removeincoming')) { - $this->remove_incoming(); + $this->removeIncoming(); } else if ($this->arg('newincoming')) { - $this->new_incoming(); + $this->newIncoming(); } else if ($this->arg('confirm')) { - $this->confirm_code(); + $this->confirmCode(); } else { - $this->show_form(_('Unexpected form submission.')); + $this->showForm(_('Unexpected form submission.')); } } - function save_preferences() - { + /** + * Handle a request to save preferences + * + * Sets the user's SMS preferences in the DB. + * + * @return void + */ + function savePreferences() + { $smsnotify = $this->boolean('smsnotify'); - + $user = common_current_user(); - assert(!is_null($user)); # should already be checked + assert(!is_null($user)); // should already be checked $user->query('BEGIN'); @@ -174,45 +257,54 @@ class SmssettingsAction extends EmailsettingsAction $user->query('COMMIT'); - $this->show_form(_('Preferences saved.'), true); + $this->showForm(_('Preferences saved.'), true); } - function add_address() - { + /** + * Add a new SMS number for confirmation + * + * When the user requests a new SMS number, sends a confirmation + * message. + * + * @return void + */ + function addAddress() + { $user = common_current_user(); - $sms = $this->trimmed('sms'); + $sms = $this->trimmed('sms'); $carrier_id = $this->trimmed('carrier'); - - # Some validation + + // Some validation if (!$sms) { - $this->show_form(_('No phone number.')); + $this->showForm(_('No phone number.')); return; } if (!$carrier_id) { - $this->show_form(_('No carrier selected.')); + $this->showForm(_('No carrier selected.')); return; } - + $sms = common_canonical_sms($sms); - + if ($user->sms == $sms) { - $this->show_form(_('That is already your phone number.')); + $this->showForm(_('That is already your phone number.')); return; - } else if ($this->sms_exists($sms)) { - $this->show_form(_('That phone number already belongs to another user.')); + } else if ($this->smsExists($sms)) { + $this->showForm(_('That phone number already belongs to another user.')); return; } - $confirm = new Confirm_address(); - $confirm->address = $sms; - $confirm->address_extra = $carrier_id; - $confirm->address_type = 'sms'; - $confirm->user_id = $user->id; - $confirm->code = common_confirmation_code(40); + $confirm = new Confirm_address(); + + $confirm->address = $sms; + $confirm->address_extra = $carrier_id; + $confirm->address_type = 'sms'; + $confirm->user_id = $user->id; + $confirm->code = common_confirmation_code(40); $result = $confirm->insert(); @@ -223,30 +315,39 @@ class SmssettingsAction extends EmailsettingsAction } $carrier = Sms_carrier::staticGet($carrier_id); - + mail_confirm_sms($confirm->code, $user->nickname, $carrier->toEmailAddress($sms)); - $msg = _('A confirmation code was sent to the phone number you added. Check your inbox (and spam box!) for the code and instructions on how to use it.'); + $msg = _('A confirmation code was sent to the phone number you added. '. + 'Check your phone for the code and instructions '. + 'on how to use it.'); - $this->show_form($msg, true); + $this->showForm($msg, true); } - function cancel_confirmation() + /** + * Cancel a pending confirmation + * + * Cancels the confirmation. + * + * @return void + */ + + function cancelConfirmation() { - - $sms = $this->trimmed('sms'); + $sms = $this->trimmed('sms'); $carrier = $this->trimmed('carrier'); - - $confirm = $this->get_confirmation(); - + + $confirm = $this->getConfirmation(); + if (!$confirm) { - $this->show_form(_('No pending confirmation to cancel.')); + $this->showForm(_('No pending confirmation to cancel.')); return; } if ($confirm->address != $sms) { - $this->show_form(_('That is the wrong confirmation number.')); + $this->showForm(_('That is the wrong confirmation number.')); return; } @@ -258,28 +359,37 @@ class SmssettingsAction extends EmailsettingsAction return; } - $this->show_form(_('Confirmation cancelled.'), true); + $this->showForm(_('Confirmation cancelled.'), true); } - function remove_address() - { + /** + * Remove a phone number from the user's account + * + * @return void + */ + function removeAddress() + { $user = common_current_user(); - $sms = $this->arg('sms'); + + $sms = $this->arg('sms'); $carrier = $this->arg('carrier'); - - # Maybe an old tab open...? + + // Maybe an old tab open...? if ($user->sms != $sms) { - $this->show_form(_('That is not your phone number.')); + $this->showForm(_('That is not your phone number.')); return; } $user->query('BEGIN'); + $original = clone($user); - $user->sms = null; - $user->carrier = null; - $user->smsemail = null; + + $user->sms = null; + $user->carrier = null; + $user->smsemail = null; + $result = $user->updateKeys($original); if (!$result) { common_log_db_error($user, 'UPDATE', __FILE__); @@ -288,13 +398,25 @@ class SmssettingsAction extends EmailsettingsAction } $user->query('COMMIT'); - $this->show_form(_('The address was removed.'), true); + $this->showForm(_('The address was removed.'), true); } - - function sms_exists($sms) + + /** + * Does this sms number exist in our database? + * + * Also checks if it belongs to someone else + * + * @param string $sms phone number to check + * + * @return boolean does the number exist + */ + + function smsExists($sms) { $user = common_current_user(); + $other = User::staticGet('sms', $sms); + if (!$other) { return false; } else { @@ -302,15 +424,22 @@ class SmssettingsAction extends EmailsettingsAction } } - function carrier_select() + /** + * Show a drop-down box with all the SMS carriers in the DB + * + * @return void + */ + + function carrierSelect() { $carrier = new Sms_carrier(); + $cnt = $carrier->find(); $this->elementStart('p'); $this->element('label', array('for' => 'carrier')); $this->elementStart('select', array('name' => 'carrier', - 'id' => 'carrier')); + 'id' => 'carrier')); $this->element('option', array('value' => 0), _('Select a carrier')); while ($carrier->fetch()) { @@ -321,23 +450,30 @@ class SmssettingsAction extends EmailsettingsAction $this->elementEnd('p'); $this->element('span', 'input_instructions', sprintf(_('Mobile carrier for your phone. '. - 'If you know a carrier that accepts ' . + 'If you know a carrier that accepts ' . 'SMS over email but isn\'t listed here, ' . 'send email to let us know at %s.'), common_config('site', 'email'))); } - function confirm_code() + /** + * Confirm an SMS confirmation code + * + * Redirects to the confirmaddress page for this code + * + * @return void + */ + + function confirmCode() { - $code = $this->trimmed('code'); - + if (!$code) { - $this->show_form(_('No code entered')); + $this->showForm(_('No code entered')); return; } - - common_redirect(common_local_url('confirmaddress', + + common_redirect(common_local_url('confirmaddress', array('code' => $code))); } } -- cgit v1.2.3-54-g00ecf From d5a876865ba0a90921a160653cf19115f3abb714 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 16 Jan 2009 21:18:30 +0000 Subject: Update twittersettings to new framework --- actions/twittersettings.php | 319 ++++++++++++++++++++++++++++++-------------- 1 file changed, 218 insertions(+), 101 deletions(-) (limited to 'actions') diff --git a/actions/twittersettings.php b/actions/twittersettings.php index d6d31c483..5492dd995 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -1,9 +1,12 @@ . + * + * @category Settings + * @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); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/settingsaction.php'); +require_once INSTALLDIR.'/lib/settingsaction.php'; define('SUBSCRIPTIONS', 80); +/** + * Settings for Twitter integration + * + * @category Settings + * @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/ + * + * @see SettingsAction + */ + class TwittersettingsAction extends SettingsAction { + /** + * Title of the page + * + * @return string Title of the page + */ + + function title() + { + _('Twitter settings'); + } + + /** + * Instructions for use + * + * @return instructions for use + */ - function get_instructions() + function getInstructions() { - return _('Add your Twitter account to automatically send your notices to Twitter, ' . - 'and subscribe to Twitter friends already here.'); + return _('Add your Twitter account to automatically send '. + ' your notices to Twitter, ' . + 'and subscribe to Twitter friends already here.'); } - function show_form($msg=null, $success=false) + /** + * Content area of the page + * + * Shows a form for associating a Twitter account with this + * Laconica account. Also lets the user set preferences. + * + * @return void + */ + + function showContent() { $user = common_current_user(); + $profile = $user->getProfile(); + $fuser = null; + $flink = Foreign_link::getByUserID($user->id, 1); // 1 == Twitter if ($flink) { $fuser = $flink->getForeignUser(); } - $this->form_header(_('Twitter settings'), $msg, $success); $this->elementStart('form', array('method' => 'post', - 'id' => 'twittersettings', - 'action' => - common_local_url('twittersettings'))); + 'id' => 'twittersettings', + 'action' => + common_local_url('twittersettings'))); $this->hidden('token', common_session_token()); $this->element('h2', null, _('Twitter Account')); @@ -56,7 +108,7 @@ class TwittersettingsAction extends SettingsAction $this->elementStart('p'); $this->element('span', 'twitter_user', $fuser->nickname); - $this->element('a', array('href' => $fuser->uri), $fuser->uri); + $this->element('a', array('href' => $fuser->uri), $fuser->uri); $this->element('span', 'input_instructions', _('Current verified Twitter account.')); $this->hidden('flink_foreign_id', $flink->foreign_id); @@ -64,7 +116,9 @@ class TwittersettingsAction extends SettingsAction $this->submit('remove', _('Remove')); } else { $this->input('twitter_username', _('Twitter user name'), - ($this->arg('twitter_username')) ? $this->arg('twitter_username') : $profile->nickname, + ($this->arg('twitter_username')) ? + $this->arg('twitter_username') : + $profile->nickname, _('No spaces, please.')); // hey, it's what Twitter says $this->password('twitter_password', _('Twitter password')); @@ -72,14 +126,23 @@ class TwittersettingsAction extends SettingsAction $this->element('h2', null, _('Preferences')); - $this->checkbox('noticesync', _('Automatically send my notices to Twitter.'), - ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND) : true); + $this->checkbox('noticesync', + _('Automatically send my notices to Twitter.'), + ($flink) ? + ($flink->noticesync & FOREIGN_NOTICE_SEND) : + true); - $this->checkbox('replysync', _('Send local "@" replies to Twitter.'), - ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true); + $this->checkbox('replysync', + _('Send local "@" replies to Twitter.'), + ($flink) ? + ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : + true); - $this->checkbox('friendsync', _('Subscribe to my Twitter friends here.'), - ($flink) ? ($flink->friendsync & FOREIGN_FRIEND_RECV) : false); + $this->checkbox('friendsync', + _('Subscribe to my Twitter friends here.'), + ($flink) ? + ($flink->friendsync & FOREIGN_FRIEND_RECV) : + false); if ($flink) { $this->submit('save', _('Save')); @@ -87,24 +150,31 @@ class TwittersettingsAction extends SettingsAction $this->submit('add', _('Add')); } - $this->show_twitter_subscriptions(); + $this->showTwitterSubscriptions(); $this->elementEnd('form'); - - common_show_footer(); } - function subscribed_twitter_users() + /** + * Gets some of the user's Twitter friends + * + * Gets the number of Twitter friends that are on this + * instance of Laconica. + * + * @return array array of User objects + */ + + function subscribedTwitterUsers() { $current_user = common_current_user(); $qry = 'SELECT user.* ' . - 'FROM subscription ' . - 'JOIN user ON subscription.subscribed = user.id ' . - 'JOIN foreign_link ON foreign_link.user_id = user.id ' . - 'WHERE subscriber = %d ' . - 'ORDER BY user.nickname'; + 'FROM subscription ' . + 'JOIN user ON subscription.subscribed = user.id ' . + 'JOIN foreign_link ON foreign_link.user_id = user.id ' . + 'WHERE subscriber = %d ' . + 'ORDER BY user.nickname'; $user = new User(); @@ -123,10 +193,20 @@ class TwittersettingsAction extends SettingsAction return $users; } - function show_twitter_subscriptions() + /** + * Show user's Twitter friends + * + * Gets the number of Twitter friends that are on this + * instance of Laconica, and shows their mini-avatars. + * + * @return void + */ + + function showTwitterSubscriptions() { - $friends = $this->subscribed_twitter_users(); + $friends = $this->subscribedTwitterUsers(); + $friends_count = count($friends); if ($friends_count > 0) { @@ -146,13 +226,19 @@ class TwittersettingsAction extends SettingsAction $this->elementStart('li'); $this->elementStart('a', array('title' => ($other->fullname) ? - $other->fullname : - $other->nickname, - 'href' => $other->profileurl, - 'rel' => 'contact', - 'class' => 'subscription')); + $other->fullname : + $other->nickname, + 'href' => $other->profileurl, + 'rel' => 'contact', + 'class' => 'subscription')); + $avatar = $other->getAvatar(AVATAR_MINI_SIZE); - $this->element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_MINI_SIZE)), + + $avatar_url = ($avatar) ? + common_avatar_display_url($avatar) : + common_default_avatar(AVATAR_MINI_SIZE); + + $this->element('img', array('src' => $avatar_url, 'width' => AVATAR_MINI_SIZE, 'height' => AVATAR_MINI_SIZE, 'class' => 'avatar mini', @@ -168,88 +254,96 @@ class TwittersettingsAction extends SettingsAction $this->elementEnd('div'); } - - // XXX Figure out a way to show all Twitter friends... ? - - /* - if ($subs_count > SUBSCRIPTIONS) { - $this->elementStart('p', array('id' => 'subscriptions_viewall')); - - $this->element('a', array('href' => common_local_url('subscriptions', - array('nickname' => $profile->nickname)), - 'class' => 'moresubscriptions'), - _('All subscriptions')); - $this->elementEnd('p'); - } - */ - } - function handle_post() + /** + * Handle posts to this form + * + * Based on the button that was pressed, muxes out to other functions + * to do the actual task requested. + * + * All sub-functions reload the form with a message -- success or failure. + * + * @return void + */ + + function handlePost() { - # CSRF protection + // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); + $this->showForm(_('There was a problem with your session token. '. + 'Try again, please.')); return; } if ($this->arg('save')) { - $this->save_preferences(); + $this->savePreferences(); } else if ($this->arg('add')) { - $this->add_twitter_acct(); + $this->addTwitterAccount(); } else if ($this->arg('remove')) { - $this->remove_twitter_acct(); + $this->removeTwitterAccount(); } else { - $this->show_form(_('Unexpected form submission.')); + $this->showForm(_('Unexpected form submission.')); } } - function add_twitter_acct() - { + /** + * Associate a Twitter account with the user's account + * + * Validates post input; verifies it against Twitter; and if + * successful stores in the database. + * + * @return void + */ + function addTwitterAccount() + { $screen_name = $this->trimmed('twitter_username'); - $password = $this->trimmed('twitter_password'); - $noticesync = $this->boolean('noticesync'); - $replysync = $this->boolean('replysync'); - $friendsync = $this->boolean('friendsync'); + $password = $this->trimmed('twitter_password'); + $noticesync = $this->boolean('noticesync'); + $replysync = $this->boolean('replysync'); + $friendsync = $this->boolean('friendsync'); if (!Validate::string($screen_name, - array( 'min_length' => 1, - 'max_length' => 15, - 'format' => VALIDATE_NUM . VALIDATE_ALPHA . '_'))) { - $this->show_form( - _('Username must have only numbers, upper- and lowercase letters, and underscore (_). 15 chars max.')); + array('min_length' => 1, + 'max_length' => 15, + 'format' => VALIDATE_NUM.VALIDATE_ALPHA.'_'))) { + $this->showForm(_('Username must have only numbers, '. + 'upper- and lowercase letters, '. + 'and underscore (_). 15 chars max.')); return; } - if (!$this->verify_credentials($screen_name, $password)) { - $this->show_form(_('Could not verify your Twitter credentials!')); + if (!$this->verifyCredentials($screen_name, $password)) { + $this->showForm(_('Could not verify your Twitter credentials!')); return; } $twit_user = twitter_user_info($screen_name, $password); if (!$twit_user) { - $this->show_form(sprintf(_('Unable to retrieve account information for "%s" from Twitter.'), - $screen_name)); + $this->showForm(sprintf(_('Unable to retrieve account information '. + 'For "%s" from Twitter.'), + $screen_name)); return; } if (!save_twitter_user($twit_user->id, $screen_name)) { - $this->show_form(_('Unable to save your Twitter settings!')); + $this->showForm(_('Unable to save your Twitter settings!')); return; } $user = common_current_user(); - $flink = DB_DataObject::factory('foreign_link'); - $flink->user_id = $user->id; - $flink->foreign_id = $twit_user->id; - $flink->service = 1; // Twitter + $flink = new Foreign_link(); + + $flink->user_id = $user->id; + $flink->foreign_id = $twit_user->id; + $flink->service = 1; // Twitter $flink->credentials = $password; - $flink->created = common_sql_now(); + $flink->created = common_sql_now(); $flink->set_flags($noticesync, $replysync, $friendsync); @@ -257,7 +351,7 @@ class TwittersettingsAction extends SettingsAction if (!$flink_id) { common_log_db_error($flink, 'INSERT', __FILE__); - $this->show_form(_('Unable to save your Twitter settings!')); + $this->showForm(_('Unable to save your Twitter settings!')); return; } @@ -265,19 +359,26 @@ class TwittersettingsAction extends SettingsAction save_twitter_friends($user, $twit_user->id, $screen_name, $password); } - $this->show_form(_('Twitter settings saved.'), true); + $this->showForm(_('Twitter settings saved.'), true); } - function remove_twitter_acct() - { + /** + * Disassociate an existing Twitter account from this account + * + * @return void + */ + function removeTwitterAccount() + { $user = common_current_user(); + $flink = Foreign_link::getByUserID($user->id, 1); + $flink_foreign_id = $this->arg('flink_foreign_id'); - # Maybe an old tab open...? + // Maybe an old tab open...? if ($flink->foreign_id != $flink_foreign_id) { - $this->show_form(_('That is not your Twitter account.')); + $this->showForm(_('That is not your Twitter account.')); return; } @@ -289,15 +390,20 @@ class TwittersettingsAction extends SettingsAction return; } - $this->show_form(_('Twitter account removed.'), true); + $this->showForm(_('Twitter account removed.'), true); } - function save_preferences() - { + /** + * Save user's Twitter-bridging preferences + * + * @return void + */ + function savePreferences() + { $noticesync = $this->boolean('noticesync'); $friendsync = $this->boolean('friendsync'); - $replysync = $this->boolean('replysync'); + $replysync = $this->boolean('replysync'); $user = common_current_user(); @@ -305,30 +411,32 @@ class TwittersettingsAction extends SettingsAction if (!$flink) { common_log_db_error($flink, 'SELECT', __FILE__); - $this->show_form(_('Couldn\'t save Twitter preferences.')); + $this->showForm(_('Couldn\'t save Twitter preferences.')); return; } $twitter_id = $flink->foreign_id; - $password = $flink->credentials; + $password = $flink->credentials; $fuser = $flink->getForeignUser(); if (!$fuser) { common_log_db_error($fuser, 'SELECT', __FILE__); - $this->show_form(_('Couldn\'t save Twitter preferences.')); + $this->showForm(_('Couldn\'t save Twitter preferences.')); return; } $screen_name = $fuser->nickname; $original = clone($flink); + $flink->set_flags($noticesync, $replysync, $friendsync); + $result = $flink->update($original); if ($result === false) { common_log_db_error($flink, 'UPDATE', __FILE__); - $this->show_form(_('Couldn\'t save Twitter preferences.')); + $this->showForm(_('Couldn\'t save Twitter preferences.')); return; } @@ -336,12 +444,22 @@ class TwittersettingsAction extends SettingsAction save_twitter_friends($user, $flink->foreign_id, $screen_name, $password); } - $this->show_form(_('Twitter preferences saved.'), true); + $this->showForm(_('Twitter preferences saved.'), true); } - function verify_credentials($screen_name, $password) + /** + * Verifies a username and password against Twitter's API + * + * @param string $screen_name Twitter user name + * @param string $password Twitter password + * + * @return boolean success flag + */ + + function verifyCredentials($screen_name, $password) { - $uri = 'http://twitter.com/account/verify_credentials.json'; + $uri = 'http://twitter.com/account/verifyCredentials.json'; + $data = get_twitter_data($uri, $screen_name, $password); if (!$data) { @@ -354,7 +472,7 @@ class TwittersettingsAction extends SettingsAction return false; } - $twitter_id = $user->id; + $twitter_id = $user->id; if ($twitter_id) { return $twitter_id; @@ -363,5 +481,4 @@ class TwittersettingsAction extends SettingsAction return false; } - } \ No newline at end of file -- cgit v1.2.3-54-g00ecf From d1b5233eacd0afb19a72651eaaa34027f3735d8c Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 16 Jan 2009 21:39:39 +0000 Subject: Update IM settings to new system --- actions/imsettings.php | 269 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 202 insertions(+), 67 deletions(-) (limited to 'actions') diff --git a/actions/imsettings.php b/actions/imsettings.php index 14df3451a..3e578b307 100644 --- a/actions/imsettings.php +++ b/actions/imsettings.php @@ -1,9 +1,12 @@ . + * + * @category Settings + * @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); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/settingsaction.php'); -require_once(INSTALLDIR.'/lib/jabber.php'); +require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/jabber.php'; + +/** + * Settings for Jabber/XMPP integration + * + * @category Settings + * @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/ + * + * @see SettingsAction + */ class ImsettingsAction extends SettingsAction { + /** + * Title of the page + * + * @return string Title of the page + */ + + function title() + { + return _('IM Settings'); + } + + /** + * Instructions for use + * + * @return instructions for use + */ - function get_instructions() + function getInstructions() { - return _('You can send and receive notices through Jabber/GTalk [instant messages](%%doc.im%%). Configure your address and settings below.'); + return _('You can send and receive notices through '. + 'Jabber/GTalk [instant messages](%%doc.im%%). '. + 'Configure your address and settings below.'); } - function show_form($msg=null, $success=false) + /** + * Content area of the page + * + * We make different sections of the form for the different kinds of + * functions, and have submit buttons with different names. These + * are muxed by handlePost() to see what the user really wants to do. + * + * @return void + */ + + function showContent() { $user = common_current_user(); - $this->form_header(_('IM Settings'), $msg, $success); $this->elementStart('form', array('method' => 'post', - 'id' => 'imsettings', - 'action' => - common_local_url('imsettings'))); + 'id' => 'imsettings', + 'action' => + common_local_url('imsettings'))); $this->hidden('token', common_session_token()); $this->element('h2', null, _('Address')); @@ -51,19 +102,27 @@ class ImsettingsAction extends SettingsAction $this->elementEnd('p'); $this->submit('remove', _('Remove')); } else { - $confirm = $this->get_confirmation(); + $confirm = $this->getConfirmation(); if ($confirm) { $this->elementStart('p'); $this->element('span', 'address unconfirmed', $confirm->address); $this->element('span', 'input_instructions', - sprintf(_('Awaiting confirmation on this address. Check your Jabber/GTalk account for a message with further instructions. (Did you add %s to your buddy list?)'), jabber_daemon_address())); + sprintf(_('Awaiting confirmation on this address. '. + 'Check your Jabber/GTalk account for a '. + 'message with further instructions. '. + '(Did you add %s to your buddy list?)'), + jabber_daemon_address())); $this->hidden('jabber', $confirm->address); $this->elementEnd('p'); $this->submit('cancel', _('Cancel')); } else { $this->input('jabber', _('IM Address'), ($this->arg('jabber')) ? $this->arg('jabber') : null, - sprintf(_('Jabber or GTalk address, like "UserName@example.org". First, make sure to add %s to your buddy list in your IM client or on GTalk.'), jabber_daemon_address())); + sprintf(_('Jabber or GTalk address, '. + 'like "UserName@example.org". '. + 'First, make sure to add %s to your '. + 'buddy list in your IM client or on GTalk.'), + jabber_daemon_address())); $this->submit('add', _('Add')); } } @@ -77,7 +136,8 @@ class ImsettingsAction extends SettingsAction _('Post a notice when my Jabber/GTalk status changes.'), $user->updatefrompresence); $this->checkbox('jabberreplies', - _('Send me replies through Jabber/GTalk from people I\'m not subscribed to.'), + _('Send me replies through Jabber/GTalk '. + 'from people I\'m not subscribed to.'), $user->jabberreplies); $this->checkbox('jabbermicroid', _('Publish a MicroID for my Jabber/GTalk address.'), @@ -85,15 +145,23 @@ class ImsettingsAction extends SettingsAction $this->submit('save', _('Save')); $this->elementEnd('form'); - common_show_footer(); } - function get_confirmation() + /** + * Get a confirmation code for this user + * + * @return Confirm_address address object for this user + */ + + function getConfirmation() { $user = common_current_user(); + $confirm = new Confirm_address(); - $confirm->user_id = $user->id; + + $confirm->user_id = $user->id; $confirm->address_type = 'jabber'; + if ($confirm->find(true)) { return $confirm; } else { @@ -101,49 +169,69 @@ class ImsettingsAction extends SettingsAction } } - function handle_post() + /** + * Handle posts to this form + * + * Based on the button that was pressed, muxes out to other functions + * to do the actual task requested. + * + * All sub-functions reload the form with a message -- success or failure. + * + * @return void + */ + + function handlePost() { - - # CSRF protection + // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); + $this->showForm(_('There was a problem with your session token. '. + 'Try again, please.')); return; } if ($this->arg('save')) { - $this->save_preferences(); + $this->savePreferences(); } else if ($this->arg('add')) { - $this->add_address(); + $this->addAddress(); } else if ($this->arg('cancel')) { - $this->cancel_confirmation(); + $this->cancelConfirmation(); } else if ($this->arg('remove')) { - $this->remove_address(); + $this->removeAddress(); } else { - $this->show_form(_('Unexpected form submission.')); + $this->showForm(_('Unexpected form submission.')); } } - function save_preferences() + /** + * Save user's Jabber preferences + * + * These are the checkboxes at the bottom of the page. They're used to + * set different settings + * + * @return void + */ + + function savePreferences() { - $jabbernotify = $this->boolean('jabbernotify'); + $jabbernotify = $this->boolean('jabbernotify'); $updatefrompresence = $this->boolean('updatefrompresence'); - $jabberreplies = $this->boolean('jabberreplies'); - $jabbermicroid = $this->boolean('jabbermicroid'); + $jabberreplies = $this->boolean('jabberreplies'); + $jabbermicroid = $this->boolean('jabbermicroid'); $user = common_current_user(); - assert(!is_null($user)); # should already be checked + assert(!is_null($user)); // should already be checked $user->query('BEGIN'); $original = clone($user); - $user->jabbernotify = $jabbernotify; + $user->jabbernotify = $jabbernotify; $user->updatefrompresence = $updatefrompresence; - $user->jabberreplies = $jabberreplies; - $user->jabbermicroid = $jabbermicroid; + $user->jabberreplies = $jabberreplies; + $user->jabbermicroid = $jabbermicroid; $result = $user->update($original); @@ -155,45 +243,54 @@ class ImsettingsAction extends SettingsAction $user->query('COMMIT'); - $this->show_form(_('Preferences saved.'), true); + $this->showForm(_('Preferences saved.'), true); } - function add_address() - { + /** + * Sends a confirmation to the address given + * + * Stores a confirmation record and sends out a + * Jabber message with the confirmation info. + * + * @return void + */ + function addAddress() + { $user = common_current_user(); $jabber = $this->trimmed('jabber'); - # Some validation + // Some validation if (!$jabber) { - $this->show_form(_('No Jabber ID.')); + $this->showForm(_('No Jabber ID.')); return; } $jabber = jabber_normalize_jid($jabber); if (!$jabber) { - $this->show_form(_('Cannot normalize that Jabber ID')); + $this->showForm(_('Cannot normalize that Jabber ID')); return; } if (!jabber_valid_base_jid($jabber)) { - $this->show_form(_('Not a valid Jabber ID')); + $this->showForm(_('Not a valid Jabber ID')); return; } else if ($user->jabber == $jabber) { - $this->show_form(_('That is already your Jabber ID.')); + $this->showForm(_('That is already your Jabber ID.')); return; - } else if ($this->jabber_exists($jabber)) { - $this->show_form(_('Jabber ID already belongs to another user.')); + } else if ($this->jabberExists($jabber)) { + $this->showForm(_('Jabber ID already belongs to another user.')); return; } - $confirm = new Confirm_address(); - $confirm->address = $jabber; - $confirm->address_type = 'jabber'; - $confirm->user_id = $user->id; - $confirm->code = common_confirmation_code(64); + $confirm = new Confirm_address(); + + $confirm->address = $jabber; + $confirm->address_type = 'jabber'; + $confirm->user_id = $user->id; + $confirm->code = common_confirmation_code(64); $result = $confirm->insert(); @@ -209,21 +306,35 @@ class ImsettingsAction extends SettingsAction $jabber); } - $msg = sprintf(_('A confirmation code was sent to the IM address you added. You must approve %s for sending messages to you.'), jabber_daemon_address()); + $msg = sprintf(_('A confirmation code was sent '. + 'to the IM address you added. '. + 'You must approve %s for '. + 'sending messages to you.'), + jabber_daemon_address()); - $this->show_form($msg, true); + $this->showForm($msg, true); } - function cancel_confirmation() + /** + * Cancel a confirmation + * + * If a confirmation exists, cancel it. + * + * @return void + */ + + function cancelConfirmation() { $jabber = $this->arg('jabber'); - $confirm = $this->get_confirmation(); + + $confirm = $this->getConfirmation(); + if (!$confirm) { - $this->show_form(_('No pending confirmation to cancel.')); + $this->showForm(_('No pending confirmation to cancel.')); return; } if ($confirm->address != $jabber) { - $this->show_form(_('That is the wrong IM address.')); + $this->showForm(_('That is the wrong IM address.')); return; } @@ -235,26 +346,38 @@ class ImsettingsAction extends SettingsAction return; } - $this->show_form(_('Confirmation cancelled.'), true); + $this->showForm(_('Confirmation cancelled.'), true); } - function remove_address() - { + /** + * Remove an address + * + * If the user has a confirmed address, remove it. + * + * @return void + */ + function removeAddress() + { $user = common_current_user(); + $jabber = $this->arg('jabber'); - # Maybe an old tab open...? + // Maybe an old tab open...? if ($user->jabber != $jabber) { - $this->show_form(_('That is not your Jabber ID.')); + $this->showForm(_('That is not your Jabber ID.')); return; } $user->query('BEGIN'); + $original = clone($user); + $user->jabber = null; + $result = $user->updateKeys($original); + if (!$result) { common_log_db_error($user, 'UPDATE', __FILE__); $this->serverError(_('Couldn\'t update user.')); @@ -262,15 +385,27 @@ class ImsettingsAction extends SettingsAction } $user->query('COMMIT'); - # XXX: unsubscribe to the old address + // XXX: unsubscribe to the old address - $this->show_form(_('The address was removed.'), true); + $this->showForm(_('The address was removed.'), true); } - function jabber_exists($jabber) + /** + * Does this Jabber ID exist? + * + * Checks if we already have another user with this address. + * + * @param string $jabber Address to check + * + * @return boolean whether the Jabber ID exists + */ + + function jabberExists($jabber) { $user = common_current_user(); + $other = User::staticGet('jabber', $jabber); + if (!$other) { return false; } else { -- cgit v1.2.3-54-g00ecf From 1b7b58192bd34f7d34ae6712ac1b09130bca6bd0 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 16 Jan 2009 22:29:13 +0000 Subject: Split avatar upload to its own page --- actions/avatarsettings.php | 306 +++++++++++++++++++++++++++++++++++++++++++++ htaccess.sample | 3 +- 2 files changed, 308 insertions(+), 1 deletion(-) create mode 100644 actions/avatarsettings.php (limited to 'actions') diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php new file mode 100644 index 000000000..de5473d9f --- /dev/null +++ b/actions/avatarsettings.php @@ -0,0 +1,306 @@ +. + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @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/settingsaction.php'; + +/** + * Upload an avatar + * + * We use jQuery to crop the image after upload. + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +class AvatarsettingsAction extends SettingsAction +{ + /** + * Title of the page + * + * @return string Title of the page + */ + + function title() + { + return _('Avatar'); + } + + /** + * Instructions for use + * + * @return instructions for use + */ + + function getInstructions() + { + return _('Set your personal avatar.'); + } + + /** + * Content area of the page + * + * Shows a form for uploading an avatar. + * + * @return void + */ + + function showContent() + { + $user = common_current_user(); + + $profile = $user->getProfile(); + + if (!$profile) { + common_log_db_error($user, 'SELECT', __FILE__); + $this->serverError(_('User without matching profile')); + return; + } + + $original = $profile->getOriginalAvatar(); + + $this->elementStart('form', array('enctype' => 'multipart/form-data', + 'method' => 'POST', + 'id' => 'avatar', + 'action' => + common_local_url('avatarsettings'))); + $this->hidden('token', common_session_token()); + + if ($original) { + $this->elementStart('div', + array('id' => 'avatar_original', + 'class' => 'avatar_view')); + $this->element('h3', null, _("Original:")); + $this->elementStart('div', array('id'=>'avatar_original_view')); + $this->element('img', array('src' => $original->url, + 'class' => 'avatar original', + 'width' => $original->width, + 'height' => $original->height, + 'alt' => $user->nickname)); + $this->elementEnd('div'); + $this->elementEnd('div'); + } + + $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); + + if ($avatar) { + $this->elementStart('div', + array('id' => 'avatar_preview', + 'class' => 'avatar_view')); + $this->element('h3', null, _("Preview:")); + $this->elementStart('div', array('id'=>'avatar_preview_view')); + $this->element('img', array('src' => $original->url,//$avatar->url, + 'class' => 'avatar profile', + 'width' => AVATAR_PROFILE_SIZE, + 'height' => AVATAR_PROFILE_SIZE, + 'alt' => $user->nickname)); + $this->elementEnd('div'); + $this->elementEnd('div'); + + foreach (array('avatar_crop_x', 'avatar_crop_y', + 'avatar_crop_w', 'avatar_crop_h') as $crop_info) { + $this->element('input', array('name' => $crop_info, + 'type' => 'hidden', + 'id' => $crop_info)); + } + $this->submit('crop', _('Crop')); + } + + $this->element('input', array('name' => 'MAX_FILE_SIZE', + 'type' => 'hidden', + 'id' => 'MAX_FILE_SIZE', + 'value' => MAX_AVATAR_SIZE)); + + $this->elementStart('p'); + + $this->element('input', array('name' => 'avatarfile', + 'type' => 'file', + 'id' => 'avatarfile')); + $this->elementEnd('p'); + + $this->submit('upload', _('Upload')); + $this->elementEnd('form'); + + } + + /** + * Handle a post + * + * We mux on the button name to figure out what the user actually wanted. + * + * @return void + */ + + function handlePost() + { + // CSRF protection + + $token = $this->trimmed('token'); + if (!$token || $token != common_session_token()) { + $this->show_form(_('There was a problem with your session token. '. + 'Try again, please.')); + return; + } + + if ($this->arg('upload')) { + $this->uploadAvatar(); + } else if ($this->arg('crop')) { + $this->cropAvatar(); + } else { + $this->showForm(_('Unexpected form submission.')); + } + } + + /** + * Handle an image upload + * + * Does all the magic for handling an image upload, and crops the + * image by default. + * + * @return void + */ + + function uploadAvatar() + { + switch ($_FILES['avatarfile']['error']) { + case UPLOAD_ERR_OK: // success, jump out + break; + case UPLOAD_ERR_INI_SIZE: + case UPLOAD_ERR_FORM_SIZE: + $this->showForm(_('That file is too big.')); + return; + case UPLOAD_ERR_PARTIAL: + @unlink($_FILES['avatarfile']['tmp_name']); + $this->showForm(_('Partial upload.')); + return; + default: + $this->showForm(_('System error uploading file.')); + return; + } + + $info = @getimagesize($_FILES['avatarfile']['tmp_name']); + + if (!$info) { + @unlink($_FILES['avatarfile']['tmp_name']); + $this->showForm(_('Not an image or corrupt file.')); + return; + } + + switch ($info[2]) { + case IMAGETYPE_GIF: + case IMAGETYPE_JPEG: + case IMAGETYPE_PNG: + break; + default: + $this->showForm(_('Unsupported image file format.')); + return; + } + + $user = common_current_user(); + + $profile = $user->getProfile(); + + if ($profile->setOriginal($_FILES['avatarfile']['tmp_name'])) { + $this->showForm(_('Avatar updated.'), true); + } else { + $this->showForm(_('Failed updating avatar.')); + } + + @unlink($_FILES['avatarfile']['tmp_name']); + } + + /** + * Handle the results of jcrop. + * + * @return void + */ + + function cropAvatar() + { + $user = common_current_user(); + + $profile = $user->getProfile(); + + $x = $this->arg('avatar_crop_x'); + $y = $this->arg('avatar_crop_y'); + $w = $this->arg('avatar_crop_w'); + $h = $this->arg('avatar_crop_h'); + + if ($profile->crop_avatars($x, $y, $w, $h)) { + $this->showForm(_('Avatar updated.'), true); + } else { + $this->showForm(_('Failed updating avatar.')); + } + } + + /** + * Add the jCrop stylesheet + * + * @return void + */ + + function showStylesheets() + { + parent::showStylesheets(); + $jcropStyle = + common_path('js/jcrop/jquery.Jcrop.css?version='.LACONICA_VERSION); + + $this->element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => $jcropStyle, + 'media' => 'screen, projection, tv')); + } + + /** + * Add the jCrop scripts + * + * @return void + */ + + function showScripts() + { + parent::showScripts(); + + $jcropPack = common_path('js/jcrop/jquery.Jcrop.pack.js'); + $jcropGo = common_path('js/jcrop/jquery.Jcrop.go.js'); + + $this->element('script', array('type' => 'text/javascript', + 'src' => $jcropPack)); + $this->element('script', array('type' => 'text/javascript', + 'src' => $jcropGo)); + } +} diff --git a/htaccess.sample b/htaccess.sample index e348635a8..10e51b5b0 100644 --- a/htaccess.sample +++ b/htaccess.sample @@ -52,8 +52,9 @@ RewriteRule ^main/tagother$ index.php?action=tagother [L,QSA] RewriteRule ^main/block$ index.php?action=block [L,QSA] -RewriteRule ^settings/delete$ index.php?action=deleteprofile [L,QSA] RewriteRule ^settings/profile$ index.php?action=profilesettings [L,QSA] +RewriteRule ^settings/avatar$ index.php?action=avatarsettings [L,QSA] +RewriteRule ^settings/password$ index.php?action=passwordsettings [L,QSA] RewriteRule ^settings/openid$ index.php?action=openidsettings [L,QSA] RewriteRule ^settings/im$ index.php?action=imsettings [L,QSA] RewriteRule ^settings/email$ index.php?action=emailsettings [L,QSA] -- cgit v1.2.3-54-g00ecf From f46fd284e4395a113cdcc6e019d6f1b4b9ef8ff6 Mon Sep 17 00:00:00 2001 From: sarven Date: Fri, 16 Jan 2009 23:41:46 +0000 Subject: Update to forms and email settings --- actions/emailsettings.php | 50 +++++++++++++++++++++++++++++++++------------- lib/htmloutputter.php | 21 +++++-------------- lib/settingsgroupnav.php | 4 ++-- theme/base/css/display.css | 9 ++++++++- 4 files changed, 51 insertions(+), 33 deletions(-) (limited to 'actions') diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 4cd63a9d3..d03d5ff84 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -85,42 +85,46 @@ class EmailsettingsAction extends SettingsAction $user = common_current_user(); $this->elementStart('form', array('method' => 'post', - 'id' => 'emailsettings', + 'id' => 'form_settings_email', + 'class' => 'form_settings', 'action' => common_local_url('emailsettings'))); - + $this->elementStart('fieldset'); + $this->element('legend', null, _('Email settings')); $this->hidden('token', common_session_token()); + $this->elementStart('div', array('id' => 'settings_email_address')); $this->element('h2', null, _('Address')); if ($user->email) { - $this->elementStart('p'); - $this->element('span', 'address confirmed', $user->email); - $this->element('span', 'input_instructions', - _('Current confirmed email address.')); + $this->element('p', array('id' => 'email_confirmed', $user->email)); + $this->element('p', array('class' => 'form_note'), _('Current confirmed email address.')); $this->hidden('email', $user->email); - $this->elementEnd('p'); $this->submit('remove', _('Remove')); } else { $confirm = $this->getConfirmation(); if ($confirm) { - $this->elementStart('p'); - $this->element('span', 'address unconfirmed', $confirm->address); - $this->element('span', 'input_instructions', - _('Awaiting confirmation on this address. '. - 'Check your inbox (and spam box!) for a message '. - 'with further instructions.')); + $this->element('p', array('id' => 'email_unconfirmed'), $confirm->address); + $this->element('p', array('class' => 'form_note'), + _('Awaiting confirmation on this address. '. + 'Check your inbox (and spam box!) for a message '. + 'with further instructions.')); $this->hidden('email', $confirm->address); - $this->elementEnd('p'); $this->submit('cancel', _('Cancel')); } else { + $this->elementStart('ul', 'form_datas'); + $this->elementStart('li'); $this->input('email', _('Email Address'), ($this->arg('email')) ? $this->arg('email') : null, _('Email address, like "UserName@example.org"')); + $this->elementEnd('li'); + $this->elementEnd('ul'); $this->submit('add', _('Add')); } } + $this->elementEnd('div'); + $this->elementStart('div', array('id' => 'settings_email_incoming')); if ($user->email) { $this->element('h2', null, _('Incoming email')); @@ -140,31 +144,49 @@ class EmailsettingsAction extends SettingsAction $this->elementEnd('p'); $this->submit('newincoming', _('New')); } + $this->elementEnd('div'); + $this->elementStart('div', array('id' => 'settings_email_preferences')); $this->element('h2', null, _('Preferences')); + $this->elementStart('ul', 'form_datas'); + $this->elementStart('li'); $this->checkbox('emailnotifysub', _('Send me notices of new subscriptions through email.'), $user->emailnotifysub); + $this->elementEnd('li'); + $this->elementStart('li'); $this->checkbox('emailnotifyfav', _('Send me email when someone '. 'adds my notice as a favorite.'), $user->emailnotifyfav); + $this->elementEnd('li'); + $this->elementStart('li'); $this->checkbox('emailnotifymsg', _('Send me email when someone sends me a private message.'), $user->emailnotifymsg); + $this->elementEnd('li'); + $this->elementStart('li'); $this->checkbox('emailnotifynudge', _('Allow friends to nudge me and send me an email.'), $user->emailnotifynudge); + $this->elementEnd('li'); + $this->elementStart('li'); $this->checkbox('emailpost', _('I want to post notices by email.'), $user->emailpost); + $this->elementEnd('li'); + $this->elementStart('li'); $this->checkbox('emailmicroid', _('Publish a MicroID for my email address.'), $user->emailmicroid); + $this->elementEnd('li'); + $this->elementEnd('ul'); + $this->elementEnd('div'); $this->submit('save', _('Save')); + $this->elementEnd('fieldset'); $this->elementEnd('form'); } diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index eb8a612e4..37853f345 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -155,20 +155,17 @@ class HTMLOutputter extends XMLOutputter function input($id, $label, $value=null, $instructions=null) { - $this->elementStart('p'); $this->element('label', array('for' => $id), $label); $attrs = array('name' => $id, 'type' => 'text', - 'class' => 'input_text', 'id' => $id); if ($value) { $attrs['value'] = htmlspecialchars($value); } $this->element('input', $attrs); if ($instructions) { - $this->element('span', 'input_instructions', $instructions); + $this->element('p', 'form_guide', $instructions); } - $this->elementEnd('p'); } /** @@ -192,7 +189,6 @@ class HTMLOutputter extends XMLOutputter function checkbox($id, $label, $checked=false, $instructions=null, $value='true', $disabled=false) { - $this->elementStart('p'); $attrs = array('name' => $id, 'type' => 'checkbox', 'class' => 'checkbox', @@ -213,9 +209,8 @@ class HTMLOutputter extends XMLOutputter $label); $this->text(' '); if ($instructions) { - $this->element('span', 'input_instructions', $instructions); + $this->element('p', 'form_guide', $instructions); } - $this->elementEnd('p'); } /** @@ -240,7 +235,6 @@ class HTMLOutputter extends XMLOutputter function dropdown($id, $label, $content, $instructions=null, $blank_select=false, $selected=null) { - $this->elementStart('p'); $this->element('label', array('for' => $id), $label); $this->elementStart('select', array('id' => $id, 'name' => $id)); if ($blank_select) { @@ -257,9 +251,8 @@ class HTMLOutputter extends XMLOutputter } $this->elementEnd('select'); if ($instructions) { - $this->element('span', 'input_instructions', $instructions); + $this->element('p', 'form_guide', $instructions); } - $this->elementEnd('p'); } /** @@ -296,7 +289,6 @@ class HTMLOutputter extends XMLOutputter function password($id, $label, $instructions=null) { - $this->elementStart('p'); $this->element('label', array('for' => $id), $label); $attrs = array('name' => $id, 'type' => 'password', @@ -304,9 +296,8 @@ class HTMLOutputter extends XMLOutputter 'id' => $id); $this->element('input', $attrs); if ($instructions) { - $this->element('span', 'input_instructions', $instructions); + $this->element('p', 'form_guide', $instructions); } - $this->elementEnd('p'); } /** @@ -348,7 +339,6 @@ class HTMLOutputter extends XMLOutputter function textarea($id, $label, $content=null, $instructions=null) { - $this->elementStart('p'); $this->element('label', array('for' => $id), $label); $this->element('textarea', array('rows' => 3, 'cols' => 40, @@ -356,8 +346,7 @@ class HTMLOutputter extends XMLOutputter 'id' => $id), ($content) ? $content : ''); if ($instructions) { - $this->element('span', 'input_instructions', $instructions); + $this->element('p', 'form_guide', $instructions); } - $this->elementEnd('p'); } } diff --git a/lib/settingsgroupnav.php b/lib/settingsgroupnav.php index 044c74552..bd66c65a6 100644 --- a/lib/settingsgroupnav.php +++ b/lib/settingsgroupnav.php @@ -94,7 +94,7 @@ class SettingsGroupNav extends Widget _('Other options'))); $action_name = $this->action->trimmed('action'); - $this->action->elementStart('ul', array('id' => 'nav_views')); + $this->action->elementStart('ul', array('class' => 'nav')); foreach ($menu as $menuaction => $menudesc) { if ($menuaction == 'imsettings' && @@ -104,7 +104,7 @@ class SettingsGroupNav extends Widget $this->action->menuItem(common_local_url($menuaction), $menudesc[0], $menudesc[1], - $action_name == $menuaction); + $action_name === $menuaction); } $this->action->elementEnd('ul'); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index b8b260266..027cb1666 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -100,7 +100,7 @@ border:0; display:none; } .form_settings .form_datas label { -display:block; + } .form_guide { @@ -116,6 +116,13 @@ display:inline; font-weight:bold; } +.form_settings p { +margin-bottom:18px; +} + +#settings_email_address { +margin-bottom:29px; +} /* FORM SETTINGS */ -- cgit v1.2.3-54-g00ecf From 0a5125675b4165be4c8278edf8d30f33483081fa Mon Sep 17 00:00:00 2001 From: sarven Date: Sat, 17 Jan 2009 00:01:53 +0000 Subject: Updates to form styling --- actions/emailsettings.php | 28 ++++++++++++---------------- lib/htmloutputter.php | 2 +- theme/base/css/display.css | 13 ++++++++++++- 3 files changed, 25 insertions(+), 18 deletions(-) (limited to 'actions') diff --git a/actions/emailsettings.php b/actions/emailsettings.php index d03d5ff84..090df30dd 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -89,12 +89,10 @@ class EmailsettingsAction extends SettingsAction 'class' => 'form_settings', 'action' => common_local_url('emailsettings'))); - $this->elementStart('fieldset'); - $this->element('legend', null, _('Email settings')); - $this->hidden('token', common_session_token()); - $this->elementStart('div', array('id' => 'settings_email_address')); - $this->element('h2', null, _('Address')); + $this->elementStart('fieldset',array('id' => 'settings_email_address')); + $this->element('legend', null, _('Address')); + $this->hidden('token', common_session_token()); if ($user->email) { $this->element('p', array('id' => 'email_confirmed', $user->email)); @@ -122,12 +120,11 @@ class EmailsettingsAction extends SettingsAction $this->submit('add', _('Add')); } } - $this->elementEnd('div'); - - $this->elementStart('div', array('id' => 'settings_email_incoming')); - if ($user->email) { - $this->element('h2', null, _('Incoming email')); + $this->elementEnd('fieldset'); + if ($user->email) { + $this->elementStart('fieldset',array('id' => 'settings_email_incoming')); + $this->element('legend',_('Incoming email')); if ($user->incomingemail) { $this->elementStart('p'); $this->element('span', 'address', $user->incomingemail); @@ -143,11 +140,12 @@ class EmailsettingsAction extends SettingsAction 'cancels the old one.')); $this->elementEnd('p'); $this->submit('newincoming', _('New')); + $this->elementEnd('fieldset'); } - $this->elementEnd('div'); - $this->elementStart('div', array('id' => 'settings_email_preferences')); - $this->element('h2', null, _('Preferences')); + + $this->elementStart('fieldset', array('id' => 'settings_email_preferences')); + $this->element('legend', null, _('Preferences')); $this->elementStart('ul', 'form_datas'); $this->elementStart('li'); @@ -182,11 +180,9 @@ class EmailsettingsAction extends SettingsAction $user->emailmicroid); $this->elementEnd('li'); $this->elementEnd('ul'); - $this->elementEnd('div'); + $this->elementEnd('fieldset'); $this->submit('save', _('Save')); - - $this->elementEnd('fieldset'); $this->elementEnd('form'); } diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index 37853f345..71f17604b 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -204,7 +204,7 @@ class HTMLOutputter extends XMLOutputter } $this->element('input', $attrs); $this->text(' '); - $this->element('label', array('class' => 'checkbox_label', + $this->element('label', array('class' => 'checkbox', 'for' => $id), $label); $this->text(' '); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 027cb1666..294119c55 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -64,6 +64,13 @@ font-weight:bold; } form ul li input { } + +form input.checkbox { +position:relative; +top:2px; +left:0; +} + form .error { margin-right:11px; } @@ -97,7 +104,8 @@ padding:0; border:0; } .form_settings legend { -display:none; +font-size:1.6em; +text-transform:uppercase; } .form_settings .form_datas label { @@ -124,6 +132,9 @@ margin-bottom:18px; margin-bottom:29px; } +#settings_email_preferences label { +font-weight:normal; +} /* FORM SETTINGS */ -- cgit v1.2.3-54-g00ecf From 2561199e59ce6c4f4390443bda6d17d709ce1e36 Mon Sep 17 00:00:00 2001 From: sarven Date: Sat, 17 Jan 2009 00:06:31 +0000 Subject: OpenID form settings markup --- actions/openidsettings.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'actions') diff --git a/actions/openidsettings.php b/actions/openidsettings.php index a21a9869e..f24c81795 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -85,26 +85,31 @@ class OpenidsettingsAction extends SettingsAction $user = common_current_user(); $this->elementStart('form', array('method' => 'post', - 'id' => 'openidadd', + 'id' => 'form_openid_add', + 'class' => 'form_settings', 'action' => common_local_url('openidsettings'))); + $this->elementStart('fieldset'); + $this->element('legend', null, _('Add OpenID')); $this->hidden('token', common_session_token()); - $this->element('h2', null, _('Add OpenID')); - $this->element('p', null, + $this->element('p', 'form_guide', _('If you want to add an OpenID to your account, ' . 'enter it in the box below and click "Add".')); - $this->elementStart('p'); + $this->elementStart('ul', 'form_datas'); + $this->elementStart('li'); $this->element('label', array('for' => 'openid_url'), _('OpenID URL')); $this->element('input', array('name' => 'openid_url', 'type' => 'text', 'id' => 'openid_url')); + $this->elementEnd('li'); + $this->elementEnd('ul'); $this->element('input', array('type' => 'submit', 'id' => 'add', 'name' => 'add', 'class' => 'submit', 'value' => _('Add'))); - $this->elementEnd('p'); + $this->elementEnd('fieldset'); $this->elementEnd('form'); $oid = new User_openid(); -- cgit v1.2.3-54-g00ecf From b9fb70ee70ecd465f5843241b308f2b8680120f6 Mon Sep 17 00:00:00 2001 From: sarven Date: Sat, 17 Jan 2009 00:46:33 +0000 Subject: Markup clean up and styles --- actions/emailsettings.php | 7 +++---- actions/openidsettings.php | 15 ++++++++------- lib/action.php | 3 +-- theme/base/css/display.css | 4 ++++ 4 files changed, 16 insertions(+), 13 deletions(-) (limited to 'actions') diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 090df30dd..355470815 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -90,7 +90,7 @@ class EmailsettingsAction extends SettingsAction 'action' => common_local_url('emailsettings'))); - $this->elementStart('fieldset',array('id' => 'settings_email_address')); + $this->elementStart('fieldset', array('id' => 'settings_email_address')); $this->element('legend', null, _('Address')); $this->hidden('token', common_session_token()); @@ -123,7 +123,7 @@ class EmailsettingsAction extends SettingsAction $this->elementEnd('fieldset'); if ($user->email) { - $this->elementStart('fieldset',array('id' => 'settings_email_incoming')); + $this->elementStart('fieldset', array('id' => 'settings_email_incoming')); $this->element('legend',_('Incoming email')); if ($user->incomingemail) { $this->elementStart('p'); @@ -180,9 +180,8 @@ class EmailsettingsAction extends SettingsAction $user->emailmicroid); $this->elementEnd('li'); $this->elementEnd('ul'); - $this->elementEnd('fieldset'); - $this->submit('save', _('Save')); + $this->elementEnd('fieldset'); $this->elementEnd('form'); } diff --git a/actions/openidsettings.php b/actions/openidsettings.php index f24c81795..6f17f154c 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -85,11 +85,11 @@ class OpenidsettingsAction extends SettingsAction $user = common_current_user(); $this->elementStart('form', array('method' => 'post', - 'id' => 'form_openid_add', + 'id' => 'form_settings_openid_add', 'class' => 'form_settings', 'action' => common_local_url('openidsettings'))); - $this->elementStart('fieldset'); + $this->elementStart('fieldset', array('id' => 'settings_openid_add')); $this->element('legend', null, _('Add OpenID')); $this->hidden('token', common_session_token()); $this->element('p', 'form_guide', @@ -105,7 +105,7 @@ class OpenidsettingsAction extends SettingsAction $this->elementEnd('li'); $this->elementEnd('ul'); $this->element('input', array('type' => 'submit', - 'id' => 'add', + 'id' => 'settings_openid_add_action-submit', 'name' => 'add', 'class' => 'submit', 'value' => _('Add'))); @@ -139,7 +139,7 @@ class OpenidsettingsAction extends SettingsAction } else { - $this->element('p', null, + $this->element('p', 'form_guide', _('You can remove an OpenID from your account '. 'by clicking the button marked "Remove".')); $idx = 0; @@ -147,10 +147,11 @@ class OpenidsettingsAction extends SettingsAction while ($oid->fetch()) { $this->elementStart('form', array('method' => 'POST', - 'id' => 'openiddelete' . $idx, + 'id' => 'form_settings_openid_delete' . $idx, + 'class' => 'form_settings', 'action' => common_local_url('openidsettings'))); - $this->elementStart('p'); + $this->elementStart('fieldset'); $this->hidden('token', common_session_token()); $this->element('a', array('href' => $oid->canonical), $oid->display); @@ -163,7 +164,7 @@ class OpenidsettingsAction extends SettingsAction 'name' => 'remove', 'class' => 'submit', 'value' => _('Remove'))); - $this->elementEnd('p'); + $this->elementEnd('fieldset'); $this->elementEnd('form'); $idx++; } diff --git a/lib/action.php b/lib/action.php index 1622047c0..35f6f2e3e 100644 --- a/lib/action.php +++ b/lib/action.php @@ -565,8 +565,7 @@ class Action extends HTMLOutputter // lawsuit if ($is_selected) { $lattrs['class'] = 'current'; } - (is_null($id)) ? $lattrs : $lattrs['id'] = $id; - $this->elementStart('li', $lattrs); + $this->elementStart('li', (is_null($id)) ? $lattrs : $lattr['id'] = $id); $attrs['href'] = $url; if ($title) { $attrs['title'] = $title; diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 294119c55..3aee52088 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -99,6 +99,10 @@ form input.submit { /* FORM SETTINGS */ +.form_settings { +margin-bottom:29px; +} + .form_settings fieldset { padding:0; border:0; -- cgit v1.2.3-54-g00ecf From 0b947a33bc401faaddcae3bb5b39b9cbe2d5277c Mon Sep 17 00:00:00 2001 From: sarven Date: Sat, 17 Jan 2009 00:49:48 +0000 Subject: Minor --- actions/smssettings.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'actions') diff --git a/actions/smssettings.php b/actions/smssettings.php index f214997ec..d7c621b13 100644 --- a/actions/smssettings.php +++ b/actions/smssettings.php @@ -83,12 +83,14 @@ class SmssettingsAction extends SettingsAction $user = common_current_user(); $this->elementStart('form', array('method' => 'post', - 'id' => 'smssettings', + 'id' => 'form_settings_sms', + 'class' => 'form_settings', 'action' => common_local_url('smssettings'))); + $this->elementStart('fieldset'); + $this->element('legend', null, _('Address')); $this->hidden('token', common_session_token()); - $this->element('h2', null, _('Address')); if ($user->sms) { $this->elementStart('p'); @@ -126,6 +128,7 @@ class SmssettingsAction extends SettingsAction $this->submit('add', _('Add')); } } + $this->elementEnd('fieldset'); if ($user->sms) { $this->element('h2', null, _('Incoming email')); @@ -147,8 +150,8 @@ class SmssettingsAction extends SettingsAction $this->submit('newincoming', _('New')); } - $this->element('h2', null, _('Preferences')); - + $this->elementStart('fieldset', array('id' => 'sms_preferences')); + $this->element('legend', null, _('Preferences')); $this->checkbox('smsnotify', _('Send me notices through SMS; '. 'I understand I may incur '. @@ -157,6 +160,7 @@ class SmssettingsAction extends SettingsAction $this->submit('save', _('Save')); + $this->elementEnd('fieldset'); $this->elementEnd('form'); } -- cgit v1.2.3-54-g00ecf From b2f16c523466f40589712a173a35c1b0bf54ea99 Mon Sep 17 00:00:00 2001 From: sarven Date: Sat, 17 Jan 2009 01:08:55 +0000 Subject: SMS form settings --- actions/smssettings.php | 24 +++++++++++++++--------- theme/base/css/display.css | 7 ++----- 2 files changed, 17 insertions(+), 14 deletions(-) (limited to 'actions') diff --git a/actions/smssettings.php b/actions/smssettings.php index d7c621b13..6d3c54942 100644 --- a/actions/smssettings.php +++ b/actions/smssettings.php @@ -88,7 +88,7 @@ class SmssettingsAction extends SettingsAction 'action' => common_local_url('smssettings'))); - $this->elementStart('fieldset'); + $this->elementStart('fieldset', array('id' => 'settings_sms_address')); $this->element('legend', null, _('Address')); $this->hidden('token', common_session_token()); @@ -142,21 +142,25 @@ class SmssettingsAction extends SettingsAction $this->submit('removeincoming', _('Remove')); } - $this->elementStart('p'); - $this->element('span', 'input_instructions', + $this->element('p', 'form_guide', _('Make a new email address for posting to; '. 'cancels the old one.')); - $this->elementEnd('p'); $this->submit('newincoming', _('New')); } - $this->elementStart('fieldset', array('id' => 'sms_preferences')); + $this->elementStart('fieldset', array('id' => 'settings_sms_preferences')); $this->element('legend', null, _('Preferences')); + + + $this->elementStart('ul', 'form_datas'); + $this->elementStart('li'); $this->checkbox('smsnotify', _('Send me notices through SMS; '. 'I understand I may incur '. 'exorbitant charges from my carrier.'), $user->smsnotify); + $this->elementEnd('li'); + $this->elementEnd('ul'); $this->submit('save', _('Save')); @@ -440,8 +444,9 @@ class SmssettingsAction extends SettingsAction $cnt = $carrier->find(); - $this->elementStart('p'); - $this->element('label', array('for' => 'carrier')); + $this->elementStart('ul'); + $this->elementStart('li'); + $this->element('label', array('for' => 'carrier'), _('Mobile carrier')); $this->elementStart('select', array('name' => 'carrier', 'id' => 'carrier')); $this->element('option', array('value' => 0), @@ -451,13 +456,14 @@ class SmssettingsAction extends SettingsAction $carrier->name); } $this->elementEnd('select'); - $this->elementEnd('p'); - $this->element('span', 'input_instructions', + $this->element('p', 'form_guide', sprintf(_('Mobile carrier for your phone. '. 'If you know a carrier that accepts ' . 'SMS over email but isn\'t listed here, ' . 'send email to let us know at %s.'), common_config('site', 'email'))); + $this->elementEnd('li'); + $this->elementEnd('ul'); } /** diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 3aee52088..fce4c7b86 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -99,13 +99,10 @@ form input.submit { /* FORM SETTINGS */ -.form_settings { -margin-bottom:29px; -} - .form_settings fieldset { padding:0; border:0; +margin-bottom:29px; } .form_settings legend { font-size:1.6em; @@ -136,7 +133,7 @@ margin-bottom:18px; margin-bottom:29px; } -#settings_email_preferences label { +.form_settings label.checkbox { font-weight:normal; } -- cgit v1.2.3-54-g00ecf From 3e40a564bd7f727d2c967b6f70acc14d4b801d97 Mon Sep 17 00:00:00 2001 From: sarven Date: Sat, 17 Jan 2009 01:50:21 +0000 Subject: twitter settings markup --- actions/twittersettings.php | 39 ++++++++++++++++++++++++++------------- 1 file changed, 26 insertions(+), 13 deletions(-) (limited to 'actions') diff --git a/actions/twittersettings.php b/actions/twittersettings.php index 5492dd995..cd070cb45 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -97,58 +97,71 @@ class TwittersettingsAction extends SettingsAction } $this->elementStart('form', array('method' => 'post', - 'id' => 'twittersettings', + 'id' => 'form_settings_twitter', + 'class' => 'form_settings', 'action' => common_local_url('twittersettings'))); + $this->elementStart('fieldset', array('id' => 'settings_twitter_account')); + $this->element('legend', null, _('Twitter Account')); $this->hidden('token', common_session_token()); - - $this->element('h2', null, _('Twitter Account')); - + $this->elementStart('ul', 'form_datas'); if ($fuser) { - $this->elementStart('p'); - + $this->elementStart('li'); $this->element('span', 'twitter_user', $fuser->nickname); $this->element('a', array('href' => $fuser->uri), $fuser->uri); - $this->element('span', 'input_instructions', + $this->element('p', 'form_guide', _('Current verified Twitter account.')); $this->hidden('flink_foreign_id', $flink->foreign_id); - $this->elementEnd('p'); $this->submit('remove', _('Remove')); + $this->elementEnd('li'); } else { + $this->elementStart('li'); $this->input('twitter_username', _('Twitter user name'), ($this->arg('twitter_username')) ? $this->arg('twitter_username') : $profile->nickname, _('No spaces, please.')); // hey, it's what Twitter says - + $this->elementEnd('li'); + $this->elementStart('li'); $this->password('twitter_password', _('Twitter password')); + $this->elementend('li'); } + $this->elementEnd('ul'); + $this->elementEnd('fieldset'); - $this->element('h2', null, _('Preferences')); + $this->elementStart('fieldset', array('id' => 'settings_twitter_preferences')); + $this->element('legend', null, _('Preferences')); + $this->elementStart('ul'); + $this->elementStart('li'); $this->checkbox('noticesync', _('Automatically send my notices to Twitter.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND) : true); - + $this->elementEnd('li'); + $this->elementStart('li'); $this->checkbox('replysync', _('Send local "@" replies to Twitter.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true); - + $this->elementEnd('li'); + $this->elementStart('li'); $this->checkbox('friendsync', _('Subscribe to my Twitter friends here.'), ($flink) ? ($flink->friendsync & FOREIGN_FRIEND_RECV) : false); + $this->elementEnd('li'); + $this->elementEnd('ul'); if ($flink) { $this->submit('save', _('Save')); } else { $this->submit('add', _('Add')); } + $this->elementEnd('fieldset'); $this->showTwitterSubscriptions(); @@ -481,4 +494,4 @@ class TwittersettingsAction extends SettingsAction return false; } -} \ No newline at end of file +} -- cgit v1.2.3-54-g00ecf From 05b00cc7df22d2e998d642e91fee6cea317a9b83 Mon Sep 17 00:00:00 2001 From: sarven Date: Sat, 17 Jan 2009 16:22:36 +0000 Subject: Login styles --- actions/login.php | 14 +++++++++- theme/base/css/display.css | 68 +++++++++++++++++++++------------------------- 2 files changed, 44 insertions(+), 38 deletions(-) (limited to 'actions') diff --git a/actions/login.php b/actions/login.php index 23ab16676..224b30f6f 100644 --- a/actions/login.php +++ b/actions/login.php @@ -130,15 +130,27 @@ class LoginAction extends Action function showContent() { $this->elementStart('form', array('method' => 'post', - 'id' => 'login', + 'id' => 'form_login', + 'class' => 'form_login', 'action' => common_local_url('login'))); + $this->elementStart('fieldset'); + $this->element('legend', null, _('Login to site')); + $this->elementStart('ul', 'form_datas'); + $this->elementStart('li'); $this->input('nickname', _('Nickname')); + $this->elementEnd('li'); + $this->elementStart('li'); $this->password('password', _('Password')); + $this->elementEnd('li'); + $this->elementStart('li'); $this->checkbox('rememberme', _('Remember me'), false, _('Automatically login in the future; ' . 'not for shared computers!')); + $this->elementEnd('li'); + $this->elementEnd('ul'); $this->submit('submit', _('Login')); $this->hidden('token', common_session_token()); + $this->elementEnd('fieldset'); $this->elementEnd('form'); $this->elementStart('p'); $this->element('a', array('href' => common_local_url('recoverpassword')), diff --git a/theme/base/css/display.css b/theme/base/css/display.css index ce7f69b35..afddefd27 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -30,30 +30,38 @@ h1,h2,h3,h4,h5,h6 { text-transform:uppercase; margin-bottom:7px; } -legend { font-weight:bold; } +caption { +font-weight:bold; +} +.opened { display: block !important;} +.closed { display: none !important;} + + +legend { +font-weight:bold; +font-size:1.6em; +text-transform:uppercase; +} input, textarea, select, option { padding:4px; font-family:sans-serif; font-size:1em; -moz-border-radius:4px; } -select, option { -padding-bottom:0; -} -fieldset { -padding:11px; -} input:focus, textarea:focus, select:focus { border-width:2px; border-style: solid; --moz-border-radius:4px; } -caption { -font-weight:bold; + +select, option { +padding-bottom:0; } -.opened { display: block !important;} -.closed { display: none !important;} -span.required { font-weight:bold; } +fieldset { +padding:0; +border:0; +margin-bottom:29px; +} + form ul li { list-style-type:none; margin:0 0 18px 0; @@ -71,8 +79,10 @@ top:2px; left:0; } -form .error { -margin-right:11px; +#page_notice .error { +background-color:#F7E8E8; +padding:4px 7px; +-moz-border-radius:4px; } form label.submit { display:none; @@ -83,15 +93,7 @@ display:block; .form_response { margin-bottom:18px; } -.form_response dt { -} -.form_response dd { -} -form input.remove, -form input.submit { --moz-border-radius:4px; -} form input.submit { } @@ -99,24 +101,16 @@ form input.submit { /* FORM SETTINGS */ -.form_settings fieldset { -padding:0; -border:0; -margin-bottom:29px; -} -.form_settings legend { -font-size:1.6em; -text-transform:uppercase; -} -.form_settings .form_datas label { - -} - .form_guide { font-style:italic; } -.form_settings .form_actions label { +.form_login label, +.form_settings label { +margin-right:11px; +} + +.form_actions label { display:none; } -- cgit v1.2.3-54-g00ecf From 97c98cf59ace088e487e130182ff4dc99d2d408b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 17 Jan 2009 22:30:44 +0000 Subject: Break up settings into two tabset Made two tabsets: account and connect. Removed "Invite" from the global nav to make room. --- actions/avatarsettings.php | 4 +- actions/emailsettings.php | 7 +- actions/imsettings.php | 4 +- actions/openidsettings.php | 4 +- actions/othersettings.php | 4 +- actions/passwordsettings.php | 161 ++++++++++++++++++ actions/profilesettings.php | 378 ++++++++++++------------------------------ actions/smssettings.php | 5 +- actions/twittersettings.php | 7 +- lib/accountsettingsaction.php | 134 +++++++++++++++ lib/action.php | 82 ++++----- lib/connectsettingsaction.php | 129 ++++++++++++++ lib/rssaction.php | 97 ++++++++--- lib/settingsaction.php | 15 -- lib/settingsgroupnav.php | 112 ------------- lib/util.php | 4 + 16 files changed, 665 insertions(+), 482 deletions(-) create mode 100644 actions/passwordsettings.php create mode 100644 lib/accountsettingsaction.php create mode 100644 lib/connectsettingsaction.php delete mode 100644 lib/settingsgroupnav.php (limited to 'actions') diff --git a/actions/avatarsettings.php b/actions/avatarsettings.php index de5473d9f..a9b381b0a 100644 --- a/actions/avatarsettings.php +++ b/actions/avatarsettings.php @@ -32,7 +32,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/accountsettingsaction.php'; /** * Upload an avatar @@ -47,7 +47,7 @@ require_once INSTALLDIR.'/lib/settingsaction.php'; * @link http://laconi.ca/ */ -class AvatarsettingsAction extends SettingsAction +class AvatarsettingsAction extends AccountSettingsAction { /** * Title of the page diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 355470815..b1f13c18c 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -32,7 +32,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/accountsettingsaction.php'; /** * Settings for email @@ -47,7 +47,7 @@ require_once INSTALLDIR.'/lib/settingsaction.php'; * @see Widget */ -class EmailsettingsAction extends SettingsAction +class EmailsettingsAction extends AccountSettingsAction { /** * Title of the page @@ -103,7 +103,7 @@ class EmailsettingsAction extends SettingsAction $confirm = $this->getConfirmation(); if ($confirm) { $this->element('p', array('id' => 'email_unconfirmed'), $confirm->address); - $this->element('p', array('class' => 'form_note'), + $this->element('p', array('class' => 'form_note'), _('Awaiting confirmation on this address. '. 'Check your inbox (and spam box!) for a message '. 'with further instructions.')); @@ -143,7 +143,6 @@ class EmailsettingsAction extends SettingsAction $this->elementEnd('fieldset'); } - $this->elementStart('fieldset', array('id' => 'settings_email_preferences')); $this->element('legend', null, _('Preferences')); diff --git a/actions/imsettings.php b/actions/imsettings.php index 3e578b307..98951ac30 100644 --- a/actions/imsettings.php +++ b/actions/imsettings.php @@ -31,7 +31,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/connectsettingsaction.php'; require_once INSTALLDIR.'/lib/jabber.php'; /** @@ -46,7 +46,7 @@ require_once INSTALLDIR.'/lib/jabber.php'; * @see SettingsAction */ -class ImsettingsAction extends SettingsAction +class ImsettingsAction extends ConnectSettingsAction { /** * Title of the page diff --git a/actions/openidsettings.php b/actions/openidsettings.php index 6f17f154c..257aac8d0 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -31,7 +31,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/accountsettingsaction.php'; require_once INSTALLDIR.'/lib/openid.php'; /** @@ -46,7 +46,7 @@ require_once INSTALLDIR.'/lib/openid.php'; * @link http://laconi.ca/ */ -class OpenidsettingsAction extends SettingsAction +class OpenidsettingsAction extends AccountSettingsAction { /** * Title of the page diff --git a/actions/othersettings.php b/actions/othersettings.php index 51f6f8197..a7664d74e 100644 --- a/actions/othersettings.php +++ b/actions/othersettings.php @@ -19,9 +19,9 @@ if (!defined('LACONICA')) { exit(1); } -require_once(INSTALLDIR.'/lib/settingsaction.php'); +require_once(INSTALLDIR.'/lib/accountsettingsaction.php'); -class OthersettingsAction extends SettingsAction +class OthersettingsAction extends AccountSettingsAction { function get_instructions() diff --git a/actions/passwordsettings.php b/actions/passwordsettings.php new file mode 100644 index 000000000..f96da13bd --- /dev/null +++ b/actions/passwordsettings.php @@ -0,0 +1,161 @@ +. + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @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/accountsettingsaction.php'; + +/** + * Change password + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ + +class PasswordsettingsAction extends AccountSettingsAction +{ + /** + * Title of the page + * + * @return string Title of the page + */ + + function title() + { + return _('Change password'); + } + + /** + * Instructions for use + * + * @return instructions for use + */ + + function getInstructions() + { + return _('Change your password.'); + } + + /** + * Content area of the page + * + * Shows a form for changing the password + * + * @return void + */ + + function showContent() + { + $user = common_current_user(); + $this->elementStart('form', array('method' => 'POST', + 'id' => 'password', + 'action' => + common_local_url('profilesettings'))); + + $this->hidden('token', common_session_token()); + + // Users who logged in with OpenID won't have a pwd + if ($user->password) { + $this->password('oldpassword', _('Old password')); + } + $this->password('newpassword', _('New password'), + _('6 or more characters')); + $this->password('confirm', _('Confirm'), + _('same as password above')); + $this->submit('changepass', _('Change')); + $this->elementEnd('form'); + } + + /** + * Handle a post + * + * Validate input and save changes. Reload the form with a success + * or error message. + * + * @return void + */ + + function handlePost() + { + // CSRF protection + + $token = $this->trimmed('token'); + if (!$token || $token != common_session_token()) { + $this->showForm(_('There was a problem with your session token. '. + 'Try again, please.')); + return; + } + + $user = common_current_user(); + assert(!is_null($user)); // should already be checked + + // FIXME: scrub input + + $newpassword = $this->arg('newpassword'); + $confirm = $this->arg('confirm'); + + if (0 != strcmp($newpassword, $confirm)) { + $this->showForm(_('Passwords don\'t match.')); + return; + } + + if ($user->password) { + $oldpassword = $this->arg('oldpassword'); + + if (!common_check_user($user->nickname, $oldpassword)) { + $this->showForm(_('Incorrect old password')); + return; + } + } + + $original = clone($user); + + $user->password = common_munge_password($newpassword, $user->id); + + $val = $user->validate(); + if ($val !== true) { + $this->showForm(_('Error saving user; invalid.')); + return; + } + + if (!$user->update($original)) { + $this->serverError(_('Can\'t save new password.')); + return; + } + + $this->showForm(_('Password saved.'), true); + } +} \ No newline at end of file diff --git a/actions/profilesettings.php b/actions/profilesettings.php index 6ad3f2ef5..c31f76227 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -1,9 +1,12 @@ . + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @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); } +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/accountsettingsaction.php'; -require_once(INSTALLDIR.'/lib/settingsaction.php'); +/** + * Change profile settings + * + * @category Settings + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ -class ProfilesettingsAction extends SettingsAction +class ProfilesettingsAction extends AccountSettingsAction { + /** + * Title of the page + * + * @return string Title of the page + */ - function get_instructions() + function title() { - return _('You can update your personal profile info here '. - 'so people know more about you.'); + return _('Profile settings'); } - function show_form($msg=null, $success=false) - { - $this->form_header(_('Profile settings'), $msg, $success); - $this->show_settings_form(); - $this->element('h2', null, _('Avatar')); - $this->show_avatar_form(); - $this->element('h2', null, _('Change password')); - $this->show_password_form(); -// $this->element('h2', null, _('Delete my account')); -// $this->show_delete_form(); - common_show_footer(); - } + /** + * Instructions for use + * + * @return instructions for use + */ - function handle_post() + function getInstructions() { - - # CSRF protection - - $token = $this->trimmed('token'); - if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); - return; - } - - if ($this->arg('save')) { - $this->save_profile(); - } else if ($this->arg('upload')) { - $this->upload_avatar(); - } else if ($this->arg('crop')) { - $this->crop_avatar(); - } else if ($this->arg('changepass')) { - $this->change_password(); - } else { - $this->show_form(_('Unexpected form submission.')); - } - + return _('You can update your personal profile info here '. + 'so people know more about you.'); } - function show_settings_form() - { + /** + * Content area of the page + * + * Shows a form for uploading an avatar. + * + * @return void + */ + function showContent() + { $user = common_current_user(); $profile = $user->getProfile(); @@ -78,9 +87,9 @@ class ProfilesettingsAction extends SettingsAction 'id' => 'profilesettings', 'action' => common_local_url('profilesettings'))); $this->hidden('token', common_session_token()); - + # too much common patterns here... abstractable? - + $this->input('nickname', _('Nickname'), ($this->arg('nickname')) ? $this->arg('nickname') : $profile->nickname, _('1-64 lowercase letters or numbers, no punctuation or spaces')); @@ -100,16 +109,24 @@ class ProfilesettingsAction extends SettingsAction _('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated')); $language = common_language(); - $this->dropdown('language', _('Language'), get_nice_language_list(), _('Preferred language'), true, $language); + $this->dropdown('language', _('Language'), + get_nice_language_list(), _('Preferred language'), + true, $language); + $timezone = common_timezone(); $timezones = array(); foreach(DateTimeZone::listIdentifiers() as $k => $v) { $timezones[$v] = $v; } - $this->dropdown('timezone', _('Timezone'), $timezones, _('What timezone are you normally in?'), true, $timezone); + $this->dropdown('timezone', _('Timezone'), + $timezones, _('What timezone are you normally in?'), + true, $timezone); - $this->checkbox('autosubscribe', _('Automatically subscribe to whoever subscribes to me (best for non-humans)'), - ($this->arg('autosubscribe')) ? $this->boolean('autosubscribe') : $user->autosubscribe); + $this->checkbox('autosubscribe', + _('Automatically subscribe to whoever '. + 'subscribes to me (best for non-humans)'), + ($this->arg('autosubscribe')) ? + $this->boolean('autosubscribe') : $user->autosubscribe); $this->submit('save', _('Save')); @@ -117,105 +134,26 @@ class ProfilesettingsAction extends SettingsAction } - function show_avatar_form() - { - - $user = common_current_user(); - $profile = $user->getProfile(); - - if (!$profile) { - common_log_db_error($user, 'SELECT', __FILE__); - $this->serverError(_('User without matching profile')); - return; - } - - $original = $profile->getOriginalAvatar(); - - - $this->elementStart('form', array('enctype' => 'multipart/form-data', - 'method' => 'POST', - 'id' => 'avatar', - 'action' => - common_local_url('profilesettings'))); - $this->hidden('token', common_session_token()); - - if ($original) { - $this->elementStart('div', array('id'=>'avatar_original', 'class'=>'avatar_view')); - $this->element('h3', null, _("Original:")); - $this->elementStart('div', array('id'=>'avatar_original_view')); - $this->element('img', array('src' => $original->url, - 'class' => 'avatar original', - 'width' => $original->width, - 'height' => $original->height, - 'alt' => $user->nickname)); - $this->elementEnd('div'); - $this->elementEnd('div'); - } - - $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); - - if ($avatar) { - $this->elementStart('div', array('id'=>'avatar_preview', 'class'=>'avatar_view')); - $this->element('h3', null, _("Preview:")); - $this->elementStart('div', array('id'=>'avatar_preview_view')); - $this->element('img', array('src' => $original->url,//$avatar->url, - 'class' => 'avatar profile', - 'width' => AVATAR_PROFILE_SIZE, - 'height' => AVATAR_PROFILE_SIZE, - 'alt' => $user->nickname)); - $this->elementEnd('div'); - $this->elementEnd('div'); - - foreach(array('avatar_crop_x', 'avatar_crop_y', 'avatar_crop_w', 'avatar_crop_h') as $crop_info) { - $this->element('input', array('name' => $crop_info, - 'type' => 'hidden', - 'id' => $crop_info)); - } - $this->submit('crop', _('Crop')); - } - - $this->element('input', array('name' => 'MAX_FILE_SIZE', - 'type' => 'hidden', - 'id' => 'MAX_FILE_SIZE', - 'value' => MAX_AVATAR_SIZE)); - - $this->elementStart('p'); - - $this->element('input', array('name' => 'avatarfile', - 'type' => 'file', - 'id' => 'avatarfile')); - $this->elementEnd('p'); + /** + * Handle a post + * + * Validate input and save changes. Reload the form with a success + * or error message. + * + * @return void + */ - $this->submit('upload', _('Upload')); - $this->elementEnd('form'); - - } - - function show_password_form() + function handlePost() { + # CSRF protection - $user = common_current_user(); - $this->elementStart('form', array('method' => 'POST', - 'id' => 'password', - 'action' => - common_local_url('profilesettings'))); - - $this->hidden('token', common_session_token()); - - # Users who logged in with OpenID won't have a pwd - if ($user->password) { - $this->password('oldpassword', _('Old password')); + $token = $this->trimmed('token'); + if (!$token || $token != common_session_token()) { + $this->showForm(_('There was a problem with your session token. '. + 'Try again, please.')); + return; } - $this->password('newpassword', _('New password'), - _('6 or more characters')); - $this->password('confirm', _('Confirm'), - _('same as password above')); - $this->submit('changepass', _('Change')); - $this->elementEnd('form'); - } - function save_profile() - { $nickname = $this->trimmed('nickname'); $fullname = $this->trimmed('fullname'); $homepage = $this->trimmed('homepage'); @@ -225,38 +163,38 @@ class ProfilesettingsAction extends SettingsAction $language = $this->trimmed('language'); $timezone = $this->trimmed('timezone'); $tagstring = $this->trimmed('tags'); - + # Some validation if (!Validate::string($nickname, array('min_length' => 1, 'max_length' => 64, 'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) { - $this->show_form(_('Nickname must have only lowercase letters and numbers and no spaces.')); + $this->showForm(_('Nickname must have only lowercase letters and numbers and no spaces.')); return; } else if (!User::allowed_nickname($nickname)) { - $this->show_form(_('Not a valid nickname.')); + $this->showForm(_('Not a valid nickname.')); return; } else if (!is_null($homepage) && (strlen($homepage) > 0) && !Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) { - $this->show_form(_('Homepage is not a valid URL.')); + $this->showForm(_('Homepage is not a valid URL.')); return; } else if (!is_null($fullname) && strlen($fullname) > 255) { - $this->show_form(_('Full name is too long (max 255 chars).')); + $this->showForm(_('Full name is too long (max 255 chars).')); return; } else if (!is_null($bio) && strlen($bio) > 140) { - $this->show_form(_('Bio is too long (max 140 chars).')); + $this->showForm(_('Bio is too long (max 140 chars).')); return; } else if (!is_null($location) && strlen($location) > 255) { - $this->show_form(_('Location is too long (max 255 chars).')); + $this->showForm(_('Location is too long (max 255 chars).')); return; } else if (is_null($timezone) || !in_array($timezone, DateTimeZone::listIdentifiers())) { - $this->show_form(_('Timezone not selected.')); + $this->showForm(_('Timezone not selected.')); return; - } else if ($this->nickname_exists($nickname)) { - $this->show_form(_('Nickname already in use. Try another one.')); + } else if ($this->nicknameExists($nickname)) { + $this->showForm(_('Nickname already in use. Try another one.')); return; } else if (!is_null($language) && strlen($language) > 50) { - $this->show_form(_('Language is too long (max 50 chars).')); + $this->showForm(_('Language is too long (max 50 chars).')); return; } @@ -265,14 +203,14 @@ class ProfilesettingsAction extends SettingsAction } else { $tags = array(); } - + foreach ($tags as $tag) { if (!common_valid_profile_tag($tag)) { - $this->show_form(sprintf(_('Invalid tag: "%s"'), $tag)); + $this->showForm(sprintf(_('Invalid tag: "%s"'), $tag)); return; } } - + $user = common_current_user(); $user->query('BEGIN'); @@ -346,139 +284,29 @@ class ProfilesettingsAction extends SettingsAction } # Set the user tags - + $result = $user->setSelfTags($tags); if (!$result) { $this->serverError(_('Couldn\'t save tags.')); return; } - + $user->query('COMMIT'); common_broadcast_profile($profile); - $this->show_form(_('Settings saved.'), true); + $this->showForm(_('Settings saved.'), true); } - - function upload_avatar() - { - switch ($_FILES['avatarfile']['error']) { - case UPLOAD_ERR_OK: # success, jump out - break; - case UPLOAD_ERR_INI_SIZE: - case UPLOAD_ERR_FORM_SIZE: - $this->show_form(_('That file is too big.')); - return; - case UPLOAD_ERR_PARTIAL: - @unlink($_FILES['avatarfile']['tmp_name']); - $this->show_form(_('Partial upload.')); - return; - default: - $this->show_form(_('System error uploading file.')); - return; - } - - $info = @getimagesize($_FILES['avatarfile']['tmp_name']); - - if (!$info) { - @unlink($_FILES['avatarfile']['tmp_name']); - $this->show_form(_('Not an image or corrupt file.')); - return; - } - - switch ($info[2]) { - case IMAGETYPE_GIF: - case IMAGETYPE_JPEG: - case IMAGETYPE_PNG: - break; - default: - $this->show_form(_('Unsupported image file format.')); - return; - } - - $user = common_current_user(); - $profile = $user->getProfile(); - - if ($profile->setOriginal($_FILES['avatarfile']['tmp_name'])) { - $this->show_form(_('Avatar updated.'), true); - } else { - $this->show_form(_('Failed updating avatar.')); - } - - @unlink($_FILES['avatarfile']['tmp_name']); - } - - function crop_avatar() { - - $user = common_current_user(); - $profile = $user->getProfile(); - - $x = $this->arg('avatar_crop_x'); - $y = $this->arg('avatar_crop_y'); - $w = $this->arg('avatar_crop_w'); - $h = $this->arg('avatar_crop_h'); - - if ($profile->crop_avatars($x, $y, $w, $h)) { - $this->show_form(_('Avatar updated.'), true); - } else { - $this->show_form(_('Failed updating avatar.')); - } - } - - function nickname_exists($nickname) + function nicknameExists($nickname) { $user = common_current_user(); $other = User::staticGet('nickname', $nickname); if (!$other) { - return false; + return false; } else { return $other->id != $user->id; } } - - function change_password() - { - - $user = common_current_user(); - assert(!is_null($user)); # should already be checked - - # FIXME: scrub input - - $newpassword = $this->arg('newpassword'); - $confirm = $this->arg('confirm'); - $token = $this->arg('token'); - - if (0 != strcmp($newpassword, $confirm)) { - $this->show_form(_('Passwords don\'t match.')); - return; - } - - if ($user->password) { - $oldpassword = $this->arg('oldpassword'); - - if (!common_check_user($user->nickname, $oldpassword)) { - $this->show_form(_('Incorrect old password')); - return; - } - } - - $original = clone($user); - - $user->password = common_munge_password($newpassword, $user->id); - - $val = $user->validate(); - if ($val !== true) { - $this->show_form(_('Error saving user; invalid.')); - return; - } - - if (!$user->update($original)) { - $this->serverError(_('Can\'t save new password.')); - return; - } - - $this->show_form(_('Password saved.'), true); - } } diff --git a/actions/smssettings.php b/actions/smssettings.php index 6d3c54942..845266d18 100644 --- a/actions/smssettings.php +++ b/actions/smssettings.php @@ -31,7 +31,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/connectsettingsaction.php'; /** * Settings for SMS @@ -45,7 +45,7 @@ require_once INSTALLDIR.'/lib/settingsaction.php'; * @see SettingsAction */ -class SmssettingsAction extends SettingsAction +class SmssettingsAction extends ConnectSettingsAction { /** * Title of the page @@ -151,7 +151,6 @@ class SmssettingsAction extends SettingsAction $this->elementStart('fieldset', array('id' => 'settings_sms_preferences')); $this->element('legend', null, _('Preferences')); - $this->elementStart('ul', 'form_datas'); $this->elementStart('li'); $this->checkbox('smsnotify', diff --git a/actions/twittersettings.php b/actions/twittersettings.php index cd070cb45..597623c80 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -31,7 +31,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/settingsaction.php'; +require_once INSTALLDIR.'/lib/connectsettingsaction.php'; define('SUBSCRIPTIONS', 80); @@ -47,7 +47,7 @@ define('SUBSCRIPTIONS', 80); * @see SettingsAction */ -class TwittersettingsAction extends SettingsAction +class TwittersettingsAction extends ConnectSettingsAction { /** * Title of the page @@ -129,7 +129,8 @@ class TwittersettingsAction extends SettingsAction $this->elementEnd('ul'); $this->elementEnd('fieldset'); - $this->elementStart('fieldset', array('id' => 'settings_twitter_preferences')); + $this->elementStart('fieldset', + array('id' => 'settings_twitter_preferences')); $this->element('legend', null, _('Preferences')); $this->elementStart('ul'); diff --git a/lib/accountsettingsaction.php b/lib/accountsettingsaction.php new file mode 100644 index 000000000..46090b8c1 --- /dev/null +++ b/lib/accountsettingsaction.php @@ -0,0 +1,134 @@ +. + * + * @category Settings + * @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/settingsaction.php'; + +/** + * Base class for account settings actions + * + * @category Settings + * @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/ + * + * @see Widget + */ + +class AccountSettingsAction extends SettingsAction +{ + /** + * Show the local navigation menu + * + * This is the same for all settings, so we show it here. + * + * @return void + */ + + function showLocalNav() + { + $menu = new AccountSettingsNav($this); + $menu->show(); + } +} + +/** + * A widget for showing the settings group local nav menu + * + * @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/ + * + * @see HTMLOutputter + */ + +class AccountSettingsNav extends Widget +{ + var $action = null; + + /** + * Construction + * + * @param Action $action current action, used for output + */ + + function __construct($action=null) + { + parent::__construct($action); + $this->action = $action; + } + + /** + * Show the menu + * + * @return void + */ + + function show() + { + # action => array('prompt', 'title') + $menu = + array('profilesettings' => + array(_('Profile'), + _('Change your profile settings')), + 'avatarsettings' => + array(_('Avatar'), + _('Upload an avatar')), + 'passwordsettings' => + array(_('Password'), + _('Change your password')), + 'emailsettings' => + array(_('Email'), + _('Change email handling')), + 'openidsettings' => + array(_('OpenID'), + _('Add or remove OpenIDs')), + 'othersettings' => + array(_('Other'), + _('Other options'))); + + $action_name = $this->action->trimmed('action'); + $this->action->elementStart('ul', array('class' => 'nav')); + + foreach ($menu as $menuaction => $menudesc) { + $this->action->menuItem(common_local_url($menuaction), + $menudesc[0], + $menudesc[1], + $action_name === $menuaction); + } + + $this->action->elementEnd('ul'); + } +} diff --git a/lib/action.php b/lib/action.php index 71520b84e..e62a032b6 100644 --- a/lib/action.php +++ b/lib/action.php @@ -208,20 +208,20 @@ class Action extends HTMLOutputter // lawsuit $this->showLogo(); $this->showPrimaryNav(); $this->showSiteNotice(); - if (common_logged_in()) { - $this->showNoticeForm(); - } else { - $this->showAnonymousMessage(); - } + if (common_logged_in()) { + $this->showNoticeForm(); + } else { + $this->showAnonymousMessage(); + } $this->elementEnd('div'); } function showLogo() { $this->elementStart('address', array('id' => 'site_contact', - 'class' => 'vcard')); + 'class' => 'vcard')); $this->elementStart('a', array('class' => 'url home bookmark', - 'href' => common_local_url('public'))); + 'href' => common_local_url('public'))); if (common_config('site', 'logo') || file_exists(theme_file('logo.png'))) { $this->element('img', array('class' => 'logo photo', @@ -237,21 +237,21 @@ class Action extends HTMLOutputter // lawsuit { $this->elementStart('dl', array('id' => 'site_nav_global_primary')); $this->element('dt', null, _('Primary site navigation')); - $this->elementStart('dd'); + $this->elementStart('dd'); $user = common_current_user(); $this->elementStart('ul', array('class' => 'nav')); if ($user) { $this->menuItem(common_local_url('all', array('nickname' => $user->nickname)), - _('Home')); + _('Home')); } $this->menuItem(common_local_url('peoplesearch'), _('Search')); if ($user) { $this->menuItem(common_local_url('profilesettings'), - _('Settings')); - $this->menuItem(common_local_url('invite'), - _('Invite')); + _('Account')); + $this->menuItem(common_local_url('imsettings'), + _('Connect')); $this->menuItem(common_local_url('logout'), - _('Logout')); + _('Logout')); } else { $this->menuItem(common_local_url('login'), _('Login')); if (!common_config('site', 'closed')) { @@ -260,25 +260,25 @@ class Action extends HTMLOutputter // lawsuit $this->menuItem(common_local_url('openidlogin'), _('OpenID')); } $this->menuItem(common_local_url('doc', array('title' => 'help')), - _('Help')); + _('Help')); $this->elementEnd('ul'); - $this->elementEnd('dd'); + $this->elementEnd('dd'); $this->elementEnd('dl'); } // Revist. Should probably do an hAtom pattern here function showSiteNotice() { - $text = common_config('site', 'notice'); - if ($text) { - $this->elementStart('dl', array('id' => 'site_notice', - 'class' => 'system_notice')); - $this->element('dt', null, _('Site notice')); - $this->element('dd', null, $text); - $this->elementEnd('dl'); - } + $text = common_config('site', 'notice'); + if ($text) { + $this->elementStart('dl', array('id' => 'site_notice', + 'class' => 'system_notice')); + $this->element('dt', null, _('Site notice')); + $this->element('dd', null, $text); + $this->elementEnd('dl'); + } } - + // MAY overload if no notice form needed... or direct message box???? function showNoticeForm() @@ -289,9 +289,9 @@ class Action extends HTMLOutputter // lawsuit function showAnonymousMessage() { - // needs to be defined by the class + // needs to be defined by the class } - + function showCore() { $this->elementStart('div', array('id' => 'core')); @@ -331,13 +331,13 @@ class Action extends HTMLOutputter // lawsuit function showPageNoticeBlock() { - $this->elementStart('dl', array('id' => 'page_notice', - 'class' => 'system_notice')); - $this->element('dt', null, _('Page notice')); - $this->elementStart('dd'); - $this->showPageNotice(); - $this->elementEnd('dd'); - $this->elementEnd('dl'); + $this->elementStart('dl', array('id' => 'page_notice', + 'class' => 'system_notice')); + $this->element('dt', null, _('Page notice')); + $this->elementStart('dd'); + $this->showPageNotice(); + $this->elementEnd('dd'); + $this->elementEnd('dl'); } // SHOULD overload (unless there's not a notice) @@ -345,7 +345,7 @@ class Action extends HTMLOutputter // lawsuit function showPageNotice() { } - + // MUST overload function showContent() @@ -391,17 +391,17 @@ class Action extends HTMLOutputter // lawsuit $this->elementStart('dd', null); $this->elementStart('ul', array('class' => 'nav')); $this->menuItem(common_local_url('doc', array('title' => 'help')), - _('Help')); + _('Help')); $this->menuItem(common_local_url('doc', array('title' => 'about')), - _('About')); + _('About')); $this->menuItem(common_local_url('doc', array('title' => 'faq')), - _('FAQ')); + _('FAQ')); $this->menuItem(common_local_url('doc', array('title' => 'privacy')), - _('Privacy')); + _('Privacy')); $this->menuItem(common_local_url('doc', array('title' => 'source')), - _('Source')); + _('Source')); $this->menuItem(common_local_url('doc', array('title' => 'contact')), - _('Contact')); + _('Contact')); $this->elementEnd('ul'); $this->elementEnd('dd'); $this->elementEnd('dl'); @@ -567,7 +567,7 @@ class Action extends HTMLOutputter // lawsuit } (is_null($id)) ? $lattrs : $lattrs['id'] = $id; - + $this->elementStart('li', $lattrs); $attrs['href'] = $url; if ($title) { diff --git a/lib/connectsettingsaction.php b/lib/connectsettingsaction.php new file mode 100644 index 000000000..30629680e --- /dev/null +++ b/lib/connectsettingsaction.php @@ -0,0 +1,129 @@ +. + * + * @category Settings + * @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/settingsaction.php'; + +/** + * Base class for connection settings actions + * + * @category Settings + * @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/ + * + * @see Widget + */ + +class ConnectSettingsAction extends SettingsAction +{ + /** + * Show the local navigation menu + * + * This is the same for all settings, so we show it here. + * + * @return void + */ + + function showLocalNav() + { + $menu = new ConnectSettingsNav($this); + $menu->show(); + } +} + +/** + * A widget for showing the connect group local nav menu + * + * @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/ + * + * @see HTMLOutputter + */ + +class ConnectSettingsNav extends Widget +{ + var $action = null; + + /** + * Construction + * + * @param Action $action current action, used for output + */ + + function __construct($action=null) + { + parent::__construct($action); + $this->action = $action; + } + + /** + * Show the menu + * + * @return void + */ + + function show() + { + # action => array('prompt', 'title') + $menu = + array('imsettings' => + array(_('IM'), + _('Updates by instant messenger (IM)')), + 'smssettings' => + array(_('SMS'), + _('Updates by SMS')), + 'twittersettings' => + array(_('Twitter'), + _('Twitter integration options'))); + + $action_name = $this->action->trimmed('action'); + $this->action->elementStart('ul', array('class' => 'nav')); + + foreach ($menu as $menuaction => $menudesc) { + if ($menuaction == 'imsettings' && + !common_config('xmpp', 'enabled')) { + continue; + } + $this->action->menuItem(common_local_url($menuaction), + $menudesc[0], + $menudesc[1], + $action_name === $menuaction); + } + + $this->action->elementEnd('ul'); + } +} diff --git a/lib/rssaction.php b/lib/rssaction.php index 9564cfb46..2c532912b 100644 --- a/lib/rssaction.php +++ b/lib/rssaction.php @@ -1,9 +1,12 @@ . + * + * @category Mail + * @package Laconica + * @author Evan Prodromou + * @author Earle Martin + * @copyright 2008-9 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); } @@ -23,35 +34,84 @@ define('DEFAULT_RSS_LIMIT', 48); class Rss10Action extends Action { - # This will contain the details of each feed item's author and be used to generate SIOC data. + var $creators = array(); + var $limit = DEFAULT_RSS_LIMIT; + + /** + * Constructor + * + * Just wraps the Action constructor. + * + * @param string $output URI to output to, default = stdout + * @param boolean $indent Whether to indent output, default true + * + * @see Action::__construct + */ - function is_readonly() + function __construct($output='php://output', $indent=true) + { + parent::__construct($output, $indent); + } + + /** + * Do we need to write to the database? + * + * @return boolean true + */ + + function isReadonly() { return true; } + /** + * Read arguments and initialize members + * + * @param array $args Arguments from $_REQUEST + * @return boolean success + */ + + function prepare($args) + { + $this->limit = (int) $this->trimmed('limit'); + if ($this->limit == 0) { + $this->limit = DEFAULT_RSS_LIMIT; + } + return true; + } + + /** + * Handle a request + * + * @param array $args Arguments from $_REQUEST + * + * @return void + */ + function handle($args) { parent::handle($args); - $limit = (int) $this->trimmed('limit'); - if ($limit == 0) { - $limit = DEFAULT_RSS_LIMIT; - } $this->show_rss($limit); } - function init() - { - return true; - } - - function get_notices() + /** + * Get the notices to output in this stream + * + * @return array an array of Notice objects sorted in reverse chron + */ + + function getNotices() { return array(); } + /** + * Get a description of the channel + * + * Returns an array with the following + * @return array function get_channel() { return array('url' => '', @@ -67,11 +127,6 @@ class Rss10Action extends Action function show_rss($limit=0) { - - if (!$this->init()) { - return; - } - $notices = $this->get_notices($limit); $this->init_rss(); diff --git a/lib/settingsaction.php b/lib/settingsaction.php index 8624803ac..dfe1f114b 100644 --- a/lib/settingsaction.php +++ b/lib/settingsaction.php @@ -31,8 +31,6 @@ if (!defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/settingsgroupnav.php'; - /** * Base class for settings group of actions * @@ -149,17 +147,4 @@ class SettingsAction extends Action return ''; } - /** - * Show the local navigation menu - * - * This is the same for all settings, so we show it here. - * - * @return void - */ - - function showLocalNav() - { - $menu = new SettingsGroupNav($this); - $menu->show(); - } } diff --git a/lib/settingsgroupnav.php b/lib/settingsgroupnav.php deleted file mode 100644 index bd66c65a6..000000000 --- a/lib/settingsgroupnav.php +++ /dev/null @@ -1,112 +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); -} - -require_once INSTALLDIR.'/lib/widget.php'; - -/** - * A widget for showing the settings group local nav menu - * - * @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/ - * - * @see HTMLOutputter - */ - -class SettingsGroupNav extends Widget -{ - var $action = null; - - /** - * Construction - * - * @param Action $action current action, used for output - */ - - function __construct($action=null) - { - parent::__construct($action); - $this->action = $action; - } - - /** - * Show the menu - * - * @return void - */ - - function show() - { - # action => array('prompt', 'title') - $menu = - array('profilesettings' => - array(_('Profile'), - _('Change your profile settings')), - 'emailsettings' => - array(_('Email'), - _('Change email handling')), - 'openidsettings' => - array(_('OpenID'), - _('Add or remove OpenIDs')), - 'smssettings' => - array(_('SMS'), - _('Updates by SMS')), - 'imsettings' => - array(_('IM'), - _('Updates by instant messenger (IM)')), - 'twittersettings' => - array(_('Twitter'), - _('Twitter integration options')), - 'othersettings' => - array(_('Other'), - _('Other options'))); - - $action_name = $this->action->trimmed('action'); - $this->action->elementStart('ul', array('class' => 'nav')); - - foreach ($menu as $menuaction => $menudesc) { - if ($menuaction == 'imsettings' && - !common_config('xmpp', 'enabled')) { - continue; - } - $this->action->menuItem(common_local_url($menuaction), - $menudesc[0], - $menudesc[1], - $action_name === $menuaction); - } - - $this->action->elementEnd('ul'); - } -} diff --git a/lib/util.php b/lib/util.php index 9ca817eab..d67c64972 100644 --- a/lib/util.php +++ b/lib/util.php @@ -770,6 +770,8 @@ function common_fancy_url($action, $args=null) return common_path('main/openid'); case 'profilesettings': return common_path('settings/profile'); + case 'passwordsettings': + return common_path('settings/password'); case 'emailsettings': return common_path('settings/email'); case 'openidsettings': @@ -852,6 +854,8 @@ function common_fancy_url($action, $args=null) return common_path($path); case 'imsettings': return common_path('settings/im'); + case 'avatarsettings': + return common_path('settings/avatar'); case 'peoplesearch': return common_path('search/people' . (($args) ? ('?' . http_build_query($args)) : '')); case 'noticesearch': -- cgit v1.2.3-54-g00ecf From 99a4daa5015a3dd9254df7fffcd107963f7c8f36 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 17 Jan 2009 22:42:53 +0000 Subject: Bring othersettings up to date --- actions/othersettings.php | 208 ++++++++++++++++++++-------------------------- 1 file changed, 92 insertions(+), 116 deletions(-) (limited to 'actions') diff --git a/actions/othersettings.php b/actions/othersettings.php index a7664d74e..f35630f36 100644 --- a/actions/othersettings.php +++ b/actions/othersettings.php @@ -1,9 +1,12 @@ . + * + * @category Settings + * @package Laconica + * @author Robin Millette + * @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); } +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/accountsettingsaction.php'; -require_once(INSTALLDIR.'/lib/accountsettingsaction.php'); +/** + * Miscellaneous settings actions + * + * Currently this just manages URL shortening. + * + * @category Settings + * @package Laconica + * @author Robin Millette + * @author Zach Copley + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ class OthersettingsAction extends AccountSettingsAction { + /** + * Title of the page + * + * @return string Title of the page + */ - function get_instructions() + function title() + { + return _('Other Settings'); + } + + /** + * Instructions for use + * + * @return instructions for use + */ + + function getInstructions() { return _('Manage various other options.'); } - function show_form($msg=null, $success=false) + /** + * Content area of the page + * + * Shows a form for uploading an avatar. + * + * @return void + */ + + function showContent() { $user = common_current_user(); - $this->form_header(_('Other Settings'), $msg, $success); - $this->element('h2', null, _('URL Auto-shortening')); $this->elementStart('form', array('method' => 'post', - 'id' => 'othersettings', - 'action' => - common_local_url('othersettings'))); + 'id' => 'othersettings', + 'action' => + common_local_url('othersettings'))); $this->hidden('token', common_session_token()); + // I18N + $services = array( - '' => 'None', - 'ur1.ca' => 'ur1.ca (free service)', - '2tu.us' => '2tu.us (free service)', - 'ptiturl.com' => 'ptiturl.com', - 'bit.ly' => 'bit.ly', - 'tinyurl.com' => 'tinyurl.com', - 'is.gd' => 'is.gd', - 'snipr.com' => 'snipr.com', - 'metamark.net' => 'metamark.net' - ); - - $this->dropdown('urlshorteningservice', _('Service'), $services, _('Automatic shortening service to use.'), false, $user->urlshorteningservice); + '' => 'None', + 'ur1.ca' => 'ur1.ca (free service)', + '2tu.us' => '2tu.us (free service)', + 'ptiturl.com' => 'ptiturl.com', + 'bit.ly' => 'bit.ly', + 'tinyurl.com' => 'tinyurl.com', + 'is.gd' => 'is.gd', + 'snipr.com' => 'snipr.com', + 'metamark.net' => 'metamark.net' + ); + + $this->dropdown('urlshorteningservice', _('Service'), + $services, _('Automatic shortening service to use.'), + false, $user->urlshorteningservice); $this->submit('save', _('Save')); $this->elementEnd('form'); - -// $this->element('h2', null, _('Delete my account')); -// $this->show_delete_form(); - - common_show_footer(); - } - - function show_feeds_list($feeds) - { - $this->elementStart('div', array('class' => 'feedsdel')); - $this->element('p', null, 'Feeds:'); - $this->elementStart('ul', array('class' => 'xoxo')); - - foreach ($feeds as $key => $value) { - $this->common_feed_item($feeds[$key]); - } - $this->elementEnd('ul'); - $this->elementEnd('div'); } - //TODO move to common.php (and retrace its origin) - function common_feed_item($feed) - { - $user = common_current_user(); - $nickname = $user->nickname; - - switch($feed['item']) { - case 'notices': default: - $feed_classname = $feed['type']; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = "$nickname's ".$feed['version']." notice feed"; - $feed['textContent'] = "RSS"; - break; - - case 'foaf': - $feed_classname = "foaf"; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = "$nickname's FOAF file"; - $feed['textContent'] = "FOAF"; - break; - } - $this->elementStart('li'); - $this->element('a', array('href' => $feed['href'], - 'class' => $feed_classname, - 'type' => $feed_mimetype, - 'title' => $feed_title), - $feed['textContent']); - $this->elementEnd('li'); - } + /** + * Handle a post + * + * Saves the changes to url-shortening prefs and shows a success or failure + * message. + * + * @return void + */ -// function show_delete_form() { -// $user = common_current_user(); -// $notices = DB_DataObject::factory('notice'); -// $notices->profile_id = $user->id; -// $notice_count = (int) $notices->count(); -// -// $this->elementStart('form', array('method' => 'POST', -// 'id' => 'delete', -// 'action' => -// common_local_url('deleteprofile'))); -// -// $this->hidden('token', common_session_token()); -// $this->element('p', null, "You can copy your notices and contacts by saving the two links below before deleting your account. Be careful, this operation cannot be undone."); -// -// $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('limit' => $notice_count, 'nickname' => $user->nickname)), -// 'type' => 'rss', -// 'version' => 'RSS 1.0', -// 'item' => 'notices'), -// 1=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)), -// 'type' => 'rdf', -// 'version' => 'FOAF', -// 'item' => 'foaf'))); -// -// $this->submit('deleteaccount', _('Delete my account')); -// $this->elementEnd('form'); -// } - - function handle_post() + function handlePost() { - - # CSRF protection + // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); + $this->showForm(_('There was a problem with your session token. '. + 'Try again, please.')); return; } - if ($this->arg('save')) { - $this->save_preferences(); - }else { - $this->show_form(_('Unexpected form submission.')); - } - } - - function save_preferences() - { - $urlshorteningservice = $this->trimmed('urlshorteningservice'); if (!is_null($urlshorteningservice) && strlen($urlshorteningservice) > 50) { - $this->show_form(_('URL shortening service is too long (max 50 chars).')); + $this->showForm(_('URL shortening service is too long (max 50 chars).')); return; } $user = common_current_user(); - assert(!is_null($user)); # should already be checked + assert(!is_null($user)); // should already be checked $user->query('BEGIN'); @@ -183,6 +159,6 @@ class OthersettingsAction extends AccountSettingsAction $user->query('COMMIT'); - $this->show_form(_('Preferences saved.'), true); + $this->showForm(_('Preferences saved.'), true); } } -- cgit v1.2.3-54-g00ecf From d3f27765d95d0c4e0c5d8f224822c469ea64660b Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sat, 17 Jan 2009 23:17:57 +0000 Subject: Adapt replies to new framework --- actions/replies.php | 186 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 140 insertions(+), 46 deletions(-) (limited to 'actions') diff --git a/actions/replies.php b/actions/replies.php index 84fd894ff..ea8ef4764 100644 --- a/actions/replies.php +++ b/actions/replies.php @@ -1,9 +1,12 @@ . + * + * @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); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/actions/showstream.php'); +require_once INSTALLDIR.'/lib/personalgroupnav.php'; +require_once INSTALLDIR.'/lib/noticelist.php'; +require_once INSTALLDIR.'/lib/feedlist.php'; -class RepliesAction extends StreamAction -{ +/** + * List of replies + * + * @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/ + */ - function handle($args) +class RepliesAction extends Action +{ + var $user = null; + var $page = null; + + /** + * Prepare the object + * + * Check the input values and initialize the object. + * Shows an error page on bad input. + * + * @param array $args $_REQUEST data + * + * @return boolean success flag + */ + + function prepare($args) { - - parent::handle($args); + parent::prepare($args); $nickname = common_canonical_nickname($this->arg('nickname')); - $user = User::staticGet('nickname', $nickname); - if (!$user) { - $this->no_such_user(); - return; + $this->user = User::staticGet('nickname', $nickname); + + if (!$this->user) { + $this->clientError(_('No such user.')); + return false; } - $profile = $user->getProfile(); + $profile = $this->user->getProfile(); if (!$profile) { $this->serverError(_('User has no profile.')); - return; + return false; } - # Looks like we're good; show the header + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - common_show_header(sprintf(_("Replies to %s"), $profile->nickname), - array($this, 'show_header'), $user, - array($this, 'show_top')); + return true; + } - $this->show_replies($user); + /** + * Handle a request + * + * Just show the page. All args already handled. + * + * @param array $args $_REQUEST data + * + * @return void + */ - common_show_footer(); + function handle($args) + { + parent::handle($args); + $this->showPage(); } - function no_such_user() + /** + * Title of the page + * + * Includes name of user and page number. + * + * @return string title of page + */ + + function title() { - $this->clientError(_('No such user.')); + if ($this->page == 1) { + return sprintf(_("Replies to %s"), $this->user->nickname); + } else { + return sprintf(_("Replies to %s, page %d"), + $profile->nickname, + $this->page); + } } - function show_header($user) + /** + * Feeds for the section + * + * @return void + */ + + function showFeeds() { + $rssurl = common_local_url('repliesrss', + array('nickname' => $this->user->nickname)); + $rsstitle = sprintf(_('Feed for replies to %s'), $this->user->nickname); + $this->element('link', array('rel' => 'alternate', - 'href' => common_local_url('repliesrss', array('nickname' => - $user->nickname)), + 'href' => $rssurl, 'type' => 'application/rss+xml', - 'title' => sprintf(_('Feed for replies to %s'), $user->nickname))); + 'title' => $rsstitle)); } - function show_top($user) + /** + * show the personal group nav + * + * @return void + */ + + function showLocalNav() { - $cur = common_current_user(); + $nav = new PersonalGroupNav($this); + $nav->show(); + } - if ($cur && $cur->id == $user->id) { - common_notice_form('replies'); - } + /** + * Show the replies feed links + * + * @return void + */ + + function showExportData() + { + $fl = new FeedList($this); - $this->views_menu(); + $rssurl = common_local_url('repliesrss', + array('nickname' => $this->user->nickname)); - $this->show_feeds_list(array(0=>array('href'=>common_local_url('repliesrss', array('nickname' => $user->nickname)), - 'type' => 'rss', - 'version' => 'RSS 1.0', - 'item' => 'repliesrss'))); + $fl->show(array(0=>array('href'=> $rssurl, + 'type' => 'rss', + 'version' => 'RSS 1.0', + 'item' => 'repliesrss'))); } - function show_replies($user) - { + /** + * Show the content + * + * A list of notices that are replies to the user, plus pagination. + * + * @return void + */ - $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + function showContent() + { + $notice = $this->user->getReplies(($this->page-1) * NOTICES_PER_PAGE, + NOTICES_PER_PAGE + 1); - $notice = $user->getReplies(($page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); + $nl = new NoticeList($notice, $this); - $cnt = $this->show_notice_list($notice); + $cnt = $nl->show(); - common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, - $page, 'replies', array('nickname' => $user->nickname)); + $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, + $this->page, 'replies', + array('nickname' => $this->user->nickname)); } } -- cgit v1.2.3-54-g00ecf From 0ecdd5363df5e80464f80f58347102d2f1adb4fe Mon Sep 17 00:00:00 2001 From: sarven Date: Sat, 17 Jan 2009 23:49:12 +0000 Subject: Profile settings styles --- actions/profilesettings.php | 30 +++++++++++++++++++++++++----- theme/base/css/display.css | 33 +++++++++++++++++++++++++++++++-- 2 files changed, 56 insertions(+), 7 deletions(-) (limited to 'actions') diff --git a/actions/profilesettings.php b/actions/profilesettings.php index c31f76227..12251b83b 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -84,52 +84,72 @@ class ProfilesettingsAction extends AccountSettingsAction $profile = $user->getProfile(); $this->elementStart('form', array('method' => 'POST', - 'id' => 'profilesettings', + 'id' => 'form_settings_profile', + 'class' => 'form_settings', 'action' => common_local_url('profilesettings'))); + $this->elementStart('fieldset'); + $this->element('legend', null, _('Profile information')); $this->hidden('token', common_session_token()); # too much common patterns here... abstractable? + $this->elementStart('ul', 'form_datas'); + $this->elementStart('li'); $this->input('nickname', _('Nickname'), ($this->arg('nickname')) ? $this->arg('nickname') : $profile->nickname, _('1-64 lowercase letters or numbers, no punctuation or spaces')); + $this->elementEnd('li'); + $this->elementStart('li'); $this->input('fullname', _('Full name'), ($this->arg('fullname')) ? $this->arg('fullname') : $profile->fullname); + $this->elementEnd('li'); + $this->elementStart('li'); $this->input('homepage', _('Homepage'), ($this->arg('homepage')) ? $this->arg('homepage') : $profile->homepage, _('URL of your homepage, blog, or profile on another site')); + $this->elementEnd('li'); + $this->elementStart('li'); $this->textarea('bio', _('Bio'), ($this->arg('bio')) ? $this->arg('bio') : $profile->bio, _('Describe yourself and your interests in 140 chars')); + $this->elementEnd('li'); + $this->elementStart('li'); $this->input('location', _('Location'), ($this->arg('location')) ? $this->arg('location') : $profile->location, _('Where you are, like "City, State (or Region), Country"')); + $this->elementEnd('li'); + $this->elementStart('li'); $this->input('tags', _('Tags'), ($this->arg('tags')) ? $this->arg('tags') : implode(' ', $user->getSelfTags()), _('Tags for yourself (letters, numbers, -, ., and _), comma- or space- separated')); - + $this->elementEnd('li'); + $this->elementStart('li'); $language = common_language(); $this->dropdown('language', _('Language'), get_nice_language_list(), _('Preferred language'), true, $language); - + $this->elementEnd('li'); $timezone = common_timezone(); $timezones = array(); foreach(DateTimeZone::listIdentifiers() as $k => $v) { $timezones[$v] = $v; } + $this->elementStart('li'); $this->dropdown('timezone', _('Timezone'), $timezones, _('What timezone are you normally in?'), true, $timezone); - + $this->elementEnd('li'); + $this->elementStart('li'); $this->checkbox('autosubscribe', _('Automatically subscribe to whoever '. 'subscribes to me (best for non-humans)'), ($this->arg('autosubscribe')) ? $this->boolean('autosubscribe') : $user->autosubscribe); - + $this->elementEnd('li'); + $this->elementEnd('ul'); $this->submit('save', _('Save')); + $this->elementEnd('fieldset'); $this->elementEnd('form'); } diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 15377a7b5..396d12ef0 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -109,9 +109,23 @@ margin-bottom:29px; font-style:italic; } + +.form_settings .form_datas li { +width:100%; +float:left; +} + .form_login label, -.form_settings label { +.form_settings .form_datas label, +.form_login input, +.form_settings .form_datas input { margin-right:11px; +float:left; +} + +.form_settings label { +margin-top:7px; +width:123px; } .form_actions label { @@ -123,16 +137,31 @@ display:inline; font-weight:bold; } +#form_settings_profile legend { +display:none; +} + +.form_settings .form_datas p.form_guide { +clear:both; +margin-left:134px; +margin-bottom:0; +} + .form_settings p { -margin-bottom:18px; +margin-bottom:11px; } #settings_email_address { margin-bottom:29px; } +.form_settings input.checkbox { +margin-top:3px; +} .form_settings label.checkbox { font-weight:normal; +width:auto; +margin-top:0; } /* FORM SETTINGS */ -- cgit v1.2.3-54-g00ecf From 4687f6dac93a9f7b1f276eda7677821c5069433b Mon Sep 17 00:00:00 2001 From: sarven Date: Sat, 17 Jan 2009 23:52:37 +0000 Subject: Other settings markup --- actions/othersettings.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'actions') diff --git a/actions/othersettings.php b/actions/othersettings.php index f35630f36..cbb2c0cb9 100644 --- a/actions/othersettings.php +++ b/actions/othersettings.php @@ -83,11 +83,14 @@ class OthersettingsAction extends AccountSettingsAction { $user = common_current_user(); - $this->element('h2', null, _('URL Auto-shortening')); + $this->elementStart('form', array('method' => 'post', - 'id' => 'othersettings', + 'id' => 'form_settings_other', + 'class' => 'form_settings', 'action' => common_local_url('othersettings'))); + $this->elementStart('fieldset'); + $this->element('legend', null, _('URL Auto-shortening')); $this->hidden('token', common_session_token()); // I18N @@ -104,12 +107,15 @@ class OthersettingsAction extends AccountSettingsAction 'metamark.net' => 'metamark.net' ); + $this->elementStart('ul', 'form_datas'); + $this->elementStart('li'); $this->dropdown('urlshorteningservice', _('Service'), $services, _('Automatic shortening service to use.'), false, $user->urlshorteningservice); - + $this->elementEnd('li'); + $this->elementEnd('ul'); $this->submit('save', _('Save')); - + $this->elementEnd('fieldset'); $this->elementEnd('form'); } -- cgit v1.2.3-54-g00ecf From 620d0594fc5603d42292fcc5d43ccf20366f4fe8 Mon Sep 17 00:00:00 2001 From: sarven Date: Sun, 18 Jan 2009 00:58:43 +0000 Subject: Reusing @class form_settings --- actions/login.php | 1 - theme/base/css/display.css | 2 -- 2 files changed, 3 deletions(-) (limited to 'actions') diff --git a/actions/login.php b/actions/login.php index 224b30f6f..e92087a28 100644 --- a/actions/login.php +++ b/actions/login.php @@ -131,7 +131,6 @@ class LoginAction extends Action { $this->elementStart('form', array('method' => 'post', 'id' => 'form_login', - 'class' => 'form_login', 'action' => common_local_url('login'))); $this->elementStart('fieldset'); $this->element('legend', null, _('Login to site')); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 5d2ef324a..435cb1576 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -115,9 +115,7 @@ width:100%; float:left; } -.form_login label, .form_settings .form_datas label, -.form_login input, .form_settings .form_datas input { margin-right:11px; float:left; -- cgit v1.2.3-54-g00ecf From 88c7da66f0102b0890d52a53aba47c02a16fa5c2 Mon Sep 17 00:00:00 2001 From: sarven Date: Sun, 18 Jan 2009 01:02:42 +0000 Subject: Minor cleanup for login style --- actions/login.php | 1 + theme/base/css/display.css | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'actions') diff --git a/actions/login.php b/actions/login.php index e92087a28..c213e2ab5 100644 --- a/actions/login.php +++ b/actions/login.php @@ -131,6 +131,7 @@ class LoginAction extends Action { $this->elementStart('form', array('method' => 'post', 'id' => 'form_login', + 'class' => 'form_settings', 'action' => common_local_url('login'))); $this->elementStart('fieldset'); $this->element('legend', null, _('Login to site')); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 435cb1576..35a146fa7 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -149,10 +149,6 @@ margin-bottom:0; margin-bottom:11px; } -#settings_email_address { -margin-bottom:29px; -} - .form_settings input.checkbox { margin-top:3px; } @@ -162,6 +158,10 @@ width:auto; margin-top:0; } +#form_login p.form_guide { +margin-left:0; +} + /* FORM SETTINGS */ -- cgit v1.2.3-54-g00ecf From 3e18c2f0f8bbab01e16f66254dc9eadc9e1ffd60 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sun, 18 Jan 2009 01:31:39 +0000 Subject: trac750 Facebook App - generate HTML similar to uiredisign for everything --- actions/facebookhome.php | 10 +-- actions/facebookinvite.php | 8 +-- actions/facebooksettings.php | 14 ++--- lib/facebookaction.php | 145 +++++++++++++++++++++++++++++++------------ lib/facebookutil.php | 133 ++++++++++++++++++++++++++++++++++++++- 5 files changed, 253 insertions(+), 57 deletions(-) (limited to 'actions') diff --git a/actions/facebookhome.php b/actions/facebookhome.php index b780b8cc3..46f886451 100644 --- a/actions/facebookhome.php +++ b/actions/facebookhome.php @@ -19,7 +19,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once(INSTALLDIR.'/lib/facebookaction.php'); +require_once INSTALLDIR.'/lib/facebookaction.php'; class FacebookhomeAction extends FacebookAction { @@ -35,6 +35,8 @@ class FacebookhomeAction extends FacebookAction $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); if ($flink) { + $user = $flink->getUser(); + common_set_user($user); $this->showHome($flink, null); } else { $this->login($fbuid); @@ -103,7 +105,7 @@ class FacebookhomeAction extends FacebookAction update_profile_box($facebook, $fbuid, $user, $notice); - $this->show_header('Home'); + $this->showHeader('Home'); if ($msg) { common_element('fb:success', array('message' => $msg)); @@ -111,7 +113,7 @@ class FacebookhomeAction extends FacebookAction echo $this->show_notices($user); - $this->show_footer(); + $this->showFooter(); } function show_notices($user) @@ -132,7 +134,7 @@ class FacebookhomeAction extends FacebookAction function show_notice_list($notice) { - $nl = new NoticeList($notice); + $nl = new FacebookNoticeList($notice); return $nl->show(); } diff --git a/actions/facebookinvite.php b/actions/facebookinvite.php index fe0c5e493..d7e82dae7 100644 --- a/actions/facebookinvite.php +++ b/actions/facebookinvite.php @@ -41,7 +41,7 @@ class FacebookinviteAction extends FacebookAction $facebook = get_facebook(); $fbuid = $facebook->require_login(); - $this->show_header('Invite'); + $this->showHeader('Invite'); common_element('h2', null, _('Thanks for inviting your friends to use Identi.ca!')); common_element('p', null, _('Invitations have been sent to the following users:')); @@ -60,7 +60,7 @@ class FacebookinviteAction extends FacebookAction common_element_end("ul"); - $this->show_footer(); + $this->showFooter(); } function showInviteForm() @@ -69,7 +69,7 @@ class FacebookinviteAction extends FacebookAction $facebook = get_facebook(); $fbuid = $facebook->require_login(); - $this->show_header('Invite'); + $this->showHeader('Invite'); // Get a list of users who are already using the app for exclusion $exclude_ids = $facebook->api_client->friends_getAppUsers(); @@ -104,7 +104,7 @@ class FacebookinviteAction extends FacebookAction common_element_end("ul"); - $this->show_footer(); + $this->showFooter(); } diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php index ab04ad82b..eafd91123 100644 --- a/actions/facebooksettings.php +++ b/actions/facebooksettings.php @@ -19,7 +19,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once(INSTALLDIR.'/lib/facebookaction.php'); +require_once INSTALLDIR.'/lib/facebookaction.php'; class FacebooksettingsAction extends FacebookAction { @@ -29,13 +29,13 @@ class FacebooksettingsAction extends FacebookAction parent::handle($args); if ($this->arg('save')) { - $this->save_settings(); + $this->saveSettings(); } else { - $this->show_form(); + $this->showForm(); } } - function save_settings() { + function saveSettings() { $noticesync = $this->arg('noticesync'); $replysync = $this->arg('replysync'); @@ -59,14 +59,14 @@ class FacebooksettingsAction extends FacebookAction } } - function show_form($msg = null, $success = false) { + function showForm($msg = null, $success = false) { $facebook = get_facebook(); $fbuid = $facebook->require_login(); $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); - $this->show_header('Settings', $msg, $success); + $this->showHeader('Settings', $msg, $success); common_element_start('fb:if-section-not-added', array('section' => 'profile')); common_element('h2', null, _('Add an Identi.ca box to my profile')); @@ -108,7 +108,7 @@ class FacebooksettingsAction extends FacebookAction } - $this->show_footer(); + $this->showFooter(); } } diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 3a00c71dd..1bf026281 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -17,9 +17,11 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/facebookutil.php'); +require_once INSTALLDIR.'/lib/facebookutil.php'; class FacebookAction extends Action { @@ -29,32 +31,67 @@ class FacebookAction extends Action parent::handle($args); } - function show_header($selected = 'Home', $msg = null, $success = false) + function showLogo(){ + + global $xw; + + common_element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => get_facebook_css())); + + common_element_start('a', array('class' => 'url home bookmark', + 'href' => common_local_url('public'))); + if (common_config('site', 'logo') || file_exists(theme_file('logo.png'))) { + common_element('img', array('class' => 'logo photo', + 'src' => (common_config('site', 'logo')) ? + common_config('site', 'logo') : theme_path('logo.png'), + 'alt' => common_config('site', 'name'))); + } + + common_element('span', array('class' => 'fn org'), common_config('site', 'name')); + common_element_end('a'); + + } + + function showHeader($selected = 'Home', $msg = null, $success = false) { start_fbml(); - # Add a timestamp to the CSS file so Facebook cache wont ignore our changes - $ts = filemtime(theme_file('facebookapp.css')); - $cssurl = theme_path('facebookapp.css') . "?ts=$ts"; + $this->showLogo(); - common_element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => $cssurl)); + common_element_start('dl', array("id" => 'site_nav_local_views')); + common_element('dt', null, _('Local Views')); + common_element_start('dd'); + + common_element_start('ul', array('class' => 'nav')); + + common_element_start('li', array('class' => + ($selected == 'Home') ? 'current' : 'facebook_home')); + common_element('a', + array('href' => 'index.php', 'title' => _('Home')), _('Home')); + common_element_end('li'); - common_element('fb:dashboard'); + + common_element_start('li', + array('class' => + ($selected == 'Invite') ? 'current' : 'facebook_invite')); + common_element('a', + array('href' => 'invite.php', 'title' => _('Invite')), _('Invite')); + common_element_end('li'); - common_element_start('fb:tabs'); - common_element('fb:tab-item', array('title' => 'Home', - 'href' => 'index.php', - 'selected' => ($selected == 'Home'))); - common_element('fb:tab-item', array('title' => 'Invite', - 'href' => 'invite.php', - 'selected' => ($selected == 'Invite'))); - common_element('fb:tab-item', array('title' => 'Settings', - 'href' => 'settings.php', - 'selected' => ($selected == 'Settings'))); - common_element_end('fb:tabs'); + common_element_start('li', + array('class' => + ($selected == 'Settings') ? 'current' : 'facebook_settings')); + common_element('a', + array('href' => 'settings.php', + 'title' => _('Settings')), _('Settings')); + common_element_end('li'); + + common_element_end('ul'); + + common_element_end('dd'); + common_element_end('dl'); if ($msg) { @@ -69,44 +106,73 @@ class FacebookAction extends Action } - function show_footer() + function showFooter() { common_element_end('div'); common_end_xml(); } + + function showInstructions() + { + global $xw; + + common_element_start('dl', array('class' => 'system_notice')); + common_element('dt', null, 'Page Notice'); + + $loginmsg_part1 = _('To use the %s Facebook Application you need to login ' . + 'with your username and password. Don\'t have a username yet? '); + + $loginmsg_part2 = _(' a new account.'); + + common_element_start('dd'); + common_element_start('p'); + common_text(sprintf($loginmsg_part1, common_config('site', 'name'))); + common_element('a', + array('href' => common_local_url('register')), _('Register')); + common_text($loginmsg_part2); + common_element_end('dd'); + common_element_end('dl'); + } + function showLoginForm($msg = null) { start_fbml(); - common_element_start('a', array('href' => 'http://identi.ca')); - common_element('img', array('src' => 'http://theme.identi.ca/identica/logo.png', - 'alt' => 'Identi.ca', - 'id' => 'logo')); - common_element_end('a'); + common_element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => get_facebook_css())); + + $this->showLogo(); + + common_element_start('div', array('class' => 'content')); + common_element('h1', null, _('Login')); + if ($msg) { common_element('fb:error', array('message' => $msg)); } + + $this->showInstructions(); - common_element("h2", null, - _('To add the Identi.ca application, you need to log into your Identi.ca account.')); - + common_element_start('div', array('id' => 'content_inner')); - common_element_start('div', array('class' => 'instructions')); - common_element_start('p'); - common_raw('Login with your username and password. Don\'t have a username yet?' - .' Register a new account.'); - common_element_end('p'); - common_element_end('div'); - - common_element_start('div', array('id' => 'content')); common_element_start('form', array('method' => 'post', 'id' => 'login', 'action' => 'index.php')); + + common_element_start('fieldset'); + common_element('legend', null, _('Login to site')); + + common_element_start('ul', array('class' => 'form_datas')); + common_element_start('li'); common_input('nickname', _('Nickname')); + common_element_end('li'); + common_element_start('li'); common_password('password', _('Password')); - + common_element_end('li'); + common_element_end('ul'); + common_submit('submit', _('Login')); common_element_end('form'); @@ -114,6 +180,7 @@ class FacebookAction extends Action common_element('a', array('href' => common_local_url('recoverpassword')), _('Lost or forgotten password?')); common_element_end('p'); + common_element_end('div'); common_end_xml(); diff --git a/lib/facebookutil.php b/lib/facebookutil.php index 2529b8a4b..532e9c9d7 100644 --- a/lib/facebookutil.php +++ b/lib/facebookutil.php @@ -17,8 +17,8 @@ * along with this program. If not, see . */ -require_once(INSTALLDIR.'/extlib/facebook/facebook.php'); -require_once(INSTALLDIR.'/lib/noticelist.php'); +require_once INSTALLDIR.'/extlib/facebook/facebook.php'; +require_once INSTALLDIR.'/lib/noticelist.php'; define("FACEBOOK_SERVICE", 2); // Facebook is foreign_service ID 2 @@ -94,7 +94,7 @@ function update_profile_box($facebook, $fbuid, $user, $notice) $xw = new XMLWriter(); $xw->openMemory(); - $item = new NoticeListItem($notice); + $item = new FacebookNoticeListItem($notice); $item->show(); $fbml = "$style " . $xw->outputMemory(false) . ""; @@ -104,3 +104,130 @@ function update_profile_box($facebook, $fbuid, $user, $notice) $facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main); } + +function get_facebook_css() +{ + # Add a timestamp to the CSS file so Facebook cache wont ignore our changes + $ts = filemtime(theme_file('facebookapp.css')); + $cssurl = theme_path('facebookapp.css') . "?ts=$ts"; + return $cssurl; +} + + +class FacebookNoticeList extends NoticeList +{ + /** + * show the list of notices + * + * "Uses up" the stream by looping through it. So, probably can't + * be called twice on the same list. + * + * @return int count of notices listed. + */ + + function show() + { + common_element_start('div', array('id' =>'notices_primary')); + common_element('h2', null, _('Notices')); + common_element_start('ul', array('class' => 'notices')); + + $cnt = 0; + + while ($this->notice->fetch() && $cnt <= NOTICES_PER_PAGE) { + $cnt++; + + if ($cnt > NOTICES_PER_PAGE) { + break; + } + + $item = $this->newListItem($this->notice); + $item->show(); + } + + common_element_end('ul'); + common_element_end('div'); + + return $cnt; + } + + /** + * returns a new list item for the current notice + * + * Overridden to return a Facebook specific list item. + * + * @param Notice $notice the current notice + * + * @return FacebookNoticeListItem a list item for displaying the notice + * formatted for display in the Facebook App. + */ + + function newListItem($notice) + { + return new FacebookNoticeListItem($notice); + } + +} + +class FacebookNoticeListItem extends NoticeListItem +{ + /** + * recipe function for displaying a single notice in the Facebook App. + * + * Overridden to strip out some of the controls that we don't + * want to be available. + * + * @return void + */ + + function show() + { + $this->showStart(); + + common_element_start('div', 'entry-title'); + $this->showAuthor(); + $this->showContent(); + common_element_end('div'); + + common_element_start('div', 'entry-content'); + $this->showNoticeLink(); + $this->showNoticeSource(); + $this->showReplyTo(); + common_element_end('div'); + + $this->showEnd(); + } + + function showStart() + { + // XXX: RDFa + // TODO: add notice_type class e.g., notice_video, notice_image + common_element_start('li', array('class' => 'hentry notice', + 'id' => 'notice-' . $this->notice->id)); + } + + function showNoticeLink() + { + $noticeurl = common_local_url('shownotice', + array('notice' => $this->notice->id)); + // XXX: we need to figure this out better. Is this right? + if (strcmp($this->notice->uri, $noticeurl) != 0 && + preg_match('/^http/', $this->notice->uri)) { + $noticeurl = $this->notice->uri; + } + + common_element_start('dl', 'timestamp'); + common_element('dt', null, _('Published')); + common_element_start('dd', null); + common_element_start('a', array('rel' => 'bookmark', + 'href' => $noticeurl)); + $dt = common_date_iso8601($this->notice->created); + common_element('abbr', array('class' => 'published', + 'title' => $dt), + common_date_string($this->notice->created)); + common_element_end('a'); + common_element_end('dd'); + common_element_end('dl'); + } + +} + -- cgit v1.2.3-54-g00ecf From 4b1cc73a583ce8b73760f6e709c0fc794af1b471 Mon Sep 17 00:00:00 2001 From: sarven Date: Sun, 18 Jan 2009 03:12:39 +0000 Subject: Favor/Disfavor form @class Created icon, and add style JS selector change Fixed return actions --- actions/disfavor.php | 2 +- actions/favor.php | 2 +- actions/login.php | 6 +++--- js/util.js | 8 ++++---- lib/disfavorform.php | 6 +++--- lib/favorform.php | 4 ++-- theme/base/css/display.css | 10 ++++++---- theme/identica/css/display.css | 9 ++++++--- 8 files changed, 26 insertions(+), 21 deletions(-) (limited to 'actions') diff --git a/actions/disfavor.php b/actions/disfavor.php index fc36f7c75..3e3e4a547 100644 --- a/actions/disfavor.php +++ b/actions/disfavor.php @@ -69,7 +69,7 @@ class DisfavorAction extends Action $user->blowFavesCache(); if ($this->boolean('ajax')) { - common_start_html('text/xml;charset=utf-8', true); + $this->startHTML('text/xml;charset=utf-8', true); $this->elementStart('head'); $this->element('title', null, _('Add to favorites')); $this->elementEnd('head'); diff --git a/actions/favor.php b/actions/favor.php index 8d751a7a9..afda93cff 100644 --- a/actions/favor.php +++ b/actions/favor.php @@ -68,7 +68,7 @@ class FavorAction extends Action $user->blowFavesCache(); if ($this->boolean('ajax')) { - common_start_html('text/xml;charset=utf-8', true); + $this->startHTML('text/xml;charset=utf-8', true); $this->elementStart('head'); $this->element('title', null, _('Disfavor favorite')); $this->elementEnd('head'); diff --git a/actions/login.php b/actions/login.php index c213e2ab5..4e580d360 100644 --- a/actions/login.php +++ b/actions/login.php @@ -107,13 +107,13 @@ class LoginAction extends Action function showForm($error=null) { - $this->error = $error; - $this->showPage(); + $this->error = $error; + $this->showPage(); } function title() { - return _('Login'); + return _('Login'); } function showPageNotice() diff --git a/js/util.js b/js/util.js index 6fe477075..0a03b86c2 100644 --- a/js/util.js +++ b/js/util.js @@ -81,10 +81,10 @@ $(document).ready(function(){ this.appendChild(ajax); } - $("form.favor").ajaxForm(favoptions); - $("form.disfavor").ajaxForm(disoptions); - $("form.favor").each(addAjaxHidden); - $("form.disfavor").each(addAjaxHidden); + $("form.form_favor").ajaxForm(favoptions); + $("form.form_disfavor").ajaxForm(disoptions); + $("form.form_favor").each(addAjaxHidden); + $("form.form_disfavor").each(addAjaxHidden); $("#nudge").ajaxForm ({ dataType: 'xml', beforeSubmit: function(xml) { $("form#nudge input[type=submit]").attr("disabled", "disabled"); diff --git a/lib/disfavorform.php b/lib/disfavorform.php index ffca0cd8b..d0c3b1832 100644 --- a/lib/disfavorform.php +++ b/lib/disfavorform.php @@ -88,7 +88,7 @@ class DisfavorForm extends Form function action() { - common_local_url('disfavor'); + return common_local_url('disfavor'); } /** @@ -136,7 +136,7 @@ class DisfavorForm extends Form function formClass() { - return 'disfavor'; + return 'form_disfavor'; } -} \ No newline at end of file +} diff --git a/lib/favorform.php b/lib/favorform.php index 37e13fb1c..f3a7a9756 100644 --- a/lib/favorform.php +++ b/lib/favorform.php @@ -88,7 +88,7 @@ class FavorForm extends Form function action() { - common_local_url('favor'); + return common_local_url('favor'); } /** @@ -148,6 +148,6 @@ class FavorForm extends Form function formClass() { - return 'notice_favorite'; + return 'form_favor'; } } diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 789eaee4c..9146a2bf5 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -817,11 +817,13 @@ float:left; } .notice-options .notice_delete, .notice-options .notice_reply, -.notice-options .notice_favorite { +.notice-options .form_favor, +.notice-options .form_disfavor { position:absolute; top:0; } -.notice-options .notice_favorite { +.notice-options .form_favor, +.notice-options .form_disfavor { left:0; } .notice-options .notice_reply { @@ -861,11 +863,11 @@ padding:2px 0 2px 10px; } .notice-options .notice_delete dt, -.notice-options .notice_favorite legend { +.notice-options .form_favor legend { display:none; } .notice-options .notice_delete fieldset, -.notice-options .notice_favorite fieldset { +.notice-options .form_favor fieldset { border:0; padding:0; } diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index d3d28001a..832862551 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -62,7 +62,7 @@ border-color:#fff; background-color:rgba(255, 255, 255, 0.2); } #site_nav_local_views a:hover { -background-color:rgba(255, 255, 255, 0.7);: +background-color:rgba(255, 255, 255, 0.7); } @@ -87,7 +87,7 @@ background-image:url(../../base/images/icons/icon_atom.jpg); } #export_data li a.foaf { background-image:url(../../base/images/icons/icon_foaf.gif); -=} +} #export_data li a.export_vcard { background-image:url(../../base/images/icons/icon_vcard.gif); } @@ -173,9 +173,12 @@ background-color:transparent; .notice-options .notice_reply a { background:transparent url(../images/icons/twotone/green/reply.gif) no-repeat 0 45%; } -.notice-options form.notice_favorite input.submit { +.notice-options form.form_favor input.submit { background:transparent url(../images/icons/twotone/green/favourite.gif) no-repeat 0 45%; } +.notice-options form.form_disfavor input.submit { +background:transparent url(../images/icons/twotone/green/disfavourite.gif) no-repeat 0 45%; +} .notice-options .notice_delete a { background:transparent url(../images/icons/twotone/green/trash.gif) no-repeat 0 45%; } -- cgit v1.2.3-54-g00ecf From 8fdf888edbd74e707d2698c7625dc90b22f0aeef Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sun, 18 Jan 2009 06:12:47 +0000 Subject: trac750 Javascript file for Facebook app --- actions/facebooksettings.php | 17 +++++++---------- js/facebookapp.js | 25 +++++++++++++++++++++++++ lib/facebookaction.php | 15 ++++++++++++--- lib/facebookutil.php | 10 +++++++++- 4 files changed, 53 insertions(+), 14 deletions(-) create mode 100644 js/facebookapp.js (limited to 'actions') diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php index eafd91123..372c40c28 100644 --- a/actions/facebooksettings.php +++ b/actions/facebooksettings.php @@ -68,19 +68,18 @@ class FacebooksettingsAction extends FacebookAction $this->showHeader('Settings', $msg, $success); - common_element_start('fb:if-section-not-added', array('section' => 'profile')); - common_element('h2', null, _('Add an Identi.ca box to my profile')); + common_element('form', array('id' => 'redirect_form', + 'style' => 'display: none;')); + common_element_start('p'); - common_element('fb:add-section-button', array('section' => 'profile')); - common_element_end('p'); - - common_element_end('fb:if-section-not-added'); - common_element_start('p'); - common_element_start('fb:prompt-permission', array('perms' => 'status_update')); + common_element_start('fb:prompt-permission', array('perms' => 'status_update', + 'next_fbjs' => 'redirectSettings()')); common_element('h2', null, _('Allow Identi.ca to update my Facebook status')); common_element_end('fb:prompt-permission'); common_element_end('p'); + + if ($facebook->api_client->users_hasAppPermission('status_update')) { common_element_start('form', array('method' => 'post', @@ -94,8 +93,6 @@ class FacebooksettingsAction extends FacebookAction common_checkbox('replysync', _('Send local "@" replies to Facebook.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true); - // function common_input($id, $label, $value=null,$instructions=null) - $prefix = $facebook->api_client->data_getUserPreference(1); diff --git a/js/facebookapp.js b/js/facebookapp.js new file mode 100644 index 000000000..3f809e50c --- /dev/null +++ b/js/facebookapp.js @@ -0,0 +1,25 @@ +/* + * Laconica - a distributed open-source microblogging tool + * Copyright (C) 2008, Controlez-Vous, Inc. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +// Psycho Facebook redirect hack, used because 'document.location' +// simply does not work in FBJS +function redirectSettings() { + form = document.getElementById('redirect_form'); + form.setAction('settings.php'); + form.submit(); +} diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 1bf026281..a8f16b34a 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -37,7 +37,11 @@ class FacebookAction extends Action common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', - 'href' => get_facebook_css())); + 'href' => getFacebookCSS())); + + common_element('script', array('type' => 'text/javascript', + 'src' => getFacebookJS()), + ' '); common_element_start('a', array('class' => 'url home bookmark', 'href' => common_local_url('public'))); @@ -58,6 +62,12 @@ class FacebookAction extends Action start_fbml(); + common_element_start('fb:if-section-not-added', array('section' => 'profile')); + common_element_start('span', array('id' => 'add_to_profile')); + common_element('fb:add-section-button', array('section' => 'profile')); + common_element_end('span'); + common_element_end('fb:if-section-not-added'); + $this->showLogo(); common_element_start('dl', array("id" => 'site_nav_local_views')); @@ -141,8 +151,7 @@ class FacebookAction extends Action common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', - 'href' => get_facebook_css())); - + 'href' => getFacebookCSS())); $this->showLogo(); diff --git a/lib/facebookutil.php b/lib/facebookutil.php index 532e9c9d7..61469b3c6 100644 --- a/lib/facebookutil.php +++ b/lib/facebookutil.php @@ -105,7 +105,7 @@ function update_profile_box($facebook, $fbuid, $user, $notice) $facebook->api_client->profile_setFBML(null, $fbuid, $fbml, null, null, $fbml_main); } -function get_facebook_css() +function getFacebookCSS() { # Add a timestamp to the CSS file so Facebook cache wont ignore our changes $ts = filemtime(theme_file('facebookapp.css')); @@ -113,6 +113,14 @@ function get_facebook_css() return $cssurl; } +function getFacebookJS() { + + # Add a timestamp to the FBJS file so Facebook cache wont ignore our changes + $ts = filemtime(INSTALLDIR.'/js/facebookapp.js'); + $jsurl = common_path('js/facebookapp.js') . "?ts=$ts"; + return $jsurl; +} + class FacebookNoticeList extends NoticeList { -- cgit v1.2.3-54-g00ecf From 5a313fef6e8b8ff8480d917f9fc49d41aee6e486 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 18 Jan 2009 12:48:47 +0000 Subject: Add tabset to login and make it phpcs-compliant --- actions/login.php | 157 ++++++++++++++++++++++++++++++++++++++++++-------- lib/logingroupnav.php | 96 ++++++++++++++++++++++++++++++ 2 files changed, 229 insertions(+), 24 deletions(-) create mode 100644 lib/logingroupnav.php (limited to 'actions') diff --git a/actions/login.php b/actions/login.php index 4e580d360..9fcf740eb 100644 --- a/actions/login.php +++ b/actions/login.php @@ -1,9 +1,12 @@ . + * + * @category Login + * @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); } +if (!defined('LACONICA')) { + exit(1); +} + +/** + * List of replies + * + * @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 LoginAction extends Action { + /** + * Has there been an error? + */ + var $error = null; - + + /** + * Is this a read-only action? + * + * @return boolean true + */ + function isReadOnly() { return true; } + /** + * Handle input, produce output + * + * Switches on request method; either shows the form or handles its input. + * + * @param array $args $_REQUEST data + * + * @return void + */ + function handle($args) { parent::handle($args); @@ -40,21 +82,32 @@ class LoginAction extends Action } } + /** + * Check the login data + * + * Determines if the login data is valid. If so, logs the user + * in, and redirects to the 'with friends' page, or to the stored + * return-to URL. + * + * @return void + */ + function checkLogin() { - # XXX: login throttle + // XXX: login throttle - # CSRF protection - token set in common_notice_form() + // CSRF protection - token set in common_notice_form() $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->clientError(_('There was a problem with your session token. Try again, please.')); + $this->clientError(_('There was a problem with your session token. '. + 'Try again, please.')); return; } $nickname = common_canonical_nickname($this->trimmed('nickname')); $password = $this->arg('password'); if (common_check_user($nickname, $password)) { - # success! + // success! if (!common_set_user($nickname)) { $this->serverError(_('Error setting user.')); return; @@ -64,10 +117,10 @@ class LoginAction extends Action common_debug('Adding rememberme cookie for ' . $nickname); common_rememberme(); } - # success! + // success! $url = common_get_returnto(); if ($url) { - # We don't have to return to it again + // We don't have to return to it again common_set_returnto(null); } else { $url = common_local_url('all', @@ -80,7 +133,7 @@ class LoginAction extends Action return; } - # success! + // success! if (!common_set_user($user)) { $this->serverError(_('Error setting user.')); return; @@ -92,10 +145,10 @@ class LoginAction extends Action common_debug('Adding rememberme cookie for ' . $nickname); common_rememberme($user); } - # success! + // success! $url = common_get_returnto(); if ($url) { - # We don't have to return to it again + // We don't have to return to it again common_set_returnto(null); } else { $url = common_local_url('all', @@ -105,30 +158,65 @@ class LoginAction extends Action common_redirect($url); } + /** + * Store an error and show the page + * + * This used to show the whole page; now, it's just a wrapper + * that stores the error in an attribute. + * + * @param string $error error, if any. + * + * @return void + */ + function showForm($error=null) { $this->error = $error; $this->showPage(); } + /** + * Title of the page + * + * @return string title of the page + */ + function title() { return _('Login'); } + /** + * Show page notice + * + * Display a notice for how to use the page, or the + * error if it exists. + * + * @return void + */ + function showPageNotice() { if ($this->error) { $this->element('p', 'error', $this->error); } else { - $instr = $this->getInstructions(); + $instr = $this->getInstructions(); $output = common_markup_to_html($instr); + $this->raw($output); } } - + + /** + * Core of the display code + * + * Shows the login form. + * + * @return void + */ + function showContent() - { + { $this->elementStart('form', array('method' => 'post', 'id' => 'form_login', 'class' => 'form_settings', @@ -158,14 +246,21 @@ class LoginAction extends Action $this->elementEnd('p'); } + /** + * Instructions for using the form + * + * For "remembered" logins, we make the user re-login when they + * try to change settings. Different instructions for this case. + * + * @return void + */ + function getInstructions() { - if (common_logged_in() && - !common_is_real_login() && - common_get_returnto()) - { - # rememberme logins have to reauthenticate before - # changing any profile settings (cookie-stealing protection) + if (common_logged_in() && !common_is_real_login() && + common_get_returnto()) { + // rememberme logins have to reauthenticate before + // changing any profile settings (cookie-stealing protection) return _('For security reasons, please re-enter your ' . 'user name and password ' . 'before changing your settings.'); @@ -176,4 +271,18 @@ class LoginAction extends Action 'try [OpenID](%%action.openidlogin%%). '); } } + + /** + * A local menu + * + * Shows different login/register actions. + * + * @return void + */ + + function showLocalNav() + { + $nav = new LoginGroupNav($this); + $nav->show(); + } } diff --git a/lib/logingroupnav.php b/lib/logingroupnav.php new file mode 100644 index 000000000..285d60b30 --- /dev/null +++ b/lib/logingroupnav.php @@ -0,0 +1,96 @@ +. + * + * @category Menu + * @package Laconica + * @author Evan Prodromou + * @copyright 2008 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/widget.php'; + +/** + * Menu for login group of actions + * + * @category Output + * @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/ + * + * @see Widget + */ + +class LoginGroupNav extends Widget +{ + var $action = null; + + /** + * Construction + * + * @param Action $action current action, used for output + */ + + function __construct($action=null) + { + parent::__construct($action); + $this->action = $action; + } + + /** + * Show the menu + * + * @return void + */ + + function show() + { + # action => array('prompt', 'title') + $menu = + array('login' => + array(_('Login'), + _('Login with a username and password')), + 'register' => + array(_('Register'), + _('Sign up for a new account')), + 'openid' => + array(_('OpenID'), + _('Login or register with OpenID'))); + + $action_name = $this->action->trimmed('action'); + $this->action->elementStart('ul', array('class' => 'nav')); + + foreach ($menu as $menuaction => $menudesc) { + $this->action->menuItem(common_local_url($menuaction), + $menudesc[0], + $menudesc[1], + $action_name === $menuaction); + } + + $this->action->elementEnd('ul'); + } +} -- cgit v1.2.3-54-g00ecf From b4b686c1185c8b5c923f584b097371b21fa5198f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 18 Jan 2009 12:55:07 +0000 Subject: Fix file and class descriptors --- actions/login.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actions') diff --git a/actions/login.php b/actions/login.php index 9fcf740eb..2a94110b2 100644 --- a/actions/login.php +++ b/actions/login.php @@ -2,7 +2,7 @@ /** * Laconica, the distributed open-source microblogging tool * - * List of replies + * Login form * * PHP version 5 * @@ -32,7 +32,7 @@ if (!defined('LACONICA')) { } /** - * List of replies + * Login form * * @category Personal * @package Laconica -- cgit v1.2.3-54-g00ecf From 4163f450040d92f417a2481e65cada97f77d74f2 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 18 Jan 2009 13:37:58 +0000 Subject: Update register action to match phpcs and new framework --- actions/register.php | 366 +++++++++++++++++++++++++++++++++++++++------------ lib/common.php | 4 + 2 files changed, 289 insertions(+), 81 deletions(-) (limited to 'actions') diff --git a/actions/register.php b/actions/register.php index b4d0d43fb..b15aea08e 100644 --- a/actions/register.php +++ b/actions/register.php @@ -1,9 +1,12 @@ . + * + * @category Login + * @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); } +if (!defined('LACONICA')) { + exit(1); +} + +/** + * An action for registering a new user account + * + * @category Login + * @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 RegisterAction extends Action { + /** + * Has there been an error? + */ + + var $error = null; + + /** + * Have we registered? + */ + + var $registered = false; + + /** + * Title of the page + * + * @return string title + */ + + function title() + { + if ($this->registered) { + return _('Registration successful'); + } else { + return _('Register'); + } + } + + /** + * Handle input, produce output + * + * Switches on request method; either shows the form or handles its input. + * + * Checks if registration is closed and shows an error if so. + * + * @param array $args $_REQUEST data + * + * @return void + */ + function handle($args) { parent::handle($args); @@ -30,33 +91,43 @@ class RegisterAction extends Action } else if (common_logged_in()) { $this->clientError(_('Already logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { - $this->try_register(); + $this->tryRegister(); } else { - $this->show_form(); + $this->showForm(); } } - function try_register() + /** + * Try to register a user + * + * Validates the input and tries to save a new user and profile + * record. On success, shows an instructions page. + * + * @return void + */ + + function tryRegister() { $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); + $this->showForm(_('There was a problem with your session token. '. + 'Try again, please.')); return; } $nickname = $this->trimmed('nickname'); - $email = $this->trimmed('email'); + $email = $this->trimmed('email'); $fullname = $this->trimmed('fullname'); $homepage = $this->trimmed('homepage'); - $bio = $this->trimmed('bio'); + $bio = $this->trimmed('bio'); $location = $this->trimmed('location'); - # We don't trim these... whitespace is OK in a password! + // We don't trim these... whitespace is OK in a password! $password = $this->arg('password'); - $confirm = $this->arg('confirm'); + $confirm = $this->arg('confirm'); - # invitation code, if any + // invitation code, if any $code = $this->trimmed('code'); @@ -69,80 +140,105 @@ class RegisterAction extends Action return; } - # Input scrubbing + // Input scrubbing $nickname = common_canonical_nickname($nickname); - $email = common_canonical_email($email); + $email = common_canonical_email($email); if (!$this->boolean('license')) { - $this->show_form(_('You can\'t register if you don\'t agree to the license.')); + $this->showForm(_('You can\'t register if you don\'t '. + 'agree to the license.')); } else if ($email && !Validate::email($email, true)) { - $this->show_form(_('Not a valid email address.')); + $this->showForm(_('Not a valid email address.')); } else if (!Validate::string($nickname, array('min_length' => 1, 'max_length' => 64, - 'format' => VALIDATE_NUM . VALIDATE_ALPHA_LOWER))) { - $this->show_form(_('Nickname must have only lowercase letters and numbers and no spaces.')); - } else if ($this->nickname_exists($nickname)) { - $this->show_form(_('Nickname already in use. Try another one.')); + 'format' => NICKNAME_FMT))) { + $this->showForm(_('Nickname must have only lowercase letters '. + 'and numbers and no spaces.')); + } else if ($this->nicknameExists($nickname)) { + $this->showForm(_('Nickname already in use. Try another one.')); } else if (!User::allowed_nickname($nickname)) { - $this->show_form(_('Not a valid nickname.')); - } else if ($this->email_exists($email)) { - $this->show_form(_('Email address already exists.')); + $this->showForm(_('Not a valid nickname.')); + } else if ($this->emailExists($email)) { + $this->showForm(_('Email address already exists.')); } else if (!is_null($homepage) && (strlen($homepage) > 0) && - !Validate::uri($homepage, array('allowed_schemes' => array('http', 'https')))) { - $this->show_form(_('Homepage is not a valid URL.')); + !Validate::uri($homepage, + array('allowed_schemes' => + array('http', 'https')))) { + $this->showForm(_('Homepage is not a valid URL.')); return; } else if (!is_null($fullname) && strlen($fullname) > 255) { - $this->show_form(_('Full name is too long (max 255 chars).')); + $this->showForm(_('Full name is too long (max 255 chars).')); return; } else if (!is_null($bio) && strlen($bio) > 140) { - $this->show_form(_('Bio is too long (max 140 chars).')); + $this->showForm(_('Bio is too long (max 140 chars).')); return; } else if (!is_null($location) && strlen($location) > 255) { - $this->show_form(_('Location is too long (max 255 chars).')); + $this->showForm(_('Location is too long (max 255 chars).')); return; } else if (strlen($password) < 6) { - $this->show_form(_('Password must be 6 or more characters.')); + $this->showForm(_('Password must be 6 or more characters.')); return; } else if ($password != $confirm) { - $this->show_form(_('Passwords don\'t match.')); - } else if ($user = User::register(array('nickname' => $nickname, 'password' => $password, 'email' => $email, - 'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio, - 'location' => $location, 'code' => $code))) { + $this->showForm(_('Passwords don\'t match.')); + } else if ($user = User::register(array('nickname' => $nickname, + 'password' => $password, + 'email' => $email, + 'fullname' => $fullname, + 'homepage' => $homepage, + 'bio' => $bio, + 'location' => $location, + 'code' => $code))) { if (!$user) { - $this->show_form(_('Invalid username or password.')); + $this->showForm(_('Invalid username or password.')); return; } - # success! + // success! if (!common_set_user($user)) { $this->serverError(_('Error setting user.')); return; } - # this is a real login + // this is a real login common_real_login(true); if ($this->boolean('rememberme')) { common_debug('Adding rememberme cookie for ' . $nickname); common_rememberme($user); } - # Re-init language env in case it changed (not yet, but soon) + // Re-init language env in case it changed (not yet, but soon) common_init_language(); - $this->show_success(); + $this->showSuccess(); } else { - $this->show_form(_('Invalid username or password.')); + $this->showForm(_('Invalid username or password.')); } } - # checks if *CANONICAL* nickname exists + /** + * Does the given nickname already exist? + * + * Checks a canonical nickname against the database. + * + * @param string $nickname nickname to check + * + * @return boolean true if the nickname already exists + */ - function nickname_exists($nickname) + function nicknameExists($nickname) { $user = User::staticGet('nickname', $nickname); return ($user !== false); } - # checks if *CANONICAL* email exists + /** + * Does the given email address already exist? + * + * Checks a canonical email address against the database. + * + * @param string $email email address to check + * + * @return boolean true if the address already exists + */ - function email_exists($email) + function emailExists($email) { $email = common_canonical_email($email); if (!$email || strlen($email) == 0) { @@ -152,15 +248,29 @@ class RegisterAction extends Action return ($user !== false); } - function show_top($error=null) + /** + * Instructions or a notice for the page + * + * Shows the error, if any, or instructions for registration. + * + * @return void + */ + + function showPageNotice() { - if ($error) { - $this->element('p', 'error', $error); + if ($this->registered) { + return; + } else if ($this->error) { + $this->element('p', 'error', $this->error); } else { - $instr = common_markup_to_html(_('With this form you can create a new account. ' . - 'You can then post notices and link up to friends and colleagues. '. - '(Have an [OpenID](http://openid.net/)? ' . - 'Try our [OpenID registration](%%action.openidlogin%%)!)')); + $instr = + common_markup_to_html(_('With this form you can create '. + ' a new account. ' . + 'You can then post notices and '. + 'link up to friends and colleagues. '. + '(Have an [OpenID](http://openid.net/)? ' . + 'Try our [OpenID registration]'. + '(%%action.openidlogin%%)!)')); $this->elementStart('div', 'instructions'); $this->raw($instr); @@ -168,10 +278,48 @@ class RegisterAction extends Action } } - function show_form($error=null) + /** + * Wrapper for showing a page + * + * Stores an error and shows the page + * + * @param string $error Error, if any + * + * @return void + */ + + function showForm($error=null) { - global $config; + $this->error = $error; + $this->showPage(); + } + + /** + * Show the page content + * + * Either shows the registration form or, if registration was successful, + * instructions for using the site. + * + * @return void + */ + function showContent() + { + if ($this->registered) { + $this->showSuccessContent(); + } else { + $this->showFormContent(); + } + } + + /** + * Show the registration form + * + * @return void + */ + + function showFormContent() + { $code = $this->trimmed('code'); if ($code) { @@ -183,10 +331,9 @@ class RegisterAction extends Action return; } - common_show_header(_('Register'), null, $error, array($this, 'show_top')); $this->elementStart('form', array('method' => 'post', - 'id' => 'login', - 'action' => common_local_url('register'))); + 'id' => 'login', + 'action' => common_local_url('register'))); $this->hidden('token', common_session_token()); @@ -195,33 +342,40 @@ class RegisterAction extends Action } $this->input('nickname', _('Nickname'), $this->trimmed('nickname'), - _('1-64 lowercase letters or numbers, no punctuation or spaces. Required.')); + _('1-64 lowercase letters or numbers, '. + 'no punctuation or spaces. Required.')); $this->password('password', _('Password'), _('6 or more characters. Required.')); $this->password('confirm', _('Confirm'), _('Same as password above. Required.')); if ($invite && $invite->address_type == 'email') { $this->input('email', _('Email'), $invite->address, - _('Used only for updates, announcements, and password recovery')); + _('Used only for updates, announcements, '. + 'and password recovery')); } else { $this->input('email', _('Email'), $this->trimmed('email'), - _('Used only for updates, announcements, and password recovery')); + _('Used only for updates, announcements, '. + 'and password recovery')); } $this->input('fullname', _('Full name'), $this->trimmed('fullname'), - _('Longer name, preferably your "real" name')); + _('Longer name, preferably your "real" name')); $this->input('homepage', _('Homepage'), $this->trimmed('homepage'), - _('URL of your homepage, blog, or profile on another site')); + _('URL of your homepage, blog, '. + 'or profile on another site')); $this->textarea('bio', _('Bio'), $this->trimmed('bio'), - _('Describe yourself and your interests in 140 chars')); + _('Describe yourself and your '. + 'interests in 140 chars')); $this->input('location', _('Location'), $this->trimmed('location'), - _('Where you are, like "City, State (or Region), Country"')); + _('Where you are, like "City, '. + 'State (or Region), Country"')); $this->checkbox('rememberme', _('Remember me'), $this->boolean('rememberme'), - _('Automatically login in the future; not for shared computers!')); + _('Automatically login in the future; '. + 'not for shared computers!')); $this->elementStart('p'); $attrs = array('type' => 'checkbox', 'id' => 'license', @@ -232,37 +386,87 @@ class RegisterAction extends Action } $this->element('input', $attrs); $this->text(_('My text and files are available under ')); - $this->element('a', array('href' => $config['license']['url']), + $this->element('a', array('href' => common_config('license', 'url')), $config['license']['title']); - $this->text(_(' except this private data: password, email address, IM address, phone number.')); + $this->text(_(' except this private data: password, '. + 'email address, IM address, phone number.')); $this->elementEnd('p'); $this->submit('submit', _('Register')); $this->elementEnd('form'); - common_show_footer(); } - function show_success() + /** + * Show some information about registering for the site + * + * Save the registration flag, run showPage + * + * @return void + */ + + function showSuccess() + { + $this->registered = true; + $this->showPage(); + } + + /** + * Show some information about registering for the site + * + * Gives some information and options for new registrees. + * + * @return void + */ + + function showSuccessContent() { $nickname = $this->arg('nickname'); - common_show_header(_('Registration successful')); + + $profileurl = common_local_url('showstream', + array('nickname' => $nickname)); + $this->elementStart('div', 'success'); - $instr = sprintf(_('Congratulations, %s! And welcome to %%%%site.name%%%%. From here, you may want to...'. "\n\n" . - '* Go to [your profile](%s) and post your first message.' . "\n" . - '* Add a [Jabber/GTalk address](%%%%action.imsettings%%%%) so you can send notices through instant messages.' . "\n" . - '* [Search for people](%%%%action.peoplesearch%%%%) that you may know or that share your interests. ' . "\n" . - '* Update your [profile settings](%%%%action.profilesettings%%%%) to tell others more about you. ' . "\n" . - '* Read over the [online docs](%%%%doc.help%%%%) for features you may have missed. ' . "\n\n" . - 'Thanks for signing up and we hope you enjoy using this service.'), - $nickname, common_local_url('showstream', array('nickname' => $nickname))); + $instr = sprintf(_('Congratulations, %s! And welcome to %%%%site.name%%%%. '. + 'From here, you may want to...'. "\n\n" . + '* Go to [your profile](%s) '. + 'and post your first message.' . "\n" . + '* Add a [Jabber/GTalk address]'. + '(%%%%action.imsettings%%%%) '. + 'so you can send notices '. + 'through instant messages.' . "\n" . + '* [Search for people](%%%%action.peoplesearch%%%%) '. + 'that you may know or '. + 'that share your interests. ' . "\n" . + '* Update your [profile settings]'. + '(%%%%action.profilesettings%%%%)'. + ' to tell others more about you. ' . "\n" . + '* Read over the [online docs](%%%%doc.help%%%%)'. + ' for features you may have missed. ' . "\n\n" . + 'Thanks for signing up and we hope '. + 'you enjoy using this service.'), + $nickname, $profileurl); + $this->raw(common_markup_to_html($instr)); + $have_email = $this->trimmed('email'); if ($have_email) { - $emailinstr = _('(You should receive a message by email momentarily, with ' . - 'instructions on how to confirm your email address.)'); + $emailinstr = _('(You should receive a message by email '. + 'momentarily, with ' . + 'instructions on how to confirm '. + 'your email address.)'); $this->raw(common_markup_to_html($emailinstr)); } $this->elementEnd('div'); - common_show_footer(); } + /** + * Show the login group nav menu + * + * @return void + */ + + function showLocalNav() + { + $nav = new LoginGroupNav($this); + $nav->show(); + } } diff --git a/lib/common.php b/lib/common.php index 05fef045a..1068d4c13 100644 --- a/lib/common.php +++ b/lib/common.php @@ -163,6 +163,10 @@ require_once(INSTALLDIR.'/lib/subs.php'); require_once(INSTALLDIR.'/lib/Shorturl_api.php'); require_once(INSTALLDIR.'/lib/twitter.php'); +// XXX: other formats here + +define('NICKNAME_FMT', VALIDATE_NUM.VALIDATE_ALPHA_LOWER); + function __autoload($class) { if ($class == 'OAuthRequest') { -- cgit v1.2.3-54-g00ecf From df58688a58f8ccf36dd39746ef876375f7d9d4e2 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 18 Jan 2009 13:38:29 +0000 Subject: Fix comment blocks for login --- actions/login.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actions') diff --git a/actions/login.php b/actions/login.php index 2a94110b2..9fa501a5d 100644 --- a/actions/login.php +++ b/actions/login.php @@ -52,12 +52,12 @@ class LoginAction extends Action /** * Is this a read-only action? * - * @return boolean true + * @return boolean false */ function isReadOnly() { - return true; + return false; } /** -- cgit v1.2.3-54-g00ecf From 321d52a15cc2dc461ffa850b397a934b6e543077 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 18 Jan 2009 17:06:38 +0000 Subject: Make newnotice work --- actions/newnotice.php | 202 +++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 165 insertions(+), 37 deletions(-) (limited to 'actions') diff --git a/actions/newnotice.php b/actions/newnotice.php index b6ed87f81..572adbb23 100644 --- a/actions/newnotice.php +++ b/actions/newnotice.php @@ -1,28 +1,86 @@ . + * along with this program. If not, see . + * + * @category Personal + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @author Sarven Capadisli + * @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); } +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/noticelist.php'; -require_once INSTALLDIR . '/lib/noticelist.php'; +/** + * Action for posting new notices + * + * @category Personal + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @author Sarven Capadisli + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ class NewnoticeAction extends Action { + /** + * Error message, if any + */ + + var $msg = null; + + /** + * Title of the page + * + * Note that this usually doesn't get called unless something went wrong + * + * @return string page title + */ + + function title() + { + return _('New notice'); + } + + /** + * Handle input, produce output + * + * Switches based on GET or POST method. On GET, shows a form + * for posting a notice. On POST, saves the results of that form. + * + * Results may be a full page, or just a single notice list item, + * depending on whether AJAX was requested. + * + * @param array $args $_REQUEST contents + * + * @return void + */ function handle($args) { @@ -32,36 +90,47 @@ class NewnoticeAction extends Action $this->clientError(_('Not logged in.')); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { - # CSRF protection - token set in common_notice_form() + // CSRF protection - token set in common_notice_form() $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->clientError(_('There was a problem with your session token. Try again, please.')); + $this->clientError(_('There was a problem with your session token. '. + 'Try again, please.')); return; } - $this->save_new_notice(); + $this->saveNewNotice(); } else { - $this->show_form(); + $this->showForm(); } } - function save_new_notice() - { + /** + * Save a new notice, based on arguments + * + * If successful, will show the notice, or return an Ajax-y result. + * If not, it will show an error message -- possibly Ajax-y. + * + * Also, if the notice input looks like a command, it will run the + * command and show the results -- again, possibly ajaxy. + * + * @return void + */ + function saveNewNotice() + { $user = common_current_user(); - assert($user); # XXX: maybe an error instead... + assert($user); // XXX: maybe an error instead... $content = $this->trimmed('status_textarea'); if (!$content) { - $this->show_form(_('No content!')); + $this->showForm(_('No content!')); return; } else { $content_shortened = common_shorten_links($content); if (mb_strlen($content_shortened) > 140) { - common_debug("Content = '$content_shortened'", __FILE__); - common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__); - $this->show_form(_('That\'s too long. Max notice size is 140 chars.')); + $this->showForm(_('That\'s too long. '. + 'Max notice size is 140 chars.')); return; } } @@ -81,10 +150,11 @@ class NewnoticeAction extends Action $replyto = $this->trimmed('inreplyto'); - $notice = Notice::saveNew($user->id, $content, 'web', 1, ($replyto == 'false') ? null : $replyto); + $notice = Notice::saveNew($user->id, $content, 'web', 1, + ($replyto == 'false') ? null : $replyto); if (is_string($notice)) { - $this->show_form($notice); + $this->showForm($notice); return; } @@ -96,7 +166,7 @@ class NewnoticeAction extends Action $this->element('title', null, _('Notice posted')); $this->elementEnd('head'); $this->elementStart('body'); - $this->show_notice($notice); + $this->showNotice($notice); $this->elementEnd('body'); $this->elementEnd('html'); } else { @@ -113,7 +183,17 @@ class NewnoticeAction extends Action } } - function ajax_error_msg($msg) + /** + * Show an Ajax-y error message + * + * Goes back to the browser, where it's shown in a popup. + * + * @param string $msg Message to show + * + * @return void + */ + + function ajaxErrorMsg($msg) { common_start_html('text/xml;charset=utf-8', true); $this->elementStart('head'); @@ -125,17 +205,42 @@ class NewnoticeAction extends Action $this->elementEnd('html'); } - function show_top($content=null) - { - common_notice_form(null, $content); - } + /** + * Formerly page output + * + * This used to be the whole page output; now that's been largely + * subsumed by showPage. So this just stores an error message, if + * it was passed, and calls showPage. + * + * Note that since we started doing Ajax output, this page is rarely + * seen. + * + * @param string $msg An error message, if any + * + * @return void + */ - function show_form($msg=null) + function showForm($msg=null) { if ($msg && $this->boolean('ajax')) { - $this->ajax_error_msg($msg); + $this->ajaxErrorMsg($msg); return; } + + $this->msg = $msg; + $this->showPage(); + } + + /** + * Overload for replies or bad results + * + * We show content in the notice form if there were replies or results. + * + * @return void + */ + + function showNoticeForm() + { $content = $this->trimmed('status_textarea'); if (!$content) { $replyto = $this->trimmed('replyto'); @@ -144,18 +249,41 @@ class NewnoticeAction extends Action $content = '@' . $profile->nickname . ' '; } } - common_show_header(_('New notice'), null, $content, - array($this, 'show_top')); - if ($msg) { - $this->element('p', array('id' => 'error'), $msg); + + $notice_form = new NoticeForm($this, $content); + $notice_form->show(); + } + + /** + * Show an error message + * + * Shows an error message if there is one. + * + * @return void + * + * @todo maybe show some instructions? + */ + + function showPageNotice() + { + if ($this->msg) { + $this->element('p', array('id' => 'error'), $this->msg); } - common_show_footer(); } - function show_notice($notice) + /** + * Output a notice + * + * Used to generate the notice code for Ajax results. + * + * @param Notice $notice Notice that was saved + * + * @return void + */ + + function showNotice($notice) { - $nli = new NoticeListItem($notice); + $nli = new NoticeListItem($notice, $this); $nli->show(); } - } -- cgit v1.2.3-54-g00ecf From 727d9e8865393a60ca243cdf647303b0a66f6977 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 18 Jan 2009 17:11:18 +0000 Subject: Change use of self_url to selfUrl --- actions/confirmaddress.php | 2 +- actions/tagother.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'actions') diff --git a/actions/confirmaddress.php b/actions/confirmaddress.php index 53410fbe6..3d1a3c275 100644 --- a/actions/confirmaddress.php +++ b/actions/confirmaddress.php @@ -26,7 +26,7 @@ class ConfirmaddressAction extends Action { parent::handle($args); if (!common_logged_in()) { - common_set_returnto($this->self_url()); + common_set_returnto($this->selfUrl()); common_redirect(common_local_url('login')); return; } diff --git a/actions/tagother.php b/actions/tagother.php index e11e3a00d..e60eb8b58 100644 --- a/actions/tagother.php +++ b/actions/tagother.php @@ -93,7 +93,7 @@ class TagotherAction extends Action $this->elementStart('form', array('method' => 'post', 'id' => 'tag_user', 'name' => 'tagother', - 'action' => $this->self_url())); + 'action' => $this->selfUrl())); $this->hidden('token', common_session_token()); $this->hidden('id', $profile->id); $this->input('tags', _('Tags'), -- cgit v1.2.3-54-g00ecf From 2c4db393f54eddbe021b11a42ed2bb6abf5b11b2 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 18 Jan 2009 18:32:33 +0000 Subject: Fix output of email settings for confirmed address --- actions/emailsettings.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/emailsettings.php b/actions/emailsettings.php index b1f13c18c..8b8a5351e 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -95,7 +95,7 @@ class EmailsettingsAction extends AccountSettingsAction $this->hidden('token', common_session_token()); if ($user->email) { - $this->element('p', array('id' => 'email_confirmed', $user->email)); + $this->element('p', array('id' => 'email_confirmed'), $user->email); $this->element('p', array('class' => 'form_note'), _('Current confirmed email address.')); $this->hidden('email', $user->email); $this->submit('remove', _('Remove')); -- cgit v1.2.3-54-g00ecf From c0f23a2703edbc64486a00ea72b87f5be62cc445 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 18 Jan 2009 18:35:11 +0000 Subject: Update shownotice for new framework, make phpcs-clean --- actions/shownotice.php | 177 +++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 141 insertions(+), 36 deletions(-) (limited to 'actions') diff --git a/actions/shownotice.php b/actions/shownotice.php index 82d4bd270..52faba93e 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -1,9 +1,12 @@ . + * + * @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); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/stream.php'); +require_once INSTALLDIR.'/lib/personalgroupnav.php'; +require_once INSTALLDIR.'/lib/noticelist.php'; +require_once INSTALLDIR.'/lib/feedlist.php'; -class ShownoticeAction extends StreamAction +/** + * Show a single notice + * + * @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 ShownoticeAction 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; + /** + * 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) { @@ -53,45 +100,112 @@ class ShownoticeAction extends StreamAction return true; } - function last_modified() + /** + * Is this action read-only? + * + * @return boolean true + */ + + function isReadOnly() + { + 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), - ($this->avatar) ? strtotime($this->avatar->modified) : 0)) . '"'; + $avtime)) . '"'; } - function handle($args) + /** + * 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)); + } + + /** + * Handle input + * + * Only handles get, so just show the page. + * + * @param array $args $_REQUEST data (unused) + * + * @return void + */ + function handle($args) + { parent::handle($args); - common_show_header(sprintf(_('%1$s\'s status on %2$s'), - $this->profile->nickname, - common_exact_date($this->notice->created)), - array($this, 'show_header'), null, - array($this, 'show_top')); + $this->showPage(); + } + /** + * Fill the content area of the page + * + * Shows a single notice list item. + * + * @return void + */ + + function showContent() + { $this->elementStart('ul', array('id' => 'notices')); - $nli = new NoticeListItem($this->notice); + $nli = new NoticeListItem($this->notice, $this); $nli->show(); $this->elementEnd('ul'); - - common_show_footer(); } - function show_header() - { + /** + * Extra content + * + * We show the microid(s) for the author, if any. + * + * @return void + */ + function extraHead() + { $user = User::staticGet($this->profile->id); if (!$user) { @@ -99,26 +213,17 @@ class ShownoticeAction extends StreamAction } if ($user->emailmicroid && $user->email && $this->notice->uri) { + $id = new Microid('mailto:'. $user->email, + $this->notice->uri); $this->element('meta', array('name' => 'microid', - 'content' => "mailto+http:sha1:" . sha1(sha1('mailto:' . $user->email) . sha1($this->notice->uri)))); + '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' => "xmpp+http:sha1:" . sha1(sha1('xmpp:' . $user->jabber) . sha1($this->notice->uri)))); - } - } - - function show_top() - { - $cur = common_current_user(); - if ($cur && $cur->id == $this->profile->id) { - common_notice_form(); + 'content' => $id->toString())); } } - - function no_such_notice() - { - $this->clientError(_('No such notice.')); - } } -- cgit v1.2.3-54-g00ecf From f2b06b8bbd56ce94d7b46ffcec36e2be3f260fe9 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Sun, 18 Jan 2009 18:41:41 +0000 Subject: update commitaddress --- actions/confirmaddress.php | 86 ++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 76 insertions(+), 10 deletions(-) (limited to 'actions') diff --git a/actions/confirmaddress.php b/actions/confirmaddress.php index 3d1a3c275..725c1f1e3 100644 --- a/actions/confirmaddress.php +++ b/actions/confirmaddress.php @@ -1,9 +1,12 @@ . + * + * @category Confirm + * @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); } +if (!defined('LACONICA')) { + exit(1); +} + +/** + * Confirm an address + * + * When users change their SMS, email, Jabber, or other addresses, we send out + * a confirmation code to make sure the owner of that address approves. This class + * accepts those codes. + * + * @category Confirm + * @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 ConfirmaddressAction extends Action { + /** type of confirmation. */ + + var $type = null; + + /** + * Accept a confirmation code + * + * Checks the code and confirms the address in the + * user record + * + * @param args $args $_REQUEST array + * + * @return void + */ function handle($args) { @@ -62,8 +102,8 @@ class ConfirmaddressAction extends Action $cur->$type = $confirm->address; if ($type == 'sms') { - $cur->carrier = ($confirm->address_extra)+0; - $carrier = Sms_carrier::staticGet($cur->carrier); + $cur->carrier = ($confirm->address_extra)+0; + $carrier = Sms_carrier::staticGet($cur->carrier); $cur->smsemail = $carrier->toEmailAddress($cur->sms); } @@ -89,9 +129,35 @@ class ConfirmaddressAction extends Action $cur->query('COMMIT'); - common_show_header(_('Confirm Address')); + $this->type = $type; + $this->showPage(); + } + + /** + * Title of the page + * + * @return string title + */ + + function title() + { + return _('Confirm Address'); + } + + /** + * Show a confirmation message. + * + * @return void + */ + + function showContent() + { + $cur = common_current_user(); + $type = $this->type; + $this->element('p', null, - sprintf(_('The address "%s" has been confirmed for your account.'), $cur->$type)); - common_show_footer(); + sprintf(_('The address "%s" has been '. + 'confirmed for your account.'), + $cur->$type)); } } -- cgit v1.2.3-54-g00ecf From 5da9511c317648da6beb5fa2752f084166b88adc Mon Sep 17 00:00:00 2001 From: sarven Date: Sun, 18 Jan 2009 19:42:08 +0000 Subject: Markup and styles for the Register page --- actions/register.php | 31 +++++++++++++++++++++++++++---- theme/base/css/display.css | 6 ++++-- 2 files changed, 31 insertions(+), 6 deletions(-) (limited to 'actions') diff --git a/actions/register.php b/actions/register.php index b15aea08e..f0d47f19b 100644 --- a/actions/register.php +++ b/actions/register.php @@ -332,22 +332,32 @@ class RegisterAction extends Action } $this->elementStart('form', array('method' => 'post', - 'id' => 'login', + 'id' => 'form_register', + 'class' => 'form_settings', 'action' => common_local_url('register'))); - + $this->elementStart('fieldset'); + $this->element('legend', null, 'Account settings'); $this->hidden('token', common_session_token()); if ($code) { $this->hidden('code', $code); } + $this->elementStart('ul', 'form_datas'); + $this->elementStart('li'); $this->input('nickname', _('Nickname'), $this->trimmed('nickname'), _('1-64 lowercase letters or numbers, '. 'no punctuation or spaces. Required.')); + $this->elementEnd('li'); + $this->elementStart('li'); $this->password('password', _('Password'), _('6 or more characters. Required.')); + $this->elementEnd('li'); + $this->elementStart('li'); $this->password('confirm', _('Confirm'), _('Same as password above. Required.')); + $this->elementEnd('li'); + $this->elementStart('li'); if ($invite && $invite->address_type == 'email') { $this->input('email', _('Email'), $invite->address, _('Used only for updates, announcements, '. @@ -357,26 +367,36 @@ class RegisterAction extends Action _('Used only for updates, announcements, '. 'and password recovery')); } + $this->elementEnd('li'); + $this->elementStart('li'); $this->input('fullname', _('Full name'), $this->trimmed('fullname'), _('Longer name, preferably your "real" name')); + $this->elementEnd('li'); + $this->elementStart('li'); $this->input('homepage', _('Homepage'), $this->trimmed('homepage'), _('URL of your homepage, blog, '. 'or profile on another site')); + $this->elementEnd('li'); + $this->elementStart('li'); $this->textarea('bio', _('Bio'), $this->trimmed('bio'), _('Describe yourself and your '. 'interests in 140 chars')); + $this->elementEnd('li'); + $this->elementStart('li'); $this->input('location', _('Location'), $this->trimmed('location'), _('Where you are, like "City, '. 'State (or Region), Country"')); + $this->elementEnd('li'); + $this->elementStart('li', array('id' => 'settings_rememberme')); $this->checkbox('rememberme', _('Remember me'), $this->boolean('rememberme'), _('Automatically login in the future; '. 'not for shared computers!')); - $this->elementStart('p'); + $this->elementEnd('li'); $attrs = array('type' => 'checkbox', 'id' => 'license', 'name' => 'license', @@ -384,14 +404,17 @@ class RegisterAction extends Action if ($this->boolean('license')) { $attrs['checked'] = 'checked'; } + $this->elementStart('li'); $this->element('input', $attrs); $this->text(_('My text and files are available under ')); $this->element('a', array('href' => common_config('license', 'url')), $config['license']['title']); $this->text(_(' except this private data: password, '. 'email address, IM address, phone number.')); - $this->elementEnd('p'); + $this->elementEnd('li'); + $this->elementEnd('ul'); $this->submit('submit', _('Register')); + $this->elementEnd('fieldset'); $this->elementEnd('form'); } diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 7433a45e4..b5c47e1bb 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -136,7 +136,8 @@ font-weight:bold; } #form_settings_profile legend, -#form_login legend { +#form_login legend, +#form_register legend { display:none; } @@ -159,7 +160,8 @@ width:auto; margin-top:0; } -#form_login p.form_guide { +#form_login p.form_guide, +#form_register #settings_rememberme p.form_guide { margin-left:0; } -- cgit v1.2.3-54-g00ecf From d46c2cc8a70d83f7bf761ea8c778a8cd56d8e692 Mon Sep 17 00:00:00 2001 From: sarven Date: Sun, 18 Jan 2009 20:36:50 +0000 Subject: IM settings markup and style. Added confirmed/unconfirmed styles --- actions/emailsettings.php | 4 ++-- actions/imsettings.php | 42 +++++++++++++++++++++++++++--------------- theme/base/css/display.css | 9 +++------ theme/identica/css/display.css | 11 +++++++++++ 4 files changed, 43 insertions(+), 23 deletions(-) (limited to 'actions') diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 8b8a5351e..7ae62fb55 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -95,14 +95,14 @@ class EmailsettingsAction extends AccountSettingsAction $this->hidden('token', common_session_token()); if ($user->email) { - $this->element('p', array('id' => 'email_confirmed'), $user->email); + $this->element('p', array('id' => 'form_confirmed'), $user->email); $this->element('p', array('class' => 'form_note'), _('Current confirmed email address.')); $this->hidden('email', $user->email); $this->submit('remove', _('Remove')); } else { $confirm = $this->getConfirmation(); if ($confirm) { - $this->element('p', array('id' => 'email_unconfirmed'), $confirm->address); + $this->element('p', array('id' => 'form_unconfirmed'), $confirm->address); $this->element('p', array('class' => 'form_note'), _('Awaiting confirmation on this address. '. 'Check your inbox (and spam box!) for a message '. diff --git a/actions/imsettings.php b/actions/imsettings.php index 98951ac30..edbd81b57 100644 --- a/actions/imsettings.php +++ b/actions/imsettings.php @@ -86,36 +86,35 @@ class ImsettingsAction extends ConnectSettingsAction { $user = common_current_user(); $this->elementStart('form', array('method' => 'post', - 'id' => 'imsettings', + 'id' => 'form_settings_im', + 'class' => 'form_settings', 'action' => common_local_url('imsettings'))); + $this->elementStart('fieldset', array('id' => 'settings_im_address')); + $this->element('legend', null, _('Address')); $this->hidden('token', common_session_token()); - $this->element('h2', null, _('Address')); - if ($user->jabber) { - $this->elementStart('p'); - $this->element('span', 'address confirmed', $user->jabber); - $this->element('span', 'input_instructions', + $this->element('p', 'form_confirmed', $user->jabber); + $this->element('p', 'form_note', _('Current confirmed Jabber/GTalk address.')); $this->hidden('jabber', $user->jabber); - $this->elementEnd('p'); $this->submit('remove', _('Remove')); } else { $confirm = $this->getConfirmation(); if ($confirm) { - $this->elementStart('p'); - $this->element('span', 'address unconfirmed', $confirm->address); - $this->element('span', 'input_instructions', + $this->element('p', 'form_unconfirmed', $confirm->address); + $this->element('p', 'form_note', sprintf(_('Awaiting confirmation on this address. '. 'Check your Jabber/GTalk account for a '. 'message with further instructions. '. '(Did you add %s to your buddy list?)'), jabber_daemon_address())); $this->hidden('jabber', $confirm->address); - $this->elementEnd('p'); $this->submit('cancel', _('Cancel')); } else { + $this->elementStart('ul', 'form_datas'); + $this->elementStart('li'); $this->input('jabber', _('IM Address'), ($this->arg('jabber')) ? $this->arg('jabber') : null, sprintf(_('Jabber or GTalk address, '. @@ -123,27 +122,40 @@ class ImsettingsAction extends ConnectSettingsAction 'First, make sure to add %s to your '. 'buddy list in your IM client or on GTalk.'), jabber_daemon_address())); + $this->elementEnd('li'); + $this->elementEnd('ul'); $this->submit('add', _('Add')); } } - - $this->element('h2', null, _('Preferences')); - + $this->elementEnd('fieldset'); + + $this->elementStart('fieldset', array('id' => 'settings_im_preferences')); + $this->element('legend', null, _('Preferences')); + $this->elementStart('ul', 'form_datas'); + $this->elementStart('li'); $this->checkbox('jabbernotify', _('Send me notices through Jabber/GTalk.'), $user->jabbernotify); + $this->elementEnd('li'); + $this->elementStart('li'); $this->checkbox('updatefrompresence', _('Post a notice when my Jabber/GTalk status changes.'), $user->updatefrompresence); + $this->elementEnd('li'); + $this->elementStart('li'); $this->checkbox('jabberreplies', _('Send me replies through Jabber/GTalk '. 'from people I\'m not subscribed to.'), $user->jabberreplies); + $this->elementEnd('li'); + $this->elementStart('li'); $this->checkbox('jabbermicroid', _('Publish a MicroID for my Jabber/GTalk address.'), $user->jabbermicroid); + $this->elementEnd('li'); + $this->elementEnd('ul'); $this->submit('save', _('Save')); - + $this->elementEnd('fieldset'); $this->elementEnd('form'); } diff --git a/theme/base/css/display.css b/theme/base/css/display.css index b5c47e1bb..2857070f8 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -79,11 +79,12 @@ top:2px; left:0; } -#page_notice .error { -background-color:#F7E8E8; +#page_notice .error, +#page_notice .success { padding:4px 7px; -moz-border-radius:4px; } + form label.submit { display:none; } @@ -666,10 +667,6 @@ border-top:1px dashed #D1D9E4; list-style-type:none; /*margin-bottom:11px;*/ } -.notices li.over { -background-color:#fcfcfc; -} - /* NOTICES */ #notices_primary { diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index 832862551..0235c2d7d 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -71,6 +71,12 @@ background-color:rgba(255, 255, 255, 0.7); background-color:#fff; } +#page_notice .error { +background-color:#F7E8E8; +} +#page_notice .success { +background-color:#EFF3DC; +} @@ -135,6 +141,11 @@ color:#555; /* NOTICES */ +.notices li.over { +background-color:#fcfcfc; +} + + .notice div.entry-content a { } -- cgit v1.2.3-54-g00ecf From aea172bee0f2ffdda55cc77016dd609481d7dfee Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sun, 18 Jan 2009 21:08:56 +0000 Subject: trac750 Removed psychotic FB redirect hack. Found a better way with document.setLocation() --- actions/facebooksettings.php | 12 ++++++------ js/facebookapp.js | 9 +-------- 2 files changed, 7 insertions(+), 14 deletions(-) (limited to 'actions') diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php index 372c40c28..b678f19a1 100644 --- a/actions/facebooksettings.php +++ b/actions/facebooksettings.php @@ -67,19 +67,19 @@ class FacebooksettingsAction extends FacebookAction $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); $this->showHeader('Settings', $msg, $success); - - common_element('form', array('id' => 'redirect_form', - 'style' => 'display: none;')); common_element_start('p'); + + // Figure what the URL of our app is. + $app_props = $facebook->api_client->Admin_getAppProperties(array('canvas_name')); + $app_url = 'http://apps.facebook.com/' . $app_props['canvas_name'] . '/settings.php'; + common_element_start('fb:prompt-permission', array('perms' => 'status_update', - 'next_fbjs' => 'redirectSettings()')); + 'next_fbjs' => 'document.setLocation(\'' . $app_url . '\')')); common_element('h2', null, _('Allow Identi.ca to update my Facebook status')); common_element_end('fb:prompt-permission'); common_element_end('p'); - - if ($facebook->api_client->users_hasAppPermission('status_update')) { common_element_start('form', array('method' => 'post', diff --git a/js/facebookapp.js b/js/facebookapp.js index 3f809e50c..c7e8d6aa2 100644 --- a/js/facebookapp.js +++ b/js/facebookapp.js @@ -15,11 +15,4 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ - -// Psycho Facebook redirect hack, used because 'document.location' -// simply does not work in FBJS -function redirectSettings() { - form = document.getElementById('redirect_form'); - form.setAction('settings.php'); - form.submit(); -} + \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 061de33e576ac542459fd48ab61877eece05ea39 Mon Sep 17 00:00:00 2001 From: sarven Date: Sun, 18 Jan 2009 21:14:47 +0000 Subject: SMS settings markup and styles. Minor check with twitter settings form_datas --- actions/smssettings.php | 33 +++++++++++++++++++-------------- actions/twittersettings.php | 2 +- theme/base/css/display.css | 18 +++++++++++++----- 3 files changed, 33 insertions(+), 20 deletions(-) (limited to 'actions') diff --git a/actions/smssettings.php b/actions/smssettings.php index 845266d18..489fd1f58 100644 --- a/actions/smssettings.php +++ b/actions/smssettings.php @@ -93,37 +93,42 @@ class SmssettingsAction extends ConnectSettingsAction $this->hidden('token', common_session_token()); if ($user->sms) { - $this->elementStart('p'); $carrier = $user->getCarrier(); - $this->element('span', 'address confirmed', + $this->element('p', 'form_confirmed', $user->sms . ' (' . $carrier->name . ')'); - $this->element('span', 'input_instructions', + $this->element('p', 'form_guide', _('Current confirmed SMS-enabled phone number.')); $this->hidden('sms', $user->sms); $this->hidden('carrier', $user->carrier); - $this->elementEnd('p'); $this->submit('remove', _('Remove')); } else { $confirm = $this->getConfirmation(); if ($confirm) { $carrier = Sms_carrier::staticGet($confirm->address_extra); - $this->elementStart('p'); - $this->element('span', 'address unconfirmed', + $this->element('p', 'form_unconfirmed', $confirm->address . ' (' . $carrier->name . ')'); - $this->element('span', 'input_instructions', + $this->element('p', 'form_guide', _('Awaiting confirmation on this phone number.')); $this->hidden('sms', $confirm->address); $this->hidden('carrier', $confirm->address_extra); - $this->elementEnd('p'); $this->submit('cancel', _('Cancel')); + + $this->elementStart('ul', 'form_datas'); + $this->elementStart('li'); $this->input('code', _('Confirmation code'), null, _('Enter the code you received on your phone.')); + $this->elementEnd('li'); + $this->elementEnd('ul'); $this->submit('confirm', _('Confirm')); } else { + $this->elementStart('ul', 'form_datas'); + $this->elementStart('li'); $this->input('sms', _('SMS Phone number'), ($this->arg('sms')) ? $this->arg('sms') : null, _('Phone number, no punctuation or spaces, '. 'with area code')); + $this->elementEnd('li'); + $this->elementEnd('ul'); $this->carrierSelect(); $this->submit('add', _('Add')); } @@ -131,14 +136,13 @@ class SmssettingsAction extends ConnectSettingsAction $this->elementEnd('fieldset'); if ($user->sms) { - $this->element('h2', null, _('Incoming email')); + $this->elementStart('fieldset', array('id' => 'settings_sms_incoming_email')); + $this->element('legend', null, _('Incoming email')); if ($user->incomingemail) { - $this->elementStart('p'); - $this->element('span', 'address', $user->incomingemail); - $this->element('span', 'input_instructions', + $this->element('p', 'form_unconfirmed', $user->incomingemail); + $this->element('p', 'form_note', _('Send email to this address to post new notices.')); - $this->elementEnd('p'); $this->submit('removeincoming', _('Remove')); } @@ -146,6 +150,7 @@ class SmssettingsAction extends ConnectSettingsAction _('Make a new email address for posting to; '. 'cancels the old one.')); $this->submit('newincoming', _('New')); + $this->elementEnd('fieldset'); } $this->elementStart('fieldset', array('id' => 'settings_sms_preferences')); @@ -443,7 +448,7 @@ class SmssettingsAction extends ConnectSettingsAction $cnt = $carrier->find(); - $this->elementStart('ul'); + $this->elementStart('ul', 'form_datas'); $this->elementStart('li'); $this->element('label', array('for' => 'carrier'), _('Mobile carrier')); $this->elementStart('select', array('name' => 'carrier', diff --git a/actions/twittersettings.php b/actions/twittersettings.php index 597623c80..079099123 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -133,7 +133,7 @@ class TwittersettingsAction extends ConnectSettingsAction array('id' => 'settings_twitter_preferences')); $this->element('legend', null, _('Preferences')); - $this->elementStart('ul'); + $this->elementStart('ul', 'form_datas'); $this->elementStart('li'); $this->checkbox('noticesync', _('Automatically send my notices to Twitter.'), diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 2857070f8..08805c1e0 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -116,15 +116,19 @@ width:100%; float:left; } -.form_settings .form_datas label, +.form_settings .form_datas label { +float:left; +} +.form_settings .form_datas textarea, +.form_settings .form_datas select, .form_settings .form_datas input { -margin-right:11px; +margin-left:11px; float:left; } .form_settings label { margin-top:7px; -width:123px; +width:152px; } .form_actions label { @@ -144,7 +148,7 @@ display:none; .form_settings .form_datas p.form_guide { clear:both; -margin-left:134px; +margin-left:163px; margin-bottom:0; } @@ -154,11 +158,15 @@ margin-bottom:11px; .form_settings input.checkbox { margin-top:3px; +margin-left:0; } .form_settings label.checkbox { font-weight:normal; -width:auto; margin-top:0; +margin-right:0; +margin-left:11px; +float:left; +width:90%; } #form_login p.form_guide, -- cgit v1.2.3-54-g00ecf From 7749228f52d914d4949cb5fa139cdd6ade4ead6e Mon Sep 17 00:00:00 2001 From: sarven Date: Sun, 18 Jan 2009 21:22:31 +0000 Subject: OpenID settings remove style --- actions/openidsettings.php | 4 ++-- theme/base/css/display.css | 11 ++--------- 2 files changed, 4 insertions(+), 11 deletions(-) (limited to 'actions') diff --git a/actions/openidsettings.php b/actions/openidsettings.php index 257aac8d0..126d2c992 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -124,7 +124,7 @@ class OpenidsettingsAction extends AccountSettingsAction if ($cnt == 1 && !$user->password) { - $this->element('p', null, + $this->element('p', 'form_guide', _('Removing your only OpenID '. 'would make it impossible to log in! ' . 'If you need to remove it, '. @@ -162,7 +162,7 @@ class OpenidsettingsAction extends AccountSettingsAction $this->element('input', array('type' => 'submit', 'id' => 'remove'.$idx, 'name' => 'remove', - 'class' => 'submit', + 'class' => 'submit remove', 'value' => _('Remove'))); $this->elementEnd('fieldset'); $this->elementEnd('form'); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 08805c1e0..76e52ffc9 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -84,18 +84,11 @@ left:0; padding:4px 7px; -moz-border-radius:4px; } - form label.submit { display:none; } -form .error_message { -display:block; -} -.form_response { -margin-bottom:18px; -} - -form input.submit { +.form_settings input.remove { +margin-left:11px; } -- cgit v1.2.3-54-g00ecf From 9d384aadb1f27cea85d23c944f787cf300a4389a Mon Sep 17 00:00:00 2001 From: sarven Date: Sun, 18 Jan 2009 22:08:51 +0000 Subject: @id for site_nav_global_primary items in order to target for styling --- actions/register.php | 1 + lib/action.php | 22 +++++++++++++--------- theme/identica/css/display.css | 19 ++++++++++++++++--- 3 files changed, 30 insertions(+), 12 deletions(-) (limited to 'actions') diff --git a/actions/register.php b/actions/register.php index f0d47f19b..08243c1e2 100644 --- a/actions/register.php +++ b/actions/register.php @@ -399,6 +399,7 @@ class RegisterAction extends Action $this->elementEnd('li'); $attrs = array('type' => 'checkbox', 'id' => 'license', + 'class' => 'checkbox', 'name' => 'license', 'value' => 'true'); if ($this->boolean('license')) { diff --git a/lib/action.php b/lib/action.php index 320814a8a..3d61afde2 100644 --- a/lib/action.php +++ b/lib/action.php @@ -242,25 +242,29 @@ class Action extends HTMLOutputter // lawsuit $this->elementStart('ul', array('class' => 'nav')); if ($user) { $this->menuItem(common_local_url('all', array('nickname' => $user->nickname)), - _('Home')); + _('Home'), _('Personal timeline'), false, 'nav_home'); } - $this->menuItem(common_local_url('peoplesearch'), _('Search')); + $this->menuItem(common_local_url('peoplesearch'), + _('Search'), _('Search the site for people and text'), false, 'nav_search'); if ($user) { $this->menuItem(common_local_url('profilesettings'), - _('Account')); + _('Account'), _('Account settings'), false, 'nav_account'); $this->menuItem(common_local_url('imsettings'), - _('Connect')); + _('Connect'), _('Connect settings'), false, 'nav_connect'); $this->menuItem(common_local_url('logout'), - _('Logout')); + _('Logout'), _('Logout from the site'), false, 'nav_logout'); } else { - $this->menuItem(common_local_url('login'), _('Login')); + $this->menuItem(common_local_url('login'), + _('Login'), _('Login to the site'), false, 'nav_login'); if (!common_config('site', 'closed')) { - $this->menuItem(common_local_url('register'), _('Register')); + $this->menuItem(common_local_url('register'), + _('Register'), _('Create an account'), false, 'nav_register'); } - $this->menuItem(common_local_url('openidlogin'), _('OpenID')); + $this->menuItem(common_local_url('openidlogin'), + _('OpenID'), _('Login with OpenID'), false, 'nav_openid'); } $this->menuItem(common_local_url('doc', array('title' => 'help')), - _('Help')); + _('Help'), _('Help me!'), false, 'nav_help'); $this->elementEnd('ul'); $this->elementEnd('dd'); $this->elementEnd('dl'); diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index 0235c2d7d..a5b177004 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -57,6 +57,21 @@ background-color:transparent; } +#site_nav_global_primary a { +} + +#nav_register a { +background-color:#A9BF4F; +color:#fff; +text-decoration:none; +font-weight:bold; +padding:2px 4px; + +} +#nav_login a { +} + + #site_nav_local_views a { border-color:#fff; background-color:rgba(255, 255, 255, 0.2); @@ -71,6 +86,7 @@ background-color:rgba(255, 255, 255, 0.7); background-color:#fff; } + #page_notice .error { background-color:#F7E8E8; } @@ -78,9 +94,6 @@ background-color:#F7E8E8; background-color:#EFF3DC; } - - - #export_data li a { background-repeat:no-repeat; background-position:0 45%; -- cgit v1.2.3-54-g00ecf From 12f7ec980ceb40d5241b63b88e7601e293c9f277 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 19 Jan 2009 00:50:45 +0000 Subject: trac750 Better workflow for asking user for status update permission --- actions/facebookhome.php | 94 ++++++++++++++++++++++++++++++++++++++++++-- actions/facebooksettings.php | 49 +++++++++++++++-------- lib/facebookaction.php | 60 ++++++++++++++-------------- lib/facebookutil.php | 26 ++++++------ 4 files changed, 166 insertions(+), 63 deletions(-) (limited to 'actions') diff --git a/actions/facebookhome.php b/actions/facebookhome.php index 46f886451..d211e8844 100644 --- a/actions/facebookhome.php +++ b/actions/facebookhome.php @@ -31,14 +31,41 @@ class FacebookhomeAction extends FacebookAction $facebook = get_facebook(); $fbuid = $facebook->require_login(); + // If the user has opted not to initially allow the app to have + // Facebook status update permission, store that preference. Only + // promt the user the first time she uses the app + if ($this->arg('skip')) { + $facebook->api_client->data_setUserPreference( + FACEBOOK_PROMPTED_UPDATE_PREF, 'true'); + } + // Check to see whether there's already a Facebook link for this user $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); if ($flink) { + $user = $flink->getUser(); common_set_user($user); + + // If this is the first time the user has started the app + // prompt for Facebook status update permission + if (!$facebook->api_client->users_hasAppPermission('status_update')) { + + if ($facebook->api_client->data_getUserPreference( + FACEBOOK_PROMPTED_UPDATE_PREF) != 'true') { + $this->getUpdatePermission(); + return; + } + } + + // Use is authenticated and has already been prompted once for + // Facebook status update permission? Then show the main page + // of the app $this->showHome($flink, null); + } else { + + // User hasn't authenticated yet, prompt for creds $this->login($fbuid); } @@ -73,16 +100,18 @@ class FacebookhomeAction extends FacebookAction // XXX: Do some error handling here $this->setDefaults(); - $this->showHome($flink, _('You can now use Identi.ca from Facebook!')); + //$this->showHome($flink, _('You can now use Identi.ca from Facebook!')); + + $this->getUpdatePermission(); return; - + } else { $msg = _('Incorrect username or password.'); } } $this->showLoginForm($msg); - + } function setDefaults() @@ -90,7 +119,10 @@ class FacebookhomeAction extends FacebookAction $facebook = get_facebook(); // A default prefix string for notices - $facebook->api_client->data_setUserPreference(1, 'dented: '); + $facebook->api_client->data_setUserPreference( + FACEBOOK_NOTICE_PREFIX, 'dented: '); + $facebook->api_client->data_setUserPreference( + FACEBOOK_PROMPTED_UPDATE_PREF, 'false'); } function showHome($flink, $msg) @@ -138,4 +170,58 @@ class FacebookhomeAction extends FacebookAction return $nl->show(); } + function getUpdatePermission() { + + $facebook = get_facebook(); + $fbuid = $facebook->require_login(); + + start_fbml(); + + common_element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => getFacebookCSS())); + + $this->showLogo(); + + common_element_start('div', array('class' => 'content')); + + // Figure what the URL of our app is. + $app_props = $facebook->api_client->Admin_getAppProperties( + array('canvas_name', 'application_name')); + $app_url = 'http://apps.facebook.com/' . $app_props['canvas_name'] . '/index.php'; + $app_name = $app_props['application_name']; + + $instructions = sprintf(_('If you would like the %s app to automatically update ' . + 'your Facebook status with your latest notice, you need ' . + 'to give it permission.'), $app_name); + + common_element_start('p'); + common_element('span', array('id' => 'permissions_notice'), $instructions); + common_element_end('p'); + + common_element_start('form', array('method' => 'post', + 'action' => $app_url, + 'id' => 'facebook-skip-permissions')); + + common_element_start('ul', array('id' => 'fb-permissions-list')); + common_element_start('li', array('id' => 'fb-permissions-item')); + common_element_start('fb:prompt-permission', array('perms' => 'status_update', + 'next_fbjs' => 'document.setLocation(\'' . $app_url . '\')')); + common_element('span', array('class' => 'facebook-button'), + _('Allow Identi.ca to update my Facebook status')); + common_element_end('fb:prompt-permission'); + common_element_end('li'); + + common_element_start('li', array('id' => 'fb-permissions-item')); + common_submit('skip', _('Skip')); + common_element_end('li'); + common_element_end('ul'); + + common_element_end('form'); + common_element_end('div'); + + common_end_xml(); + + } + } diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php index b678f19a1..84e9a343b 100644 --- a/actions/facebooksettings.php +++ b/actions/facebooksettings.php @@ -50,12 +50,13 @@ class FacebooksettingsAction extends FacebookAction $flink->set_flags($noticesync, $replysync, false); $result = $flink->update($original); - $facebook->api_client->data_setUserPreference(1, substr($prefix, 0, 128)); + $facebook->api_client->data_setUserPreference(FACEBOOK_NOTICE_PREFIX, + substr($prefix, 0, 128)); if ($result) { - $this->show_form('Sync preferences saved.', true); + $this->showForm('Sync preferences saved.', true); } else { - $this->show_form('There was a problem saving your sync preferences!'); + $this->showForm('There was a problem saving your sync preferences!'); } } @@ -67,18 +68,7 @@ class FacebooksettingsAction extends FacebookAction $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); $this->showHeader('Settings', $msg, $success); - - common_element_start('p'); - - // Figure what the URL of our app is. - $app_props = $facebook->api_client->Admin_getAppProperties(array('canvas_name')); - $app_url = 'http://apps.facebook.com/' . $app_props['canvas_name'] . '/settings.php'; - - common_element_start('fb:prompt-permission', array('perms' => 'status_update', - 'next_fbjs' => 'document.setLocation(\'' . $app_url . '\')')); - common_element('h2', null, _('Allow Identi.ca to update my Facebook status')); - common_element_end('fb:prompt-permission'); - common_element_end('p'); + if ($facebook->api_client->users_hasAppPermission('status_update')) { @@ -90,11 +80,11 @@ class FacebooksettingsAction extends FacebookAction common_checkbox('noticesync', _('Automatically update my Facebook status with my notices.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND) : true); - common_checkbox('replysync', _('Send local "@" replies to Facebook.'), + common_checkbox('replysync', _('Send "@" replies to Facebook.'), ($flink) ? ($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) : true); $prefix = $facebook->api_client->data_getUserPreference(1); - + common_input('prefix', _('Prefix'), ($prefix) ? $prefix : null, @@ -103,6 +93,31 @@ class FacebooksettingsAction extends FacebookAction common_element_end('form'); + } else { + + // Figure what the URL of our app is. + $app_props = $facebook->api_client->Admin_getAppProperties( + array('canvas_name', 'application_name')); + $app_url = 'http://apps.facebook.com/' . $app_props['canvas_name'] . '/settings.php'; + $app_name = $app_props['application_name']; + + $instructions = sprintf(_('If you would like the %s app to automatically update ' . + 'your Facebook status with your latest notice, you need ' . + 'to give it permission.'), $app_name); + + common_element_start('p'); + common_element('span', array('id' => 'permissions_notice'), $instructions); + common_element_end('p'); + + common_element_start('ul', array('id' => 'fb-permissions-list')); + common_element_start('li', array('id' => 'fb-permissions-item')); + common_element_start('fb:prompt-permission', array('perms' => 'status_update', + 'next_fbjs' => 'document.setLocation(\'' . $app_url . '\')')); + common_element('span', array('class' => 'facebook-button'), + _('Allow Identi.ca to update my Facebook status')); + common_element_end('fb:prompt-permission'); + common_element_end('li'); + common_element_end('ul'); } $this->showFooter(); diff --git a/lib/facebookaction.php b/lib/facebookaction.php index a8f16b34a..0a364851f 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { +if (!defined('LACONICA')) { exit(1); } @@ -32,9 +32,9 @@ class FacebookAction extends Action } function showLogo(){ - + global $xw; - + common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => getFacebookCSS())); @@ -47,14 +47,14 @@ class FacebookAction extends Action 'href' => common_local_url('public'))); if (common_config('site', 'logo') || file_exists(theme_file('logo.png'))) { common_element('img', array('class' => 'logo photo', - 'src' => (common_config('site', 'logo')) ? + 'src' => (common_config('site', 'logo')) ? common_config('site', 'logo') : theme_path('logo.png'), 'alt' => common_config('site', 'name'))); } - + common_element('span', array('class' => 'fn org'), common_config('site', 'name')); common_element_end('a'); - + } function showHeader($selected = 'Home', $msg = null, $success = false) @@ -76,25 +76,25 @@ class FacebookAction extends Action common_element_start('ul', array('class' => 'nav')); - common_element_start('li', array('class' => + common_element_start('li', array('class' => ($selected == 'Home') ? 'current' : 'facebook_home')); - common_element('a', + common_element('a', array('href' => 'index.php', 'title' => _('Home')), _('Home')); common_element_end('li'); - - common_element_start('li', + + common_element_start('li', array('class' => ($selected == 'Invite') ? 'current' : 'facebook_invite')); - common_element('a', + common_element('a', array('href' => 'invite.php', 'title' => _('Invite')), _('Invite')); common_element_end('li'); - common_element_start('li', + common_element_start('li', array('class' => ($selected == 'Settings') ? 'current' : 'facebook_settings')); - common_element('a', - array('href' => 'settings.php', + common_element('a', + array('href' => 'settings.php', 'title' => _('Settings')), _('Settings')); common_element_end('li'); @@ -125,24 +125,24 @@ class FacebookAction extends Action function showInstructions() { - global $xw; - + global $xw; + common_element_start('dl', array('class' => 'system_notice')); common_element('dt', null, 'Page Notice'); - + $loginmsg_part1 = _('To use the %s Facebook Application you need to login ' . - 'with your username and password. Don\'t have a username yet? '); - + 'with your username and password. Don\'t have a username yet? '); + $loginmsg_part2 = _(' a new account.'); - + common_element_start('dd'); common_element_start('p'); common_text(sprintf($loginmsg_part1, common_config('site', 'name'))); - common_element('a', + common_element('a', array('href' => common_local_url('register')), _('Register')); common_text($loginmsg_part2); common_element_end('dd'); - common_element_end('dl'); + common_element_end('dl'); } function showLoginForm($msg = null) @@ -154,14 +154,14 @@ class FacebookAction extends Action 'href' => getFacebookCSS())); $this->showLogo(); - + common_element_start('div', array('class' => 'content')); common_element('h1', null, _('Login')); - + if ($msg) { common_element('fb:error', array('message' => $msg)); } - + $this->showInstructions(); common_element_start('div', array('id' => 'content_inner')); @@ -169,19 +169,19 @@ class FacebookAction extends Action common_element_start('form', array('method' => 'post', 'id' => 'login', 'action' => 'index.php')); - + common_element_start('fieldset'); common_element('legend', null, _('Login to site')); - + common_element_start('ul', array('class' => 'form_datas')); - common_element_start('li'); + common_element_start('li'); common_input('nickname', _('Nickname')); common_element_end('li'); common_element_start('li'); common_password('password', _('Password')); common_element_end('li'); common_element_end('ul'); - + common_submit('submit', _('Login')); common_element_end('form'); @@ -189,7 +189,7 @@ class FacebookAction extends Action common_element('a', array('href' => common_local_url('recoverpassword')), _('Lost or forgotten password?')); common_element_end('p'); - + common_element_end('div'); common_end_xml(); diff --git a/lib/facebookutil.php b/lib/facebookutil.php index 61469b3c6..74e594592 100644 --- a/lib/facebookutil.php +++ b/lib/facebookutil.php @@ -21,6 +21,8 @@ require_once INSTALLDIR.'/extlib/facebook/facebook.php'; require_once INSTALLDIR.'/lib/noticelist.php'; define("FACEBOOK_SERVICE", 2); // Facebook is foreign_service ID 2 +define("FACEBOOK_NOTICE_PREFIX", 1); +define("FACEBOOK_PROMPTED_UPDATE_PREF", 2); // Gets all the notices from users with a Facebook link since a given ID function get_facebook_notices($since) @@ -106,18 +108,18 @@ function update_profile_box($facebook, $fbuid, $user, $notice) } function getFacebookCSS() -{ +{ # Add a timestamp to the CSS file so Facebook cache wont ignore our changes $ts = filemtime(theme_file('facebookapp.css')); - $cssurl = theme_path('facebookapp.css') . "?ts=$ts"; + $cssurl = theme_path('facebookapp.css') . "?ts=$ts"; return $cssurl; } function getFacebookJS() { - + # Add a timestamp to the FBJS file so Facebook cache wont ignore our changes $ts = filemtime(INSTALLDIR.'/js/facebookapp.js'); - $jsurl = common_path('js/facebookapp.js') . "?ts=$ts"; + $jsurl = common_path('js/facebookapp.js') . "?ts=$ts"; return $jsurl; } @@ -157,7 +159,7 @@ class FacebookNoticeList extends NoticeList return $cnt; } - + /** * returns a new list item for the current notice * @@ -173,7 +175,7 @@ class FacebookNoticeList extends NoticeList { return new FacebookNoticeListItem($notice); } - + } class FacebookNoticeListItem extends NoticeListItem @@ -190,7 +192,7 @@ class FacebookNoticeListItem extends NoticeListItem function show() { $this->showStart(); - + common_element_start('div', 'entry-title'); $this->showAuthor(); $this->showContent(); @@ -201,10 +203,10 @@ class FacebookNoticeListItem extends NoticeListItem $this->showNoticeSource(); $this->showReplyTo(); common_element_end('div'); - + $this->showEnd(); } - + function showStart() { // XXX: RDFa @@ -222,9 +224,9 @@ class FacebookNoticeListItem extends NoticeListItem preg_match('/^http/', $this->notice->uri)) { $noticeurl = $this->notice->uri; } - + common_element_start('dl', 'timestamp'); - common_element('dt', null, _('Published')); + common_element('dt', null, _('Published')); common_element_start('dd', null); common_element_start('a', array('rel' => 'bookmark', 'href' => $noticeurl)); @@ -237,5 +239,5 @@ class FacebookNoticeListItem extends NoticeListItem common_element_end('dl'); } -} +} -- cgit v1.2.3-54-g00ecf From cd6b9d6c4608cc5bb524031f8de97a3dc5cc3ea9 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 19 Jan 2009 02:13:25 +0000 Subject: trac750 fix method calls to get CSS files --- actions/facebookhome.php | 10 +++++++++- lib/facebookaction.php | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) (limited to 'actions') diff --git a/actions/facebookhome.php b/actions/facebookhome.php index d211e8844..7430cc41f 100644 --- a/actions/facebookhome.php +++ b/actions/facebookhome.php @@ -179,7 +179,15 @@ class FacebookhomeAction extends FacebookAction common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', - 'href' => getFacebookCSS())); + 'href' => getFacebookBaseCSS())); + + common_element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => getFacebookThemeCSS())); + + common_element('script', array('type' => 'text/javascript', + 'src' => getFacebookJS()), + ' '); $this->showLogo(); diff --git a/lib/facebookaction.php b/lib/facebookaction.php index fd171c457..263248f67 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -155,7 +155,15 @@ class FacebookAction extends Action common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', - 'href' => getFacebookCSS())); + 'href' => getFacebookBaseCSS())); + + common_element('link', array('rel' => 'stylesheet', + 'type' => 'text/css', + 'href' => getFacebookThemeCSS())); + + common_element('script', array('type' => 'text/javascript', + 'src' => getFacebookJS()), + ' '); $this->showLogo(); -- cgit v1.2.3-54-g00ecf From 0b5f0f4faaf04fdf13dbd5dea1f081b9e1cc6071 Mon Sep 17 00:00:00 2001 From: sarven Date: Mon, 19 Jan 2009 03:09:13 +0000 Subject: Renamed form_datas to form_data --- actions/emailsettings.php | 4 ++-- actions/imsettings.php | 4 ++-- actions/login.php | 2 +- actions/openidsettings.php | 2 +- actions/othersettings.php | 2 +- actions/profilesettings.php | 2 +- actions/register.php | 2 +- actions/smssettings.php | 8 ++++---- actions/twittersettings.php | 4 ++-- lib/noticeform.php | 2 +- theme/base/css/display.css | 22 +++++++++++----------- 11 files changed, 27 insertions(+), 27 deletions(-) (limited to 'actions') diff --git a/actions/emailsettings.php b/actions/emailsettings.php index 7ae62fb55..b84acb214 100644 --- a/actions/emailsettings.php +++ b/actions/emailsettings.php @@ -110,7 +110,7 @@ class EmailsettingsAction extends AccountSettingsAction $this->hidden('email', $confirm->address); $this->submit('cancel', _('Cancel')); } else { - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('email', _('Email Address'), ($this->arg('email')) ? $this->arg('email') : null, @@ -146,7 +146,7 @@ class EmailsettingsAction extends AccountSettingsAction $this->elementStart('fieldset', array('id' => 'settings_email_preferences')); $this->element('legend', null, _('Preferences')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->checkbox('emailnotifysub', _('Send me notices of new subscriptions through email.'), diff --git a/actions/imsettings.php b/actions/imsettings.php index edbd81b57..e0f5ede3a 100644 --- a/actions/imsettings.php +++ b/actions/imsettings.php @@ -113,7 +113,7 @@ class ImsettingsAction extends ConnectSettingsAction $this->hidden('jabber', $confirm->address); $this->submit('cancel', _('Cancel')); } else { - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('jabber', _('IM Address'), ($this->arg('jabber')) ? $this->arg('jabber') : null, @@ -131,7 +131,7 @@ class ImsettingsAction extends ConnectSettingsAction $this->elementStart('fieldset', array('id' => 'settings_im_preferences')); $this->element('legend', null, _('Preferences')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->checkbox('jabbernotify', _('Send me notices through Jabber/GTalk.'), diff --git a/actions/login.php b/actions/login.php index 9fa501a5d..11cf1f02a 100644 --- a/actions/login.php +++ b/actions/login.php @@ -223,7 +223,7 @@ class LoginAction extends Action 'action' => common_local_url('login'))); $this->elementStart('fieldset'); $this->element('legend', null, _('Login to site')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('nickname', _('Nickname')); $this->elementEnd('li'); diff --git a/actions/openidsettings.php b/actions/openidsettings.php index 126d2c992..92469d20f 100644 --- a/actions/openidsettings.php +++ b/actions/openidsettings.php @@ -95,7 +95,7 @@ class OpenidsettingsAction extends AccountSettingsAction $this->element('p', 'form_guide', _('If you want to add an OpenID to your account, ' . 'enter it in the box below and click "Add".')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->element('label', array('for' => 'openid_url'), _('OpenID URL')); diff --git a/actions/othersettings.php b/actions/othersettings.php index cbb2c0cb9..b542233ca 100644 --- a/actions/othersettings.php +++ b/actions/othersettings.php @@ -107,7 +107,7 @@ class OthersettingsAction extends AccountSettingsAction 'metamark.net' => 'metamark.net' ); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->dropdown('urlshorteningservice', _('Service'), $services, _('Automatic shortening service to use.'), diff --git a/actions/profilesettings.php b/actions/profilesettings.php index 12251b83b..6dd4775e5 100644 --- a/actions/profilesettings.php +++ b/actions/profilesettings.php @@ -93,7 +93,7 @@ class ProfilesettingsAction extends AccountSettingsAction # too much common patterns here... abstractable? - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('nickname', _('Nickname'), ($this->arg('nickname')) ? $this->arg('nickname') : $profile->nickname, diff --git a/actions/register.php b/actions/register.php index 08243c1e2..159daaa73 100644 --- a/actions/register.php +++ b/actions/register.php @@ -343,7 +343,7 @@ class RegisterAction extends Action $this->hidden('code', $code); } - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('nickname', _('Nickname'), $this->trimmed('nickname'), _('1-64 lowercase letters or numbers, '. diff --git a/actions/smssettings.php b/actions/smssettings.php index 489fd1f58..f89cbe1ab 100644 --- a/actions/smssettings.php +++ b/actions/smssettings.php @@ -113,7 +113,7 @@ class SmssettingsAction extends ConnectSettingsAction $this->hidden('carrier', $confirm->address_extra); $this->submit('cancel', _('Cancel')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('code', _('Confirmation code'), null, _('Enter the code you received on your phone.')); @@ -121,7 +121,7 @@ class SmssettingsAction extends ConnectSettingsAction $this->elementEnd('ul'); $this->submit('confirm', _('Confirm')); } else { - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->input('sms', _('SMS Phone number'), ($this->arg('sms')) ? $this->arg('sms') : null, @@ -156,7 +156,7 @@ class SmssettingsAction extends ConnectSettingsAction $this->elementStart('fieldset', array('id' => 'settings_sms_preferences')); $this->element('legend', null, _('Preferences')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->checkbox('smsnotify', _('Send me notices through SMS; '. @@ -448,7 +448,7 @@ class SmssettingsAction extends ConnectSettingsAction $cnt = $carrier->find(); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->element('label', array('for' => 'carrier'), _('Mobile carrier')); $this->elementStart('select', array('name' => 'carrier', diff --git a/actions/twittersettings.php b/actions/twittersettings.php index 079099123..efc8215cd 100644 --- a/actions/twittersettings.php +++ b/actions/twittersettings.php @@ -104,7 +104,7 @@ class TwittersettingsAction extends ConnectSettingsAction $this->elementStart('fieldset', array('id' => 'settings_twitter_account')); $this->element('legend', null, _('Twitter Account')); $this->hidden('token', common_session_token()); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); if ($fuser) { $this->elementStart('li'); $this->element('span', 'twitter_user', $fuser->nickname); @@ -133,7 +133,7 @@ class TwittersettingsAction extends ConnectSettingsAction array('id' => 'settings_twitter_preferences')); $this->element('legend', null, _('Preferences')); - $this->elementStart('ul', 'form_datas'); + $this->elementStart('ul', 'form_data'); $this->elementStart('li'); $this->checkbox('noticesync', _('Automatically send my notices to Twitter.'), diff --git a/lib/noticeform.php b/lib/noticeform.php index d6a3aa9c2..f0205f1c1 100644 --- a/lib/noticeform.php +++ b/lib/noticeform.php @@ -123,7 +123,7 @@ class NoticeForm extends Form { $user = common_current_user(); - $this->out->elementStart('ul', 'form_datas'); + $this->out->elementStart('ul', 'form_data'); $this->out->elementStart('li', array('id' => 'notice_text')); $this->out->element('label', array('for' => 'notice_data-text'), sprintf(_('What\'s up, %s?'), $user->nickname)); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 716f3256f..d659a4b4c 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -114,17 +114,17 @@ font-style:italic; } -.form_settings .form_datas li { +.form_settings .form_data li { width:100%; float:left; } -.form_settings .form_datas label { +.form_settings .form_data label { float:left; } -.form_settings .form_datas textarea, -.form_settings .form_datas select, -.form_settings .form_datas input { +.form_settings .form_data textarea, +.form_settings .form_data select, +.form_settings .form_data input { margin-left:11px; float:left; } @@ -149,7 +149,7 @@ font-weight:bold; display:none; } -.form_settings .form_datas p.form_guide { +.form_settings .form_data p.form_guide { clear:both; margin-left:163px; margin-bottom:0; @@ -424,7 +424,7 @@ display:block; font-size:1.3em; margin-bottom:7px; } -#form_notice .form_datas li { +#form_notice .form_data li { float:left; } @@ -979,12 +979,12 @@ background-color:#D1D9E4; #user_actions #user_subscribe .form_note, -#user_actions #user_subscribe .form_datas, +#user_actions #user_subscribe .form_data, #user_actions #user_subscribe .form_actions label { display:none; } #form_user-relationship .form_note, -#form_user-relationship .form_datas, +#form_user-relationship .form_data, #form_user-relationship .form_actions label { display:block; } @@ -992,7 +992,7 @@ display:block; #user_actions #user-relationship_submit { margin-bottom:0; } -#form_user-relationship .form_datas li label { +#form_user-relationship .form_data li label { margin-right:11px; } @@ -1070,7 +1070,7 @@ font-size:2.2em; -#form_settings_photo .form_datas { +#form_settings_photo .form_data { clear:both; } -- cgit v1.2.3-54-g00ecf From 739baf0396b2e6796f07616cdb9d52d09cf6ed2f Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Mon, 19 Jan 2009 07:24:12 +0000 Subject: trac750 Add notice input box to FB app and ability to post notices --- actions/facebookhome.php | 93 ++++++++++++++++++++++---------- actions/facebookinvite.php | 3 +- actions/facebookremove.php | 2 +- actions/facebooksettings.php | 4 +- lib/facebookaction.php | 124 +++++++++++++++++++++++++++++++------------ lib/facebookutil.php | 38 ++++++++++++- scripts/update_facebook.php | 10 ++-- 7 files changed, 205 insertions(+), 69 deletions(-) (limited to 'actions') diff --git a/actions/facebookhome.php b/actions/facebookhome.php index 7430cc41f..3696df90a 100644 --- a/actions/facebookhome.php +++ b/actions/facebookhome.php @@ -30,6 +30,9 @@ class FacebookhomeAction extends FacebookAction $facebook = get_facebook(); $fbuid = $facebook->require_login(); + + // Check to see whether there's already a Facebook link for this user + $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); // If the user has opted not to initially allow the app to have // Facebook status update permission, store that preference. Only @@ -39,11 +42,13 @@ class FacebookhomeAction extends FacebookAction FACEBOOK_PROMPTED_UPDATE_PREF, 'true'); } - // Check to see whether there's already a Facebook link for this user - $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); - if ($flink) { + if ($_POST['submit'] == 'Send') { + $this->saveNewNotice($flink); + return; + } + $user = $flink->getUser(); common_set_user($user); @@ -136,19 +141,16 @@ class FacebookhomeAction extends FacebookAction $notice = $user->getCurrentNotice(); update_profile_box($facebook, $fbuid, $user, $notice); - - $this->showHeader('Home'); - - if ($msg) { - common_element('fb:success', array('message' => $msg)); - } - - echo $this->show_notices($user); + $this->showHeader($msg); + $this->showNoticeForm($user); + $this->showNav('Home'); + + echo $this->showNotices($user); $this->showFooter(); } - function show_notices($user) + function showNotices($user) { $page = $this->trimmed('page'); @@ -158,13 +160,13 @@ class FacebookhomeAction extends FacebookAction $notice = $user->noticesWithFriends(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); - $cnt = $this->show_notice_list($notice); + $cnt = $this->showNoticeList($notice); - common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, - $page, 'all', array('nickname' => $user->nickname)); + facebookPagination($page > 1, $cnt > NOTICES_PER_PAGE, + $page, 'all', array('nickname' => $user->nickname)); } - function show_notice_list($notice) + function showNoticeList($notice) { $nl = new FacebookNoticeList($notice); return $nl->show(); @@ -175,19 +177,10 @@ class FacebookhomeAction extends FacebookAction $facebook = get_facebook(); $fbuid = $facebook->require_login(); - start_fbml(); + startFBML(); - common_element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => getFacebookBaseCSS())); - - common_element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => getFacebookThemeCSS())); - - common_element('script', array('type' => 'text/javascript', - 'src' => getFacebookJS()), - ' '); + $this->showStylesheets(); + $this->showScripts(); $this->showLogo(); @@ -231,5 +224,49 @@ class FacebookhomeAction extends FacebookAction common_end_xml(); } + + function saveNewNotice($flink) + { + + $user = $flink->getUser(); + $content = $_POST['status_textarea']; + + if (!$content) { + $this->showHome($flink, _('No content!')); + return; + } else { + $content_shortened = common_shorten_links($content); + + if (mb_strlen($content_shortened) > 140) { + common_debug("Content = '$content_shortened'", __FILE__); + common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__); + $this->showHome($flink, _('That\'s too long. Max notice size is 140 chars.')); + return; + } + } + + $inter = new CommandInterpreter(); + + $cmd = $inter->handle_command($user, $content_shortened); + + if ($cmd) { + $cmd->execute(new WebChannel()); + return; + } + + $replyto = $this->trimmed('inreplyto'); + + $notice = Notice::saveNew($user->id, $content, + 'Facebook', 1, ($replyto == 'false') ? null : $replyto); + + if (is_string($notice)) { + $this->showHome($flink, 'Error!'); + return; + } + + common_broadcast_notice($notice); + $this->showHome($flink, 'Success!'); + } + } diff --git a/actions/facebookinvite.php b/actions/facebookinvite.php index d7e82dae7..e67bfaa00 100644 --- a/actions/facebookinvite.php +++ b/actions/facebookinvite.php @@ -69,7 +69,8 @@ class FacebookinviteAction extends FacebookAction $facebook = get_facebook(); $fbuid = $facebook->require_login(); - $this->showHeader('Invite'); + $this->showHeader(); + $this->showNav('Invite'); // Get a list of users who are already using the app for exclusion $exclude_ids = $facebook->api_client->friends_getAppUsers(); diff --git a/actions/facebookremove.php b/actions/facebookremove.php index a200fefbf..557c0655b 100644 --- a/actions/facebookremove.php +++ b/actions/facebookremove.php @@ -19,7 +19,7 @@ if (!defined('LACONICA')) { exit(1); } -require_once(INSTALLDIR.'/lib/facebookaction.php'); +require_once INSTALLDIR.'/lib/facebookaction.php'; class FacebookremoveAction extends FacebookAction { diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php index 84e9a343b..a08abc937 100644 --- a/actions/facebooksettings.php +++ b/actions/facebooksettings.php @@ -67,8 +67,8 @@ class FacebooksettingsAction extends FacebookAction $flink = Foreign_link::getByForeignID($fbuid, FACEBOOK_SERVICE); - $this->showHeader('Settings', $msg, $success); - + $this->showHeader($msg, $success); + $this->showNav('Settings'); if ($facebook->api_client->users_hasAppPermission('status_update')) { diff --git a/lib/facebookaction.php b/lib/facebookaction.php index 263248f67..cd43a2ccb 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -35,17 +35,8 @@ class FacebookAction extends Action global $xw; - common_element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => getFacebookBaseCSS())); - - common_element('link', array('rel' => 'stylesheet', - 'type' => 'text/css', - 'href' => getFacebookThemeCSS())); - - common_element('script', array('type' => 'text/javascript', - 'src' => getFacebookJS()), - ' '); + $this->showStylesheets(); + $this->showScripts(); common_element_start('a', array('class' => 'url home bookmark', 'href' => common_local_url('public'))); @@ -61,19 +52,34 @@ class FacebookAction extends Action } - function showHeader($selected = 'Home', $msg = null, $success = false) - { - start_fbml(); + function showHeader($msg = null, $success = false) + { + startFBML(); common_element_start('fb:if-section-not-added', array('section' => 'profile')); common_element_start('span', array('id' => 'add_to_profile')); common_element('fb:add-section-button', array('section' => 'profile')); common_element_end('span'); common_element_end('fb:if-section-not-added'); - + $this->showLogo(); + if ($msg) { + if ($success) { + common_element('fb:success', array('message' => $msg)); + } else { + // XXX do an error message here + } + } + + common_element_start('div', 'main_body'); + + } + + function showNav($selected = 'Home') + { + common_element_start('dl', array("id" => 'site_nav_local_views')); common_element('dt', null, _('Local Views')); common_element_start('dd'); @@ -86,7 +92,6 @@ class FacebookAction extends Action array('href' => 'index.php', 'title' => _('Home')), _('Home')); common_element_end('li'); - common_element_start('li', array('class' => ($selected == 'Invite') ? 'current' : 'facebook_invite')); @@ -107,17 +112,6 @@ class FacebookAction extends Action common_element_end('dd'); common_element_end('dl'); - - if ($msg) { - if ($success) { - common_element('fb:success', array('message' => $msg)); - } else { - // XXX do an error message here - } - } - - common_element_start('div', 'main_body'); - } function showFooter() @@ -149,10 +143,11 @@ class FacebookAction extends Action common_element_end('dl'); } - function showLoginForm($msg = null) - { - start_fbml(); + function showStylesheets() + { + global $xw; + common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => getFacebookBaseCSS())); @@ -160,10 +155,23 @@ class FacebookAction extends Action common_element('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => getFacebookThemeCSS())); - + } + + function showScripts() + { + global $xw; + common_element('script', array('type' => 'text/javascript', - 'src' => getFacebookJS()), - ' '); + 'src' => getFacebookJS())); + + } + + function showLoginForm($msg = null) + { + startFBML(); + + $this->showStylesheets(); + $this->showScripts(); $this->showLogo(); @@ -179,6 +187,7 @@ class FacebookAction extends Action common_element_start('div', array('id' => 'content_inner')); common_element_start('form', array('method' => 'post', + 'class' => 'form_settings', 'id' => 'login', 'action' => 'index.php')); @@ -209,4 +218,53 @@ class FacebookAction extends Action } + function showNoticeForm($user) + { + + global $xw; + + common_element_start('form', array('id' => 'form_notice', + 'method' => 'post', + 'action' => 'index.php')); + + common_element_start('fieldset'); + common_element('legend', null, 'Send a notice'); + + common_element_start('ul', 'form_datas'); + common_element_start('li', array('id' => 'noticcommon_elemente_text')); + common_element('label', array('for' => 'notice_data-text'), + sprintf(_('What\'s up, %s?'), $user->nickname)); + + common_element('textarea', array('id' => 'notice_data-text', + 'cols' => 35, + 'rows' => 4, + 'name' => 'status_textarea')); + common_element_end('li'); + common_element_end('ul'); + + common_element_start('dl', 'form_note'); + common_element('dt', null, _('Available characters')); + common_element('dd', array('id' => 'notice_text-count'), + '140'); + common_element_end('dl'); + + common_element_start('ul', array('class' => 'form_actions')); + + common_element_start('li', array('id' => 'notice_submit')); + + common_submit('submit', _('Send')); + + /* + common_element('input', array('id' => 'notice_action-submit', + 'class' => 'submit', + 'name' => 'status_submit', + 'type' => 'submit', + 'value' => _('Send'))); + */ + common_element_end('li'); + common_element_end('ul'); + common_element_end('fieldset'); + common_element_end('form'); + } + } diff --git a/lib/facebookutil.php b/lib/facebookutil.php index cc4941bdc..a133ce8ba 100644 --- a/lib/facebookutil.php +++ b/lib/facebookutil.php @@ -44,7 +44,7 @@ function get_facebook() return new Facebook($apikey, $secret); } -function start_fbml($indent = true) +function startFBML($indent = true) { global $xw; $xw = new XMLWriter(); @@ -132,6 +132,42 @@ function getFacebookJS() { } +// Does a little before-after block for next/prev page + +function facebookPagination($have_before, $have_after, $page, $action, $args=null) +{ + + if ($have_before || $have_after) { + common_element_start('div', array('id' => 'pagination')); + common_element_start('ul', array('id' => 'nav_pagination')); + } + + if ($have_before) { + $pargs = array('page' => $page-1); + $newargs = ($args) ? array_merge($args,$pargs) : $pargs; + + common_element_start('li', 'before'); + common_element('a', array('href' => "index.php?page=$newargs[page]", 'rel' => 'prev'), + _('« After')); + common_element_end('li'); + } + + if ($have_after) { + $pargs = array('page' => $page+1); + $newargs = ($args) ? array_merge($args,$pargs) : $pargs; + common_element_start('li', 'after'); + common_element('a', array('href' => "index.php?page=$newargs[page]", 'rel' => 'next'), + _('Before »')); + common_element_end('li'); + } + + if ($have_before || $have_after) { + common_element_end('ul'); + common_element_end('div'); + } +} + + class FacebookNoticeList extends NoticeList { /** diff --git a/scripts/update_facebook.php b/scripts/update_facebook.php index 8c91df384..0c54cec7c 100755 --- a/scripts/update_facebook.php +++ b/scripts/update_facebook.php @@ -67,9 +67,13 @@ while($notice->fetch()) { // If it's not a reply, or if the user WANTS to send replies... if (!preg_match('/@[a-zA-Z0-9_]{1,15}\b/u', $content) || (($flink->noticesync & FOREIGN_NOTICE_SEND_REPLY) == FOREIGN_NOTICE_SEND_REPLY)) { - update_status($fbuid, $content); - update_profile_box($facebook, $fbuid, $user, $notice); - $cnt++; + + // Avoid a Loop + if ($notice->source != 'Facebook') { + update_status($fbuid, $content); + update_profile_box($facebook, $fbuid, $user, $notice); + $cnt++; + } } } } -- cgit v1.2.3-54-g00ecf From 6edbf3ca781d20f2ec98daf32080c60e804d8215 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 19 Jan 2009 13:22:22 +0000 Subject: Update favorited for new layout and framework --- actions/favorited.php | 199 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 145 insertions(+), 54 deletions(-) (limited to 'actions') diff --git a/actions/favorited.php b/actions/favorited.php index 936905732..0223564f3 100644 --- a/actions/favorited.php +++ b/actions/favorited.php @@ -1,105 +1,196 @@ . + * along with this program. If not, see . + * + * @category Public + * @package Laconica + * @author Zach Copley + * @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); } +if (!defined('LACONICA')) { + exit(1); +} + +require_once INSTALLDIR.'/lib/publicgroupnav.php'; +require_once INSTALLDIR.'/lib/noticelist.php'; -require_once(INSTALLDIR.'/lib/stream.php'); +/** + * List of popular notices + * + * We provide a list of the most popular notices. Popularity + * is measured by + * + * @category Personal + * @package Laconica + * @author Zach Copley + * @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 FavoritedAction extends StreamAction +class FavoritedAction extends Action { + var $page = null; - function handle($args) + /** + * Title of the page + * + * @return string Title of the page + */ + + function title() { - parent::handle($args); + if ($this->page == 1) { + return _('Popular notices'); + } else { + return sprintf(_('Popular notices, page %d'), $this->page); + } + } - $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + /** + * Instructions for use + * + * @return instructions for use + */ - common_show_header(_('Popular notices'), - array($this, 'show_header'), null, - array($this, 'show_top')); + function getInstructions() + { + return _('The most popular notices on the site right now.'); + } - $this->show_notices($page); + /** + * Is this page read-only? + * + * @return boolean true + */ - common_show_footer(); + function isReadOnly() + { + return true; } - function show_top() + /** + * Take arguments for running + * + * @param array $args $_REQUEST args + * + * @return boolean success flag + * + * @todo move queries from showContent() to here + */ + + function prepare($args) { - $instr = $this->get_instructions(); + parent::prepare($args); + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + return true; + } + + /** + * Handle request + * + * Shows a page with list of favorite notices + * + * @param array $args $_REQUEST args; handled in prepare() + * + * @return void + */ + + function handle($args) + { + parent::handle($args); + + $this->showPage(); + } + + /** + * Show the page notice + * + * Shows instructions for the page + * + * @return void + */ + + function showPageNotice() + { + $instr = $this->getInstructions(); $output = common_markup_to_html($instr); + $this->elementStart('div', 'instructions'); $this->raw($output); $this->elementEnd('div'); - $this->public_views_menu(); } - function show_header() - { - return; - } + /** + * Local navigation + * + * This page is part of the public group, so show that. + * + * @return void + */ - function get_instructions() + function showLocalNav() { - return _('Showing recently popular notices'); + $nav = new PublicGroupNav($this); + $nav->show(); } - function show_notices($page) - { + /** + * Content area + * + * Shows the list of popular notices + * + * @return void + */ - $qry = 'SELECT notice.*, sum(exp(-(now() - fave.modified) / %s)) as weight ' . - 'FROM notice JOIN fave ON notice.id = fave.notice_id ' . - 'GROUP BY fave.notice_id ' . - 'ORDER BY weight DESC'; + function showContent() + { + $qry = 'SELECT notice.*, '. + 'sum(exp(-(now() - fave.modified) / %s)) as weight ' . + 'FROM notice JOIN fave ON notice.id = fave.notice_id ' . + 'GROUP BY fave.notice_id ' . + 'ORDER BY weight DESC'; - $offset = ($page - 1) * NOTICES_PER_PAGE; - $limit = NOTICES_PER_PAGE + 1; + $offset = ($this->page - 1) * NOTICES_PER_PAGE; + $limit = NOTICES_PER_PAGE + 1; - if (common_config('db','type') == 'pgsql') { + if (common_config('db', 'type') == 'pgsql') { $qry .= ' LIMIT ' . $limit . ' OFFSET ' . $offset; } else { $qry .= ' LIMIT ' . $offset . ', ' . $limit; } - # Figure out how to cache this query + // XXX: Figure out how to cache this query $notice = new Notice; $notice->query(sprintf($qry, common_config('popular', 'dropoff'))); - $this->elementStart('ul', array('id' => 'notices')); - - $cnt = 0; - - while ($notice->fetch() && $cnt <= NOTICES_PER_PAGE) { - $cnt++; + $nl = new NoticeList($notice, $this); - if ($cnt > NOTICES_PER_PAGE) { - break; - } + $cnt = $nl->show(); - $item = new NoticeListItem($notice); - $item->show(); - } - - $this->elementEnd('ul'); - - common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, - $page, 'favorited'); + $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, + $this->page, 'favorited'); } - } -- cgit v1.2.3-54-g00ecf From e703f5e347574c2f68c97a3884bec209f924602f Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 19 Jan 2009 13:27:45 +0000 Subject: First pass at with-friends; doesn't pass phpcs --- actions/all.php | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'actions') diff --git a/actions/all.php b/actions/all.php index 548d7a103..428466f24 100644 --- a/actions/all.php +++ b/actions/all.php @@ -27,77 +27,77 @@ class AllAction extends Action { var $user = null; var $page = null; - + function isReadOnly() { return true; } - + function prepare($args) { - parent::prepare($args); + parent::prepare($args); $nickname = common_canonical_nickname($this->arg('nickname')); - $this->user = User::staticGet('nickname', $nickname); + $this->user = User::staticGet('nickname', $nickname); $this->page = $this->trimmed('page'); if (!$this->page) { $this->page = 1; } - return true; + return true; } - + function handle($args) { parent::handle($args); - + if (!$this->user) { $this->clientError(_('No such user.')); return; } - - $this->showPage(); + + $this->showPage(); } - + function title() { - if ($this->page > 1) { - return sprintf(_("%s and friends, page %d"), $this->user->nickname, $this->page); - } else { - return sprintf(_("%s and friends"), $this->user->nickname); - } + if ($this->page > 1) { + return sprintf(_("%s and friends, page %d"), $this->user->nickname, $this->page); + } else { + return sprintf(_("%s and friends"), $this->user->nickname); + } } - + function showFeeds() { $this->element('link', array('rel' => 'alternate', 'href' => common_local_url('allrss', array('nickname' => - $this->user->nickname)), + $this->user->nickname)), 'type' => 'application/rss+xml', 'title' => sprintf(_('Feed for friends of %s'), $this->user->nickname))); } - + function showLocalNav() { - $nav = new PersonalGroupNav($this); - $nav->show(); + $nav = new PersonalGroupNav($this); + $nav->show(); } function showExportData() { $fl = new FeedList($this); $fl->show(array(0=>array('href'=>common_local_url('allrss', array('nickname' => $this->user->nickname)), - 'type' => 'rss', - 'version' => 'RSS 1.0', - 'item' => 'allrss'))); + 'type' => 'rss', + 'version' => 'RSS 1.0', + 'item' => 'allrss'))); } - + function showContent() { $notice = $this->user->noticesWithFriends(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); - + $nl = new NoticeList($notice, $this); $cnt = $nl->show(); - + $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, $this->page, 'all', array('nickname' => $this->user->nickname)); } -- cgit v1.2.3-54-g00ecf From 91457944003049d021947fde0a5f2658393010d9 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 19 Jan 2009 13:44:10 +0000 Subject: Update facebook stuff to use new methods change facebook stuff to use new methods for XML and HTML. --- actions/facebookhome.php | 32 +++---- actions/facebooksettings.php | 20 ++--- lib/facebookaction.php | 198 +++++++++++++++++++++---------------------- 3 files changed, 123 insertions(+), 127 deletions(-) (limited to 'actions') diff --git a/actions/facebookhome.php b/actions/facebookhome.php index ae29ee1f8..14342f944 100644 --- a/actions/facebookhome.php +++ b/actions/facebookhome.php @@ -184,7 +184,7 @@ class FacebookhomeAction extends FacebookAction $this->showLogo(); - common_element_start('div', array('class' => 'content')); + $this->elementStart('div', array('class' => 'content')); // Figure what the URL of our app is. $app_props = $facebook->api_client->Admin_getAppProperties( @@ -196,30 +196,30 @@ class FacebookhomeAction extends FacebookAction 'your Facebook status with your latest notice, you need ' . 'to give it permission.'), $app_name); - common_element_start('p'); - common_element('span', array('id' => 'permissions_notice'), $instructions); - common_element_end('p'); + $this->elementStart('p'); + $this->element('span', array('id' => 'permissions_notice'), $instructions); + $this->elementEnd('p'); - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'action' => $app_url, 'id' => 'facebook-skip-permissions')); - common_element_start('ul', array('id' => 'fb-permissions-list')); - common_element_start('li', array('id' => 'fb-permissions-item')); - common_element_start('fb:prompt-permission', array('perms' => 'status_update', + $this->elementStart('ul', array('id' => 'fb-permissions-list')); + $this->elementStart('li', array('id' => 'fb-permissions-item')); + $this->elementStart('fb:prompt-permission', array('perms' => 'status_update', 'next_fbjs' => 'document.setLocation(\'' . $app_url . '\')')); - common_element('span', array('class' => 'facebook-button'), + $this->element('span', array('class' => 'facebook-button'), _('Allow Identi.ca to update my Facebook status')); - common_element_end('fb:prompt-permission'); - common_element_end('li'); + $this->elementEnd('fb:prompt-permission'); + $this->elementEnd('li'); - common_element_start('li', array('id' => 'fb-permissions-item')); + $this->elementStart('li', array('id' => 'fb-permissions-item')); common_submit('skip', _('Skip')); - common_element_end('li'); - common_element_end('ul'); + $this->elementEnd('li'); + $this->elementEnd('ul'); - common_element_end('form'); - common_element_end('div'); + $this->elementEnd('form'); + $this->elementEnd('div'); common_end_xml(); diff --git a/actions/facebooksettings.php b/actions/facebooksettings.php index bc034bc46..d4f03e58c 100644 --- a/actions/facebooksettings.php +++ b/actions/facebooksettings.php @@ -104,19 +104,19 @@ class FacebooksettingsAction extends FacebookAction 'your Facebook status with your latest notice, you need ' . 'to give it permission.'), $app_name); - common_element_start('p'); - common_element('span', array('id' => 'permissions_notice'), $instructions); - common_element_end('p'); + $this->elementStart('p'); + $this->element('span', array('id' => 'permissions_notice'), $instructions); + $this->elementEnd('p'); - common_element_start('ul', array('id' => 'fb-permissions-list')); - common_element_start('li', array('id' => 'fb-permissions-item')); - common_element_start('fb:prompt-permission', array('perms' => 'status_update', + $this->elementStart('ul', array('id' => 'fb-permissions-list')); + $this->elementStart('li', array('id' => 'fb-permissions-item')); + $this->elementStart('fb:prompt-permission', array('perms' => 'status_update', 'next_fbjs' => 'document.setLocation(\'' . $app_url . '\')')); - common_element('span', array('class' => 'facebook-button'), + $this->element('span', array('class' => 'facebook-button'), _('Allow Identi.ca to update my Facebook status')); - common_element_end('fb:prompt-permission'); - common_element_end('li'); - common_element_end('ul'); + $this->elementEnd('fb:prompt-permission'); + $this->elementEnd('li'); + $this->elementEnd('ul'); } $this->showFooter(); diff --git a/lib/facebookaction.php b/lib/facebookaction.php index cd43a2ccb..6d42596e8 100644 --- a/lib/facebookaction.php +++ b/lib/facebookaction.php @@ -38,132 +38,129 @@ class FacebookAction extends Action $this->showStylesheets(); $this->showScripts(); - common_element_start('a', array('class' => 'url home bookmark', + $this->elementStart('a', array('class' => 'url home bookmark', 'href' => common_local_url('public'))); if (common_config('site', 'logo') || file_exists(theme_file('logo.png'))) { - common_element('img', array('class' => 'logo photo', + $this->element('img', array('class' => 'logo photo', 'src' => (common_config('site', 'logo')) ? common_config('site', 'logo') : theme_path('logo.png'), 'alt' => common_config('site', 'name'))); } - common_element('span', array('class' => 'fn org'), common_config('site', 'name')); - common_element_end('a'); + $this->element('span', array('class' => 'fn org'), common_config('site', 'name')); + $this->elementEnd('a'); } - - function showHeader($msg = null, $success = false) + function showHeader($msg = null, $success = false) { startFBML(); - common_element_start('fb:if-section-not-added', array('section' => 'profile')); - common_element_start('span', array('id' => 'add_to_profile')); - common_element('fb:add-section-button', array('section' => 'profile')); - common_element_end('span'); - common_element_end('fb:if-section-not-added'); - + $this->elementStart('fb:if-section-not-added', array('section' => 'profile')); + $this->elementStart('span', array('id' => 'add_to_profile')); + $this->element('fb:add-section-button', array('section' => 'profile')); + $this->elementEnd('span'); + $this->elementEnd('fb:if-section-not-added'); + $this->showLogo(); if ($msg) { if ($success) { - common_element('fb:success', array('message' => $msg)); + $this->element('fb:success', array('message' => $msg)); } else { // XXX do an error message here } } - common_element_start('div', 'main_body'); - + $this->elementStart('div', 'main_body'); + } function showNav($selected = 'Home') { - common_element_start('dl', array("id" => 'site_nav_local_views')); - common_element('dt', null, _('Local Views')); - common_element_start('dd'); + $this->elementStart('dl', array("id" => 'site_nav_local_views')); + $this->element('dt', null, _('Local Views')); + $this->elementStart('dd'); - common_element_start('ul', array('class' => 'nav')); + $this->elementStart('ul', array('class' => 'nav')); - common_element_start('li', array('class' => + $this->elementStart('li', array('class' => ($selected == 'Home') ? 'current' : 'facebook_home')); - common_element('a', + $this->element('a', array('href' => 'index.php', 'title' => _('Home')), _('Home')); - common_element_end('li'); + $this->elementEnd('li'); - common_element_start('li', + $this->elementStart('li', array('class' => ($selected == 'Invite') ? 'current' : 'facebook_invite')); - common_element('a', + $this->element('a', array('href' => 'invite.php', 'title' => _('Invite')), _('Invite')); - common_element_end('li'); + $this->elementEnd('li'); - common_element_start('li', + $this->elementStart('li', array('class' => ($selected == 'Settings') ? 'current' : 'facebook_settings')); - common_element('a', + $this->element('a', array('href' => 'settings.php', 'title' => _('Settings')), _('Settings')); - common_element_end('li'); + $this->elementEnd('li'); - common_element_end('ul'); + $this->elementEnd('ul'); - common_element_end('dd'); - common_element_end('dl'); + $this->elementEnd('dd'); + $this->elementEnd('dl'); } function showFooter() { - common_element_end('div'); - common_end_xml(); + $this->elementEnd('div'); + $this->endXml(); } - function showInstructions() { global $xw; - common_element_start('dl', array('class' => 'system_notice')); - common_element('dt', null, 'Page Notice'); + $this->elementStart('dl', array('class' => 'system_notice')); + $this->element('dt', null, 'Page Notice'); $loginmsg_part1 = _('To use the %s Facebook Application you need to login ' . 'with your username and password. Don\'t have a username yet? '); $loginmsg_part2 = _(' a new account.'); - common_element_start('dd'); - common_element_start('p'); - common_text(sprintf($loginmsg_part1, common_config('site', 'name'))); - common_element('a', + $this->elementStart('dd'); + $this->elementStart('p'); + $this->text(sprintf($loginmsg_part1, common_config('site', 'name'))); + $this->element('a', array('href' => common_local_url('register')), _('Register')); - common_text($loginmsg_part2); - common_element_end('dd'); - common_element_end('dl'); + $this->text($loginmsg_part2); + $this->elementEnd('dd'); + $this->elementEnd('dl'); } - - function showStylesheets() + function showStylesheets() { global $xw; - - common_element('link', array('rel' => 'stylesheet', + + $this->element('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => getFacebookBaseCSS())); - common_element('link', array('rel' => 'stylesheet', + $this->element('link', array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => getFacebookThemeCSS())); } - - function showScripts() + + function showScripts() { global $xw; - - common_element('script', array('type' => 'text/javascript', + + $this->element('script', array('type' => 'text/javascript', 'src' => getFacebookJS())); - + } function showLoginForm($msg = null) @@ -175,96 +172,95 @@ class FacebookAction extends Action $this->showLogo(); - common_element_start('div', array('class' => 'content')); - common_element('h1', null, _('Login')); + $this->elementStart('div', array('class' => 'content')); + $this->element('h1', null, _('Login')); if ($msg) { - common_element('fb:error', array('message' => $msg)); + $this->element('fb:error', array('message' => $msg)); } $this->showInstructions(); - common_element_start('div', array('id' => 'content_inner')); + $this->elementStart('div', array('id' => 'content_inner')); - common_element_start('form', array('method' => 'post', + $this->elementStart('form', array('method' => 'post', 'class' => 'form_settings', 'id' => 'login', 'action' => 'index.php')); - common_element_start('fieldset'); - common_element('legend', null, _('Login to site')); + $this->elementStart('fieldset'); + $this->element('legend', null, _('Login to site')); - common_element_start('ul', array('class' => 'form_datas')); - common_element_start('li'); - common_input('nickname', _('Nickname')); - common_element_end('li'); - common_element_start('li'); - common_password('password', _('Password')); - common_element_end('li'); - common_element_end('ul'); + $this->elementStart('ul', array('class' => 'form_datas')); + $this->elementStart('li'); + $this->input('nickname', _('Nickname')); + $this->elementEnd('li'); + $this->elementStart('li'); + $this->password('password', _('Password')); + $this->elementEnd('li'); + $this->elementEnd('ul'); - common_submit('submit', _('Login')); - common_element_end('form'); + $this->submit('submit', _('Login')); + $this->elementEnd('form'); - common_element_start('p'); - common_element('a', array('href' => common_local_url('recoverpassword')), + $this->elementStart('p'); + $this->element('a', array('href' => common_local_url('recoverpassword')), _('Lost or forgotten password?')); - common_element_end('p'); + $this->elementEnd('p'); - common_element_end('div'); + $this->elementEnd('div'); - common_end_xml(); + $this->endXml(); } - - function showNoticeForm($user) + function showNoticeForm($user) { - + global $xw; - common_element_start('form', array('id' => 'form_notice', + $this->elementStart('form', array('id' => 'form_notice', 'method' => 'post', 'action' => 'index.php')); - common_element_start('fieldset'); - common_element('legend', null, 'Send a notice'); + $this->elementStart('fieldset'); + $this->element('legend', null, 'Send a notice'); - common_element_start('ul', 'form_datas'); - common_element_start('li', array('id' => 'noticcommon_elemente_text')); - common_element('label', array('for' => 'notice_data-text'), + $this->elementStart('ul', 'form_datas'); + $this->elementStart('li', array('id' => 'noticcommon_elemente_text')); + $this->element('label', array('for' => 'notice_data-text'), sprintf(_('What\'s up, %s?'), $user->nickname)); - common_element('textarea', array('id' => 'notice_data-text', + $this->element('textarea', array('id' => 'notice_data-text', 'cols' => 35, 'rows' => 4, 'name' => 'status_textarea')); - common_element_end('li'); - common_element_end('ul'); + $this->elementEnd('li'); + $this->elementEnd('ul'); - common_element_start('dl', 'form_note'); - common_element('dt', null, _('Available characters')); - common_element('dd', array('id' => 'notice_text-count'), + $this->elementStart('dl', 'form_note'); + $this->element('dt', null, _('Available characters')); + $this->element('dd', array('id' => 'notice_text-count'), '140'); - common_element_end('dl'); + $this->elementEnd('dl'); + + $this->elementStart('ul', array('class' => 'form_actions')); + + $this->elementStart('li', array('id' => 'notice_submit')); - common_element_start('ul', array('class' => 'form_actions')); + $this->submit('submit', _('Send')); - common_element_start('li', array('id' => 'notice_submit')); - - common_submit('submit', _('Send')); - /* - common_element('input', array('id' => 'notice_action-submit', + $this->element('input', array('id' => 'notice_action-submit', 'class' => 'submit', 'name' => 'status_submit', 'type' => 'submit', 'value' => _('Send'))); */ - common_element_end('li'); - common_element_end('ul'); - common_element_end('fieldset'); - common_element_end('form'); + $this->elementEnd('li'); + $this->elementEnd('ul'); + $this->elementEnd('fieldset'); + $this->elementEnd('form'); } } -- cgit v1.2.3-54-g00ecf From b635b6de04073e7b2876801a5f335cc1a80fb084 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 19 Jan 2009 15:28:27 +0000 Subject: Update showfavorites --- actions/showfavorites.php | 199 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 150 insertions(+), 49 deletions(-) (limited to 'actions') diff --git a/actions/showfavorites.php b/actions/showfavorites.php index caa823893..d2c91c025 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -1,9 +1,12 @@ . + * + * @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); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/actions/showstream.php'); +require_once INSTALLDIR.'/lib/personalgroupnav.php'; +require_once INSTALLDIR.'/lib/noticelist.php'; +require_once INSTALLDIR.'/lib/feedlist.php'; -class ShowfavoritesAction extends StreamAction -{ +/** + * List of replies + * + * @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/ + */ - function handle($args) +class ShowfavoritesAction extends Action +{ + /** User we're getting the faves of */ + var $user = null; + /** Page of the faves we're on */ + var $page = null; + + /** + * Title of the page + * + * Includes name of user and page number. + * + * @return string title of page + */ + + function title() { + if ($this->page == 1) { + return sprintf(_("%s favorite notices"), $this->user->nickname); + } else { + return sprintf(_("%s favorite notices, page %d"), + $this->user->nickname, + $this->page); + } + } - parent::handle($args); + /** + * Prepare the object + * + * Check the input values and initialize the object. + * Shows an error page on bad input. + * + * @param array $args $_REQUEST data + * + * @return boolean success flag + */ + + function prepare($args) + { + parent::prepare($args); $nickname = common_canonical_nickname($this->arg('nickname')); - $user = User::staticGet('nickname', $nickname); - if (!$user) { + $this->user = User::staticGet('nickname', $nickname); + + if (!$this->user) { $this->clientError(_('No such user.')); - return; + return false; } - $profile = $user->getProfile(); + $this->page = $this->trimmed('page'); - if (!$profile) { - $this->serverError(_('User has no profile.')); - return; + if (!$this->page) { + $this->page = 1; } - # Looks like we're good; show the header - - common_show_header(sprintf(_("%s favorite notices"), $profile->nickname), - array($this, 'show_header'), $user, - array($this, 'show_top')); + return true; + } - $this->show_notices($user); + /** + * Handle a request + * + * Just show the page. All args already handled. + * + * @param array $args $_REQUEST data + * + * @return void + */ - common_show_footer(); + function handle($args) + { + parent::handle($args); + $this->showPage(); } - function show_header($user) + /** + * Feeds for the section + * + * @return void + */ + + function showFeeds() { + $feedurl = common_local_url('favoritesrss', + array('nickname' => + $this->user->nickname)); + $feedtitle = sprintf(_('Feed for favorites of %s'), + $this->user->nickname); + $this->element('link', array('rel' => 'alternate', - 'href' => common_local_url('favoritesrss', array('nickname' => - $user->nickname)), + 'href' => $feedurl, 'type' => 'application/rss+xml', - 'title' => sprintf(_('Feed for favorites of %s'), $user->nickname))); + 'title' => $feedtitle)); } - function show_top($user) - { - $cur = common_current_user(); - - if ($cur && $cur->id == $user->id) { - common_notice_form('all'); - } + /** + * show the personal group nav + * + * @return void + */ - $this->show_feeds_list(array(0=>array('href'=>common_local_url('favoritesrss', array('nickname' => $user->nickname)), - 'type' => 'rss', - 'version' => 'RSS 1.0', - 'item' => 'Favorites'))); - $this->views_menu(); + function showLocalNav() + { + $nav = new PersonalGroupNav($this); + $nav->show(); } - function show_notices($user) + /** + * Show the replies feed links + * + * @return void + */ + + function showExportData() { + $feedurl = common_local_url('favoritesrss', + array('nickname' => + $this->user->nickname)); - $page = $this->trimmed('page'); - if (!$page) { - $page = 1; - } + $fl = new FeedList($this); + + // XXX: I18N + + $fl->show(array(0=>array('href'=> $feedurl, + 'type' => 'rss', + 'version' => 'RSS 1.0', + 'item' => 'Favorites'))); + } + + /** + * Show the content + * + * A list of notices that this user has marked as a favorite + * + * @return void + */ - $notice = $user->favoriteNotices(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); + function showContent() + { + $notice = $this->user->favoriteNotices(($this->page-1)*NOTICES_PER_PAGE, + NOTICES_PER_PAGE + 1); if (!$notice) { $this->serverError(_('Could not retrieve favorite notices.')); return; } - $cnt = $this->show_notice_list($notice); + $nl = new NoticeList($notice, $this); + + $cnt = $nl->show(); - common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, - $page, 'showfavorites', array('nickname' => $user->nickname)); + $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, + $this->page, 'showfavorites', + array('nickname' => $this->user->nickname)); } } -- cgit v1.2.3-54-g00ecf From bc15d027a804e60e76bdaf6fd47e69d41b395e7e Mon Sep 17 00:00:00 2001 From: sarven Date: Mon, 19 Jan 2009 16:50:22 +0000 Subject: Changed @id to @class for notices ul --- actions/shownotice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actions') diff --git a/actions/shownotice.php b/actions/shownotice.php index 52faba93e..7033a1672 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -190,7 +190,7 @@ class ShownoticeAction extends Action function showContent() { - $this->elementStart('ul', array('id' => 'notices')); + $this->elementStart('ul', array('class' => 'notices')); $nli = new NoticeListItem($this->notice, $this); $nli->show(); $this->elementEnd('ul'); -- cgit v1.2.3-54-g00ecf From 7ca32eb2e6d36b9173bb2864c439492034f0beaf Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 19 Jan 2009 16:56:41 +0000 Subject: Upgraded showstream, didn't make it phpcs-compatible --- actions/showstream.php | 391 +++++++++++++++++++++++++------------------------ 1 file changed, 200 insertions(+), 191 deletions(-) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index ed38c67f9..aaa55b330 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -1,9 +1,12 @@ . + * + * @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); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/stream.php'); +require_once INSTALLDIR.'/lib/personalgroupnav.php'; +require_once INSTALLDIR.'/lib/noticelist.php'; +require_once INSTALLDIR.'/lib/feedlist.php'; -define('SUBSCRIPTIONS_PER_ROW', 4); -define('SUBSCRIPTIONS', 80); +/** + * User profile page + * + * When I created this page, "show stream" seemed like the best name for it. + * Now, it seems like a really bad name. + * + * It shows a stream of the user's posts, plus lots of profile info, links + * to subscriptions and stuff, etc. + * + * @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 ShowstreamAction extends StreamAction +class ShowstreamAction extends Action { + var $user = null; + var $page = null; + var $profile = null; - function handle($args) + function title() { + if ($this->page == 1) { + return $this->user->nickname; + } else { + return sprintf(_("%s, page %d"), + $this->user->nickname, + $this->page); + } + } - parent::handle($args); + function prepare($args) + { + parent::prepare($args); $nickname_arg = $this->arg('nickname'); $nickname = common_canonical_nickname($nickname_arg); - # Permanent redirect on non-canonical nickname + // Permanent redirect on non-canonical nickname if ($nickname_arg != $nickname) { $args = array('nickname' => $nickname); @@ -43,181 +83,182 @@ class ShowstreamAction extends StreamAction $args['page'] = $this->arg['page']; } common_redirect(common_local_url('showstream', $args), 301); - return; + return false; } - $user = User::staticGet('nickname', $nickname); + $this->user = User::staticGet('nickname', $nickname); - if (!$user) { - $this->no_such_user(); - return; + if (!$this->user) { + $this->clientError(_('No such user.'), 404); + return false; } - $profile = $user->getProfile(); + $this->profile = $this->user->getProfile(); - if (!$profile) { + if (!$this->profile) { $this->serverError(_('User has no profile.')); - return; + return false; } - # Looks like we're good; start output + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - # For YADIS discovery, we also have a tag + return true; + } - header('X-XRDS-Location: '. common_local_url('xrds', array('nickname' => - $user->nickname))); + function handle($args) + { - common_show_header($profile->nickname, - array($this, 'show_header'), $user, - array($this, 'show_top')); + // Looks like we're good; start output - $this->show_profile($profile); + // For YADIS discovery, we also have a tag - $this->show_notices($user); + header('X-XRDS-Location: '. common_local_url('xrds', array('nickname' => + $this->user->nickname))); - common_show_footer(); + $this->showPage(); } - function show_top($user) + function showContent() { - $cur = common_current_user(); + $this->showProfile(); + $this->showNotices(); + } - if ($cur && $cur->id == $user->id) { - common_notice_form('showstream'); - } + function showLocalNav() + { + $nav = new PersonalGroupNav($this); + $nav->show(); + } - $this->views_menu(); - - $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('nickname' => $user->nickname)), - 'type' => 'rss', - 'version' => 'RSS 1.0', - 'item' => 'notices'), - 1=>array('href'=>common_local_url('usertimeline', array('nickname' => $user->nickname)), - 'type' => 'atom', - 'version' => 'Atom 1.0', - 'item' => 'usertimeline'), - - 2=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)), - 'type' => 'rdf', - 'version' => 'FOAF', - 'item' => 'foaf'))); + function showPageTitle() + { + // Don't show the H1; we have one in the profile block + } + + function showExportData() + { + $fl = new FeedList($this); + $fl->show(array(0=>array('href'=>common_local_url('userrss', + array('nickname' => $this->user->nickname)), + 'type' => 'rss', + 'version' => 'RSS 1.0', + 'item' => 'notices'), + 1=>array('href'=>common_local_url('usertimeline', + array('nickname' => $this->user->nickname)), + 'type' => 'atom', + 'version' => 'Atom 1.0', + 'item' => 'usertimeline'), + 2=>array('href'=>common_local_url('foaf', + array('nickname' => $this->user->nickname)), + 'type' => 'rdf', + 'version' => 'FOAF', + 'item' => 'foaf'))); } - function show_header($user) + function showFeeds() { - # Feeds + // Feeds $this->element('link', array('rel' => 'alternate', 'href' => common_local_url('api', array('apiaction' => 'statuses', 'method' => 'user_timeline.rss', - 'argument' => $user->nickname)), + 'argument' => $this->user->nickname)), 'type' => 'application/rss+xml', - 'title' => sprintf(_('Notice feed for %s'), $user->nickname))); + 'title' => sprintf(_('Notice feed for %s'), $this->user->nickname))); $this->element('link', array('rel' => 'alternate feed', 'href' => common_local_url('api', array('apiaction' => 'statuses', 'method' => 'user_timeline.atom', - 'argument' => $user->nickname)), + 'argument' => $this->user->nickname)), 'type' => 'application/atom+xml', - 'title' => sprintf(_('Notice feed for %s'), $user->nickname))); + 'title' => sprintf(_('Notice feed for %s'), $this->user->nickname))); $this->element('link', array('rel' => 'alternate', 'href' => common_local_url('userrss', array('nickname' => - $user->nickname)), + $this->user->nickname)), 'type' => 'application/rdf+xml', - 'title' => sprintf(_('Notice feed for %s'), $user->nickname))); - # FOAF + 'title' => sprintf(_('Notice feed for %s'), $this->user->nickname))); + } + + function extraHead() + { + // FOAF $this->element('link', array('rel' => 'meta', 'href' => common_local_url('foaf', array('nickname' => - $user->nickname)), + $this->user->nickname)), 'type' => 'application/rdf+xml', 'title' => 'FOAF')); - # for remote subscriptions etc. + // for remote subscriptions etc. $this->element('meta', array('http-equiv' => 'X-XRDS-Location', 'content' => common_local_url('xrds', array('nickname' => - $user->nickname)))); - $profile = $user->getProfile(); - if ($profile->bio) { + $this->user->nickname)))); + + if ($this->profile->bio) { $this->element('meta', array('name' => 'description', - 'content' => $profile->bio)); + 'content' => $this->profile->bio)); } - if ($user->emailmicroid && $user->email && $profile->profileurl) { + if ($this->user->emailmicroid && $this->user->email && $this->profile->profileurl) { + $id = new Microid('mailto:'.$this->user->email, + $this->selfUrl()); $this->element('meta', array('name' => 'microid', - 'content' => "mailto+http:sha1:" . sha1(sha1('mailto:' . $user->email) . sha1($profile->profileurl)))); + 'content' => $id->toString())); } - if ($user->jabbermicroid && $user->jabber && $profile->profileurl) { + if ($this->user->jabbermicroid && $this->user->jabber && $this->profile->profileurl) { + $id = new Microid('xmpp:'.$this->user->jabber, + $this->selfUrl()); $this->element('meta', array('name' => 'microid', - 'content' => "xmpp+http:sha1:" . sha1(sha1('xmpp:' . $user->jabber) . sha1($profile->profileurl)))); + 'content' => $id->toString())); } - # See https://wiki.mozilla.org/Microsummaries + // See https://wiki.mozilla.org/Microsummaries $this->element('link', array('rel' => 'microsummary', 'href' => common_local_url('microsummary', - array('nickname' => $profile->nickname)))); + array('nickname' => $this->profile->nickname)))); } - function no_such_user() + function showProfile() { - $this->clientError(_('No such user.'), 404); - } - - function show_profile($profile) - { - $this->elementStart('div', array('id' => 'profile', 'class' => 'vcard')); - $this->show_personal($profile); - - $this->show_last_notice($profile); - - $cur = common_current_user(); - - $this->show_subscriptions($profile); - - $this->elementEnd('div'); - } - - function show_personal($profile) - { - - $avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE); + $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); $this->elementStart('div', array('id' => 'profile_avatar')); $this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE), 'class' => 'avatar profile photo', 'width' => AVATAR_PROFILE_SIZE, 'height' => AVATAR_PROFILE_SIZE, - 'alt' => $profile->nickname)); + 'alt' => $this->profile->nickname)); $this->elementStart('ul', array('id' => 'profile_actions')); $this->elementStart('li', array('id' => 'profile_subscribe')); $cur = common_current_user(); if ($cur) { - if ($cur->id != $profile->id) { - if ($cur->isSubscribed($profile)) { - common_unsubscribe_form($profile); + if ($cur->id != $this->profile->id) { + if ($cur->isSubscribed($this->profile)) { + $sf = new SubscribeForm($this, $this->profile); + $sf->show(); } else { - common_subscribe_form($profile); + $usf = new UnsubscribeForm($this, $this->profile); + $usf->show(); } } } else { - $this->show_remote_subscribe_link($profile); + $this->showRemoteSubscribeLink(); } $this->elementEnd('li'); - $user = User::staticGet('id', $profile->id); - common_profile_new_message_nudge($cur, $user, $profile); + common_profile_new_message_nudge($cur, $this->user, $this->profile); - if ($cur && $cur->id != $profile->id) { - $blocked = $cur->hasBlocked($profile); + if ($cur && $cur->id != $this->profile->id) { + $blocked = $cur->hasBlocked($this->profile); $this->elementStart('li', array('id' => 'profile_block')); if ($blocked) { - common_unblock_form($profile, array('action' => 'showstream', - 'nickname' => $profile->nickname)); + $bf = new BlockForm($this, $this->profile); + $bf->show(); } else { - common_block_form($profile, array('action' => 'showstream', - 'nickname' => $profile->nickname)); + $ubf = new UnblockForm($this, $this->profile); + $ubf->show(); } $this->elementEnd('li'); } @@ -228,72 +269,73 @@ class ShowstreamAction extends StreamAction $this->elementStart('div', array('id' => 'profile_information')); - if ($profile->fullname) { - $this->element('h1', array('class' => 'fn'), $profile->fullname . ' (' . $profile->nickname . ')'); + if ($this->profile->fullname) { + $this->element('h1', array('class' => 'fn'), $this->profile->fullname . ' (' . $this->profile->nickname . ')'); } else { - $this->element('h1', array('class' => 'fn nickname'), $profile->nickname); + $this->element('h1', array('class' => 'fn nickname'), $this->profile->nickname); } - if ($profile->location) { - $this->element('p', 'location', $profile->location); + if ($this->profile->location) { + $this->element('p', 'location', $this->profile->location); } - if ($profile->bio) { - $this->element('p', 'description note', $profile->bio); + if ($this->profile->bio) { + $this->element('p', 'description note', $this->profile->bio); } - if ($profile->homepage) { + if ($this->profile->homepage) { $this->elementStart('p', 'website'); - $this->element('a', array('href' => $profile->homepage, + $this->element('a', array('href' => $this->profile->homepage, 'rel' => 'me', 'class' => 'url'), - $profile->homepage); + $this->profile->homepage); $this->elementEnd('p'); } - $this->show_statistics($profile); + $this->elementEnd('div'); $this->elementEnd('div'); } - function show_remote_subscribe_link($profile) + function showRemoteSubscribeLink() { $url = common_local_url('remotesubscribe', - array('nickname' => $profile->nickname)); + array('nickname' => $this->profile->nickname)); $this->element('a', array('href' => $url, 'id' => 'remotesubscribe'), _('Subscribe')); } - function show_unsubscribe_form($profile) + function showNotices() { - $this->elementStart('form', array('id' => 'unsubscribe', 'method' => 'post', - 'action' => common_local_url('unsubscribe'))); - $this->hidden('token', common_session_token()); - $this->element('input', array('id' => 'unsubscribeto', - 'name' => 'unsubscribeto', - 'type' => 'hidden', - 'value' => $profile->nickname)); - $this->element('input', array('type' => 'submit', - 'class' => 'submit', - 'value' => _('Unsubscribe'))); - $this->elementEnd('form'); + $notice = $this->user->getNotices(($this->page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); + + $pnl = new ProfileNoticeList($notice, $this); + $cnt = $pnl->show(); + + $this->pagination($this->page>1, $cnt>NOTICES_PER_PAGE, $this->page, + 'showstream', array('nickname' => $this->user->nickname)); } - function show_subscriptions($profile) + function showSections() { - global $config; + $this->showStatistics(); + $this->showSubscriptions(); + } - $subs = DB_DataObject::factory('subscription'); - $subs->subscriber = $profile->id; - $subs->whereAdd('subscribed != ' . $profile->id); + function showSubscriptions() + { + $subs = new Subscription(); + $subs->subscriber = $this->profile->id; + $subs->whereAdd('subscribed != ' . $this->profile->id); $subs->orderBy('created DESC'); - # We ask for an extra one to know if we need to do another page + // We ask for an extra one to know if we need to do another page $subs->limit(0, SUBSCRIPTIONS + 1); $subs_count = $subs->find(); - $this->elementStart('div', array('id' => 'subscriptions')); + $this->elementStart('div', array('id' => 'subscriptions', + 'class' => 'section')); $this->element('h2', null, _('Subscriptions')); @@ -341,7 +383,7 @@ class ShowstreamAction extends StreamAction $this->elementStart('p', array('id' => 'subscriptions_viewall')); $this->element('a', array('href' => common_local_url('subscriptions', - array('nickname' => $profile->nickname)), + array('nickname' => $this->profile->nickname)), 'class' => 'moresubscriptions'), _('All subscriptions')); $this->elementEnd('p'); @@ -350,49 +392,51 @@ class ShowstreamAction extends StreamAction $this->elementEnd('div'); } - function show_statistics($profile) + function showStatistics() { // XXX: WORM cache this - $subs = DB_DataObject::factory('subscription'); - $subs->subscriber = $profile->id; + $subs = new Subscription(); + $subs->subscriber = $this->profile->id; $subs_count = (int) $subs->count() - 1; - $subbed = DB_DataObject::factory('subscription'); - $subbed->subscribed = $profile->id; + $subbed = new Subscription(); + $subbed->subscribed = $this->profile->id; $subbed_count = (int) $subbed->count() - 1; - $notices = DB_DataObject::factory('notice'); - $notices->profile_id = $profile->id; + $notices = new Notice(); + $notices->profile_id = $this->profile->id; $notice_count = (int) $notices->count(); - $this->elementStart('div', 'statistics'); + $this->elementStart('div', array('id' => 'statistics', + 'class' => 'section')); + $this->element('h2', 'statistics', _('Statistics')); - # Other stats...? + // Other stats...? $this->elementStart('dl', 'statistics'); $this->element('dt', 'membersince', _('Member since')); $this->element('dd', 'membersince', date('j M Y', - strtotime($profile->created))); + strtotime($this->profile->created))); $this->elementStart('dt', 'subscriptions'); $this->element('a', array('href' => common_local_url('subscriptions', - array('nickname' => $profile->nickname))), + array('nickname' => $this->profile->nickname))), _('Subscriptions')); $this->elementEnd('dt'); $this->element('dd', 'subscriptions', (is_int($subs_count)) ? $subs_count : '0'); $this->elementStart('dt', 'subscribers'); $this->element('a', array('href' => common_local_url('subscribers', - array('nickname' => $profile->nickname))), + array('nickname' => $this->profile->nickname))), _('Subscribers')); $this->elementEnd('dt'); $this->element('dd', 'subscribers', (is_int($subbed_count)) ? $subbed_count : '0'); $this->element('dt', 'notices', _('Notices')); $this->element('dd', 'notices', (is_int($notice_count)) ? $notice_count : '0'); - # XXX: link these to something + // XXX: link these to something $this->element('dt', 'tags', _('Tags')); $this->elementStart('dd', 'tags'); - $tags = Profile_tag::getTags($profile->id, $profile->id); + $tags = Profile_tag::getTags($this->profile->id, $this->profile->id); $this->elementStart('ul', 'tags xoxo'); foreach ($tags as $tag) { @@ -411,50 +455,15 @@ class ShowstreamAction extends StreamAction $this->elementEnd('div'); } - function show_notices($user) - { - - $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - - $notice = $user->getNotices(($page-1)*NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); - - $pnl = new ProfileNoticeList($notice); - $cnt = $pnl->show(); - - common_pagination($page>1, $cnt>NOTICES_PER_PAGE, $page, - 'showstream', array('nickname' => $user->nickname)); - } - - function show_last_notice($profile) - { - - $this->element('h2', null, _('Currently')); - - $notice = $profile->getCurrentNotice(); - - if ($notice) { - # FIXME: URL, image, video, audio - $this->elementStart('p', array('class' => 'notice_current')); - if ($notice->rendered) { - $this->raw($notice->rendered); - } else { - # XXX: may be some uncooked notices in the DB, - # we cook them right now. This can probably disappear in future - # versions (>> 0.4.x) - $this->raw(common_render_content($notice->content, $notice)); - } - $this->elementEnd('p'); - } - } } -# We don't show the author for a profile, since we already know who it is! +// We don't show the author for a profile, since we already know who it is! class ProfileNoticeList extends NoticeList { function newListItem($notice) { - return new ProfileNoticeListItem($notice); + return new ProfileNoticeListItem($notice, $this->out); } } -- cgit v1.2.3-54-g00ecf From a5f3e3b759879aaed31a82fa98a89d6d3594af8c Mon Sep 17 00:00:00 2001 From: sarven Date: Mon, 19 Jan 2009 17:12:35 +0000 Subject: Removed unnecessary empty containers (page_notice, aside, local navigation) --- actions/shownotice.php | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'actions') diff --git a/actions/shownotice.php b/actions/shownotice.php index 7033a1672..beae478ba 100644 --- a/actions/shownotice.php +++ b/actions/shownotice.php @@ -180,6 +180,18 @@ class ShownoticeAction extends Action $this->showPage(); } + + /** + * Don't show local navigation + * + * @return void + */ + + function showLocalNavBlock() + { + } + + /** * Fill the content area of the page * @@ -196,6 +208,29 @@ class ShownoticeAction extends Action $this->elementEnd('ul'); } + + + /** + * Don't show page notice + * + * @return void + */ + + function showPageNoticeBlock() + { + } + + + /** + * Don't show aside + * + * @return void + */ + + function showAside() { + } + + /** * Extra content * -- cgit v1.2.3-54-g00ecf From 4f100c8159536283247ee27cda3eafcbae14b16d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 19 Jan 2009 17:49:12 +0000 Subject: Update featured for new framework, but not phpcs-clean yet --- actions/featured.php | 95 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 30 deletions(-) (limited to 'actions') diff --git a/actions/featured.php b/actions/featured.php index 035622691..d1ac6e054 100644 --- a/actions/featured.php +++ b/actions/featured.php @@ -1,67 +1,102 @@ . + * along with this program. If not, see . + * + * @category Public + * @package Laconica + * @author Zach Copley + * @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); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/stream.php'); require_once(INSTALLDIR.'/lib/profilelist.php'); +require_once INSTALLDIR.'/lib/publicgroupnav.php'; -class FeaturedAction extends StreamAction +/** + * List of featured users + * + * @category Public + * @package Laconica + * @author Zach Copley + * @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 FeaturedAction extends Action { + var $page = null; - function handle($args) + function prepare($args) { - parent::handle($args); + parent::prepare($args); + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + return true; + } - common_show_header(_('Featured users'), - array($this, 'show_header'), null, - array($this, 'show_top')); + function title() + { + if ($this->page == 1) { + return _('Featured users'); + } else { + return sprintf(_('Featured users, page %d'), $this->page); + } + } - $this->show_notices($page); + function handle($args) + { + parent::handle($args); - common_show_footer(); + $this->showPage(); } - function show_top() + function showPageNotice() { - $instr = $this->get_instructions(); + $instr = $this->getInstructions(); $output = common_markup_to_html($instr); $this->elementStart('div', 'instructions'); $this->raw($output); $this->elementEnd('div'); - $this->public_views_menu(); } - function show_header() + function showLocalNav() { + $nav = new PublicGroupNav($this); + $nav->show(); } - function get_instructions() + function getInstructions() { - return _('Featured users'); + return sprintf(_('A selection of some of the great users on %s'), + common_config('site', 'name')); } - function show_notices($page) + function showContent() { - // XXX: Note I'm doing it this two-stage way because a raw query // with a JOIN was *not* working. --Zach @@ -77,7 +112,7 @@ class FeaturedAction extends StreamAction $user = new User; $user->whereAdd(sprintf('nickname IN (%s)', implode(',', $quoted))); - $user->limit(($page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1); + $user->limit(($this->page - 1) * PROFILES_PER_PAGE, PROFILES_PER_PAGE + 1); $user->orderBy('user.nickname ASC'); $user->find(); @@ -95,14 +130,14 @@ class FeaturedAction extends StreamAction $cnt = $profile->find(); if ($cnt > 0) { - $featured = new ProfileList($profile); - $featured->show_list(); + $featured = new ProfileList($profile, null, $this); + $featured->show(); } $profile->free(); - common_pagination($page > 1, $cnt > PROFILES_PER_PAGE, $page, 'featured'); + $this->pagination($this->page > 1, $cnt > PROFILES_PER_PAGE, + $this->page, 'featured'); } } - } \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 8b89fbb3f02553579c8dcfc9843ef47aff4d31b5 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 19 Jan 2009 18:09:59 +0000 Subject: Mark featured users as readonly --- actions/featured.php | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'actions') diff --git a/actions/featured.php b/actions/featured.php index d1ac6e054..f3bade6a5 100644 --- a/actions/featured.php +++ b/actions/featured.php @@ -50,6 +50,11 @@ class FeaturedAction extends Action { var $page = null; + function isReadOnly() + { + return true; + } + function prepare($args) { parent::prepare($args); -- cgit v1.2.3-54-g00ecf From 7c0286bfcc64525b85cafb68434f0689c03519bc Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 19 Jan 2009 18:10:20 +0000 Subject: Favorites is readonly --- actions/showfavorites.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'actions') diff --git a/actions/showfavorites.php b/actions/showfavorites.php index d2c91c025..bb68f8d94 100644 --- a/actions/showfavorites.php +++ b/actions/showfavorites.php @@ -52,6 +52,17 @@ class ShowfavoritesAction extends Action /** Page of the faves we're on */ var $page = null; + /** + * Is this a read-only page? + * + * @return boolean true + */ + + function isReadOnly() + { + return true; + } + /** * Title of the page * -- cgit v1.2.3-54-g00ecf From 930f82a95170e05ad2d4fc079cc944d29521797d Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 19 Jan 2009 18:21:14 +0000 Subject: Update tag to use new framework Broke up the tag action into two different actions (publictagcloud and tag). Brought it up-to-date with the new framework, but haven't fixed it for phpcs yet. --- actions/publictagcloud.php | 149 +++++++++++++++++++++++++++++++++++++++++ actions/tag.php | 161 +++++++++++---------------------------------- htaccess.sample | 2 +- lib/publicgroupnav.php | 4 +- lib/util.php | 10 ++- 5 files changed, 195 insertions(+), 131 deletions(-) create mode 100644 actions/publictagcloud.php (limited to 'actions') diff --git a/actions/publictagcloud.php b/actions/publictagcloud.php new file mode 100644 index 000000000..ec28edbad --- /dev/null +++ b/actions/publictagcloud.php @@ -0,0 +1,149 @@ +. + * + * @category Public + * @package Laconica + * @author Mike Cochrane + * @author Evan Prodromou + * @copyright 2008 Mike Cochrane + * @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); } + +define('TAGS_PER_PAGE', 100); + +/** + * Public tag cloud for notices + * + * @category Personal + * @package Laconica + * @author Mike Cochrane + * @author Evan Prodromou + * @copyright 2008 Mike Cochrane + * @copyright 2008-2009 Control Yourself, Inc. + * @link http://laconi.ca/ + */ + +class PublictagcloudAction extends Action +{ + function isReadOnly() + { + return true; + } + + function title() + { + return _('Public tag cloud'); + } + + function showPageNotice() + { + $this->element('p', 'instructions', + sprintf(_('These are most popular recent tags on %s '), + common_config('site', 'name'))); + } + + function showLocalNav() + { + $nav = new PublicGroupNav($this); + $nav->show(); + } + + function handle($args) + { + parent::handle($args); + $this->showPage(); + } + + function showContent() + { + # This should probably be cached rather than recalculated + $tags = new Notice_tag(); + + #Need to clear the selection and then only re-add the field + #we are grouping by, otherwise it's not a valid 'group by' + #even though MySQL seems to let it slide... + $tags->selectAdd(); + $tags->selectAdd('tag'); + + #Add the aggregated columns... + $tags->selectAdd('max(notice_id) as last_notice_id'); + if(common_config('db','type')=='pgsql') { + $calc='sum(exp(-extract(epoch from (now()-created))/%s)) as weight'; + } else { + $calc='sum(exp(-(now() - created)/%s)) as weight'; + } + $tags->selectAdd(sprintf($calc, common_config('tag', 'dropoff'))); + $tags->groupBy('tag'); + $tags->orderBy('weight DESC'); + + $tags->limit(TAGS_PER_PAGE); + + $cnt = $tags->find(); + + if ($cnt > 0) { + $this->elementStart('p', 'tagcloud'); + + $tw = array(); + $sum = 0; + while ($tags->fetch()) { + $tw[$tags->tag] = $tags->weight; + $sum += $tags->weight; + } + + ksort($tw); + + foreach ($tw as $tag => $weight) { + $this->showTag($tag, $weight, $weight/$sum); + } + + $this->elementEnd('p'); + } + } + + function showTag($tag, $weight, $relative) + { + # XXX: these should probably tune to the size of the site + if ($relative > 0.1) { + $cls = 'largest'; + } else if ($relative > 0.05) { + $cls = 'verylarge'; + } else if ($relative > 0.02) { + $cls = 'large'; + } else if ($relative > 0.01) { + $cls = 'medium'; + } else if ($relative > 0.005) { + $cls = 'small'; + } else if ($relative > 0.002) { + $cls = 'verysmall'; + } else { + $cls = 'smallest'; + } + + $this->element('a', array('class' => "$cls weight-$weight relative-$relative", + 'href' => common_local_url('tag', array('tag' => $tag))), + $tag); + $this->text(' '); + } +} diff --git a/actions/tag.php b/actions/tag.php index 3096b75b3..039cd9660 100644 --- a/actions/tag.php +++ b/actions/tag.php @@ -19,154 +19,71 @@ if (!defined('LACONICA')) { exit(1); } -require_once(INSTALLDIR.'/actions/showstream.php'); -define('TAGS_PER_PAGE', 100); - -class TagAction extends StreamAction +class TagAction extends Action { - - function handle($args) + function prepare($args) { + parent::prepare($args); + $this->tag = $this->trimmed('tag'); - parent::handle($args); - - # Looks like we're good; show the header - - if (isset($args['tag']) && $args['tag']) { - $tag = $args['tag']; - common_show_header(sprintf(_("Notices tagged with %s"), $tag), - array($this, 'show_header'), $tag, - array($this, 'show_top')); - $this->show_notices($tag); - } else { - common_show_header(_("Tags"), - array($this, 'show_header'), '', - array($this, 'show_top')); - $this->show_tags(); + if (!$this->tag) { + common_redirect(common_local_url('publictagcloud'), 301); + return false; } - common_show_footer(); + $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; + return true; } - function show_header($tag = false) + function title() { - if ($tag) { - $this->element('link', array('rel' => 'alternate', - 'href' => common_local_url('tagrss', array('tag' => $tag)), - 'type' => 'application/rss+xml', - 'title' => sprintf(_('Feed for tag %s'), $tag))); + if ($this->page == 1) { + return sprintf(_("Notices tagged with %s"), $this->tag); + } else { + return sprintf(_("Notices tagged with %s, page %d"), + $this->tag, + $this->page); } } - function get_instructions() + function handle($args) { - return _('Showing most popular tags from the last week'); + parent::handle($args); + + $this->showPage(); } - function show_top($tag = false) + function showFeeds() { - if (!$tag) { - $instr = $this->get_instructions(); - $output = common_markup_to_html($instr); - $this->elementStart('div', 'instructions'); - $this->raw($output); - $this->elementEnd('div'); - $this->public_views_menu(); - } - else { - $this->show_feeds_list(array(0=>array('href'=>common_local_url('tagrss'), - 'type' => 'rss', - 'version' => 'RSS 1.0', - 'item' => 'tagrss'))); - } + $this->element('link', array('rel' => 'alternate', + 'href' => common_local_url('tagrss', array('tag' => $this->tag)), + 'type' => 'application/rss+xml', + 'title' => sprintf(_('Feed for tag %s'), $this->tag))); } - function show_tags() + function showPageNotice() { - # This should probably be cached rather than recalculated - $tags = DB_DataObject::factory('Notice_tag'); - - #Need to clear the selection and then only re-add the field - #we are grouping by, otherwise it's not a valid 'group by' - #even though MySQL seems to let it slide... - $tags->selectAdd(); - $tags->selectAdd('tag'); - - #Add the aggregated columns... - $tags->selectAdd('max(notice_id) as last_notice_id'); - if(common_config('db','type')=='pgsql') { - $calc='sum(exp(-extract(epoch from (now()-created))/%s)) as weight'; - } else { - $calc='sum(exp(-(now() - created)/%s)) as weight'; - } - $tags->selectAdd(sprintf($calc, common_config('tag', 'dropoff'))); - $tags->groupBy('tag'); - $tags->orderBy('weight DESC'); - - # $tags->whereAdd('created > "' . strftime('%Y-%m-%d %H:%M:%S', strtotime('-1 MONTH')) . '"'); - - $tags->limit(TAGS_PER_PAGE); - - $cnt = $tags->find(); - - if ($cnt > 0) { - $this->elementStart('p', 'tagcloud'); - - $tw = array(); - $sum = 0; - while ($tags->fetch()) { - $tw[$tags->tag] = $tags->weight; - $sum += $tags->weight; - } - - ksort($tw); - - foreach ($tw as $tag => $weight) { - $this->show_tag($tag, $weight, $weight/$sum); - } - - $this->elementEnd('p'); - } + return sprintf(_('Messages tagged "%s", most recent first'), $this->tag); } - function show_tag($tag, $weight, $relative) + function showExportData() { - - # XXX: these should probably tune to the size of the site - if ($relative > 0.1) { - $cls = 'largest'; - } else if ($relative > 0.05) { - $cls = 'verylarge'; - } else if ($relative > 0.02) { - $cls = 'large'; - } else if ($relative > 0.01) { - $cls = 'medium'; - } else if ($relative > 0.005) { - $cls = 'small'; - } else if ($relative > 0.002) { - $cls = 'verysmall'; - } else { - $cls = 'smallest'; - } - - $this->element('a', array('class' => "$cls weight-$weight relative-$relative", - 'href' => common_local_url('tag', array('tag' => $tag))), - $tag); - $this->text(' '); + $fl = new FeedList($this); + $fl->show(array(0=>array('href'=>common_local_url('tagrss', array('tag' => $this->tag)), + 'type' => 'rss', + 'version' => 'RSS 1.0', + 'item' => 'tagrss'))); } - function show_notices($tag) + function showContent() { + $notice = Notice_tag::getStream($this->tag, (($this->page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1); - $cnt = 0; - - $page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; - - $notice = Notice_tag::getStream($tag, (($page-1)*NOTICES_PER_PAGE), NOTICES_PER_PAGE + 1); + $nl = new NoticeList($notice, $this); - $cnt = $this->show_notice_list($notice); + $cnt = $nl->show(); - common_pagination($page > 1, $cnt > NOTICES_PER_PAGE, - $page, 'tag', array('tag' => $tag)); + $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, + $this->page, 'tag', array('tag' => $this->tag)); } } diff --git a/htaccess.sample b/htaccess.sample index 10e51b5b0..b0e3e93e0 100644 --- a/htaccess.sample +++ b/htaccess.sample @@ -76,7 +76,7 @@ RewriteRule ^message/(\d+)$ index.php?action=showmessage&message=$1 [L,QSA] RewriteRule ^user/(\d+)$ index.php?action=userbyid&id=$1 [L,QSA] -RewriteRule ^tags/?$ index.php?action=tag [L,QSA] +RewriteRule ^tags/?$ index.php?action=publictagcloud [L,QSA] RewriteRule ^tag/([a-zA-Z0-9]+)/rss$ index.php?action=tagrss&tag=$1 [L,QSA] RewriteRule ^tag(/(.*))?$ index.php?action=tag&tag=$2 [L,QSA] diff --git a/lib/publicgroupnav.php b/lib/publicgroupnav.php index 97b57ec17..8dd97a3b7 100644 --- a/lib/publicgroupnav.php +++ b/lib/publicgroupnav.php @@ -76,8 +76,8 @@ class PublicGroupNav extends Widget $this->out->menuItem(common_local_url('public'), _('Public'), _('Public timeline'), $action_name == 'public', 'nav_timeline_public'); - $this->out->menuItem(common_local_url('tag'), _('Recent tags'), - _('Recent tags'), $action_name == 'tag', 'nav_recent-tags'); + $this->out->menuItem(common_local_url('publictagcloud'), _('Recent tags'), + _('Recent tags'), $action_name == 'publictagcloud', 'nav_recent-tags'); if (count(common_config('nickname', 'featured')) > 0) { $this->out->menuItem(common_local_url('featured'), _('Featured'), diff --git a/lib/util.php b/lib/util.php index d67c64972..73c4cdcc8 100644 --- a/lib/util.php +++ b/lib/util.php @@ -865,13 +865,11 @@ function common_fancy_url($action, $args=null) case 'avatarbynickname': return common_path($args['nickname'].'/avatar/'.$args['size']); case 'tag': - if (isset($args['tag']) && $args['tag']) { - $path = 'tag/' . $args['tag']; - unset($args['tag']); - } else { - $path = 'tags'; - } + $path = 'tag/' . $args['tag']; + unset($args['tag']); return common_path($path . (($args) ? ('?' . http_build_query($args)) : '')); + case 'publictagcloud': + return common_path('tags'); case 'peopletag': $path = 'peopletag/' . $args['tag']; unset($args['tag']); -- cgit v1.2.3-54-g00ecf From 774fc5378bc89ccfa05ba613ffae96addd3427cf Mon Sep 17 00:00:00 2001 From: sarven Date: Mon, 19 Jan 2009 22:40:21 +0000 Subject: user_profile markup --- actions/showstream.php | 126 +++++++++++++++++++++++++++++-------------------- 1 file changed, 76 insertions(+), 50 deletions(-) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index aaa55b330..60270cfd7 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -219,19 +219,89 @@ class ShowstreamAction extends Action function showProfile() { - $this->elementStart('div', array('id' => 'profile', 'class' => 'vcard')); + $this->elementStart('div', array('id' => 'user_profile', 'class' => 'vcard author')); + $this->element('h2', null, _('User profile')); $avatar = $this->profile->getAvatar(AVATAR_PROFILE_SIZE); - $this->elementStart('div', array('id' => 'profile_avatar')); + $this->elementStart('dl', 'user_depiction'); + $this->element('dt', null, _('Photo')); + $this->elementStart('dd'); $this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_PROFILE_SIZE), - 'class' => 'avatar profile photo', + 'class' => 'photo avatar', 'width' => AVATAR_PROFILE_SIZE, 'height' => AVATAR_PROFILE_SIZE, 'alt' => $this->profile->nickname)); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + + if ($this->profile->fullname) { + $this->elementStart('dl', 'user_fn'); + $this->element('dt', null, _('Full name')); + $this->elementStart('dd'); + $this->element('a', array('href' => $this->profile->homepage, + 'rel' => 'me', 'class' => 'fn url uid'), + $this->profile->fullname); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + } + + $this->elementStart('dl', 'user_nickname'); + $this->element('dt', null, _('Nickname')); + $this->elementStart('dd'); + $this->element('span', 'fn nickname', $this->profile->nickname); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + + if ($this->profile->location) { + $this->elementStart('dl', 'user_location'); + $this->element('dt', null, _('Location')); + $this->element('dd', 'location', $this->profile->location); + $this->elementEnd('dl'); + } + + if ($this->profile->homepage) { + $this->elementStart('dl', 'user_url'); + $this->element('dt', null, _('URL')); + $this->elementStart('dd'); + $this->element('a', array('href' => $this->profile->homepage, + 'rel' => 'me', 'class' => 'url'), + $this->profile->homepage); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + } + + if ($this->profile->bio) { + $this->elementStart('dl', 'user_note'); + $this->element('dt', null, _('Note')); + $this->element('dd', 'note', $this->profile->bio); + $this->elementEnd('dl'); + } + + $tags = Profile_tag::getTags($this->profile->id, $this->profile->id); + if (count($tags) > 0) { + $this->elementStart('dl', 'user_tags'); + $this->element('dt', null, _('Tags')); + $this->elementStart('dd', 'tags'); + $this->elementStart('ul', 'tags xoxo'); + foreach ($tags as $tag) { + $this->elementStart('li'); + $this->element('a', array('rel' => 'tag', + 'href' => common_local_url('peopletag', + array('tag' => $tag))), + $tag); + $this->elementEnd('li'); + } + $this->elementEnd('ul'); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + } + $this->elementEnd('div'); - $this->elementStart('ul', array('id' => 'profile_actions')); - $this->elementStart('li', array('id' => 'profile_subscribe')); + $this->elementStart('div', array('id' => 'user_actions')); + $this->element('h2', null, _('User actions')); + $this->elementStart('ul'); + $this->elementStart('li', array('id' => 'user_subscribe')); $cur = common_current_user(); if ($cur) { if ($cur->id != $this->profile->id) { @@ -252,7 +322,7 @@ class ShowstreamAction extends Action if ($cur && $cur->id != $this->profile->id) { $blocked = $cur->hasBlocked($this->profile); - $this->elementStart('li', array('id' => 'profile_block')); + $this->elementStart('li', array('id' => 'user_block')); if ($blocked) { $bf = new BlockForm($this, $this->profile); $bf->show(); @@ -262,33 +332,7 @@ class ShowstreamAction extends Action } $this->elementEnd('li'); } - $this->elementEnd('ul'); - - $this->elementEnd('div'); - - $this->elementStart('div', array('id' => 'profile_information')); - - if ($this->profile->fullname) { - $this->element('h1', array('class' => 'fn'), $this->profile->fullname . ' (' . $this->profile->nickname . ')'); - } else { - $this->element('h1', array('class' => 'fn nickname'), $this->profile->nickname); - } - - if ($this->profile->location) { - $this->element('p', 'location', $this->profile->location); - } - if ($this->profile->bio) { - $this->element('p', 'description note', $this->profile->bio); - } - if ($this->profile->homepage) { - $this->elementStart('p', 'website'); - $this->element('a', array('href' => $this->profile->homepage, - 'rel' => 'me', 'class' => 'url'), - $this->profile->homepage); - $this->elementEnd('p'); - } - $this->elementEnd('div'); $this->elementEnd('div'); @@ -394,7 +438,6 @@ class ShowstreamAction extends Action function showStatistics() { - // XXX: WORM cache this $subs = new Subscription(); $subs->subscriber = $this->profile->id; @@ -433,23 +476,6 @@ class ShowstreamAction extends Action $this->element('dd', 'subscribers', (is_int($subbed_count)) ? $subbed_count : '0'); $this->element('dt', 'notices', _('Notices')); $this->element('dd', 'notices', (is_int($notice_count)) ? $notice_count : '0'); - // XXX: link these to something - $this->element('dt', 'tags', _('Tags')); - $this->elementStart('dd', 'tags'); - $tags = Profile_tag::getTags($this->profile->id, $this->profile->id); - - $this->elementStart('ul', 'tags xoxo'); - foreach ($tags as $tag) { - $this->elementStart('li'); - $this->element('a', array('rel' => 'bookmark tag', - 'href' => common_local_url('peopletag', - array('tag' => $tag))), - $tag); - $this->elementEnd('li'); - } - $this->elementEnd('ul'); - $this->elementEnd('dd'); - $this->elementEnd('dl'); $this->elementEnd('div'); -- cgit v1.2.3-54-g00ecf From 8e8c5805862344b82f2b1b0a30cb376ec5d91160 Mon Sep 17 00:00:00 2001 From: sarven Date: Mon, 19 Jan 2009 23:19:05 +0000 Subject: showPageTitle() and showPageNoticeBlock() and using url on nickname instead of fullname --- actions/showstream.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index 60270cfd7..39c74f0ee 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -132,7 +132,12 @@ class ShowstreamAction extends Action function showPageTitle() { - // Don't show the H1; we have one in the profile block + $this->element('h1', NULL, $this->profile->nickname._("'s profile")); + } + + function showPageNoticeBlock() + { + return; } function showExportData() @@ -238,17 +243,16 @@ class ShowstreamAction extends Action $this->elementStart('dl', 'user_fn'); $this->element('dt', null, _('Full name')); $this->elementStart('dd'); - $this->element('a', array('href' => $this->profile->homepage, - 'rel' => 'me', 'class' => 'fn url uid'), - $this->profile->fullname); + $this->element('span', 'fn', $this->profile->fullname); $this->elementEnd('dd'); $this->elementEnd('dl'); } - $this->elementStart('dl', 'user_nickname'); $this->element('dt', null, _('Nickname')); $this->elementStart('dd'); - $this->element('span', 'fn nickname', $this->profile->nickname); + $this->element('a', array('href' => $this->profile->profileurl, + 'rel' => 'me', 'class' => 'fn nickname url uid'), + $this->profile->nickname); $this->elementEnd('dd'); $this->elementEnd('dl'); -- cgit v1.2.3-54-g00ecf From ec1249d3ad05b20e06b94dd4052d299eb8c1c17d Mon Sep 17 00:00:00 2001 From: sarven Date: Tue, 20 Jan 2009 04:57:15 +0000 Subject: User statistics markup --- actions/showstream.php | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index 39c74f0ee..ead8521e6 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -455,31 +455,39 @@ class ShowstreamAction extends Action $notices->profile_id = $this->profile->id; $notice_count = (int) $notices->count(); - $this->elementStart('div', array('id' => 'statistics', + $this->elementStart('div', array('id' => 'user_statistics', 'class' => 'section')); - $this->element('h2', 'statistics', _('Statistics')); + $this->element('h2', null, _('Statistics')); // Other stats...? - $this->elementStart('dl', 'statistics'); - $this->element('dt', 'membersince', _('Member since')); - $this->element('dd', 'membersince', date('j M Y', + $this->elementStart('dl', 'user_member-since'); + $this->element('dt', null, _('Member since')); + $this->element('dd', null, date('j M Y', strtotime($this->profile->created))); + $this->elementEnd('dl'); - $this->elementStart('dt', 'subscriptions'); + $this->elementStart('dl', 'user_subscriptions'); + $this->elementStart('dt'); $this->element('a', array('href' => common_local_url('subscriptions', array('nickname' => $this->profile->nickname))), _('Subscriptions')); $this->elementEnd('dt'); - $this->element('dd', 'subscriptions', (is_int($subs_count)) ? $subs_count : '0'); - $this->elementStart('dt', 'subscribers'); + $this->element('dd', null, (is_int($subs_count)) ? $subs_count : '0'); + $this->elementEnd('dl'); + + $this->elementStart('dl', 'user_subscribers'); + $this->elementStart('dt'); $this->element('a', array('href' => common_local_url('subscribers', array('nickname' => $this->profile->nickname))), _('Subscribers')); $this->elementEnd('dt'); $this->element('dd', 'subscribers', (is_int($subbed_count)) ? $subbed_count : '0'); - $this->element('dt', 'notices', _('Notices')); - $this->element('dd', 'notices', (is_int($notice_count)) ? $notice_count : '0'); + $this->elementEnd('dl'); + + $this->elementStart('dl', 'user_notices'); + $this->element('dt', null, _('Notices')); + $this->element('dd', null, (is_int($notice_count)) ? $notice_count : '0'); $this->elementEnd('dl'); $this->elementEnd('div'); -- cgit v1.2.3-54-g00ecf From 7f60558cbbe6f7cd862d9e9cf11667f29d8b08d8 Mon Sep 17 00:00:00 2001 From: sarven Date: Tue, 20 Jan 2009 05:04:41 +0000 Subject: User subscriptions markup --- actions/showstream.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index ead8521e6..23013b007 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -382,14 +382,14 @@ class ShowstreamAction extends Action $subs_count = $subs->find(); - $this->elementStart('div', array('id' => 'subscriptions', + $this->elementStart('div', array('id' => 'user_subscriptions', 'class' => 'section')); $this->element('h2', null, _('Subscriptions')); if ($subs_count > 0) { - $this->elementStart('ul', array('id' => 'subscriptions_avatars')); + $this->elementStart('ul', 'users'); for ($i = 0; $i < min($subs_count, SUBSCRIPTIONS); $i++) { @@ -411,15 +411,16 @@ class ShowstreamAction extends Action $other->nickname, 'href' => $other->profileurl, 'rel' => 'contact', - 'class' => 'subscription fn url')); + 'class' => 'url')); $avatar = $other->getAvatar(AVATAR_MINI_SIZE); $this->element('img', array('src' => (($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_MINI_SIZE)), 'width' => AVATAR_MINI_SIZE, 'height' => AVATAR_MINI_SIZE, - 'class' => 'avatar mini photo', + 'class' => 'avatar photo', 'alt' => ($other->fullname) ? $other->fullname : $other->nickname)); + $this->element('span', 'fn nickname', $other->nickname); $this->elementEnd('a'); $this->elementEnd('li'); } @@ -428,11 +429,11 @@ class ShowstreamAction extends Action } if ($subs_count > SUBSCRIPTIONS) { - $this->elementStart('p', array('id' => 'subscriptions_viewall')); + $this->elementStart('p'); $this->element('a', array('href' => common_local_url('subscriptions', array('nickname' => $this->profile->nickname)), - 'class' => 'moresubscriptions'), + 'class' => 'mores'), _('All subscriptions')); $this->elementEnd('p'); } -- cgit v1.2.3-54-g00ecf From 918bd84c0d22251d30289b6bed41d4d2d417f591 Mon Sep 17 00:00:00 2001 From: sarven Date: Tue, 20 Jan 2009 05:06:46 +0000 Subject: Removed extra div --- actions/showstream.php | 2 -- 1 file changed, 2 deletions(-) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index 23013b007..c8a6db675 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -338,8 +338,6 @@ class ShowstreamAction extends Action } $this->elementEnd('ul'); $this->elementEnd('div'); - - $this->elementEnd('div'); } function showRemoteSubscribeLink() -- cgit v1.2.3-54-g00ecf From 27308afe8509d14ae2efc20cd806fa8541eee017 Mon Sep 17 00:00:00 2001 From: sarven Date: Tue, 20 Jan 2009 05:11:45 +0000 Subject: Added mark_hash for content (i.e., to indicate tags with the character '#') --- actions/showstream.php | 1 + 1 file changed, 1 insertion(+) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index c8a6db675..b877f5df3 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -289,6 +289,7 @@ class ShowstreamAction extends Action $this->elementStart('ul', 'tags xoxo'); foreach ($tags as $tag) { $this->elementStart('li'); + $this->element('span', 'mark_hash', '#'); $this->element('a', array('rel' => 'tag', 'href' => common_local_url('peopletag', array('tag' => $tag))), -- cgit v1.2.3-54-g00ecf From 96dc058bfa499e4acf9248b116eada2009d72371 Mon Sep 17 00:00:00 2001 From: sarven Date: Tue, 20 Jan 2009 05:58:35 +0000 Subject: Using nickname only for uid --- actions/showstream.php | 17 +++++++++-------- theme/base/css/display.css | 17 ++++++++++------- 2 files changed, 19 insertions(+), 15 deletions(-) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index b877f5df3..1d79ea30d 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -239,6 +239,15 @@ class ShowstreamAction extends Action $this->elementEnd('dd'); $this->elementEnd('dl'); + $this->elementStart('dl', 'user_nickname'); + $this->element('dt', null, _('Nickname')); + $this->elementStart('dd'); + $this->element('a', array('href' => $this->profile->profileurl, + 'rel' => 'me', 'class' => 'nickname url uid'), + $this->profile->nickname); + $this->elementEnd('dd'); + $this->elementEnd('dl'); + if ($this->profile->fullname) { $this->elementStart('dl', 'user_fn'); $this->element('dt', null, _('Full name')); @@ -247,14 +256,6 @@ class ShowstreamAction extends Action $this->elementEnd('dd'); $this->elementEnd('dl'); } - $this->elementStart('dl', 'user_nickname'); - $this->element('dt', null, _('Nickname')); - $this->elementStart('dd'); - $this->element('a', array('href' => $this->profile->profileurl, - 'rel' => 'me', 'class' => 'fn nickname url uid'), - $this->profile->nickname); - $this->elementEnd('dd'); - $this->elementEnd('dl'); if ($this->profile->location) { $this->elementStart('dl', 'user_location'); diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 59429cf72..406ba3f9a 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -489,7 +489,7 @@ margin-bottom:0; /* user_profile */ #user_profile { position:relative; -width:633px; +width:475px; min-height:123px; float:left; margin-bottom:17px; @@ -514,7 +514,7 @@ width:96px; #user_profile .user_tags { float:left; clear:left; -margin-left:125px; +margin-left:113px; width:322px; margin-bottom:4px; } @@ -524,21 +524,24 @@ margin-bottom:4px; width:auto; clear:none; } -#user_profile .user_nickname { +#user_profile .user_fn { margin-left:11px; +margin-left:4px; +margin-right:4px; +font-weight:bold; } #user_profile .user_nickname .nickname { font-style:italic; font-weight:bold; -margin-left:4px; -margin-right:4px; } -#user_profile .user_nickname dd:before { +#user_profile .user_fn dd:before { content: "("; +font-weight:normal; } -#user_profile .user_nickname dd:after { +#user_profile .user_fn dd:after { content: ")"; +font-weight:normal; } #user_profile dt { -- cgit v1.2.3-54-g00ecf From f93575bd46db8eb559b6eef6abcab4e13b349748 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 20 Jan 2009 20:29:31 +0000 Subject: uiredesign and phpdocs --- actions/doc.php | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 62 insertions(+), 8 deletions(-) (limited to 'actions') diff --git a/actions/doc.php b/actions/doc.php index 3d14b25b8..fd48ac110 100644 --- a/actions/doc.php +++ b/actions/doc.php @@ -1,5 +1,17 @@ + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + * * Laconica - a distributed open-source microblogging tool * Copyright (C) 2008, Controlez-Vous, Inc. * @@ -17,24 +29,66 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} + +/** + * Documentation class. + * + * @category Action + * @package Laconica + * @author Evan Prodromou + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + +*/ class DocAction extends Action { + var $filename; + var $title; + /** + * Class handler. + * + * @param array $args array of arguments + * + * @return nothing + */ function handle($args) { parent::handle($args); - $title = $this->trimmed('title'); - $filename = INSTALLDIR.'/doc/'.$title; - if (!file_exists($filename)) { + $this->title = $this->trimmed('title'); + $this->filename = INSTALLDIR.'/doc/'.$this->title; + if (!file_exists($this->filename)) { $this->clientError(_('No such document.')); return; } - $c = file_get_contents($filename); + $this->showPage(); + } + + /** + * Display content. + * + * @return nothing + */ + function showContent() + { + $c = file_get_contents($this->filename); $output = common_markup_to_html($c); - common_show_header(_(ucfirst($title))); $this->raw($output); - common_show_footer(); + } + + /** + * Page title. + * + * @return page title + */ + function title() + { + return ucfirst($this->title); } } + -- cgit v1.2.3-54-g00ecf From 15264328420839c5ec3951f306169f5640037bce Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 20 Jan 2009 20:44:03 +0000 Subject: tiny phpdoc fixes --- actions/doc.php | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'actions') diff --git a/actions/doc.php b/actions/doc.php index fd48ac110..aaf006f07 100644 --- a/actions/doc.php +++ b/actions/doc.php @@ -42,9 +42,7 @@ if (!defined('LACONICA')) { * @author Robin Millette * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @link http://laconi.ca/ - - -*/ + */ class DocAction extends Action { var $filename; @@ -56,7 +54,7 @@ class DocAction extends Action * @param array $args array of arguments * * @return nothing - */ + */ function handle($args) { parent::handle($args); @@ -73,7 +71,7 @@ class DocAction extends Action * Display content. * * @return nothing - */ + */ function showContent() { $c = file_get_contents($this->filename); @@ -85,7 +83,7 @@ class DocAction extends Action * Page title. * * @return page title - */ + */ function title() { return ucfirst($this->title); -- cgit v1.2.3-54-g00ecf From 4471f62bc5d883fda015156ec7d3391cc7f3ac41 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 20 Jan 2009 20:55:16 +0000 Subject: uiredesign + phpdocs --- actions/logout.php | 47 +++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 6 deletions(-) (limited to 'actions') diff --git a/actions/logout.php b/actions/logout.php index 86d6270ab..0ff8dc754 100644 --- a/actions/logout.php +++ b/actions/logout.php @@ -1,5 +1,16 @@ + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + * * Laconica - a distributed open-source microblogging tool * Copyright (C) 2008, Controlez-Vous, Inc. * @@ -17,18 +28,42 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/openid.php'); +require_once INSTALLDIR.'/lib/openid.php'; +/** + * Logout action class. + * + * @category Action + * @package Laconica + * @author Evan Prodromou + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + */ class LogoutAction extends Action { + /** + * This is read only. + * + * @return boolean true + */ function isReadOnly() { return true; } - + + /** + * Class handler. + * + * @param array $args array of arguments + * + * @return nothing + */ function handle($args) { parent::handle($args); @@ -36,8 +71,8 @@ class LogoutAction extends Action $this->clientError(_('Not logged in.')); } else { common_set_user(null); - common_real_login(false); # not logged in - common_forgetme(); # don't log back in! + common_real_login(false); // not logged in + common_forgetme(); // don't log back in! common_redirect(common_local_url('public')); } } -- cgit v1.2.3-54-g00ecf From 6e6d651b254b8a890dccadca05bd8c9a450bcabf Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 20 Jan 2009 21:05:55 +0000 Subject: uiredesign + phpdocs. --- actions/microsummary.php | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) (limited to 'actions') diff --git a/actions/microsummary.php b/actions/microsummary.php index b46c5bee5..196dd5de8 100644 --- a/actions/microsummary.php +++ b/actions/microsummary.php @@ -1,5 +1,16 @@ + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + * * Laconica - a distributed open-source microblogging tool * Copyright (C) 2008, Controlez-Vous, Inc. * @@ -17,18 +28,35 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} +/** + * Microsummary action class. + * + * @category Action + * @package Laconica + * @author Evan Prodromou + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + */ class MicrosummaryAction extends Action { - + /** + * Class handler. + * + * @param array $args array of arguments + * + * @return nothing + */ function handle($args) { - parent::handle($args); $nickname = common_canonical_nickname($this->arg('nickname')); - $user = User::staticGet('nickname', $nickname); + $user = User::staticGet('nickname', $nickname); if (!$user) { $this->clientError(_('No such user'), 404); -- cgit v1.2.3-54-g00ecf From cadad553793844e7ef56bab164b1a5866d8d16e7 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 20 Jan 2009 21:21:00 +0000 Subject: uiredesign + phpdocs --- actions/publicrss.php | 80 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 61 insertions(+), 19 deletions(-) (limited to 'actions') diff --git a/actions/publicrss.php b/actions/publicrss.php index 822bc2db7..b98c27205 100644 --- a/actions/publicrss.php +++ b/actions/publicrss.php @@ -1,5 +1,17 @@ + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + * * Laconica - a distributed open-source microblogging tool * Copyright (C) 2008, Controlez-Vous, Inc. * @@ -17,27 +29,45 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } - -require_once(INSTALLDIR.'/lib/rssaction.php'); +if (!defined('LACONICA')) { + exit(1); +} -// Formatting of RSS handled by Rss10Action +require_once INSTALLDIR.'/lib/rssaction.php'; +/** + * Formatting of RSS handled by Rss10Action + * + * @category Action + * @package Laconica + * @author Evan Prodromou + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + */ class PublicrssAction extends Rss10Action { - + /** + * Initialization. + * + * @return boolean true + */ function init() { return true; } - function get_notices($limit=0) + /** + * Get notices + * + * @param integer $limit max number of notices to return + * + * @return array notices + */ + function getNotices($limit=0) { - $notices = array(); - - $notice = Notice::publicStream(0, ($limit == 0) ? 48 : $limit); - + $notice = Notice::publicStream(0, ($limit == 0) ? 48 : $limit); while ($notice->fetch()) { $notices[] = clone($notice); } @@ -45,18 +75,30 @@ class PublicrssAction extends Rss10Action return $notices; } - function get_channel() + /** + * Get channel. + * + * @return array associative array on channel information + */ + function getChannel() { global $config; - $c = array('url' => common_local_url('publicrss'), - 'title' => sprintf(_('%s Public Stream'), $config['site']['name']), - 'link' => common_local_url('public'), - 'description' => sprintf(_('All updates for %s'), $config['site']['name'])); + $c = array( + 'url' => common_local_url('publicrss') + , 'title' => sprintf(_('%s Public Stream'), $config['site']['name']) + , 'link' => common_local_url('public') + , 'description' => sprintf(_('All updates for %s'), $config['site']['name'])); return $c; } - function get_image() + /** + * Get image. + * + * @return nothing + */ + function getImage() { - return null; + // nop } -} \ No newline at end of file +} + -- cgit v1.2.3-54-g00ecf From 1cf469e244692055aab54f2f5c67e5b365767a33 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Tue, 20 Jan 2009 21:31:56 +0000 Subject: uiredesign + phpdocs --- actions/userbyid.php | 54 ++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 10 deletions(-) (limited to 'actions') diff --git a/actions/userbyid.php b/actions/userbyid.php index 4bb896c38..8b0aec057 100644 --- a/actions/userbyid.php +++ b/actions/userbyid.php @@ -1,5 +1,15 @@ + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ * Laconica - a distributed open-source microblogging tool * Copyright (C) 2008, Controlez-Vous, Inc. * @@ -17,16 +27,39 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} +/** + * User by ID action class. + * + * @category Action + * @package Laconica + * @author Evan Prodromou + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + */ class UserbyidAction extends Action { - + /** + * Is read only? + * + * @return boolean true + */ function isReadOnly() { return true; } - + + /** + * Class handler. + * + * @param array $args array of arguments + * + * @return nothing + */ function handle($args) { parent::handle($args); @@ -41,12 +74,13 @@ class UserbyidAction extends Action // support redirecting to FOAF rdf/xml if the agent prefers it $page_prefs = 'application/rdf+xml,text/html,application/xhtml+xml,application/xml;q=0.3,text/xml;q=0.2'; - $httpaccept = isset($_SERVER['HTTP_ACCEPT']) ? $_SERVER['HTTP_ACCEPT'] : null; - $type = common_negotiate_type(common_accept_to_prefs($httpaccept), - common_accept_to_prefs($page_prefs)); - $page = $type == 'application/rdf+xml' ? 'foaf' : 'showstream'; - - $url = common_local_url($page, array('nickname' => $user->nickname)); + $httpaccept = isset($_SERVER['HTTP_ACCEPT']) + ? $_SERVER['HTTP_ACCEPT'] : null; + $type = common_negotiate_type(common_accept_to_prefs($httpaccept), + common_accept_to_prefs($page_prefs)); + $page = $type == 'application/rdf+xml' ? 'foaf' : 'showstream'; + $url = common_local_url($page, array('nickname' => $user->nickname)); common_redirect($url, 303); } } + -- cgit v1.2.3-54-g00ecf From bb4a6a514bb62a0fef2314512c121951a40437e7 Mon Sep 17 00:00:00 2001 From: sarven Date: Tue, 20 Jan 2009 22:36:57 +0000 Subject: user_actions form markup and styling --- actions/showstream.php | 1 + lib/blockform.php | 15 ++++++++++++++- lib/subscribeform.php | 2 +- lib/unblockform.php | 13 ++++++++++++- lib/unsubscribeform.php | 2 +- theme/base/css/display.css | 30 ++++++++++++------------------ theme/identica/css/display.css | 35 +++++++++++++++++++++++------------ 7 files changed, 64 insertions(+), 34 deletions(-) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index 1d79ea30d..d550ec295 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -22,6 +22,7 @@ * @category Personal * @package Laconica * @author Evan Prodromou + * @author Sarven Capadisli * @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/ diff --git a/lib/blockform.php b/lib/blockform.php index 51e43f8b5..b7790681d 100644 --- a/lib/blockform.php +++ b/lib/blockform.php @@ -88,6 +88,19 @@ class BlockForm extends Form return 'block-' . $this->profile->id; } + + /** + * class of the form + * + * @return string class of the form + */ + + function formClass() + { + return 'form_user_block'; + } + + /** * Action of the form * @@ -127,4 +140,4 @@ class BlockForm extends Form { $this->out->submit('submit', _('Block')); } -} \ No newline at end of file +} diff --git a/lib/subscribeform.php b/lib/subscribeform.php index 8b69efd1a..231e740a7 100644 --- a/lib/subscribeform.php +++ b/lib/subscribeform.php @@ -89,7 +89,7 @@ class SubscribeForm extends Form function formClass() { - return 'form_subscribe'; + return 'form_user_subscribe'; } diff --git a/lib/unblockform.php b/lib/unblockform.php index 4cb9ae4f5..025011a82 100644 --- a/lib/unblockform.php +++ b/lib/unblockform.php @@ -88,6 +88,17 @@ class UnblockForm extends Form return 'unblock-' . $this->profile->id; } + /** + * class of the form + * + * @return string class of the form + */ + + function formClass() + { + return 'form_user_unblock'; + } + /** * Action of the form * @@ -127,4 +138,4 @@ class UnblockForm extends Form { $this->out->submit('submit', _('Unblock')); } -} \ No newline at end of file +} diff --git a/lib/unsubscribeform.php b/lib/unsubscribeform.php index b222f0e54..092369db7 100644 --- a/lib/unsubscribeform.php +++ b/lib/unsubscribeform.php @@ -89,7 +89,7 @@ class UnsubscribeForm extends Form function formClass() { - return 'form_unsubscribe'; + return 'form_user_unsubscribe'; } /** diff --git a/theme/base/css/display.css b/theme/base/css/display.css index 3c776aea0..fc1f35e35 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -570,8 +570,7 @@ display:none; list-style-type:none; } #user_actions li { -border-top-width:1px; -border-top-style:dotted; +margin-bottom:4px; } #user_actions li:first-child { border-top:0; @@ -584,34 +583,29 @@ padding:0; display:none; } -#user_actions a, #user_actions input.submit { display:block; text-align:left; -padding:4px 0 4px 19px; +cursor:pointer; +width:100%; } #user_actions a { text-decoration:none; } -#user_subscribe a, -#TB_window input.submit, -#user_actions input.submit { -border:0; -cursor:pointer; -padding-left:16px; -width:100%; -font-size:0.9em; -} -#user_subscribe a { -width:auto; + + +.form_user_block input.submit, +.form_user_unblock input.submit { +border:0; padding-left:20px; } -#user_subscribe a, -#TB_window input.submit, + + +#user_subscribe input.submit, .form_user_subscribe input.submit { -font-weight:bold; + } diff --git a/theme/identica/css/display.css b/theme/identica/css/display.css index d5a5ce956..eb5f78b9e 100644 --- a/theme/identica/css/display.css +++ b/theme/identica/css/display.css @@ -125,30 +125,41 @@ background-image:url(../../base/images/icons/icon_vcard.gif); /*user_actions*/ #user_actions li { -border-top-color:#eee; +/*border-top-color:#eee;*/ } -#user_subscribe a, -#TB_window input.submit, -.form_user_subscribe input.submit { -background-image: url(../images/icons/twotone/green/shield.gif); -background-position: 0 45%; + + +.form_user_send-a-message input.submit, +.form_user_nudge input.submit, +.form_user_block input.submit, +.form_user_unblock input.submit { +background-position: 0 40%; background-repeat: no-repeat; +background-color:transparent; } +.form_user_subscribe input.submit, .form_user_unsubscribe input.submit { -background-color:#647819; +background-color:#A9BF4F; color:#fff; } +.form_user_unsubscribe input.submit { +background-color:#97BFD1; +} + #user_send-a-message a { -background:url(../images/icons/twotone/green/quote.gif) 0 45% no-repeat; +background-image:url(../images/icons/twotone/green/quote.gif); } .form_user_nudge input.submit { -background:url(../images/icons/twotone/green/mail.gif) 0 45% no-repeat; +background-image:url(../images/icons/twotone/green/mail.gif); } -.form_user_block input.submit { -background:url(../images/icons/twotone/green/against.gif) 0 45% no-repeat; +.form_user_block input.submit, +.form_user_unblock input.submit { +background-image:url(../images/icons/twotone/green/shield.gif); +color:#000; } + /* NOTICES */ .notices li.over { background-color:#fcfcfc; @@ -242,4 +253,4 @@ background-color:#0f0; } #home #intro #step_create-a-community a { background-color:#00f; -} \ No newline at end of file +} -- cgit v1.2.3-54-g00ecf From 1ab0de3ddd863703648bdaedf92a2ae6cc7eb6ff Mon Sep 17 00:00:00 2001 From: sarven Date: Tue, 20 Jan 2009 23:50:52 +0000 Subject: If user has fn, then it will not link to their own profile with @class 'fn'. Only put @class 'fn' on the anchor if there is no fn. --- actions/showstream.php | 7 ++++--- lib/profilelist.php | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index d550ec295..3fe71576d 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -243,9 +243,10 @@ class ShowstreamAction extends Action $this->elementStart('dl', 'user_nickname'); $this->element('dt', null, _('Nickname')); $this->elementStart('dd'); - $this->element('a', array('href' => $this->profile->profileurl, - 'rel' => 'me', 'class' => 'nickname url uid'), - $this->profile->nickname); + $hasFN = ($this->profile->fullname) ? 'nickname url uid' : 'fn nickname url uid'; + $this->element('a', array('href' => $this->profile->profileurl, + 'rel' => 'me', 'class' => $hasFN), + $this->profile->nickname); $this->elementEnd('dd'); $this->elementEnd('dl'); diff --git a/lib/profilelist.php b/lib/profilelist.php index 24b357385..973df7bb6 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -87,7 +87,7 @@ class ProfileList extends Widget function showProfile() { - $this->out->elementStart('li', array('class' => 'profile vcard', + $this->out->elementStart('li', array('class' => 'profile', 'id' => 'profile-' . $this->profile->id)); $user = common_current_user(); -- cgit v1.2.3-54-g00ecf From 592403cdc362e52f70570e6ba59afaa4857664fb Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Wed, 21 Jan 2009 00:06:56 +0000 Subject: uiredesign + phpdocs --- actions/nudge.php | 58 +++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 48 insertions(+), 10 deletions(-) (limited to 'actions') diff --git a/actions/nudge.php b/actions/nudge.php index 49223d431..bb80ce357 100644 --- a/actions/nudge.php +++ b/actions/nudge.php @@ -1,5 +1,17 @@ + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + * * Laconica - a distributed open-source microblogging tool * Copyright (C) 2008, Controlez-Vous, Inc. * @@ -17,13 +29,31 @@ * along with this program. If not, see . */ -if (!defined('LACONICA')) { exit(1); } +if (!defined('LACONICA')) { + exit(1); +} -require_once(INSTALLDIR.'/lib/mail.php'); +require_once INSTALLDIR.'/lib/mail.php'; +/** + * Nudge a user action class. + * + * @category Action + * @package Laconica + * @author Evan Prodromou + * @author Robin Millette + * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 + * @link http://laconi.ca/ + */ class NudgeAction extends Action { - + /** + * Class handler. + * + * @param array $args array of arguments + * + * @return nothing + */ function handle($args) { parent::handle($args); @@ -33,16 +63,16 @@ class NudgeAction extends Action return; } - $user = common_current_user(); + $user = common_current_user(); $other = User::staticGet('nickname', $this->arg('nickname')); if ($_SERVER['REQUEST_METHOD'] != 'POST') { - common_redirect(common_local_url('showstream', array('nickname' => $other->nickname))); + common_redirect(common_local_url('showstream', + array('nickname' => $other->nickname))); return; } - # CSRF protection - + // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { @@ -73,14 +103,22 @@ class NudgeAction extends Action } } + /** + * Do the actual notification + * + * @param class $user nudger + * @param class $other nudgee + * + * @return nothing + */ function notify($user, $other) { if ($other->id != $user->id) { if ($other->email && $other->emailnotifynudge) { mail_notify_nudge($user, $other); } - # XXX: notify by IM - # XXX: notify by SMS + // XXX: notify by IM + // XXX: notify by SMS } } } -- cgit v1.2.3-54-g00ecf From 560374e1702babd53f588c868f0189e2f935b5e7 Mon Sep 17 00:00:00 2001 From: Robin Millette Date: Wed, 21 Jan 2009 00:07:15 +0000 Subject: uiredesign + phpdocs --- actions/userbyid.php | 2 ++ 1 file changed, 2 insertions(+) (limited to 'actions') diff --git a/actions/userbyid.php b/actions/userbyid.php index 8b0aec057..1e30d1aac 100644 --- a/actions/userbyid.php +++ b/actions/userbyid.php @@ -1,4 +1,5 @@ * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3 * @link http://laconi.ca/ + * Laconica - a distributed open-source microblogging tool * Copyright (C) 2008, Controlez-Vous, Inc. * -- cgit v1.2.3-54-g00ecf From f51984175a7f14d9fdc07a7ef4434bb06acf5d34 Mon Sep 17 00:00:00 2001 From: sarven Date: Wed, 21 Jan 2009 01:22:08 +0000 Subject: Matching markup for tags --- actions/showstream.php | 2 +- lib/profilelist.php | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'actions') diff --git a/actions/showstream.php b/actions/showstream.php index 3fe71576d..3882af845 100644 --- a/actions/showstream.php +++ b/actions/showstream.php @@ -288,7 +288,7 @@ class ShowstreamAction extends Action if (count($tags) > 0) { $this->elementStart('dl', 'user_tags'); $this->element('dt', null, _('Tags')); - $this->elementStart('dd', 'tags'); + $this->elementStart('dd'); $this->elementStart('ul', 'tags xoxo'); foreach ($tags as $tag) { $this->elementStart('li'); diff --git a/lib/profilelist.php b/lib/profilelist.php index b2a9925c1..f7ed5d19c 100644 --- a/lib/profilelist.php +++ b/lib/profilelist.php @@ -156,8 +156,7 @@ class ProfileList extends Widget # Get tags $tags = Profile_tag::getTags($this->owner->id, $this->profile->id); - $this->out->elementStart('div', 'tags_user'); - $this->out->elementStart('dl'); + $this->out->elementStart('dl', 'user_tags'); $this->out->elementStart('dt'); if ($user->id == $this->owner->id) { $this->out->element('a', array('href' => common_local_url('tagother', @@ -166,13 +165,13 @@ class ProfileList extends Widget } else { $this->out->text(_('Tags')); } - $this->out->text(":"); $this->out->elementEnd('dt'); $this->out->elementStart('dd'); if ($tags) { $this->out->elementStart('ul', 'tags xoxo'); foreach ($tags as $tag) { $this->out->elementStart('li'); + $this->element('span', 'mark_hash', '#'); $this->out->element('a', array('rel' => 'tag', 'href' => common_local_url($this->action, array('nickname' => $this->owner->nickname, @@ -186,7 +185,6 @@ class ProfileList extends Widget } $this->out->elementEnd('dd'); $this->out->elementEnd('dl'); - $this->out->elementEnd('div'); } if ($user && $user->id == $this->owner->id) { -- cgit v1.2.3-54-g00ecf From 624ca93c9d2a55d7acfca453ba22268d09154dab Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 20 Jan 2009 17:49:47 -0800 Subject: Converted direct messaging actions to new uiredesign --- actions/inbox.php | 51 +++++------ actions/newmessage.php | 123 ++++++++++++++++--------- actions/outbox.php | 31 +++---- lib/mailbox.php | 237 +++++++++++++++++++++++-------------------------- lib/personal.php | 43 +++++++-- 5 files changed, 264 insertions(+), 221 deletions(-) (limited to 'actions') diff --git a/actions/inbox.php b/actions/inbox.php index da27814a6..b553ab26c 100644 --- a/actions/inbox.php +++ b/actions/inbox.php @@ -46,66 +46,57 @@ require_once INSTALLDIR.'/lib/mailbox.php'; class InboxAction extends MailboxAction { + /** - * returns the title of the page + * Title of the page * - * @param User $user current user - * @param int $page current page - * - * @return string localised title of the page - * - * @see MailboxAction::getTitle() + * @return string page title */ - - function getTitle($user, $page) - { - if ($page > 1) { - $title = sprintf(_("Inbox for %s - page %d"), $user->nickname, $page); + + function title() + { + if ($this->page > 1) { + return sprintf(_("Inbox for %s - page %d"), $this->user->nickname, + $this->page); } else { - $title = sprintf(_("Inbox for %s"), $user->nickname); + return sprintf(_("Inbox for %s"), $this->user->nickname); } - return $title; } /** - * retrieve the messages for this user and this page + * Retrieve the messages for this user and this page * * Does a query for the right messages - * - * @param User $user The current user - * @param int $page The page the user is on - * + * * @return Message data object with stream for messages * * @see MailboxAction::getMessages() */ - function getMessages($user, $page) + function getMessages() { $message = new Message(); - $message->to_profile = $user->id; - + $message->to_profile = $this->user->id; $message->orderBy('created DESC, id DESC'); - $message->limit((($page-1)*MESSAGES_PER_PAGE), MESSAGES_PER_PAGE + 1); + $message->limit((($this->page - 1) * MESSAGES_PER_PAGE), + MESSAGES_PER_PAGE + 1); if ($message->find()) { return $message; - } else { + } else { return null; } } /** - * returns the profile we want to show with the message + * Returns the profile we want to show with the message * - * For inboxes, we show the sender. + * For inboxes, we show the sender; for outboxes, the recipient. * * @param Message $message The message to get the profile for * - * @return Profile The profile of the message sender - * - * @see MailboxAction::getMessageProfile() + * @return Profile The profile that matches the message */ function getMessageProfile($message) @@ -114,7 +105,7 @@ class InboxAction extends MailboxAction } /** - * instructions for using this page + * Instructions for using this page * * @return string localised instructions for using the page */ diff --git a/actions/newmessage.php b/actions/newmessage.php index 510a5f8f3..aa94f8c4f 100644 --- a/actions/newmessage.php +++ b/actions/newmessage.php @@ -1,9 +1,12 @@ . + * + * @category Personal + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @author Sarven Capadisli + * @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); +} -if (!defined('LACONICA')) { exit(1); } +/** + * Action for posting new direct messages + * + * @category Personal + * @package Laconica + * @author Evan Prodromou + * @author Zach Copley + * @author Sarven Capadisli + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://laconi.ca/ + */ class NewmessageAction extends Action { + /** + * Error message, if any + */ + + var $msg = null; + + /** + * Title of the page + * + * Note that this usually doesn't get called unless something went wrong + * + * @return string page title + */ + + function title() + { + return _('New message'); + } + + /** + * Handle input, produce output + * + * @param array $args $_REQUEST contents + * + * @return void + */ + function handle($args) { parent::handle($args); @@ -29,38 +82,42 @@ class NewmessageAction extends Action if (!common_logged_in()) { $this->clientError(_('Not logged in.'), 403); } else if ($_SERVER['REQUEST_METHOD'] == 'POST') { - $this->save_new_message(); + $this->saveNewMessage(); } else { - $this->show_form(); + $this->showForm(); } } - function save_new_message() + function saveNewMessage() { $user = common_current_user(); - assert($user); # XXX: maybe an error instead... + assert($user); // XXX: maybe an error instead... - # CSRF protection + // CSRF protection $token = $this->trimmed('token'); if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); + $this->showForm(_('There was a problem with your session token. ' . + 'Try again, please.')); return; } $content = $this->trimmed('content'); - $to = $this->trimmed('to'); + $to = $this->trimmed('to'); if (!$content) { - $this->show_form(_('No content!')); + $this->showForm(_('No content!')); return; } else { $content_shortened = common_shorten_links($content); if (mb_strlen($content_shortened) > 140) { common_debug("Content = '$content_shortened'", __FILE__); - common_debug("mb_strlen(\$content) = " . mb_strlen($content_shortened), __FILE__); - $this->show_form(_('That\'s too long. Max message size is 140 chars.')); + common_debug("mb_strlen(\$content) = " . + mb_strlen($content_shortened), + __FILE__); + $this->showForm(_('That\'s too long. ' . + 'Max message size is 140 chars.')); return; } } @@ -68,20 +125,21 @@ class NewmessageAction extends Action $other = User::staticGet('id', $to); if (!$other) { - $this->show_form(_('No recipient specified.')); + $this->showForm(_('No recipient specified.')); return; } else if (!$user->mutuallySubscribed($other)) { $this->clientError(_('You can\'t send a message to this user.'), 404); return; } else if ($user->id == $other->id) { - $this->clientError(_('Don\'t send a message to yourself; just say it to yourself quietly instead.'), 403); + $this->clientError(_('Don\'t send a message to yourself; ' . + 'just say it to yourself quietly instead.'), 403); return; } $message = Message::saveNew($user->id, $other->id, $content, 'web'); if (is_string($message)) { - $this->show_form($message); + $this->showForm($message); return; } @@ -92,21 +150,10 @@ class NewmessageAction extends Action common_redirect($url, 303); } - function show_top($params) + function showForm($msg = null) { - - list($content, $user, $to) = $params; - - assert(!is_null($user)); - - common_message_form($content, $user, $to); - } - - function show_form($msg=null) - { - $content = $this->trimmed('content'); - $user = common_current_user(); + $user = common_current_user(); $to = $this->trimmed('to'); @@ -120,22 +167,16 @@ class NewmessageAction extends Action if (!$user->mutuallySubscribed($other)) { $this->clientError(_('You can\'t send a message to this user.'), 404); return; - } + } - common_show_header(_('New message'), null, - array($content, $user, $other), - array($this, 'show_top')); - - if ($msg) { - $this->element('p', array('id'=>'error'), $msg); - } + $this->msg = $msg; - common_show_footer(); + $this->showPage(); } function notify($from, $to, $message) { mail_notify_message($message, $from, $to); - # XXX: Jabber, SMS notifications... probably queued + // XXX: Jabber, SMS notifications... probably queued } } diff --git a/actions/outbox.php b/actions/outbox.php index 9fb6dbf9f..c8d7f2812 100644 --- a/actions/outbox.php +++ b/actions/outbox.php @@ -47,46 +47,39 @@ require_once INSTALLDIR.'/lib/mailbox.php'; class OutboxAction extends MailboxAction { /** - * returns the title of the page + * Title of the page * - * @param User $user current user - * @param int $page current page - * - * @return string localised title of the page - * - * @see MailboxAction::getTitle() + * @return string page title */ - function getTitle($user, $page) + function title() { - if ($page > 1) { - $title = sprintf(_("Outbox for %s - page %d"), $user->nickname, $page); + if ($this->page > 1) { + return sprintf(_("Outbox for %s - page %d"), + $this->user->nickname, $page); } else { - $title = sprintf(_("Outbox for %s"), $user->nickname); + return sprintf(_("Outbox for %s"), $this->user->nickname); } - return $title; } /** * retrieve the messages for this user and this page * * Does a query for the right messages - * - * @param User $user The current user - * @param int $page The page the user is on - * + * * @return Message data object with stream for messages * * @see MailboxAction::getMessages() */ - function getMessages($user, $page) + function getMessages() { $message = new Message(); - $message->from_profile = $user->id; + $message->from_profile = $this->user->id; $message->orderBy('created DESC, id DESC'); - $message->limit((($page-1)*MESSAGES_PER_PAGE), MESSAGES_PER_PAGE + 1); + $message->limit((($this->page - 1) * MESSAGES_PER_PAGE), + MESSAGES_PER_PAGE + 1); if ($message->find()) { return $message; diff --git a/lib/mailbox.php b/lib/mailbox.php index bdc360a35..9af0dbd2f 100644 --- a/lib/mailbox.php +++ b/lib/mailbox.php @@ -49,6 +49,23 @@ define('MESSAGES_PER_PAGE', 20); class MailboxAction extends PersonalAction { + var $page = null; + + function prepare($args) + { + parent::prepare($args); + + $nickname = common_canonical_nickname($this->arg('nickname')); + $this->user = User::staticGet('nickname', $nickname); + $this->page = $this->trimmed('page'); + + if (!$this->page) { + $this->page = 1; + } + + return true; + } + /** * output page based on arguments * @@ -61,134 +78,42 @@ class MailboxAction extends PersonalAction { parent::handle($args); - $nickname = common_canonical_nickname($this->arg('nickname')); - - $user = User::staticGet('nickname', $nickname); - - if (!$user) { - $this->client_error(_('No such user.'), 404); + if (!$this->user) { + $this->clientError(_('No such user.'), 404); return; } $cur = common_current_user(); - if (!$cur || $cur->id != $user->id) { - $this->client_error(_('Only the user can read their own mailboxes.'), - 403); - return; - } - - $profile = $user->getProfile(); - - if (!$profile) { - $this->server_error(_('User has no profile.')); + if (!$cur || $cur->id != $this->user->id) { + $this->clientError(_('Only the user can read their own mailboxes.'), + 403); return; } - $page = $this->trimmed('page'); - - if (!$page) { - $page = 1; - } - - $this->showPage($user, $page); + $this->showPage(); } - /** - * returns the title of the page - * - * @param User $user current user - * @param int $page current page - * - * @return string localised title of the page - */ - - function getTitle($user, $page) + function showLocalNav() { - return ''; + $nav = new PersonalGroupNav($this); + $nav->show(); } - /** - * instructions for using this page - * - * @return string localised instructions for using the page - */ - - function getInstructions() + function showNoticeForm() { - return ''; + $message_form = new MessageForm($this); + $message_form->show(); } - /** - * do structured output for the "instructions" are of the page - * - * @return void - */ - - function showTop() + function showContent() { - $cur = common_current_user(); - - common_message_form(null, $cur, null); - - $this->views_menu(); - } - - /** - * show a full page of output - * - * @param User $user The current user - * @param int $page The page the user is on - * - * @return void - */ - - function showPage($user, $page) - { - common_show_header($this->getTitle($user, $page), - null, null, - array($this, 'showTop')); - - $this->showBox($user, $page); - - common_show_footer(); - } - - /** - * retrieve the messages appropriate for this mailbox - * - * Does a query for the right messages - * - * @param User $user The current user - * @param int $page The page the user is on - * - * @return Message data object with stream for messages - */ - - function getMessages($user, $page) - { - return null; - } - - /** - * show the messages for a mailbox in list format - * - * Includes the pagination links (before, after). - * - * @param User $user The current user - * @param int $page The page the user is on - * - * @return void - */ - - function showBox($user, $page) - { - $message = $this->getMessages($user, $page); + $message = $this->getMessages(); if ($message) { $cnt = 0; - common_element_start('ul', array('id' => 'messages')); + $this->elementStart('ul', array('id' => 'messages')); while ($message->fetch() && $cnt <= MESSAGES_PER_PAGE) { $cnt++; @@ -200,17 +125,22 @@ class MailboxAction extends PersonalAction $this->showMessage($message); } - common_element_end('ul'); + $this->elementEnd('ul'); - common_pagination($page > 1, $cnt > MESSAGES_PER_PAGE, - $page, $this->trimmed('action'), - array('nickname' => $user->nickname)); + $this->pagination($this->page > 1, $cnt > MESSAGES_PER_PAGE, + $this->page, $this->trimmed('action'), + array('nickname' => $this->user->nickname)); $message->free(); unset($message); } } + function getMessages() + { + return null; + } + /** * returns the profile we want to show with the message * @@ -229,6 +159,9 @@ class MailboxAction extends PersonalAction /** * show a single message in the list format * + * XXX: This needs to be extracted out into a MessageList similar + * to NoticeList. + * * @param Message $message the message to show * * @return void @@ -236,14 +169,14 @@ class MailboxAction extends PersonalAction function showMessage($message) { - common_element_start('li', array('class' => 'message_single', + $this->elementStart('li', array('class' => 'message_single', 'id' => 'message-' . $message->id)); $profile = $this->getMessageProfile($message); $avatar = $profile->getAvatar(AVATAR_STREAM_SIZE); - common_element_start('a', array('href' => $profile->profileurl)); - common_element('img', array('src' => ($avatar) ? + $this->elementStart('a', array('href' => $profile->profileurl)); + $this->element('img', array('src' => ($avatar) ? common_avatar_display_url($avatar) : common_default_avatar(AVATAR_STREAM_SIZE), 'class' => 'avatar stream', @@ -252,14 +185,14 @@ class MailboxAction extends PersonalAction 'alt' => ($profile->fullname) ? $profile->fullname : $profile->nickname)); - common_element_end('a'); - common_element('a', array('href' => $profile->profileurl, + $this->elementEnd('a'); + $this->element('a', array('href' => $profile->profileurl, 'class' => 'nickname'), $profile->nickname); // FIXME: URL, image, video, audio - common_element_start('p', array('class' => 'content')); - common_raw($message->rendered); - common_element_end('p'); + $this->elementStart('p', array('class' => 'content')); + $this->raw($message->rendered); + $this->elementEnd('p'); $messageurl = common_local_url('showmessage', array('message' => $message->id)); @@ -269,18 +202,72 @@ class MailboxAction extends PersonalAction preg_match('/^http/', $message->uri)) { $messageurl = $message->uri; } - common_element_start('p', 'time'); - common_element('a', array('class' => 'permalink', + $this->elementStart('p', 'time'); + $this->element('a', array('class' => 'permalink', 'href' => $messageurl, 'title' => common_exact_date($message->created)), common_date_string($message->created)); if ($message->source) { - common_text(_(' from ')); - $this->source_link($message->source); + $this->text(_(' from ')); + $this->showSource($message->source); } - common_element_end('p'); + $this->elementEnd('p'); - common_element_end('li'); + $this->elementEnd('li'); } + + /** + * Show the page notice + * + * Shows instructions for the page + * + * @return void + */ + + function showPageNotice() + { + $instr = $this->getInstructions(); + $output = common_markup_to_html($instr); + + $this->elementStart('div', 'instructions'); + $this->raw($output); + $this->elementEnd('div'); + } + + /** + * Show the source of the message + * + * Returns either the name (and link) of the API client that posted the notice, + * or one of other other channels. + * + * @param string $source the source of the message + * + * @return void + */ + + function showSource($source) + { + $source_name = _($source); + switch ($source) { + case 'web': + case 'xmpp': + case 'mail': + case 'omb': + case 'api': + $this->element('span', 'noticesource', $source_name); + break; + default: + $ns = Notice_source::staticGet($source); + if ($ns) { + $this->element('a', array('href' => $ns->url), + $ns->name); + } else { + $this->element('span', 'noticesource', $source_name); + } + break; + } + return; + } + } diff --git a/lib/personal.php b/lib/personal.php index 46f9ff6be..900df0257 100644 --- a/lib/personal.php +++ b/lib/personal.php @@ -1,9 +1,12 @@ . + * + * @category Personal + * @package Laconica + * @author Evan Prodromou + * @author Sarven Capadisli + * @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); } +if (!defined('LACONICA')) { + exit(1); +} + +/** + * Base class for user profile page + * + * @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 PersonalAction extends Action { + + var $user = null; + + function isReadOnly() + { + return true; + } + function handle($args) { parent::handle($args); - common_set_returnto($this->self_url()); + common_set_returnto($this->selfUrl()); } } -- cgit v1.2.3-54-g00ecf From e9b9795eeb30837ddddd980eaea9d11c055cb843 Mon Sep 17 00:00:00 2001 From: sarven Date: Wed, 21 Jan 2009 02:52:16 +0000 Subject: (dis)favor form method call fix --- actions/disfavor.php | 5 ++++- actions/favor.php | 4 +++- theme/base/css/display.css | 6 +++--- 3 files changed, 10 insertions(+), 5 deletions(-) (limited to 'actions') diff --git a/actions/disfavor.php b/actions/disfavor.php index 3e3e4a547..d4a189d19 100644 --- a/actions/disfavor.php +++ b/actions/disfavor.php @@ -19,6 +19,8 @@ if (!defined('LACONICA')) { exit(1); } +require_once INSTALLDIR.'/lib/favorform.php'; + class DisfavorAction extends Action { @@ -74,7 +76,8 @@ class DisfavorAction extends Action $this->element('title', null, _('Add to favorites')); $this->elementEnd('head'); $this->elementStart('body'); - common_favor_form($notice); + $favor = new FavorForm($this, $notice); + $favor->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { diff --git a/actions/favor.php b/actions/favor.php index afda93cff..92756366d 100644 --- a/actions/favor.php +++ b/actions/favor.php @@ -20,6 +20,7 @@ if (!defined('LACONICA')) { exit(1); } require_once(INSTALLDIR.'/lib/mail.php'); +require_once INSTALLDIR.'/lib/disfavorform.php'; class FavorAction extends Action { @@ -73,7 +74,8 @@ class FavorAction extends Action $this->element('title', null, _('Disfavor favorite')); $this->elementEnd('head'); $this->elementStart('body'); - common_disfavor_form($notice); + $disfavor = new DisFavorForm($this, $notice); + $disfavor->show(); $this->elementEnd('body'); $this->elementEnd('html'); } else { diff --git a/theme/base/css/display.css b/theme/base/css/display.css index f0bf6bfc1..d2480be14 100644 --- a/theme/base/css/display.css +++ b/theme/base/css/display.css @@ -706,7 +706,7 @@ float:none; } .profile #user_profile .user_note, .profile #user_profile .user_url { -margin-left:55px; +margin-left:59px; clear:none; display:block; width:auto; @@ -767,8 +767,8 @@ margin-right:11px; .vcard .photo { display:inline; -margin-right:7px; -margin-bottom:7px; +margin-right:11px; +margin-bottom:11px; float:left; } .vcard .url { -- cgit v1.2.3-54-g00ecf From 61850ceb5575c0fab8bd70bbe924543b09a2d765 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Tue, 20 Jan 2009 19:16:52 -0800 Subject: Converted ShowmessageAction to work with new uiredesign --- actions/showmessage.php | 189 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 130 insertions(+), 59 deletions(-) (limited to 'actions') diff --git a/actions/showmessage.php b/actions/showmessage.php index d13e9f671..289414153 100644 --- a/actions/showmessage.php +++ b/actions/showmessage.php @@ -1,9 +1,12 @@ . + * + * @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); +} -if (!defined('LACONICA')) { exit(1); } +require_once INSTALLDIR.'/lib/mailbox.php'; -require_once(INSTALLDIR.'/lib/mailbox.php'); +/** + * Show a single message + * + * // XXX: It is totally weird how this works! + * + * @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 ShowmessageAction extends MailboxAction { + /** + * Message object to show + */ - function handle($args) - { + var $message = null; + + /** + * The current user + */ + + var $user = null; - Action::handle($args); + /** + * Load attributes based on database arguments + * + * Loads all the DB stuff + * + * @param array $args $_REQUEST array + * + * @return success flag + */ - $message = $this->get_message(); + function prepare($args) + { + parent::prepare($args); + + $this->page = 1; + + $id = $this->trimmed('message'); + $this->message = Message::staticGet('id', $id); - if (!$message) { + if (!$this->message) { $this->clientError(_('No such message.'), 404); - return; + return false; } - - $cur = common_current_user(); - - if ($cur && ($cur->id == $message->from_profile || $cur->id == $message->to_profile)) { - $this->show_page($cur, 1); + + $this->user = common_current_user(); + + return true; + } + + function handle($args) + { + Action::handle($args); + + if ($this->user && ($this->user->id == $this->message->from_profile || + $this->user->id == $this->message->to_profile)) { + $this->showPage(); } else { - $this->clientError(_('Only the sender and recipient may read this message.'), 403); + $this->clientError(_('Only the sender and recipient ' . + 'may read this message.'), 403); return; } } - function get_message() - { - $id = $this->trimmed('message'); - $message = Message::staticGet('id', $id); - return $message; - } - - function get_title($user, $page) - { - $message = $this->get_message(); - if (!$message) { - return null; - } - - if ($user->id == $message->from_profile) { - $to = $message->getTo(); - $title = sprintf(_("Message to %1\$s on %2\$s"), + function title() + { + if ($this->user->id == $this->message->from_profile) { + $to = $this->message->getTo(); + return sprintf(_("Message to %1\$s on %2\$s"), $to->nickname, - common_exact_date($message->created)); - } else if ($user->id == $message->to_profile) { - $from = $message->getFrom(); - $title = sprintf(_("Message from %1\$s on %2\$s"), + common_exact_date($this->message->created)); + } else if ($this->user->id == $this->message->to_profile) { + $from = $this->message->getFrom(); + return sprintf(_("Message from %1\$s on %2\$s"), $from->nickname, - common_exact_date($message->created)); + common_exact_date($this->message->created)); } - return $title; } - - function get_messages($user, $page) - { - $message = new Message(); - $message->id = $this->trimmed('message'); + + function getMessages() + { + $message = new Message(); + $message->id = $this->message->id; $message->find(); return $message; } - function get_message_profile($message) + function getMessageProfile() { - $user = common_current_user(); - if ($user->id == $message->from_profile) { - return $message->getTo(); - } else if ($user->id == $message->to_profile) { - return $message->getFrom(); + if ($this->user->id == $this->message->from_profile) { + return $this->message->getTo(); + } else if ($this->user->id == $this->message->to_profile) { + return $this->message->getFrom(); } else { - # This shouldn't happen + // This shouldn't happen return null; } } - function get_instructions() + /** + * Don't show local navigation + * + * @return void + */ + + function showLocalNavBlock() { - return ''; } - function views_menu() + /** + * Don't show page notice + * + * @return void + */ + + function showPageNoticeBlock() { - return; } -} - \ No newline at end of file + + /** + * Don't show aside + * + * @return void + */ + + function showAside() + { + } + + /** + * Don't show any instructions + * + * @return string + */ + + function getInstructions() + { + return ''; + } +} \ No newline at end of file -- cgit v1.2.3-54-g00ecf From afde3c62d8d95b892fe095cb54822c2e7c062ca6 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 21 Jan 2009 03:59:30 +0000 Subject: Remove deleteprofile.php --- actions/deleteprofile.php | 289 ---------------------------------------------- 1 file changed, 289 deletions(-) delete mode 100644 actions/deleteprofile.php (limited to 'actions') diff --git a/actions/deleteprofile.php b/actions/deleteprofile.php deleted file mode 100644 index cc236f847..000000000 --- a/actions/deleteprofile.php +++ /dev/null @@ -1,289 +0,0 @@ -. - */ - -if (!defined('LACONICA')) { exit(1); } - -class DeleteprofileAction extends Action -{ - function handle($args) - { - parent::handle($args); - $this->serverError(_('Code not yet ready.')); - return; - if ('POST' === $_SERVER['REQUEST_METHOD']) { - $this->handle_post(); - } - else if ('GET' === $_SERVER['REQUEST_METHOD']) { - $this->show_form(); - } - } - - function get_instructions() - { - return _('Export and delete your user information.'); - } - - function form_header($title, $msg=null, $success=false) - { - common_show_header($title, - null, - array($msg, $success), - array($this, 'show_top')); - } - - function show_feeds_list($feeds) - { - $this->elementStart('div', array('class' => 'feedsdel')); - $this->element('p', null, 'Feeds:'); - $this->elementStart('ul', array('class' => 'xoxo')); - - foreach ($feeds as $key => $value) { - $this->common_feed_item($feeds[$key]); - } - $this->elementEnd('ul'); - $this->elementEnd('div'); - } - - //TODO move to common.php (and retrace its origin) - function common_feed_item($feed) - { - $user = common_current_user(); - $nickname = $user->nickname; - - switch($feed['item']) { - case 'notices': default: - $feed_classname = $feed['type']; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = "$nickname's ".$feed['version']." notice feed"; - $feed['textContent'] = "RSS"; - break; - - case 'foaf': - $feed_classname = "foaf"; - $feed_mimetype = "application/".$feed['type']."+xml"; - $feed_title = "$nickname's FOAF file"; - $feed['textContent'] = "FOAF"; - break; - } - $this->elementStart('li'); - $this->element('a', array('href' => $feed['href'], - 'class' => $feed_classname, - 'type' => $feed_mimetype, - 'title' => $feed_title), - $feed['textContent']); - $this->elementEnd('li'); - } - - function show_form($msg=null, $success=false) - { - $this->form_header(_('Delete my account'), $msg, $success); - $this->element('h2', null, _('Delete my account confirmation')); - $this->show_confirm_delete_form(); - common_show_footer(); - } - - function show_confirm_delete_form() - { - $user = common_current_user(); - $notices = DB_DataObject::factory('notice'); - $notices->profile_id = $user->id; - $notice_count = (int) $notices->count(); - - $this->elementStart('form', array('method' => 'POST', - 'id' => 'delete', - 'action' => - common_local_url('deleteprofile'))); - - $this->hidden('token', common_session_token()); - $this->element('p', null, "Last chance to copy your notices and contacts by saving the two links below before deleting your account. Be careful, this operation cannot be undone."); - - $this->show_feeds_list(array(0=>array('href'=>common_local_url('userrss', array('limit' => $notice_count, 'nickname' => $user->nickname)), - 'type' => 'rss', - 'version' => 'RSS 1.0', - 'item' => 'notices'), - 1=>array('href'=>common_local_url('foaf',array('nickname' => $user->nickname)), - 'type' => 'rdf', - 'version' => 'FOAF', - 'item' => 'foaf'))); - - $this->checkbox('confirmation', _('Check if you are sure you want to delete your account.')); - - $this->submit('deleteaccount', _('Delete my account')); - $this->elementEnd('form'); - } - - function handle_post() - { - # CSRF protection - $token = $this->trimmed('token'); - if (!$token || $token != common_session_token()) { - $this->show_form(_('There was a problem with your session token. Try again, please.')); - return; - } - - if ($this->arg('deleteaccount') && $this->arg('confirmation')) { - $this->delete_account(); - } - $this->show_form(); - } - - function delete_account() - { - $user = common_current_user(); - assert(!is_null($user)); # should already be checked - - // deleted later through the profile - /* - $avatar = new Avatar; - $avatar->profile_id = $user->id; - $n_avatars_deleted = $avatar->delete(); - */ - - $fave = new Fave; - $fave->user_id = $user->id; - $n_faves_deleted = $fave->delete(); - - $confirmation = new Confirm_address; - $confirmation->user_id = $user->id; - $n_confirmations_deleted = $confirmation->delete(); - - // TODO foreign stuff... - - $invitation = new Invitation; - $invitation->user_id = $user->id; - $n_invitations_deleted = $invitation->delete(); - - $message_from = new Message; - $message_from->from_profile = $user->id; - $n_messages_from_deleted = $message_from->delete(); - - $message_to = new Message; - $message_to->to_profile = $user->id; - $n_messages_to_deleted = $message_to->delete(); - - $notice_inbox = new Notice_inbox; - $notice_inbox->user_id = $user->id; - $n_notices_inbox_deleted = $notice_inbox->delete(); - - $profile_tagger = new Profile_tag; - $profile_tagger->tagger = $user->id; - $n_profiles_tagger_deleted = $profile_tagger->delete(); - - $profile_tagged = new Profile_tag; - $profile_tagged->tagged = $user->id; - $n_profiles_tagged_deleted = $profile_tagged->delete(); - - $remember_me = new Remember_me; - $remember_me->user_id = $user->id; - $n_remember_mes_deleted = $remember_me->delete(); - - $reply= new Reply; - $reply->profile_id = $user->id; - $n_replies_deleted = $reply->delete(); - - // FIXME we're not removings replies to deleted notices. - // notices should take care of that themselves. - - $notice = new Notice; - $notice->profile_id = $user->id; - $n_notices_deleted = $notice->delete(); - - $subscriber = new Subscription; - $subscriber->subscriber = $user->id; - $n_subscribers_deleted = $subscriber->delete(); - - $subscribed = new Subscription; - $subscribed->subscribed = $user->id; - $n_subscribeds_deleted = $subscribed->delete(); - - $user_openid = new User_openid; - $user_openid->user_id = $user->id; - $n_user_openids_deleted = $user_openid->delete(); - - $profile = new Profile; - $profile->id = $user->id; - $profile->delete_avatars(); - $n_profiles_deleted = $profile->delete(); - $n_users_deleted = $user->delete(); - - // logout and redirect to public - common_set_user(null); - common_real_login(false); # not logged in - common_forgetme(); # don't log back in! - common_redirect(common_local_url('public')); - } - - function show_top($arr) - { - $msg = $arr[0]; - $success = $arr[1]; - if ($msg) { - $this->message($msg, $success); - } else { - $inst = $this->get_instructions(); - $output = common_markup_to_html($inst); - $this->elementStart('div', 'instructions'); - $this->raw($output); - $this->elementEnd('div'); - } - $this->settings_menu(); - } - - function settings_menu() - { - # action => array('prompt', 'title') - $menu = - array('profilesettings' => - array(_('Profile'), - _('Change your profile settings')), - 'emailsettings' => - array(_('Email'), - _('Change email handling')), - 'openidsettings' => - array(_('OpenID'), - _('Add or remove OpenIDs')), - 'smssettings' => - array(_('SMS'), - _('Updates by SMS')), - 'imsettings' => - array(_('IM'), - _('Updates by instant messenger (IM)')), - 'twittersettings' => - array(_('Twitter'), - _('Twitter integration options')), - 'othersettings' => - array(_('Other'), - _('Other options'))); - - $action = $this->trimmed('action'); - $this->elementStart('ul', array('id' => 'nav_views')); - foreach ($menu as $menuaction => $menudesc) { - if ($menuaction == 'imsettings' && - !common_config('xmpp', 'enabled')) { - continue; - } - common_menu_item(common_local_url($menuaction), - $menudesc[0], - $menudesc[1], - $action == $menuaction); - } - $this->elementEnd('ul'); - } -} - -- cgit v1.2.3-54-g00ecf From 724abe9ea94092b6a5e922ebabc555d42cd65e7e Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 21 Jan 2009 03:59:47 +0000 Subject: Remove "finishimmediate" action --- actions/finishimmediate.php | 68 --------------------------------------------- 1 file changed, 68 deletions(-) delete mode 100644 actions/finishimmediate.php (limited to 'actions') diff --git a/actions/finishimmediate.php b/actions/finishimmediate.php deleted file mode 100644 index 0964c39f4..000000000 --- a/actions/finishimmediate.php +++ /dev/null @@ -1,68 +0,0 @@ -. - */ - -if (!defined('LACONICA')) { exit(1); } - -require_once(INSTALLDIR.'/lib/openid.php'); - -class FinishimmediateAction extends Action -{ - - function handle($args) - { - parent::handle($args); - - $consumer = oid_consumer(); - - $response = $consumer->complete(common_local_url('finishimmediate')); - - if ($response->status == Auth_OpenID_SUCCESS) { - $display = $response->getDisplayIdentifier(); - $canonical = ($response->endpoint->canonicalID) ? - $response->endpoint->canonicalID : $response->getDisplayIdentifier(); - - $user = oid_get_user($canonical); - - if ($user) { - oid_update_user($user, $sreg); - oid_set_last($display); # refresh for another year - common_set_user($user->nickname); - $this->go_backto(); - return; - } - } - - # Failure! Clear openid so we don't try it again - - oid_clear_last(); - $this->go_backto(); - return; - } - - function go_backto() - { - common_ensure_session(); - $backto = $_SESSION['openid_immediate_backto']; - if (!$backto) { - # gar. Well, push them to the public page - $backto = common_local_url('public'); - } - common_redirect($backto); - } -} -- cgit v1.2.3-54-g00ecf