forked from GNUsocial/gnu-social
Merge branch 'testing' of git@gitorious.org:statusnet/mainline into testing
This commit is contained in:
commit
0994589b73
@ -83,6 +83,7 @@ class AllrssAction extends Rss10Action
|
|||||||
function getNotices($limit=0)
|
function getNotices($limit=0)
|
||||||
{
|
{
|
||||||
$cur = common_current_user();
|
$cur = common_current_user();
|
||||||
|
$user = $this->user;
|
||||||
|
|
||||||
if (!empty($cur) && $cur->id == $user->id) {
|
if (!empty($cur) && $cur->id == $user->id) {
|
||||||
$notice = $this->user->noticeInbox(0, $limit);
|
$notice = $this->user->noticeInbox(0, $limit);
|
||||||
@ -90,7 +91,6 @@ class AllrssAction extends Rss10Action
|
|||||||
$notice = $this->user->noticesWithFriends(0, $limit);
|
$notice = $this->user->noticesWithFriends(0, $limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->user;
|
|
||||||
$notice = $user->noticesWithFriends(0, $limit);
|
$notice = $user->noticesWithFriends(0, $limit);
|
||||||
$notices = array();
|
$notices = array();
|
||||||
|
|
||||||
|
@ -104,17 +104,8 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
|
|||||||
|
|
||||||
function showTimeline()
|
function showTimeline()
|
||||||
{
|
{
|
||||||
$sitename = common_config('site', 'name');
|
// We'll pull common formatting out of this for other formats
|
||||||
$avatar = $this->group->homepage_logo;
|
$atom = new AtomGroupNoticeFeed($this->group);
|
||||||
$title = sprintf(_("%s timeline"), $this->group->nickname);
|
|
||||||
|
|
||||||
$subtitle = sprintf(
|
|
||||||
_('Updates from %1$s on %2$s!'),
|
|
||||||
$this->group->nickname,
|
|
||||||
$sitename
|
|
||||||
);
|
|
||||||
|
|
||||||
$logo = ($avatar) ? $avatar : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
|
|
||||||
|
|
||||||
switch($this->format) {
|
switch($this->format) {
|
||||||
case 'xml':
|
case 'xml':
|
||||||
@ -123,11 +114,11 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
|
|||||||
case 'rss':
|
case 'rss':
|
||||||
$this->showRssTimeline(
|
$this->showRssTimeline(
|
||||||
$this->notices,
|
$this->notices,
|
||||||
$title,
|
$atom->title,
|
||||||
$this->group->homeUrl(),
|
$this->group->homeUrl(),
|
||||||
$subtitle,
|
$atom->subtitle,
|
||||||
null,
|
null,
|
||||||
$logo
|
$atom->logo
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case 'atom':
|
case 'atom':
|
||||||
@ -136,38 +127,22 @@ class ApiTimelineGroupAction extends ApiPrivateAuthAction
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
$atom = new AtomGroupNoticeFeed($this->group);
|
|
||||||
|
|
||||||
// @todo set all this Atom junk up inside the feed class
|
|
||||||
|
|
||||||
#$atom->setId($id);
|
|
||||||
$atom->setTitle($title);
|
|
||||||
$atom->setSubtitle($subtitle);
|
|
||||||
$atom->setLogo($logo);
|
|
||||||
$atom->setUpdated('now');
|
|
||||||
|
|
||||||
$atom->addAuthorRaw($this->group->asAtomAuthor());
|
$atom->addAuthorRaw($this->group->asAtomAuthor());
|
||||||
$atom->setActivitySubject($this->group->asActivitySubject());
|
$atom->setActivitySubject($this->group->asActivitySubject());
|
||||||
|
|
||||||
$atom->addLink($this->group->homeUrl());
|
|
||||||
|
|
||||||
$id = $this->arg('id');
|
$id = $this->arg('id');
|
||||||
$aargs = array('format' => 'atom');
|
$aargs = array('format' => 'atom');
|
||||||
if (!empty($id)) {
|
if (!empty($id)) {
|
||||||
$aargs['id'] = $id;
|
$aargs['id'] = $id;
|
||||||
}
|
}
|
||||||
|
$self = $this->getSelfUri('ApiTimelineGroup', $aargs);
|
||||||
|
|
||||||
$atom->setId($this->getSelfUri('ApiTimelineGroup', $aargs));
|
$atom->setId($self);
|
||||||
|
$atom->setSelfLink($self);
|
||||||
$atom->addLink(
|
|
||||||
$this->getSelfUri('ApiTimelineGroup', $aargs),
|
|
||||||
array('rel' => 'self', 'type' => 'application/atom+xml')
|
|
||||||
);
|
|
||||||
|
|
||||||
$atom->addEntryFromNotices($this->notices);
|
$atom->addEntryFromNotices($this->notices);
|
||||||
|
|
||||||
//$this->raw($atom->getString());
|
$this->raw($atom->getString());
|
||||||
print $atom->getString(); // temp hack until PuSH feeds are redone cleanly
|
|
||||||
|
|
||||||
} catch (Atom10FeedException $e) {
|
} catch (Atom10FeedException $e) {
|
||||||
$this->serverError(
|
$this->serverError(
|
||||||
|
@ -112,19 +112,17 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
function showTimeline()
|
function showTimeline()
|
||||||
{
|
{
|
||||||
$profile = $this->user->getProfile();
|
$profile = $this->user->getProfile();
|
||||||
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
|
||||||
|
|
||||||
$sitename = common_config('site', 'name');
|
// We'll use the shared params from the Atom stub
|
||||||
$title = sprintf(_("%s timeline"), $this->user->nickname);
|
// for other feed types.
|
||||||
|
$atom = new AtomUserNoticeFeed($this->user);
|
||||||
|
$title = $atom->title;
|
||||||
$link = common_local_url(
|
$link = common_local_url(
|
||||||
'showstream',
|
'showstream',
|
||||||
array('nickname' => $this->user->nickname)
|
array('nickname' => $this->user->nickname)
|
||||||
);
|
);
|
||||||
$subtitle = sprintf(
|
$subtitle = $atom->subtitle;
|
||||||
_('Updates from %1$s on %2$s!'),
|
$logo = $atom->logo;
|
||||||
$this->user->nickname, $sitename
|
|
||||||
);
|
|
||||||
$logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
|
||||||
|
|
||||||
// FriendFeed's SUP protocol
|
// FriendFeed's SUP protocol
|
||||||
// Also added RSS and Atom feeds
|
// Also added RSS and Atom feeds
|
||||||
@ -146,47 +144,18 @@ class ApiTimelineUserAction extends ApiBareAuthAction
|
|||||||
|
|
||||||
header('Content-Type: application/atom+xml; charset=utf-8');
|
header('Content-Type: application/atom+xml; charset=utf-8');
|
||||||
|
|
||||||
// @todo set all this Atom junk up inside the feed class
|
|
||||||
|
|
||||||
$atom = new AtomUserNoticeFeed($this->user);
|
|
||||||
|
|
||||||
$atom->setTitle($title);
|
|
||||||
$atom->setSubtitle($subtitle);
|
|
||||||
$atom->setLogo($logo);
|
|
||||||
$atom->setUpdated('now');
|
|
||||||
|
|
||||||
$atom->addLink(
|
|
||||||
common_local_url(
|
|
||||||
'showstream',
|
|
||||||
array('nickname' => $this->user->nickname)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$id = $this->arg('id');
|
$id = $this->arg('id');
|
||||||
$aargs = array('format' => 'atom');
|
$aargs = array('format' => 'atom');
|
||||||
if (!empty($id)) {
|
if (!empty($id)) {
|
||||||
$aargs['id'] = $id;
|
$aargs['id'] = $id;
|
||||||
}
|
}
|
||||||
|
$self = $this->getSelfUri('ApiTimelineUser', $aargs);
|
||||||
$atom->setId($this->getSelfUri('ApiTimelineUser', $aargs));
|
$atom->setId($self);
|
||||||
|
$atom->setSelfLink($self);
|
||||||
$atom->addLink(
|
|
||||||
$this->getSelfUri('ApiTimelineUser', $aargs),
|
|
||||||
array('rel' => 'self', 'type' => 'application/atom+xml')
|
|
||||||
);
|
|
||||||
|
|
||||||
$atom->addLink(
|
|
||||||
$suplink,
|
|
||||||
array(
|
|
||||||
'rel' => 'http://api.friendfeed.com/2008/03#sup',
|
|
||||||
'type' => 'application/json'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
$atom->addEntryFromNotices($this->notices);
|
$atom->addEntryFromNotices($this->notices);
|
||||||
|
|
||||||
#$this->raw($atom->getString());
|
$this->raw($atom->getString());
|
||||||
print $atom->getString(); // temporary for output buffering
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'json':
|
case 'json':
|
||||||
|
@ -66,7 +66,7 @@ class SiteadminpanelAction extends AdminPanelAction
|
|||||||
|
|
||||||
function getInstructions()
|
function getInstructions()
|
||||||
{
|
{
|
||||||
return _('Basic settings for this StatusNet site.');
|
return _('Basic settings for this StatusNet site');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -90,10 +90,11 @@ class SiteadminpanelAction extends AdminPanelAction
|
|||||||
|
|
||||||
function saveSettings()
|
function saveSettings()
|
||||||
{
|
{
|
||||||
static $settings = array('site' => array('name', 'broughtby', 'broughtbyurl',
|
static $settings = array(
|
||||||
|
'site' => array('name', 'broughtby', 'broughtbyurl',
|
||||||
'email', 'timezone', 'language',
|
'email', 'timezone', 'language',
|
||||||
'site', 'textlimit', 'dupelimit'),
|
'site', 'textlimit', 'dupelimit'),
|
||||||
'snapshot' => array('run', 'reporturl', 'frequency'));
|
);
|
||||||
|
|
||||||
$values = array();
|
$values = array();
|
||||||
|
|
||||||
@ -158,25 +159,6 @@ class SiteadminpanelAction extends AdminPanelAction
|
|||||||
$this->clientError(sprintf(_('Unknown language "%s".'), $values['site']['language']));
|
$this->clientError(sprintf(_('Unknown language "%s".'), $values['site']['language']));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate report URL
|
|
||||||
|
|
||||||
if (!is_null($values['snapshot']['reporturl']) &&
|
|
||||||
!Validate::uri($values['snapshot']['reporturl'], array('allowed_schemes' => array('http', 'https')))) {
|
|
||||||
$this->clientError(_("Invalid snapshot report URL."));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate snapshot run value
|
|
||||||
|
|
||||||
if (!in_array($values['snapshot']['run'], array('web', 'cron', 'never'))) {
|
|
||||||
$this->clientError(_("Invalid snapshot run value."));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate snapshot run value
|
|
||||||
|
|
||||||
if (!Validate::number($values['snapshot']['frequency'])) {
|
|
||||||
$this->clientError(_("Snapshot frequency must be a number."));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate text limit
|
// Validate text limit
|
||||||
|
|
||||||
if (!Validate::number($values['site']['textlimit'], array('min' => 140))) {
|
if (!Validate::number($values['site']['textlimit'], array('min' => 140))) {
|
||||||
@ -285,32 +267,6 @@ class SiteAdminPanelForm extends AdminForm
|
|||||||
$this->out->elementEnd('ul');
|
$this->out->elementEnd('ul');
|
||||||
$this->out->elementEnd('fieldset');
|
$this->out->elementEnd('fieldset');
|
||||||
|
|
||||||
$this->out->elementStart('fieldset', array('id' => 'settings_admin_snapshots'));
|
|
||||||
$this->out->element('legend', null, _('Snapshots'));
|
|
||||||
$this->out->elementStart('ul', 'form_data');
|
|
||||||
$this->li();
|
|
||||||
$snapshot = array('web' => _('Randomly during Web hit'),
|
|
||||||
'cron' => _('In a scheduled job'),
|
|
||||||
'never' => _('Never'));
|
|
||||||
$this->out->dropdown('run', _('Data snapshots'),
|
|
||||||
$snapshot, _('When to send statistical data to status.net servers'),
|
|
||||||
false, $this->value('run', 'snapshot'));
|
|
||||||
$this->unli();
|
|
||||||
|
|
||||||
$this->li();
|
|
||||||
$this->input('frequency', _('Frequency'),
|
|
||||||
_('Snapshots will be sent once every N web hits'),
|
|
||||||
'snapshot');
|
|
||||||
$this->unli();
|
|
||||||
|
|
||||||
$this->li();
|
|
||||||
$this->input('reporturl', _('Report URL'),
|
|
||||||
_('Snapshots will be sent to this URL'),
|
|
||||||
'snapshot');
|
|
||||||
$this->unli();
|
|
||||||
$this->out->elementEnd('ul');
|
|
||||||
$this->out->elementEnd('fieldset');
|
|
||||||
|
|
||||||
$this->out->elementStart('fieldset', array('id' => 'settings_admin_limits'));
|
$this->out->elementStart('fieldset', array('id' => 'settings_admin_limits'));
|
||||||
$this->out->element('legend', null, _('Limits'));
|
$this->out->element('legend', null, _('Limits'));
|
||||||
$this->out->elementStart('ul', 'form_data');
|
$this->out->elementStart('ul', 'form_data');
|
||||||
|
251
actions/snapshotadminpanel.php
Normal file
251
actions/snapshotadminpanel.php
Normal file
@ -0,0 +1,251 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* StatusNet, the distributed open-source microblogging tool
|
||||||
|
*
|
||||||
|
* Snapshots administration panel
|
||||||
|
*
|
||||||
|
* PHP version 5
|
||||||
|
*
|
||||||
|
* LICENCE: 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
* @category Settings
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Zach Copley <zach@status.net>
|
||||||
|
* @copyright 2010 StatusNet, Inc.
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!defined('STATUSNET')) {
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manage snapshots
|
||||||
|
*
|
||||||
|
* @category Admin
|
||||||
|
* @package StatusNet
|
||||||
|
* @author Zach Copley <zach@status.net>
|
||||||
|
* @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
|
||||||
|
* @link http://status.net/
|
||||||
|
*/
|
||||||
|
|
||||||
|
class SnapshotadminpanelAction extends AdminPanelAction
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Returns the page title
|
||||||
|
*
|
||||||
|
* @return string page title
|
||||||
|
*/
|
||||||
|
|
||||||
|
function title()
|
||||||
|
{
|
||||||
|
return _('Snapshots');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Instructions for using this form.
|
||||||
|
*
|
||||||
|
* @return string instructions
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getInstructions()
|
||||||
|
{
|
||||||
|
return _('Manage snapshot configuration');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the snapshots admin panel form
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function showForm()
|
||||||
|
{
|
||||||
|
$form = new SnapshotAdminPanelForm($this);
|
||||||
|
$form->show();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save settings from the form
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function saveSettings()
|
||||||
|
{
|
||||||
|
static $settings = array(
|
||||||
|
'snapshot' => array('run', 'reporturl', 'frequency')
|
||||||
|
);
|
||||||
|
|
||||||
|
$values = array();
|
||||||
|
|
||||||
|
foreach ($settings as $section => $parts) {
|
||||||
|
foreach ($parts as $setting) {
|
||||||
|
$values[$section][$setting] = $this->trimmed($setting);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// This throws an exception on validation errors
|
||||||
|
|
||||||
|
$this->validate($values);
|
||||||
|
|
||||||
|
// assert(all values are valid);
|
||||||
|
|
||||||
|
$config = new Config();
|
||||||
|
|
||||||
|
$config->query('BEGIN');
|
||||||
|
|
||||||
|
foreach ($settings as $section => $parts) {
|
||||||
|
foreach ($parts as $setting) {
|
||||||
|
Config::save($section, $setting, $values[$section][$setting]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$config->query('COMMIT');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
function validate(&$values)
|
||||||
|
{
|
||||||
|
// Validate snapshot run value
|
||||||
|
|
||||||
|
if (!in_array($values['snapshot']['run'], array('web', 'cron', 'never'))) {
|
||||||
|
$this->clientError(_("Invalid snapshot run value."));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate snapshot frequency value
|
||||||
|
|
||||||
|
if (!Validate::number($values['snapshot']['frequency'])) {
|
||||||
|
$this->clientError(_("Snapshot frequency must be a number."));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate report URL
|
||||||
|
|
||||||
|
if (!is_null($values['snapshot']['reporturl'])
|
||||||
|
&& !Validate::uri(
|
||||||
|
$values['snapshot']['reporturl'],
|
||||||
|
array('allowed_schemes' => array('http', 'https')
|
||||||
|
)
|
||||||
|
)) {
|
||||||
|
$this->clientError(_("Invalid snapshot report URL."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class SnapshotAdminPanelForm extends AdminForm
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* ID of the form
|
||||||
|
*
|
||||||
|
* @return int ID of the form
|
||||||
|
*/
|
||||||
|
|
||||||
|
function id()
|
||||||
|
{
|
||||||
|
return 'form_snapshot_admin_panel';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* class of the form
|
||||||
|
*
|
||||||
|
* @return string class of the form
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formClass()
|
||||||
|
{
|
||||||
|
return 'form_settings';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action of the form
|
||||||
|
*
|
||||||
|
* @return string URL of the action
|
||||||
|
*/
|
||||||
|
|
||||||
|
function action()
|
||||||
|
{
|
||||||
|
return common_local_url('snapshotadminpanel');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Data elements of the form
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formData()
|
||||||
|
{
|
||||||
|
$this->out->elementStart(
|
||||||
|
'fieldset',
|
||||||
|
array('id' => 'settings_admin_snapshots')
|
||||||
|
);
|
||||||
|
$this->out->element('legend', null, _('Snapshots'));
|
||||||
|
$this->out->elementStart('ul', 'form_data');
|
||||||
|
$this->li();
|
||||||
|
$snapshot = array(
|
||||||
|
'web' => _('Randomly during Web hit'),
|
||||||
|
'cron' => _('In a scheduled job'),
|
||||||
|
'never' => _('Never')
|
||||||
|
);
|
||||||
|
$this->out->dropdown(
|
||||||
|
'run',
|
||||||
|
_('Data snapshots'),
|
||||||
|
$snapshot,
|
||||||
|
_('When to send statistical data to status.net servers'),
|
||||||
|
false,
|
||||||
|
$this->value('run', 'snapshot')
|
||||||
|
);
|
||||||
|
$this->unli();
|
||||||
|
|
||||||
|
$this->li();
|
||||||
|
$this->input(
|
||||||
|
'frequency',
|
||||||
|
_('Frequency'),
|
||||||
|
_('Snapshots will be sent once every N web hits'),
|
||||||
|
'snapshot'
|
||||||
|
);
|
||||||
|
$this->unli();
|
||||||
|
|
||||||
|
$this->li();
|
||||||
|
$this->input(
|
||||||
|
'reporturl',
|
||||||
|
_('Report URL'),
|
||||||
|
_('Snapshots will be sent to this URL'),
|
||||||
|
'snapshot'
|
||||||
|
);
|
||||||
|
$this->unli();
|
||||||
|
$this->out->elementEnd('ul');
|
||||||
|
$this->out->elementEnd('fieldset');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Action elements
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
|
||||||
|
function formActions()
|
||||||
|
{
|
||||||
|
$this->out->submit(
|
||||||
|
'submit',
|
||||||
|
_('Save'),
|
||||||
|
'submit',
|
||||||
|
null,
|
||||||
|
_('Save snapshot settings')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -381,6 +381,11 @@ class AdminPanelNav extends Widget
|
|||||||
_('Edit site notice'), $action_name == 'sitenoticeadminpanel', 'nav_sitenotice_admin_panel');
|
_('Edit site notice'), $action_name == 'sitenoticeadminpanel', 'nav_sitenotice_admin_panel');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (AdminPanelAction::canAdmin('snapshot')) {
|
||||||
|
$this->out->menuItem(common_local_url('snapshotadminpanel'), _('Snapshots'),
|
||||||
|
_('Snapshots configuration'), $action_name == 'snapshotadminpanel', 'nav_snapshot_admin_panel');
|
||||||
|
}
|
||||||
|
|
||||||
Event::handle('EndAdminPanelNav', array($this));
|
Event::handle('EndAdminPanelNav', array($this));
|
||||||
}
|
}
|
||||||
$this->action->elementEnd('ul');
|
$this->action->elementEnd('ul');
|
||||||
|
@ -49,6 +49,8 @@ class Atom10FeedException extends Exception
|
|||||||
class Atom10Feed extends XMLStringer
|
class Atom10Feed extends XMLStringer
|
||||||
{
|
{
|
||||||
public $xw;
|
public $xw;
|
||||||
|
|
||||||
|
// @fixme most of these should probably be read-only properties
|
||||||
private $namespaces;
|
private $namespaces;
|
||||||
private $authors;
|
private $authors;
|
||||||
private $subject;
|
private $subject;
|
||||||
@ -57,10 +59,12 @@ class Atom10Feed extends XMLStringer
|
|||||||
private $generator;
|
private $generator;
|
||||||
private $icon;
|
private $icon;
|
||||||
private $links;
|
private $links;
|
||||||
private $logo;
|
private $selfLink;
|
||||||
|
private $selfLinkType;
|
||||||
|
public $logo;
|
||||||
private $rights;
|
private $rights;
|
||||||
private $subtitle;
|
public $subtitle;
|
||||||
private $title;
|
public $title;
|
||||||
private $published;
|
private $published;
|
||||||
private $updated;
|
private $updated;
|
||||||
private $entries;
|
private $entries;
|
||||||
@ -184,6 +188,10 @@ class Atom10Feed extends XMLStringer
|
|||||||
|
|
||||||
$this->renderAuthors();
|
$this->renderAuthors();
|
||||||
|
|
||||||
|
if ($this->selfLink) {
|
||||||
|
$this->addLink($this->selfLink, array('rel' => 'self',
|
||||||
|
'type' => $this->selfLinkType));
|
||||||
|
}
|
||||||
$this->renderLinks();
|
$this->renderLinks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,6 +261,12 @@ class Atom10Feed extends XMLStringer
|
|||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setSelfLink($url, $type='application/atom+xml')
|
||||||
|
{
|
||||||
|
$this->selfLink = $url;
|
||||||
|
$this->selfLinkType = $type;
|
||||||
|
}
|
||||||
|
|
||||||
function setTitle($title)
|
function setTitle($title)
|
||||||
{
|
{
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
|
@ -49,14 +49,42 @@ class AtomGroupNoticeFeed extends AtomNoticeFeed
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param Group $group the group for the feed (optional)
|
* @param Group $group the group for the feed
|
||||||
* @param boolean $indent flag to turn indenting on or off
|
* @param boolean $indent flag to turn indenting on or off
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
function __construct($group = null, $indent = true) {
|
function __construct($group, $indent = true) {
|
||||||
parent::__construct($indent);
|
parent::__construct($indent);
|
||||||
$this->group = $group;
|
$this->group = $group;
|
||||||
|
|
||||||
|
$title = sprintf(_("%s timeline"), $group->nickname);
|
||||||
|
$this->setTitle($title);
|
||||||
|
|
||||||
|
$sitename = common_config('site', 'name');
|
||||||
|
$subtitle = sprintf(
|
||||||
|
_('Updates from %1$s on %2$s!'),
|
||||||
|
$group->nickname,
|
||||||
|
$sitename
|
||||||
|
);
|
||||||
|
$this->setSubtitle($subtitle);
|
||||||
|
|
||||||
|
$avatar = $group->homepage_logo;
|
||||||
|
$logo = ($avatar) ? $avatar : User_group::defaultLogo(AVATAR_PROFILE_SIZE);
|
||||||
|
$this->setLogo($logo);
|
||||||
|
|
||||||
|
$this->setUpdated('now');
|
||||||
|
|
||||||
|
$self = common_local_url('ApiTimelineGroup',
|
||||||
|
array('id' => $group->id,
|
||||||
|
'format' => 'atom'));
|
||||||
|
$this->setId($self);
|
||||||
|
$this->setSelfLink($self);
|
||||||
|
|
||||||
|
$this->addAuthorRaw($group->asAtomAuthor());
|
||||||
|
$this->setActivitySubject($group->asActivitySubject());
|
||||||
|
|
||||||
|
$this->addLink($group->homeUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
function getGroup()
|
function getGroup()
|
||||||
|
@ -49,19 +49,56 @@ class AtomUserNoticeFeed extends AtomNoticeFeed
|
|||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param User $user the user for the feed (optional)
|
* @param User $user the user for the feed
|
||||||
* @param boolean $indent flag to turn indenting on or off
|
* @param boolean $indent flag to turn indenting on or off
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function __construct($user = null, $indent = true) {
|
function __construct($user, $indent = true) {
|
||||||
parent::__construct($indent);
|
parent::__construct($indent);
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
if (!empty($user)) {
|
if (!empty($user)) {
|
||||||
$profile = $user->getProfile();
|
$profile = $user->getProfile();
|
||||||
$this->addAuthor($profile->nickname, $user->uri);
|
$this->addAuthor($profile->nickname, $user->uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$title = sprintf(_("%s timeline"), $user->nickname);
|
||||||
|
$this->setTitle($title);
|
||||||
|
|
||||||
|
$sitename = common_config('site', 'name');
|
||||||
|
$subtitle = sprintf(
|
||||||
|
_('Updates from %1$s on %2$s!'),
|
||||||
|
$user->nickname, $sitename
|
||||||
|
);
|
||||||
|
$this->setSubtitle($subtitle);
|
||||||
|
|
||||||
|
$avatar = $profile->getAvatar(AVATAR_PROFILE_SIZE);
|
||||||
|
$logo = ($avatar) ? $avatar->displayUrl() : Avatar::defaultImage(AVATAR_PROFILE_SIZE);
|
||||||
|
$this->setLogo($logo);
|
||||||
|
|
||||||
|
$this->setUpdated('now');
|
||||||
|
|
||||||
|
$this->addLink(
|
||||||
|
common_local_url(
|
||||||
|
'showstream',
|
||||||
|
array('nickname' => $user->nickname)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$self = common_local_url('ApiTimelineUser',
|
||||||
|
array('id' => $user->id,
|
||||||
|
'format' => 'atom'));
|
||||||
|
$this->setId($self);
|
||||||
|
$this->setSelfLink($self);
|
||||||
|
|
||||||
|
$this->addLink(
|
||||||
|
common_local_url('sup', null, null, $user->id),
|
||||||
|
array(
|
||||||
|
'rel' => 'http://api.friendfeed.com/2008/03#sup',
|
||||||
|
'type' => 'application/json'
|
||||||
|
)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUser()
|
function getUser()
|
||||||
|
@ -651,6 +651,7 @@ class Router
|
|||||||
$m->connect('admin/paths', array('action' => 'pathsadminpanel'));
|
$m->connect('admin/paths', array('action' => 'pathsadminpanel'));
|
||||||
$m->connect('admin/sessions', array('action' => 'sessionsadminpanel'));
|
$m->connect('admin/sessions', array('action' => 'sessionsadminpanel'));
|
||||||
$m->connect('admin/sitenotice', array('action' => 'sitenoticeadminpanel'));
|
$m->connect('admin/sitenotice', array('action' => 'sitenoticeadminpanel'));
|
||||||
|
$m->connect('admin/snapshot', array('action' => 'snapshotadminpanel'));
|
||||||
|
|
||||||
$m->connect('getfile/:filename',
|
$m->connect('getfile/:filename',
|
||||||
array('action' => 'getfile'),
|
array('action' => 'getfile'),
|
||||||
|
@ -164,46 +164,21 @@ class OStatusQueueHandler extends QueueHandler
|
|||||||
*/
|
*/
|
||||||
function userFeedForNotice()
|
function userFeedForNotice()
|
||||||
{
|
{
|
||||||
// @fixme this feels VERY hacky...
|
$atom = new AtomUserNoticeFeed($this->user);
|
||||||
// should probably be a cleaner way to do it
|
$atom->addEntryFromNotice($this->notice);
|
||||||
|
$feed = $atom->getString();
|
||||||
|
|
||||||
ob_start();
|
|
||||||
$api = new ApiTimelineUserAction();
|
|
||||||
$api->prepare(array('id' => $this->notice->profile_id,
|
|
||||||
'format' => 'atom',
|
|
||||||
'max_id' => $this->notice->id,
|
|
||||||
'since_id' => $this->notice->id - 1));
|
|
||||||
$api->showTimeline();
|
|
||||||
$feed = ob_get_clean();
|
|
||||||
|
|
||||||
// ...and override the content-type back to something normal... eww!
|
|
||||||
// hope there's no other headers that got set while we weren't looking.
|
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
|
||||||
|
|
||||||
common_log(LOG_DEBUG, $feed);
|
|
||||||
return $feed;
|
return $feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
function groupFeedForNotice($group_id)
|
function groupFeedForNotice($group_id)
|
||||||
{
|
{
|
||||||
// @fixme this feels VERY hacky...
|
$group = User_group::staticGet('id', $group_id);
|
||||||
// should probably be a cleaner way to do it
|
|
||||||
|
|
||||||
ob_start();
|
$atom = new AtomGroupNoticeFeed($group);
|
||||||
$api = new ApiTimelineGroupAction();
|
$atom->addEntryFromNotice($this->notice);
|
||||||
$args = array('id' => $group_id,
|
$feed = $atom->getString();
|
||||||
'format' => 'atom',
|
|
||||||
'max_id' => $this->notice->id,
|
|
||||||
'since_id' => $this->notice->id - 1);
|
|
||||||
$api->prepare($args);
|
|
||||||
$api->handle($args);
|
|
||||||
$feed = ob_get_clean();
|
|
||||||
|
|
||||||
// ...and override the content-type back to something normal... eww!
|
|
||||||
// hope there's no other headers that got set while we weren't looking.
|
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
|
||||||
|
|
||||||
common_log(LOG_DEBUG, $feed);
|
|
||||||
return $feed;
|
return $feed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user