Commit 83a8cac9 authored by Evan Prodromou's avatar Evan Prodromou

Merge branch '1.0.x' into testing

parents 6d2ba2b7 0755f45b
......@@ -99,6 +99,15 @@ class AllAction extends ProfileAction
function getFeeds()
{
return array(
new Feed(Feed::JSON,
common_local_url(
'ApiTimelineFriends', array(
'format' => 'as',
'id' => $this->user->nickname
)
),
// TRANS: %s is user nickname.
sprintf(_('Feed for friends of %s (Activity Streams JSON)'), $this->user->nickname)),
new Feed(Feed::RSS1,
common_local_url(
'allrss', array(
......
......@@ -162,7 +162,12 @@ class PublicAction extends Action
*/
function getFeeds()
{
return array(new Feed(Feed::RSS1, common_local_url('publicrss'),
return array(new Feed(Feed::JSON,
common_local_url('ApiTimelinePublic',
array('format' => 'as')),
// TRANS: Link description for public timeline feed.
_('Public Stream Feed (Activity Streams JSON)')),
new Feed(Feed::RSS1, common_local_url('publicrss'),
// TRANS: Link description for public timeline feed.
_('Public Stream Feed (RSS 1.0)')),
new Feed(Feed::RSS2,
......
......@@ -143,7 +143,16 @@ class RepliesAction extends Action
*/
function getFeeds()
{
return array(new Feed(Feed::RSS1,
return array(new Feed(Feed::JSON,
common_local_url('ApiTimelineMentions',
array(
'id' => $this->user->nickname,
'format' => 'as')),
// TRANS: Link for feed with replies for a user.
// TRANS: %s is a user nickname.
sprintf(_('Replies feed for %s (Activity Streams JSON)'),
$this->user->nickname)),
new Feed(Feed::RSS1,
common_local_url('repliesrss',
array('nickname' => $this->user->nickname)),
// TRANS: Link for feed with replies for a user.
......
......@@ -165,7 +165,15 @@ class ShowfavoritesAction extends Action
*/
function getFeeds()
{
return array(new Feed(Feed::RSS1,
return array(new Feed(Feed::JSON,
common_local_url('ApiTimelineFavorites',
array(
'id' => $this->user->nickname,
'format' => 'as')),
// TRANS: Feed link text. %s is a username.
sprintf(_('Feed for favorites of %s (Activity Streams JSON)'),
$this->user->nickname)),
new Feed(Feed::RSS1,
common_local_url('favoritesrss',
array('nickname' => $this->user->nickname)),
// TRANS: Feed link text. %s is a username.
......
......@@ -220,7 +220,14 @@ class ShowgroupAction extends Action
common_local_url('grouprss',
array('nickname' => $this->group->nickname));
return array(new Feed(Feed::RSS1,
return array(new Feed(Feed::JSON,
common_local_url('ApiTimelineGroup',
array('format' => 'as',
'id' => $this->group->id)),
// TRANS: Tooltip for feed link. %s is a group nickname.
sprintf(_('Notice feed for %s group (Activity Streams JSON)'),
$this->group->nickname)),
new Feed(Feed::RSS1,
common_local_url('grouprss',
array('nickname' => $this->group->nickname)),
// TRANS: Tooltip for feed link. %s is a group nickname.
......
......@@ -169,7 +169,18 @@ class ShowprofiletagAction extends Action
function getFeeds()
{
#XXX: make these actually work
return array(new Feed(Feed::RSS2,
return array(new Feed(Feed::JSON,
common_local_url(
'ApiTimelineList', array(
'user' => $this->tagger->id,
'id' => $this->peopletag->id,
'format' => 'as'
)
),
// TRANS: Feed title.
// TRANS: %s is tagger's nickname.
sprintf(_('Feed for friends of %s (Activity Streams JSON)'), $this->tagger->nickname)),
new Feed(Feed::RSS2,
common_local_url(
'ApiTimelineList', array(
'user' => $this->tagger->id,
......
......@@ -127,7 +127,16 @@ class ShowstreamAction extends ProfileAction
$this->user->nickname, $this->tag)));
}
return array(new Feed(Feed::RSS1,
return array(new Feed(Feed::JSON,
common_local_url('ApiTimelineUser',
array(
'id' => $this->user->id,
'format' => 'as')),
// TRANS: Title for link to notice feed.
// TRANS: %s is a user nickname.
sprintf(_('Notice feed for %s (Activity Streams JSON)'),
$this->user->nickname)),
new Feed(Feed::RSS1,
common_local_url('userrss',
array('nickname' => $this->user->nickname)),
// TRANS: Title for link to notice feed.
......
......@@ -79,7 +79,15 @@ class TagAction extends Action
function getFeeds()
{
return array(new Feed(Feed::RSS1,
return array(new Feed(Feed::JSON,
common_local_url('ApiTimelineTag',
array('format' => 'as',
'tag' => $this->tag)),
// TRANS: Link label for feed on "notices with tag" page.
// TRANS: %s is the tag the feed is for.
sprintf(_('Notice feed for tag %s (Activity Streams JSON)'),
$this->tag)),
new Feed(Feed::RSS1,
common_local_url('tagrss',
array('tag' => $this->tag)),
// TRANS: Link label for feed on "notices with tag" page.
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
*
* LICENSE:
*
* Copyright (c) 2008, 2009, Alexey Borzov <avb@php.net>
* Copyright (c) 2008-2011, Alexey Borzov <avb@php.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -37,7 +37,7 @@
* @package HTTP_Request2
* @author Alexey Borzov <avb@php.net>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version CVS: $Id: Adapter.php 274684 2009-01-26 23:07:27Z avb $
* @version SVN: $Id: Adapter.php 308322 2011-02-14 13:58:03Z avb $
* @link http://pear.php.net/package/HTTP_Request2
*/
......@@ -50,13 +50,13 @@ require_once 'HTTP/Request2/Response.php';
* Base class for HTTP_Request2 adapters
*
* HTTP_Request2 class itself only defines methods for aggregating the request
* data, all actual work of sending the request to the remote server and
* data, all actual work of sending the request to the remote server and
* receiving its response is performed by adapters.
*
* @category HTTP
* @package HTTP_Request2
* @author Alexey Borzov <avb@php.net>
* @version Release: 0.4.1
* @version Release: 2.0.0RC1
*/
abstract class HTTP_Request2_Adapter
{
......@@ -109,8 +109,8 @@ abstract class HTTP_Request2_Adapter
/**
* Calculates length of the request body, adds proper headers
*
* @param array associative array of request headers, this method will
* add proper 'Content-Length' and 'Content-Type' headers
* @param array associative array of request headers, this method will
* add proper 'Content-Length' and 'Content-Type' headers
* to this array (or remove them if not needed)
*/
protected function calculateRequestLength(&$headers)
......@@ -133,13 +133,15 @@ abstract class HTTP_Request2_Adapter
if (in_array($this->request->getMethod(), self::$bodyDisallowed) ||
0 == $this->contentLength
) {
unset($headers['content-type']);
// No body: send a Content-Length header nonetheless (request #12900),
// but do that only for methods that require a body (bug #14740)
if (in_array($this->request->getMethod(), self::$bodyRequired)) {
$headers['content-length'] = 0;
} else {
unset($headers['content-length']);
// if the method doesn't require a body and doesn't have a
// body, don't send a Content-Type header. (request #16799)
unset($headers['content-type']);
}
} else {
if (empty($headers['content-type'])) {
......
This diff is collapsed.
......@@ -6,7 +6,7 @@
*
* LICENSE:
*
* Copyright (c) 2008, 2009, Alexey Borzov <avb@php.net>
* Copyright (c) 2008-2011, Alexey Borzov <avb@php.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -37,7 +37,7 @@
* @package HTTP_Request2
* @author Alexey Borzov <avb@php.net>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version CVS: $Id: Mock.php 274406 2009-01-23 18:01:57Z avb $
* @version SVN: $Id: Mock.php 308322 2011-02-14 13:58:03Z avb $
* @link http://pear.php.net/package/HTTP_Request2
*/
......@@ -55,31 +55,31 @@ require_once 'HTTP/Request2/Adapter.php';
* <code>
* $mock = new HTTP_Request2_Adapter_Mock();
* $mock->addResponse("HTTP/1.1 ... ");
*
*
* $request = new HTTP_Request2();
* $request->setAdapter($mock);
*
*
* // This will return the response set above
* $response = $req->send();
* </code>
* </code>
*
* @category HTTP
* @package HTTP_Request2
* @author Alexey Borzov <avb@php.net>
* @version Release: 0.4.1
* @version Release: 2.0.0RC1
*/
class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter
{
/**
* A queue of responses to be returned by sendRequest()
* @var array
* @var array
*/
protected $responses = array();
/**
* Returns the next response from the queue built by addResponse()
*
* If the queue is empty will return default empty response with status 400,
* If the queue is empty it will return default empty response with status 400,
* if an Exception object was added to the queue it will be thrown.
*
* @param HTTP_Request2
......@@ -93,7 +93,7 @@ class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter
if ($response instanceof HTTP_Request2_Response) {
return $response;
} else {
// rethrow the exception,
// rethrow the exception
$class = get_class($response);
$message = $response->getMessage();
$code = $response->getCode();
......@@ -108,7 +108,7 @@ class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter
* Adds response to the queue
*
* @param mixed either a string, a pointer to an open file,
* a HTTP_Request2_Response or Exception object
* an instance of HTTP_Request2_Response or Exception
* @throws HTTP_Request2_Exception
*/
public function addResponse($response)
......@@ -135,7 +135,7 @@ class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter
public static function createResponseFromString($str)
{
$parts = preg_split('!(\r?\n){2}!m', $str, 2);
$headerLines = explode("\n", $parts[0]);
$headerLines = explode("\n", $parts[0]);
$response = new HTTP_Request2_Response(array_shift($headerLines));
foreach ($headerLines as $headerLine) {
$response->parseHeaderLine($headerLine);
......
This diff is collapsed.
<?php
/**
* Exception class for HTTP_Request2 package
* Exception classes for HTTP_Request2 package
*
* PHP version 5
*
* LICENSE:
*
* Copyright (c) 2008, 2009, Alexey Borzov <avb@php.net>
* Copyright (c) 2008-2011, Alexey Borzov <avb@php.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -37,7 +37,7 @@
* @package HTTP_Request2
* @author Alexey Borzov <avb@php.net>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version CVS: $Id: Exception.php 273003 2009-01-07 19:28:22Z avb $
* @version SVN: $Id: Exception.php 308629 2011-02-24 17:34:24Z avb $
* @link http://pear.php.net/package/HTTP_Request2
*/
......@@ -47,16 +47,114 @@
require_once 'PEAR/Exception.php';
/**
* Exception class for HTTP_Request2 package
*
* Such a class is required by the Exception RFC:
* http://pear.php.net/pepr/pepr-proposal-show.php?id=132
* Base exception class for HTTP_Request2 package
*
* @category HTTP
* @package HTTP_Request2
* @version Release: 0.4.1
* @version Release: 2.0.0RC1
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=132
*/
class HTTP_Request2_Exception extends PEAR_Exception
{
/** An invalid argument was passed to a method */
const INVALID_ARGUMENT = 1;
/** Some required value was not available */
const MISSING_VALUE = 2;
/** Request cannot be processed due to errors in PHP configuration */
const MISCONFIGURATION = 3;
/** Error reading the local file */
const READ_ERROR = 4;
/** Server returned a response that does not conform to HTTP protocol */
const MALFORMED_RESPONSE = 10;
/** Failure decoding Content-Encoding or Transfer-Encoding of response */
const DECODE_ERROR = 20;
/** Operation timed out */
const TIMEOUT = 30;
/** Number of redirects exceeded 'max_redirects' configuration parameter */
const TOO_MANY_REDIRECTS = 40;
/** Redirect to a protocol other than http(s):// */
const NON_HTTP_REDIRECT = 50;
/**
* Native error code
* @var int
*/
private $_nativeCode;
/**
* Constructor, can set package error code and native error code
*
* @param string exception message
* @param int package error code, one of class constants
* @param int error code from underlying PHP extension
*/
public function __construct($message = null, $code = null, $nativeCode = null)
{
parent::__construct($message, $code);
$this->_nativeCode = $nativeCode;
}
/**
* Returns error code produced by underlying PHP extension
*
* For Socket Adapter this may contain error number returned by
* stream_socket_client(), for Curl Adapter this will contain error number
* returned by curl_errno()
*
* @return integer
*/
public function getNativeCode()
{
return $this->_nativeCode;
}
}
/**
* Exception thrown in case of missing features
*
* @category HTTP
* @package HTTP_Request2
* @version Release: 2.0.0RC1
*/
class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception {}
/**
* Exception that represents error in the program logic
*
* This exception usually implies a programmer's error, like passing invalid
* data to methods or trying to use PHP extensions that weren't installed or
* enabled. Usually exceptions of this kind will be thrown before request even
* starts.
*
* The exception will usually contain a package error code.
*
* @category HTTP
* @package HTTP_Request2
* @version Release: 2.0.0RC1
*/
class HTTP_Request2_LogicException extends HTTP_Request2_Exception {}
/**
* Exception thrown when connection to a web or proxy server fails
*
* The exception will not contain a package error code, but will contain
* native error code, as returned by stream_socket_client() or curl_errno().
*
* @category HTTP
* @package HTTP_Request2
* @version Release: 2.0.0RC1
*/
class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception {}
/**
* Exception thrown when sending or receiving HTTP message fails
*
* The exception may contain both package error code and native error code.
*
* @category HTTP
* @package HTTP_Request2
* @version Release: 2.0.0RC1
*/
class HTTP_Request2_MessageException extends HTTP_Request2_Exception {}
?>
\ No newline at end of file
......@@ -6,7 +6,7 @@
*
* LICENSE:
*
* Copyright (c) 2008, 2009, Alexey Borzov <avb@php.net>
* Copyright (c) 2008-2011, Alexey Borzov <avb@php.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -37,7 +37,7 @@
* @package HTTP_Request2
* @author Alexey Borzov <avb@php.net>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version CVS: $Id: MultipartBody.php 287306 2009-08-14 15:22:52Z avb $
* @version SVN: $Id: MultipartBody.php 308322 2011-02-14 13:58:03Z avb $
* @link http://pear.php.net/package/HTTP_Request2
*/
......@@ -50,7 +50,7 @@
* @category HTTP
* @package HTTP_Request2
* @author Alexey Borzov <avb@php.net>
* @version Release: 0.4.1
* @version Release: 2.0.0RC1
* @link http://tools.ietf.org/html/rfc1867
*/
class HTTP_Request2_MultipartBody
......@@ -172,7 +172,7 @@ class HTTP_Request2_MultipartBody
while ($length > 0 && $this->_pos[0] <= $paramCount + $uploadCount) {
$oldLength = $length;
if ($this->_pos[0] < $paramCount) {
$param = sprintf($this->_headerParam, $boundary,
$param = sprintf($this->_headerParam, $boundary,
$this->_params[$this->_pos[0]][0]) .
$this->_params[$this->_pos[0]][1] . "\r\n";
$ret .= substr($param, $this->_pos[1], $length);
......
......@@ -6,7 +6,7 @@
*
* LICENSE:
*
* Copyright (c) 2008, 2009, Alexey Borzov <avb@php.net>
* Copyright (c) 2008-2011, Alexey Borzov <avb@php.net>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
......@@ -38,19 +38,19 @@
* @author David Jean Louis <izi@php.net>
* @author Alexey Borzov <avb@php.net>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version CVS: $Id: Log.php 272593 2009-01-02 16:27:14Z avb $
* @version SVN: $Id: Log.php 308680 2011-02-25 17:40:17Z avb $
* @link http://pear.php.net/package/HTTP_Request2
*/
/**
* Exception class for HTTP_Request2 package
*/
*/
require_once 'HTTP/Request2/Exception.php';
/**
* A debug observer useful for debugging / testing.
*
* This observer logs to a log target data corresponding to the various request
* This observer logs to a log target data corresponding to the various request
* and response events, it logs by default to php://output but can be configured
* to log to a file or via the PEAR Log package.
*
......@@ -87,7 +87,7 @@ require_once 'HTTP/Request2/Exception.php';
* @author David Jean Louis <izi@php.net>
* @author Alexey Borzov <avb@php.net>
* @license http://opensource.org/licenses/bsd-license.php New BSD License
* @version Release: 0.4.1
* @version Release: 2.0.0RC1
* @link http://pear.php.net/package/HTTP_Request2
*/
class HTTP_Request2_Observer_Log implements SplObserver
......@@ -109,7 +109,7 @@ class HTTP_Request2_Observer_Log implements SplObserver
public $events = array(
'connect',
'sentHeaders',
'sentBodyPart',
'sentBody',
'receivedHeaders',
'receivedBody',
'disconnect',
......@@ -134,7 +134,7 @@ class HTTP_Request2_Observer_Log implements SplObserver
}
if (is_resource($target) || $target instanceof Log) {
$this->target = $target;
} elseif (false === ($this->target = @fopen($target, 'w'))) {
} elseif (false === ($this->target = @fopen($target, 'ab'))) {
throw new HTTP_Request2_Exception("Unable to open '{$target}'");
}
}
......@@ -143,7 +143,7 @@ class HTTP_Request2_Observer_Log implements SplObserver
// update() {{{
/**
* Called when the request notify us of an event.
* Called when the request notifies us of an event.
*
* @param HTTP_Request2 $subject The HTTP_Request2 instance
*
......@@ -167,8 +167,8 @@ class HTTP_Request2_Observer_Log implements SplObserver
$this->log('> ' . $header);
}
break;
case 'sentBodyPart':
$this->log('> ' . $event['data']);
case 'sentBody':
$this->log('> ' . $event['data'] . ' byte(s) sent');
break;
case 'receivedHeaders':
$this->log(sprintf('< HTTP/%s %s %s',
......@@ -189,12 +189,12 @@ class HTTP_Request2_Observer_Log implements SplObserver
break;
}
}
// }}}
// log() {{{
/**
* Log the given message to the configured target.
* Logs the given message to the configured target.
*
* @param string $message Message to display
*
......
This diff is collapsed.
......@@ -49,6 +49,7 @@ class Feed
const RSS2 = 2;
const ATOM = 3;
const FOAF = 4;
const JSON = 5; // Activity Streams
var $type = null;
var $url = null;
......@@ -72,6 +73,8 @@ class Feed
return 'application/atom+xml';
case Feed::FOAF:
return 'application/rdf+xml';
case Feed::JSON:
return 'application/json';
default:
return null;
}
......@@ -92,6 +95,9 @@ class Feed
case Feed::FOAF:
// TRANS: Feed type name. FOAF stands for Friend of a Friend.
return _('FOAF');
case Feed::JSON:
// TRANS: Feed type name. See http://activitystrea.ms/
return _('Activity Streams');
default:
return null;
}
......@@ -103,6 +109,7 @@ class Feed
case Feed::RSS1:
case Feed::RSS2:
case Feed::ATOM:
case Feed::JSON:
return 'alternate';
case Feed::FOAF:
return 'meta';
......
......@@ -93,6 +93,9 @@ class FeedList extends Widget
case Feed::FOAF:
$classname = 'foaf';
break;
case Feed::JSON:
$classname = 'json';
break;
}
$this->out->elementStart('li');
......
......@@ -2009,6 +2009,13 @@ background-position:0 -64px;
#export_data li a.foaf {
background-position:0 1px;
}
#export_data li a.json {
background-image:url(../images/icons/activitystreams.png);
background-repeat:no-repeat;
background-color:transparent;
}
.form_group_leave input.submit,
.form_user_unsubscribe input.submit,
.form_user_remove_peopletag input.submit,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment