| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | <?php | 
					
						
							|  |  |  | /* | 
					
						
							| 
									
										
										
										
											2009-08-25 18:14:12 -04:00
										 |  |  |  * StatusNet - the distributed open-source microblogging tool | 
					
						
							| 
									
										
										
										
											2009-08-25 18:12:20 -04:00
										 |  |  |  * Copyright (C) 2008, 2009, StatusNet, Inc. | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  |  * | 
					
						
							|  |  |  |  * 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 | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.     See the | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  |  * GNU Affero General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU Affero General Public License | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |  * along with this program.     If not, see <http://www.gnu.org/licenses/>. | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-20 16:32:30 -07:00
										 |  |  | if (!defined('STATUSNET') && !defined('LACONICA')) { | 
					
						
							|  |  |  |     exit(1); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-10-20 16:32:30 -07:00
										 |  |  | require_once INSTALLDIR . '/plugins/Facebook/facebookaction.php'; | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-23 14:49:23 -05:00
										 |  |  | class FacebookhomeAction extends FacebookAction | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |     var $page = null; | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |     function prepare($argarray) | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         parent::prepare($argarray); | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         $this->page = $this->trimmed('page'); | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         if (!$this->page) { | 
					
						
							|  |  |  |             $this->page = 1; | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-12-23 14:33:23 -05:00
										 |  |  |     function handle($args) | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  |         parent::handle($args); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  |         // 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
 | 
					
						
							| 
									
										
										
										
											2009-01-26 06:31:25 +00:00
										 |  |  |         if ($this->arg('skip') || $args['fb_sig_request_method'] == 'GET') { | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |             $this->facebook->api_client->data_setUserPreference( | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  |                 FACEBOOK_PROMPTED_UPDATE_PREF, 'true'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         if ($this->flink) { | 
					
						
							|  |  |  |             $this->user = $this->flink->getUser(); | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |             // If this is the first time the user has started the app
 | 
					
						
							| 
									
										
										
										
											2009-01-23 05:47:34 +00:00
										 |  |  |             // prompt for Facebook status update permission
 | 
					
						
							| 
									
										
										
										
											2009-07-09 18:42:19 -04:00
										 |  |  |             if (!$this->facebook->api_client->users_hasAppPermission('publish_stream')) { | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |                  if ($this->facebook->api_client->data_getUserPreference( | 
					
						
							| 
									
										
										
										
											2009-01-23 05:47:34 +00:00
										 |  |  |                     FACEBOOK_PROMPTED_UPDATE_PREF) != 'true') { | 
					
						
							|  |  |  |                         $this->getUpdatePermission(); | 
					
						
							|  |  |  |                         return; | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |                  } | 
					
						
							|  |  |  |              } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |              // Make sure the user's profile box has the lastest notice
 | 
					
						
							|  |  |  |              $notice = $this->user->getCurrentNotice(); | 
					
						
							| 
									
										
										
										
											2009-01-23 05:47:34 +00:00
										 |  |  |              if ($notice) { | 
					
						
							|  |  |  |                  $this->updateProfileBox($notice); | 
					
						
							|  |  |  |              } | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  |              if ($this->arg('status_submit') == 'Send') { | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |                 $this->saveNewNotice(); | 
					
						
							| 
									
										
										
										
											2009-01-23 05:47:34 +00:00
										 |  |  |              } | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |             // User is authenticated and has already been prompted once for
 | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  |             // Facebook status update permission? Then show the main page
 | 
					
						
							|  |  |  |             // of the app
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |             $this->showPage(); | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  |             // User hasn't authenticated yet, prompt for creds
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |             $this->login(); | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |     function login() | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-01-23 05:37:21 +00:00
										 |  |  |         $this->showStylesheets(); | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |         $nickname = common_canonical_nickname($this->trimmed('nickname')); | 
					
						
							|  |  |  |         $password = $this->arg('password'); | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |         $msg = null; | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |         if ($nickname) { | 
					
						
							|  |  |  |             if (common_check_user($nickname, $password)) { | 
					
						
							|  |  |  |                 $user = User::staticGet('nickname', $nickname); | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |                 if (!$user) { | 
					
						
							| 
									
										
										
										
											2010-09-19 16:32:19 +02:00
										 |  |  |                     $this->showLoginForm(_m("Server error: Couldn't get user!")); | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |                 } | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |                 $flink = DB_DataObject::factory('foreign_link'); | 
					
						
							|  |  |  |                 $flink->user_id = $user->id; | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |                 $flink->foreign_id = $this->fbuid; | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |                 $flink->service = FACEBOOK_SERVICE; | 
					
						
							|  |  |  |                 $flink->created = common_sql_now(); | 
					
						
							| 
									
										
										
										
											2009-05-26 23:21:10 +00:00
										 |  |  |                 $flink->set_flags(true, false, false, false); | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |                 $flink_id = $flink->insert(); | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |                 // XXX: Do some error handling here
 | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-12 05:25:07 +00:00
										 |  |  |                 $this->setDefaults(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  |                 $this->getUpdatePermission(); | 
					
						
							| 
									
										
										
										
											2009-01-16 20:19:49 +00:00
										 |  |  |                 return; | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |             } else { | 
					
						
							| 
									
										
										
										
											2009-12-08 12:17:11 -08:00
										 |  |  |                 $msg = _m('Incorrect username or password.'); | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |         $this->showLoginForm($msg); | 
					
						
							| 
									
										
										
										
											2009-01-30 00:07:56 +00:00
										 |  |  |         $this->showFooter(); | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-12 05:25:07 +00:00
										 |  |  |     function setDefaults() | 
					
						
							|  |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         $this->facebook->api_client->data_setUserPreference( | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  |             FACEBOOK_PROMPTED_UPDATE_PREF, 'false'); | 
					
						
							| 
									
										
										
										
											2009-01-12 05:25:07 +00:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |     function showNoticeForm() | 
					
						
							| 
									
										
										
										
											2008-12-23 14:33:23 -05:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         $post_action = "$this->app_uri/index.php"; | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |         $notice_form = new FacebookNoticeForm($this, $post_action, null, | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |             $post_action, $this->user); | 
					
						
							|  |  |  |         $notice_form->show(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-01-12 05:25:07 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |     function title() | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         if ($this->page > 1) { | 
					
						
							| 
									
										
										
										
											2010-09-19 16:32:19 +02:00
										 |  |  |             // @todo FIXME: Core should have methods to get "Full name (nickname)" in a localised form
 | 
					
						
							|  |  |  |             // so that this can be used consistenly throughout StatusNet without having to implement it
 | 
					
						
							|  |  |  | 	    // over and over..
 | 
					
						
							|  |  |  |             // TRANS: Page title.
 | 
					
						
							|  |  |  |             // TRANS: %1$s is a user nickname, %2$s is a page number.
 | 
					
						
							| 
									
										
										
										
											2010-10-04 14:24:04 -07:00
										 |  |  |             return sprintf(_m('%1$s and friends, page %2$d'), $this->user->nickname, $this->page); | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2010-09-19 16:32:19 +02:00
										 |  |  |             // TRANS: Page title.
 | 
					
						
							|  |  |  |             // TRANS: %s is a user nickname
 | 
					
						
							| 
									
										
										
										
											2009-12-08 12:17:11 -08:00
										 |  |  |             return sprintf(_m("%s and friends"), $this->user->nickname); | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |     function showContent() | 
					
						
							| 
									
										
										
										
											2008-12-23 14:33:23 -05:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  |         $notice = $this->user->noticeInbox(($this->page-1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         $nl = new NoticeList($notice, $this); | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         $cnt = $nl->show(); | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         $this->pagination($this->page > 1, $cnt > NOTICES_PER_PAGE, | 
					
						
							|  |  |  |                           $this->page, 'index.php', array('nickname' => $this->user->nickname)); | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-07 18:59:25 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-19 07:24:12 +00:00
										 |  |  |     function showNoticeList($notice) | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |     { | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         $nl = new NoticeList($notice, $this); | 
					
						
							| 
									
										
										
										
											2009-01-11 07:03:59 +00:00
										 |  |  |         return $nl->show(); | 
					
						
							| 
									
										
										
										
											2008-12-23 14:19:07 -05:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  |     function getUpdatePermission() { | 
					
						
							| 
									
										
										
										
											2009-01-23 05:37:21 +00:00
										 |  |  |         $this->showStylesheets(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 06:31:25 +00:00
										 |  |  |         $this->elementStart('div', array('class' => 'facebook_guide')); | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2010-09-19 16:32:19 +02:00
										 |  |  |         // TRANS: Instructions. %s is the application name.
 | 
					
						
							| 
									
										
										
										
											2009-12-08 12:17:11 -08:00
										 |  |  |         $instructions = sprintf(_m('If you would like the %s app to automatically update ' . | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  |             'your Facebook status with your latest notice, you need ' . | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |             'to give it permission.'), $this->app_name); | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-19 13:44:10 +00:00
										 |  |  |         $this->elementStart('p'); | 
					
						
							|  |  |  |         $this->element('span', array('id' => 'permissions_notice'), $instructions); | 
					
						
							|  |  |  |         $this->elementEnd('p'); | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-19 13:44:10 +00:00
										 |  |  |         $this->elementStart('form', array('method' => 'post', | 
					
						
							| 
									
										
										
										
											2009-01-23 08:42:40 +00:00
										 |  |  |                                            'action' => "index.php", | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  |                                            'id' => 'facebook-skip-permissions')); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-19 13:44:10 +00:00
										 |  |  |         $this->elementStart('ul', array('id' => 'fb-permissions-list')); | 
					
						
							|  |  |  |         $this->elementStart('li', array('id' => 'fb-permissions-item')); | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 06:31:25 +00:00
										 |  |  |         $next = urlencode("$this->app_uri/index.php"); | 
					
						
							|  |  |  |         $api_key = common_config('facebook', 'apikey'); | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 06:31:25 +00:00
										 |  |  |         $auth_url = 'http://www.facebook.com/authorize.php?api_key=' . | 
					
						
							| 
									
										
										
										
											2009-07-09 18:42:19 -04:00
										 |  |  |             $api_key . '&v=1.0&ext_perm=publish_stream&next=' . $next . | 
					
						
							| 
									
										
										
										
											2009-01-26 06:31:25 +00:00
										 |  |  |             '&next_cancel=' . $next . '&submit=skip'; | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-26 06:31:25 +00:00
										 |  |  |         $this->elementStart('span', array('class' => 'facebook-button')); | 
					
						
							| 
									
										
										
										
											2010-09-19 16:32:19 +02:00
										 |  |  |         // @todo FIXME: sprintf not needed here?
 | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  |         $this->element('a', array('href' => $auth_url), | 
					
						
							| 
									
										
										
										
											2009-12-08 12:17:11 -08:00
										 |  |  |             sprintf(_m('Okay, do it!'), $this->app_name)); | 
					
						
							| 
									
										
										
										
											2009-01-26 06:31:25 +00:00
										 |  |  |         $this->elementEnd('span'); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-19 13:44:10 +00:00
										 |  |  |         $this->elementEnd('li'); | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-19 13:44:10 +00:00
										 |  |  |         $this->elementStart('li', array('id' => 'fb-permissions-item')); | 
					
						
							| 
									
										
										
										
											2010-09-19 16:32:19 +02:00
										 |  |  |         // TRANS: Button text. Clicking the button will skip updating Facebook permissions.
 | 
					
						
							|  |  |  |         $this->submit('skip', _m('BUTTON','Skip')); | 
					
						
							| 
									
										
										
										
											2009-01-19 13:44:10 +00:00
										 |  |  |         $this->elementEnd('li'); | 
					
						
							|  |  |  |         $this->elementEnd('ul'); | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-19 13:44:10 +00:00
										 |  |  |         $this->elementEnd('form'); | 
					
						
							|  |  |  |         $this->elementEnd('div'); | 
					
						
							| 
									
										
										
										
											2009-01-19 00:50:45 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |     /** | 
					
						
							|  |  |  |      * Generate pagination links | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @param boolean $have_before is there something before? | 
					
						
							|  |  |  |      * @param boolean $have_after  is there something after? | 
					
						
							|  |  |  |      * @param integer $page        current page | 
					
						
							|  |  |  |      * @param string  $action      current action | 
					
						
							|  |  |  |      * @param array   $args        rest of query arguments | 
					
						
							|  |  |  |      * | 
					
						
							|  |  |  |      * @return nothing | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     function pagination($have_before, $have_after, $page, $action, $args=null) | 
					
						
							|  |  |  |     { | 
					
						
							|  |  |  |         // Does a little before-after block for next/prev page
 | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         // XXX: Fix so this uses common_local_url() if possible.
 | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |         if ($have_before || $have_after) { | 
					
						
							| 
									
										
										
										
											2009-11-13 12:26:24 +00:00
										 |  |  |             $this->elementStart('dl', 'pagination'); | 
					
						
							| 
									
										
										
										
											2009-12-08 12:17:11 -08:00
										 |  |  |             $this->element('dt', null, _m('Pagination')); | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |             $this->elementStart('dd', null); | 
					
						
							|  |  |  |             $this->elementStart('ul', array('class' => 'nav')); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if ($have_before) { | 
					
						
							|  |  |  |             $pargs   = array('page' => $page-1); | 
					
						
							|  |  |  |             $newargs = $args ? array_merge($args, $pargs) : $pargs; | 
					
						
							| 
									
										
										
										
											2009-06-18 11:45:48 -07:00
										 |  |  |             $this->elementStart('li', array('class' => 'nav_prev')); | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |             $this->element('a', array('href' => "$action?page=$newargs[page]", 'rel' => 'prev'), | 
					
						
							| 
									
										
										
										
											2010-09-19 16:32:19 +02:00
										 |  |  |                            // TRANS: Pagination link.
 | 
					
						
							| 
									
										
										
										
											2009-12-08 12:17:11 -08:00
										 |  |  |                            _m('After')); | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |             $this->elementEnd('li'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if ($have_after) { | 
					
						
							|  |  |  |             $pargs   = array('page' => $page+1); | 
					
						
							|  |  |  |             $newargs = $args ? array_merge($args, $pargs) : $pargs; | 
					
						
							|  |  |  |             $this->elementStart('li', array('class' => 'nav_next')); | 
					
						
							|  |  |  |             $this->element('a', array('href' => "$action?page=$newargs[page]", 'rel' => 'next'), | 
					
						
							| 
									
										
										
										
											2010-09-19 16:32:19 +02:00
										 |  |  |                            // TRANS: Pagination link.
 | 
					
						
							| 
									
										
										
										
											2009-12-08 12:17:11 -08:00
										 |  |  |                            _m('Before')); | 
					
						
							| 
									
										
										
										
											2009-01-23 03:16:03 +00:00
										 |  |  |             $this->elementEnd('li'); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         if ($have_before || $have_after) { | 
					
						
							|  |  |  |             $this->elementEnd('ul'); | 
					
						
							|  |  |  |             $this->elementEnd('dd'); | 
					
						
							|  |  |  |             $this->elementEnd('dl'); | 
					
						
							|  |  |  |         } | 
					
						
							| 
									
										
										
										
											2009-01-19 07:24:12 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2008-12-05 22:01:32 -05:00
										 |  |  | } |