2008-12-06 03:01:32 +00:00
|
|
|
<?php
|
2009-01-23 03:16:03 +00:00
|
|
|
/**
|
2009-08-25 23:12:20 +01:00
|
|
|
* StatusNet, the distributed open-source microblogging tool
|
2008-12-06 03:01:32 +00:00
|
|
|
*
|
2009-01-23 03:16:03 +00:00
|
|
|
* Low-level generator for HTML
|
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* LICENCE: This program is free software: you can redistribute it and/or modify
|
2008-12-06 03:01:32 +00:00
|
|
|
* 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
|
2009-01-23 03:16:03 +00:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2008-12-06 03:01:32 +00:00
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
2009-01-23 03:16:03 +00:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* @category Faceboook
|
2009-08-25 23:12:20 +01:00
|
|
|
* @package StatusNet
|
2009-08-25 23:19:04 +01:00
|
|
|
* @author Zach Copley <zach@status.net>
|
2009-08-25 23:12:20 +01:00
|
|
|
* @copyright 2008 StatusNet, Inc.
|
2009-01-23 03:16:03 +00:00
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
2009-08-25 23:16:46 +01:00
|
|
|
* @link http://status.net/
|
2008-12-06 03:01:32 +00:00
|
|
|
*/
|
|
|
|
|
2009-08-25 23:42:34 +01:00
|
|
|
if (!defined('STATUSNET'))
|
2009-01-23 03:16:03 +00:00
|
|
|
{
|
2009-01-18 01:31:39 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
2008-12-06 03:01:32 +00:00
|
|
|
|
2009-01-18 01:31:39 +00:00
|
|
|
require_once INSTALLDIR.'/lib/facebookutil.php';
|
2009-01-23 03:16:03 +00:00
|
|
|
require_once INSTALLDIR.'/lib/noticeform.php';
|
|
|
|
|
2009-01-05 01:04:07 +00:00
|
|
|
|
2008-12-23 19:49:23 +00:00
|
|
|
class FacebookAction extends Action
|
|
|
|
{
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
var $facebook = null;
|
|
|
|
var $fbuid = null;
|
|
|
|
var $flink = null;
|
|
|
|
var $action = null;
|
|
|
|
var $app_uri = null;
|
|
|
|
var $app_name = null;
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 04:23:44 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* Just wraps the HTMLOutputter constructor.
|
|
|
|
*
|
|
|
|
* @param string $output URI to output to, default = stdout
|
|
|
|
* @param boolean $indent Whether to indent output, default true
|
|
|
|
*
|
|
|
|
* @see XMLOutputter::__construct
|
|
|
|
* @see HTMLOutputter::__construct
|
|
|
|
*/
|
|
|
|
function __construct($output='php://output', $indent=true, $facebook=null, $flink=null)
|
|
|
|
{
|
|
|
|
parent::__construct($output, $indent);
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 04:23:44 +00:00
|
|
|
$this->facebook = $facebook;
|
|
|
|
$this->flink = $flink;
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 04:23:44 +00:00
|
|
|
if ($this->flink) {
|
2009-05-27 00:21:10 +01:00
|
|
|
$this->fbuid = $flink->foreign_id;
|
2009-01-23 04:23:44 +00:00
|
|
|
$this->user = $flink->getUser();
|
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 07:22:01 +00:00
|
|
|
$this->args = array();
|
2009-01-23 04:23:44 +00:00
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
function prepare($argarray)
|
2009-05-27 00:21:10 +01:00
|
|
|
{
|
2009-01-23 03:16:03 +00:00
|
|
|
parent::prepare($argarray);
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 04:23:44 +00:00
|
|
|
$this->facebook = getFacebook();
|
2009-01-23 03:16:03 +00:00
|
|
|
$this->fbuid = $this->facebook->require_login();
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
$this->action = $this->trimmed('action');
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
$app_props = $this->facebook->api_client->Admin_getAppProperties(
|
|
|
|
array('canvas_name', 'application_name'));
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
$this->app_uri = 'http://apps.facebook.com/' . $app_props['canvas_name'];
|
|
|
|
$this->app_name = $app_props['application_name'];
|
|
|
|
|
|
|
|
$this->flink = Foreign_link::getByForeignID($this->fbuid, FACEBOOK_SERVICE);
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
return true;
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
function showStylesheets()
|
|
|
|
{
|
2009-08-06 00:45:12 +01:00
|
|
|
$this->cssLink('css/display.css', 'base');
|
|
|
|
$this->cssLink('css/facebookapp.css', 'base');
|
2009-01-23 03:16:03 +00:00
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
function showScripts()
|
2008-12-23 19:33:23 +00:00
|
|
|
{
|
2009-08-06 00:45:12 +01:00
|
|
|
$this->script('js/facebookapp.js');
|
2009-01-23 03:16:03 +00:00
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
/**
|
|
|
|
* Start an Facebook ready HTML document
|
|
|
|
*
|
|
|
|
* For Facebook we don't want to actually output any headers,
|
2009-02-04 22:33:50 +00:00
|
|
|
* DTD info, etc. Just Stylesheet and JavaScript links.
|
2009-01-23 03:16:03 +00:00
|
|
|
*
|
|
|
|
* If $type isn't specified, will attempt to do content negotiation.
|
|
|
|
*
|
|
|
|
* @param string $type MIME type to use; default is to do negotation.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
|
2009-05-27 00:21:10 +01:00
|
|
|
function startHTML($type=null)
|
|
|
|
{
|
2009-02-04 22:33:50 +00:00
|
|
|
$this->showStylesheets();
|
|
|
|
$this->showScripts();
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
$this->elementStart('div', array('class' => 'facebook-page'));
|
2008-12-23 19:19:07 +00:00
|
|
|
}
|
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
/**
|
|
|
|
* Ends a Facebook ready HTML document
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function endHTML()
|
|
|
|
{
|
|
|
|
$this->elementEnd('div');
|
|
|
|
$this->endXML();
|
|
|
|
}
|
2009-01-19 00:50:45 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
/**
|
|
|
|
* Show notice form.
|
|
|
|
*
|
|
|
|
* MAY overload if no notice form needed... or direct message box????
|
|
|
|
*
|
|
|
|
* @return nothing
|
|
|
|
*/
|
|
|
|
function showNoticeForm()
|
|
|
|
{
|
|
|
|
// don't do it for most of the Facebook pages
|
|
|
|
}
|
2009-01-19 00:50:45 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
function showBody()
|
|
|
|
{
|
2009-02-04 17:03:59 +00:00
|
|
|
$this->elementStart('div', array('id' => 'wrap'));
|
2009-01-23 03:16:03 +00:00
|
|
|
$this->showHeader();
|
|
|
|
$this->showCore();
|
|
|
|
$this->showFooter();
|
|
|
|
$this->elementEnd('div');
|
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
function showAside()
|
|
|
|
{
|
2009-01-18 01:31:39 +00:00
|
|
|
}
|
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
function showHead($error, $success)
|
2009-01-19 07:24:12 +00:00
|
|
|
{
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
if ($error) {
|
|
|
|
$this->element("h1", null, $error);
|
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
if ($success) {
|
|
|
|
$this->element("h1", null, $success);
|
|
|
|
}
|
2009-01-11 07:03:59 +00:00
|
|
|
|
2009-01-19 13:44:10 +00:00
|
|
|
$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');
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-19 07:24:12 +00:00
|
|
|
}
|
|
|
|
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
// Make this into a widget later
|
|
|
|
function showLocalNav()
|
2009-01-19 07:24:12 +00:00
|
|
|
{
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementStart('ul', array('class' => 'nav'));
|
2009-01-18 01:31:39 +00:00
|
|
|
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementStart('li', array('class' =>
|
2009-01-23 03:16:03 +00:00
|
|
|
($this->action == 'facebookhome') ? 'current' : 'facebook_home'));
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->element('a',
|
2009-01-18 01:31:39 +00:00
|
|
|
array('href' => 'index.php', 'title' => _('Home')), _('Home'));
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementEnd('li');
|
2008-12-23 19:19:07 +00:00
|
|
|
|
2009-06-14 09:17:22 +01:00
|
|
|
if (common_config('invite', 'enabled')) {
|
|
|
|
$this->elementStart('li',
|
|
|
|
array('class' =>
|
|
|
|
($this->action == 'facebookinvite') ? 'current' : 'facebook_invite'));
|
|
|
|
$this->element('a',
|
|
|
|
array('href' => 'invite.php', 'title' => _('Invite')), _('Invite'));
|
|
|
|
$this->elementEnd('li');
|
|
|
|
}
|
2008-12-23 19:19:07 +00:00
|
|
|
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementStart('li',
|
2009-01-18 01:31:39 +00:00
|
|
|
array('class' =>
|
2009-01-23 03:16:03 +00:00
|
|
|
($this->action == 'facebooksettings') ? 'current' : 'facebook_settings'));
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->element('a',
|
2009-01-19 00:50:45 +00:00
|
|
|
array('href' => 'settings.php',
|
2009-01-18 01:31:39 +00:00
|
|
|
'title' => _('Settings')), _('Settings'));
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementEnd('li');
|
2009-01-18 01:31:39 +00:00
|
|
|
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementEnd('ul');
|
2009-05-27 00:21:10 +01:00
|
|
|
}
|
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
/**
|
|
|
|
* Show header of the page.
|
|
|
|
*
|
|
|
|
* Calls template methods
|
|
|
|
*
|
|
|
|
* @return nothing
|
|
|
|
*/
|
|
|
|
function showHeader()
|
2008-12-23 19:33:23 +00:00
|
|
|
{
|
2009-01-23 03:16:03 +00:00
|
|
|
$this->elementStart('div', array('id' => 'header'));
|
|
|
|
$this->showLogo();
|
|
|
|
$this->showNoticeForm();
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementEnd('div');
|
2008-12-23 19:19:07 +00:00
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
/**
|
|
|
|
* Show page, a template method.
|
|
|
|
*
|
|
|
|
* @return nothing
|
|
|
|
*/
|
|
|
|
function showPage($error = null, $success = null)
|
|
|
|
{
|
|
|
|
$this->startHTML();
|
|
|
|
$this->showHead($error, $success);
|
|
|
|
$this->showBody();
|
|
|
|
$this->endHTML();
|
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2008-12-23 19:19:07 +00:00
|
|
|
|
2009-01-18 01:31:39 +00:00
|
|
|
function showInstructions()
|
|
|
|
{
|
2009-01-19 00:50:45 +00:00
|
|
|
|
2009-01-26 06:31:25 +00:00
|
|
|
$this->elementStart('div', array('class' => 'facebook_guide'));
|
|
|
|
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementStart('dl', array('class' => 'system_notice'));
|
|
|
|
$this->element('dt', null, 'Page Notice');
|
2009-01-19 00:50:45 +00:00
|
|
|
|
2009-01-18 01:31:39 +00:00
|
|
|
$loginmsg_part1 = _('To use the %s Facebook Application you need to login ' .
|
2009-01-19 00:50:45 +00:00
|
|
|
'with your username and password. Don\'t have a username yet? ');
|
2009-01-18 01:31:39 +00:00
|
|
|
$loginmsg_part2 = _(' a new account.');
|
2009-01-19 00:50:45 +00:00
|
|
|
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementStart('dd');
|
|
|
|
$this->elementStart('p');
|
|
|
|
$this->text(sprintf($loginmsg_part1, common_config('site', 'name')));
|
2009-08-09 12:12:59 +01:00
|
|
|
if (!common_config('site', 'openidonly')) {
|
|
|
|
$this->element('a',
|
|
|
|
array('href' => common_local_url('register')), _('Register'));
|
|
|
|
} else {
|
|
|
|
$this->element('a',
|
|
|
|
array('href' => common_local_url('openidlogin')), _('Register'));
|
|
|
|
}
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->text($loginmsg_part2);
|
2009-05-27 00:21:10 +01:00
|
|
|
$this->elementEnd('p');
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementEnd('dd');
|
2009-02-05 04:54:42 +00:00
|
|
|
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementEnd('dl');
|
2009-01-26 06:31:25 +00:00
|
|
|
$this->elementEnd('div');
|
2009-01-18 01:31:39 +00:00
|
|
|
}
|
|
|
|
|
2009-01-19 07:24:12 +00:00
|
|
|
|
|
|
|
function showLoginForm($msg = null)
|
|
|
|
{
|
2009-01-19 00:50:45 +00:00
|
|
|
|
2009-02-05 04:54:42 +00:00
|
|
|
$this->elementStart('div', array('id' => 'content'));
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->element('h1', null, _('Login'));
|
2009-01-19 00:50:45 +00:00
|
|
|
|
2009-01-11 07:03:59 +00:00
|
|
|
if ($msg) {
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->element('fb:error', array('message' => $msg));
|
2008-12-23 19:19:07 +00:00
|
|
|
}
|
2009-01-19 00:50:45 +00:00
|
|
|
|
2009-01-18 01:31:39 +00:00
|
|
|
$this->showInstructions();
|
2008-12-23 19:19:07 +00:00
|
|
|
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementStart('div', array('id' => 'content_inner'));
|
2008-12-23 19:19:07 +00:00
|
|
|
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementStart('form', array('method' => 'post',
|
2009-01-19 07:24:12 +00:00
|
|
|
'class' => 'form_settings',
|
2009-01-11 07:03:59 +00:00
|
|
|
'id' => 'login',
|
|
|
|
'action' => 'index.php'));
|
2009-01-19 00:50:45 +00:00
|
|
|
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementStart('fieldset');
|
2009-01-19 00:50:45 +00:00
|
|
|
|
2009-01-19 13:44:10 +00:00
|
|
|
$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');
|
2009-01-19 00:50:45 +00:00
|
|
|
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->submit('submit', _('Login'));
|
2009-05-27 00:21:10 +01:00
|
|
|
$this->elementEnd('fieldset');
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementEnd('form');
|
2008-12-23 19:19:07 +00:00
|
|
|
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementStart('p');
|
|
|
|
$this->element('a', array('href' => common_local_url('recoverpassword')),
|
2009-01-11 07:03:59 +00:00
|
|
|
_('Lost or forgotten password?'));
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementEnd('p');
|
2009-01-19 00:50:45 +00:00
|
|
|
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementEnd('div');
|
2009-02-05 04:54:42 +00:00
|
|
|
$this->elementEnd('div');
|
2009-01-11 07:03:59 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
|
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
function updateProfileBox($notice)
|
|
|
|
{
|
2008-12-23 19:19:07 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
// Need to include inline CSS for styling the Profile box
|
|
|
|
|
2009-05-27 00:21:10 +01:00
|
|
|
$app_props = $this->facebook->api_client->Admin_getAppProperties(array('icon_url'));
|
|
|
|
$icon_url = $app_props['icon_url'];
|
2009-02-05 07:07:36 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
$style = '<style>
|
2009-05-27 00:21:10 +01:00
|
|
|
.entry-title *,
|
|
|
|
.entry-content * {
|
|
|
|
font-size:14px;
|
|
|
|
font-family:"Lucida Sans Unicode", "Lucida Grande", sans-serif;
|
|
|
|
}
|
|
|
|
.entry-title a,
|
|
|
|
.entry-content a {
|
|
|
|
color:#002E6E;
|
|
|
|
}
|
2009-02-05 07:07:36 +00:00
|
|
|
|
2009-01-23 09:46:29 +00:00
|
|
|
.entry-title .vcard .photo {
|
|
|
|
float:left;
|
|
|
|
display:inline;
|
2009-05-27 00:21:10 +01:00
|
|
|
margin-right:11px;
|
|
|
|
margin-bottom:11px
|
2009-01-23 03:16:03 +00:00
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
.entry-title {
|
|
|
|
margin-bottom:11px;
|
|
|
|
}
|
2009-01-23 09:46:29 +00:00
|
|
|
.entry-title p.entry-content {
|
|
|
|
display:inline;
|
2009-05-27 00:21:10 +01:00
|
|
|
margin-left:5px;
|
2009-01-23 09:46:29 +00:00
|
|
|
}
|
|
|
|
|
2009-05-27 00:21:10 +01:00
|
|
|
div.entry-content {
|
|
|
|
clear:both;
|
|
|
|
}
|
2009-01-23 09:46:29 +00:00
|
|
|
div.entry-content dl,
|
|
|
|
div.entry-content dt,
|
|
|
|
div.entry-content dd {
|
|
|
|
display:inline;
|
2009-05-27 00:21:10 +01:00
|
|
|
text-transform:lowercase;
|
2009-01-23 09:46:29 +00:00
|
|
|
}
|
|
|
|
|
2009-02-05 07:07:36 +00:00
|
|
|
div.entry-content dd,
|
2009-05-27 00:21:10 +01:00
|
|
|
div.entry-content .device dt {
|
|
|
|
margin-left:0;
|
|
|
|
margin-right:5px;
|
2009-01-23 03:16:03 +00:00
|
|
|
}
|
2009-02-05 07:07:36 +00:00
|
|
|
div.entry-content dl.timestamp dt,
|
2009-05-27 00:21:10 +01:00
|
|
|
div.entry-content dl.response dt {
|
2009-01-23 09:46:29 +00:00
|
|
|
display:none;
|
2009-01-23 03:16:03 +00:00
|
|
|
}
|
2009-01-23 09:46:29 +00:00
|
|
|
div.entry-content dd a {
|
|
|
|
display:inline-block;
|
2009-01-23 03:16:03 +00:00
|
|
|
}
|
2009-02-05 07:07:36 +00:00
|
|
|
|
2009-05-27 00:21:10 +01:00
|
|
|
#facebook_laconica_app {
|
|
|
|
text-indent:-9999px;
|
|
|
|
height:16px;
|
|
|
|
width:16px;
|
|
|
|
display:block;
|
|
|
|
background:url('.$icon_url.') no-repeat 0 0;
|
|
|
|
float:right;
|
|
|
|
}
|
|
|
|
</style>';
|
2009-01-23 03:16:03 +00:00
|
|
|
|
|
|
|
$this->xw->openMemory();
|
|
|
|
|
2009-02-05 07:07:36 +00:00
|
|
|
$item = new FacebookProfileBoxNotice($notice, $this);
|
2009-01-23 03:16:03 +00:00
|
|
|
$item->show();
|
|
|
|
|
|
|
|
$fbml = "<fb:wide>$style " . $this->xw->outputMemory(false) . "</fb:wide>";
|
|
|
|
$fbml .= "<fb:narrow>$style " . $this->xw->outputMemory(false) . "</fb:narrow>";
|
|
|
|
|
|
|
|
$fbml_main = "<fb:narrow>$style " . $this->xw->outputMemory(false) . "</fb:narrow>";
|
|
|
|
|
2009-05-27 00:21:10 +01:00
|
|
|
$this->facebook->api_client->profile_setFBML(null, $this->fbuid, $fbml, null, null, $fbml_main);
|
2009-01-23 03:16:03 +00:00
|
|
|
|
|
|
|
$this->xw->openURI('php://output');
|
2008-12-23 19:19:07 +00:00
|
|
|
}
|
2009-05-27 00:21:10 +01: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
|
|
|
|
if ($have_before || $have_after) {
|
|
|
|
$this->elementStart('div', array('class' => 'pagination'));
|
|
|
|
$this->elementStart('dl', null);
|
|
|
|
$this->element('dt', null, _('Pagination'));
|
|
|
|
$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;
|
|
|
|
$this->elementStart('li', array('class' => 'nav_prev'));
|
|
|
|
$this->element('a', array('href' => "$this->app_uri/$action?page=$newargs[page]", 'rel' => 'prev'),
|
|
|
|
_('After'));
|
|
|
|
$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' => "$this->app_uri/$action?page=$newargs[page]", 'rel' => 'next'),
|
|
|
|
_('Before'));
|
|
|
|
$this->elementEnd('li');
|
|
|
|
}
|
|
|
|
if ($have_before || $have_after) {
|
|
|
|
$this->elementEnd('ul');
|
|
|
|
$this->elementEnd('dd');
|
|
|
|
$this->elementEnd('dl');
|
|
|
|
$this->elementEnd('div');
|
|
|
|
}
|
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-29 05:58:27 +00:00
|
|
|
function saveNewNotice()
|
|
|
|
{
|
|
|
|
|
|
|
|
$user = $this->flink->getUser();
|
|
|
|
|
|
|
|
$content = $this->trimmed('status_textarea');
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-29 05:58:27 +00:00
|
|
|
if (!$content) {
|
|
|
|
$this->showPage(_('No notice content!'));
|
|
|
|
return;
|
|
|
|
} else {
|
|
|
|
$content_shortened = common_shorten_links($content);
|
|
|
|
|
|
|
|
if (mb_strlen($content_shortened) > 140) {
|
|
|
|
$this->showPage(_('That\'s too long. Max notice size is 140 chars.'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$inter = new CommandInterpreter();
|
|
|
|
|
|
|
|
$cmd = $inter->handle_command($user, $content_shortened);
|
|
|
|
|
|
|
|
if ($cmd) {
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-29 05:58:27 +00:00
|
|
|
// XXX fix this
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-29 05:58:27 +00:00
|
|
|
$cmd->execute(new WebChannel());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$replyto = $this->trimmed('inreplyto');
|
|
|
|
|
|
|
|
$notice = Notice::saveNew($user->id, $content,
|
2009-07-09 23:42:19 +01:00
|
|
|
'web', 1, ($replyto == 'false') ? null : $replyto);
|
2009-01-29 05:58:27 +00:00
|
|
|
|
|
|
|
if (is_string($notice)) {
|
|
|
|
$this->showPage($notice);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
common_broadcast_notice($notice);
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-29 05:58:27 +00:00
|
|
|
// Also update the user's Facebook status
|
2009-07-09 23:42:19 +01:00
|
|
|
facebookBroadcastNotice($notice);
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-29 05:58:27 +00:00
|
|
|
}
|
2008-12-08 01:54:12 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
}
|
|
|
|
|
2009-05-27 00:21:10 +01:00
|
|
|
class FacebookNoticeForm extends NoticeForm
|
2009-01-23 03:16:03 +00:00
|
|
|
{
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
var $post_action = null;
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param HTMLOutputter $out output channel
|
|
|
|
* @param string $action action to return to, if any
|
|
|
|
* @param string $content content to pre-fill
|
|
|
|
*/
|
|
|
|
|
2009-05-27 00:21:10 +01:00
|
|
|
function __construct($out=null, $action=null, $content=null,
|
2009-01-23 03:16:03 +00:00
|
|
|
$post_action=null, $user=null)
|
2009-01-19 07:24:12 +00:00
|
|
|
{
|
2009-01-23 03:16:03 +00:00
|
|
|
parent::__construct($out, $action, $content, $user);
|
|
|
|
$this->post_action = $post_action;
|
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
/**
|
|
|
|
* Action of the form
|
|
|
|
*
|
|
|
|
* @return string URL of the action
|
|
|
|
*/
|
|
|
|
|
|
|
|
function action()
|
|
|
|
{
|
|
|
|
return $this->post_action;
|
|
|
|
}
|
2009-01-19 13:44:10 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
}
|
2009-01-19 07:24:12 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
class FacebookNoticeList extends NoticeList
|
|
|
|
{
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-02-05 07:07:36 +00:00
|
|
|
/**
|
|
|
|
* constructor
|
|
|
|
*
|
|
|
|
* @param Notice $notice stream of notices from DB_DataObject
|
|
|
|
*/
|
|
|
|
|
|
|
|
function __construct($notice, $out=null)
|
|
|
|
{
|
|
|
|
parent::__construct($notice, $out);
|
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
/**
|
|
|
|
* 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()
|
|
|
|
{
|
|
|
|
$this->out->elementStart('div', array('id' =>'notices_primary'));
|
|
|
|
$this->out->element('h2', null, _('Notices'));
|
|
|
|
$this->out->elementStart('ul', array('class' => 'notices'));
|
2009-01-19 07:24:12 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
$cnt = 0;
|
2009-01-19 07:24:12 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
while ($this->notice->fetch() && $cnt <= NOTICES_PER_PAGE) {
|
|
|
|
$cnt++;
|
2009-01-19 07:24:12 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
if ($cnt > NOTICES_PER_PAGE) {
|
|
|
|
break;
|
|
|
|
}
|
2009-01-19 07:24:12 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
$item = $this->newListItem($this->notice);
|
|
|
|
$item->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->out->elementEnd('ul');
|
|
|
|
$this->out->elementEnd('div');
|
|
|
|
|
|
|
|
return $cnt;
|
|
|
|
}
|
2009-01-19 13:44:10 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
/**
|
|
|
|
* 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, $this);
|
|
|
|
}
|
2009-01-19 13:44:10 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
}
|
2009-01-19 07:24:12 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
class FacebookNoticeListItem extends NoticeListItem
|
2009-05-27 00:21:10 +01:00
|
|
|
{
|
2009-02-05 07:07:36 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* constructor
|
|
|
|
*
|
|
|
|
* Also initializes the profile attribute.
|
|
|
|
*
|
|
|
|
* @param Notice $notice The notice we'll display
|
|
|
|
*/
|
|
|
|
|
|
|
|
function __construct($notice, $out=null)
|
|
|
|
{
|
|
|
|
parent::__construct($notice, $out);
|
|
|
|
}
|
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
/**
|
|
|
|
* 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();
|
2009-05-27 00:21:10 +01:00
|
|
|
$this->showNotice();
|
|
|
|
$this->showNoticeInfo();
|
2009-01-19 07:24:12 +00:00
|
|
|
|
2009-05-27 00:21:10 +01:00
|
|
|
// XXX: Need to update to show attachements and controls
|
2009-01-23 03:16:03 +00:00
|
|
|
|
|
|
|
$this->showEnd();
|
|
|
|
}
|
|
|
|
|
2008-12-06 03:01:32 +00:00
|
|
|
}
|
2009-02-05 07:07:36 +00:00
|
|
|
|
|
|
|
class FacebookProfileBoxNotice extends FacebookNoticeListItem
|
2009-05-27 00:21:10 +01:00
|
|
|
{
|
|
|
|
|
2009-02-05 07:07:36 +00:00
|
|
|
/**
|
|
|
|
* constructor
|
|
|
|
*
|
|
|
|
* Also initializes the profile attribute.
|
|
|
|
*
|
|
|
|
* @param Notice $notice The notice we'll display
|
|
|
|
*/
|
|
|
|
|
|
|
|
function __construct($notice, $out=null)
|
|
|
|
{
|
|
|
|
parent::__construct($notice, $out);
|
|
|
|
}
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-02-05 07:07:36 +00:00
|
|
|
/**
|
2009-05-27 00:21:10 +01:00
|
|
|
* Recipe function for displaying a single notice in the
|
|
|
|
* Facebook App profile notice box
|
2009-02-05 07:07:36 +00:00
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
|
|
|
|
function show()
|
|
|
|
{
|
2009-05-27 00:21:10 +01:00
|
|
|
$this->showNotice();
|
|
|
|
$this->showNoticeInfo();
|
2009-02-05 07:07:36 +00:00
|
|
|
$this->showAppLink();
|
|
|
|
}
|
|
|
|
|
2009-05-27 00:21:10 +01:00
|
|
|
function showAppLink()
|
2009-02-05 07:07:36 +00:00
|
|
|
{
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-02-05 07:07:36 +00:00
|
|
|
$this->facebook = getFacebook();
|
|
|
|
|
|
|
|
$app_props = $this->facebook->api_client->Admin_getAppProperties(
|
|
|
|
array('canvas_name', 'application_name'));
|
|
|
|
|
|
|
|
$this->app_uri = 'http://apps.facebook.com/' . $app_props['canvas_name'];
|
|
|
|
$this->app_name = $app_props['application_name'];
|
2009-05-27 00:21:10 +01:00
|
|
|
|
2009-02-05 07:07:36 +00:00
|
|
|
$this->out->elementStart('a', array('id' => 'facebook_laconica_app',
|
|
|
|
'href' => $this->app_uri));
|
|
|
|
$this->out->text($this->app_name);
|
|
|
|
$this->out->elementEnd('a');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|