2008-12-06 03:01:32 +00:00
|
|
|
<?php
|
2009-01-23 03:16:03 +00:00
|
|
|
/**
|
|
|
|
* Laconica, 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
|
|
|
|
* @package Laconica
|
|
|
|
* @author Zach Copley <zach@controlyourself.ca>
|
|
|
|
* @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/
|
2008-12-06 03:01:32 +00:00
|
|
|
*/
|
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
if (!defined('LACONICA'))
|
|
|
|
{
|
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-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;
|
|
|
|
|
|
|
|
function prepare($argarray)
|
|
|
|
{
|
|
|
|
parent::prepare($argarray);
|
|
|
|
|
|
|
|
common_debug("Facebookaction::prepare");
|
|
|
|
|
|
|
|
$this->facebook = get_facebook();
|
|
|
|
$this->fbuid = $this->facebook->require_login();
|
|
|
|
|
|
|
|
$this->action = $this->trimmed('action');
|
|
|
|
|
|
|
|
$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'];
|
|
|
|
|
|
|
|
$this->flink = Foreign_link::getByForeignID($this->fbuid, FACEBOOK_SERVICE);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function showStylesheets()
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->element('link', array('rel' => 'stylesheet',
|
|
|
|
'type' => 'text/css',
|
|
|
|
'href' => getFacebookBaseCSS()));
|
2008-12-06 03:01:32 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
$this->element('link', array('rel' => 'stylesheet',
|
|
|
|
'type' => 'text/css',
|
|
|
|
'href' => getFacebookThemeCSS()));
|
|
|
|
}
|
|
|
|
|
|
|
|
function showScripts()
|
2008-12-23 19:33:23 +00:00
|
|
|
{
|
2009-01-23 03:16:03 +00:00
|
|
|
$this->element('script', array('type' => 'text/javascript',
|
|
|
|
'src' => getFacebookJS()),
|
|
|
|
' ');
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Start an Facebook ready HTML document
|
|
|
|
*
|
|
|
|
* For Facebook we don't want to actually output any headers,
|
|
|
|
* DTD info, etc.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
|
|
|
function startHTML($type=null)
|
|
|
|
{
|
|
|
|
$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()
|
|
|
|
{
|
|
|
|
$this->elementStart('div', 'wrap');
|
|
|
|
$this->showHeader();
|
|
|
|
$this->showCore();
|
|
|
|
$this->showFooter();
|
|
|
|
$this->elementEnd('div');
|
|
|
|
}
|
|
|
|
|
|
|
|
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-01-23 03:16:03 +00:00
|
|
|
$this->showStylesheets();
|
|
|
|
$this->showScripts();
|
|
|
|
|
|
|
|
if ($error) {
|
|
|
|
$this->element("h1", null, $error);
|
|
|
|
}
|
|
|
|
|
|
|
|
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-01-23 03:16:03 +00:00
|
|
|
|
2009-01-19 07:24:12 +00: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-23 03:16:03 +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-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 == 'facebookinvite') ? 'current' : 'facebook_invite'));
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->element('a',
|
2009-01-18 01:31:39 +00:00
|
|
|
array('href' => 'invite.php', 'title' => _('Invite')), _('Invite'));
|
2009-01-19 13:44:10 +00:00
|
|
|
$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-01-18 01:31:39 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
}
|
2008-12-23 19:19:07 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
/**
|
|
|
|
* Show primary navigation.
|
|
|
|
*
|
|
|
|
* @return nothing
|
|
|
|
*/
|
|
|
|
function showPrimaryNav()
|
|
|
|
{
|
|
|
|
// we don't want to show anything for this
|
2008-12-23 19:19:07 +00: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();
|
|
|
|
$this->showPrimaryNav();
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->elementEnd('div');
|
2008-12-23 19:19:07 +00: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();
|
|
|
|
}
|
|
|
|
|
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
|
|
|
global $xw;
|
|
|
|
|
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')));
|
|
|
|
$this->element('a',
|
2009-01-18 01:31:39 +00:00
|
|
|
array('href' => common_local_url('register')), _('Register'));
|
2009-01-19 13:44:10 +00:00
|
|
|
$this->text($loginmsg_part2);
|
|
|
|
$this->elementEnd('dd');
|
|
|
|
$this->elementEnd('dl');
|
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-01-19 13:44:10 +00:00
|
|
|
$this->elementStart('div', array('class' => 'content'));
|
|
|
|
$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');
|
|
|
|
$this->element('legend', null, _('Login to site'));
|
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'));
|
|
|
|
$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-01-11 07:03:59 +00: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
|
|
|
|
|
|
|
|
$style = '<style>
|
|
|
|
#notices {
|
|
|
|
clear: both;
|
|
|
|
margin: 0 auto;
|
|
|
|
padding: 0;
|
|
|
|
list-style-type: none;
|
|
|
|
width: 600px;
|
|
|
|
border-top: 1px solid #dec5b5;
|
|
|
|
}
|
|
|
|
#notices a:hover {
|
|
|
|
text-decoration: underline;
|
|
|
|
}
|
|
|
|
.notice_single {
|
|
|
|
clear: both;
|
|
|
|
display: block;
|
|
|
|
margin: 0;
|
|
|
|
padding: 5px 5px 5px 0;
|
|
|
|
min-height: 48px;
|
|
|
|
font-family: Georgia, "Times New Roman", Times, serif;
|
|
|
|
font-size: 13px;
|
|
|
|
line-height: 16px;
|
|
|
|
border-bottom: 1px solid #dec5b5;
|
|
|
|
background-color:#FCFFF5;
|
|
|
|
opacity:1;
|
|
|
|
}
|
|
|
|
.notice_single:hover {
|
|
|
|
background-color: #f7ebcc;
|
|
|
|
}
|
|
|
|
.notice_single p {
|
|
|
|
display: inline;
|
|
|
|
margin: 0;
|
|
|
|
padding: 0;
|
|
|
|
}
|
|
|
|
</style>';
|
|
|
|
|
|
|
|
$this->xw->openMemory();
|
|
|
|
|
|
|
|
$item = new FacebookNoticeListItem($notice, $this);
|
|
|
|
$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>";
|
|
|
|
|
|
|
|
$this->facebook->api_client->profile_setFBML(null, $this->fbuid, $fbml, null, null, $fbml_main);
|
|
|
|
|
|
|
|
$this->xw->openURI('php://output');
|
2008-12-23 19:19:07 +00: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');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-08 01:54:12 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
class FacebookNoticeForm extends NoticeForm
|
|
|
|
{
|
|
|
|
|
|
|
|
var $post_action = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Constructor
|
|
|
|
*
|
|
|
|
* @param HTMLOutputter $out output channel
|
|
|
|
* @param string $action action to return to, if any
|
|
|
|
* @param string $content content to pre-fill
|
|
|
|
*/
|
|
|
|
|
|
|
|
function __construct($out=null, $action=null, $content=null,
|
|
|
|
$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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 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-01-19 07:24:12 +00:00
|
|
|
|
2009-01-23 03:16:03 +00:00
|
|
|
$this->out->elementStart('div', 'entry-title');
|
|
|
|
$this->showAuthor();
|
|
|
|
$this->showContent();
|
|
|
|
$this->out->elementEnd('div');
|
|
|
|
|
|
|
|
$this->out->elementStart('div', 'entry-content');
|
|
|
|
$this->showNoticeLink();
|
|
|
|
$this->showNoticeSource();
|
|
|
|
$this->showReplyTo();
|
|
|
|
$this->out->elementEnd('div');
|
|
|
|
|
|
|
|
$this->showEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->out->elementStart('dl', 'timestamp');
|
|
|
|
$this->out->element('dt', null, _('Published'));
|
|
|
|
$this->out->elementStart('dd', null);
|
|
|
|
$this->out->elementStart('a', array('rel' => 'bookmark',
|
|
|
|
'href' => $noticeurl));
|
|
|
|
$dt = common_date_iso8601($this->notice->created);
|
|
|
|
$this->out->element('abbr', array('class' => 'published',
|
|
|
|
'title' => $dt),
|
|
|
|
common_date_string($this->notice->created));
|
|
|
|
$this->out->elementEnd('a');
|
|
|
|
$this->out->elementEnd('dd');
|
|
|
|
$this->out->elementEnd('dl');
|
2009-01-19 07:24:12 +00:00
|
|
|
}
|
|
|
|
|
2008-12-06 03:01:32 +00:00
|
|
|
}
|