[ROUTES] Allow accept-header specification during router creation
Router: - Fix calls to connect, most of them were misusing the function's params URLMapper: - Minor fixes - Documentation - Add support for accept-header specification Plugins/*: - Fix calls to connect
This commit is contained in:
parent
2032c7c1f7
commit
5c0a3102ff
116
extlib/AcceptHeader.php
Normal file
116
extlib/AcceptHeader.php
Normal file
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
/**
|
||||
* Note : Code is released under the GNU LGPL
|
||||
*
|
||||
* Please do not change the header of this file
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or modify it under the terms of the GNU
|
||||
* Lesser General Public License as published by the Free Software Foundation; either version 2 of
|
||||
* the License, or (at your option) any later version.
|
||||
*
|
||||
* This library 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 Lesser General Public License for more details.
|
||||
*/
|
||||
|
||||
/**
|
||||
* The AcceptHeader page will parse and sort the different
|
||||
* allowed types for the content negociations
|
||||
*
|
||||
* @author Pierrick Charron <pierrick@webstart.fr>
|
||||
*/
|
||||
class AcceptHeader extends \ArrayObject
|
||||
{
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $header Value of the Accept header
|
||||
* @return void
|
||||
*/
|
||||
public function __construct($header)
|
||||
{
|
||||
$acceptedTypes = $this->_parse($header);
|
||||
usort($acceptedTypes, [$this, '_compare']);
|
||||
parent::__construct($acceptedTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the accept header and return an array containing
|
||||
* all the informations about the Accepted types
|
||||
*
|
||||
* @param string $data Value of the Accept header
|
||||
* @return array
|
||||
*/
|
||||
private function _parse($data)
|
||||
{
|
||||
$array = [];
|
||||
$items = explode(',', $data);
|
||||
foreach ($items as $item) {
|
||||
$elems = explode(';', $item);
|
||||
|
||||
$acceptElement = [];
|
||||
$mime = current($elems);
|
||||
list($type, $subtype) = explode('/', $mime);
|
||||
$acceptElement['type'] = trim($type);
|
||||
$acceptElement['subtype'] = trim($subtype);
|
||||
$acceptElement['raw'] = $mime;
|
||||
|
||||
$acceptElement['params'] = [];
|
||||
while (next($elems)) {
|
||||
list($name, $value) = explode('=', current($elems));
|
||||
$acceptElement['params'][trim($name)] = trim($value);
|
||||
}
|
||||
|
||||
$array[] = $acceptElement;
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two Accepted types with their parameters to know
|
||||
* if one media type should be used instead of an other
|
||||
*
|
||||
* @param array $a The first media type and its parameters
|
||||
* @param array $b The second media type and its parameters
|
||||
* @return int
|
||||
*/
|
||||
private function _compare($a, $b)
|
||||
{
|
||||
$a_q = isset($a['params']['q']) ? floatval($a['params']['q']) : 1.0;
|
||||
$b_q = isset($b['params']['q']) ? floatval($b['params']['q']) : 1.0;
|
||||
if ($a_q === $b_q) {
|
||||
$a_count = count($a['params']);
|
||||
$b_count = count($b['params']);
|
||||
if ($a_count === $b_count) {
|
||||
if ($r = $this->_compareSubType($a['subtype'], $b['subtype'])) {
|
||||
return $r;
|
||||
} else {
|
||||
return $this->_compareSubType($a['type'], $b['type']);
|
||||
}
|
||||
} else {
|
||||
return $a_count < $b_count;
|
||||
}
|
||||
} else {
|
||||
return $a_q < $b_q;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare two subtypes
|
||||
*
|
||||
* @param string $a First subtype to compare
|
||||
* @param string $b Second subtype to compare
|
||||
* @return int
|
||||
*/
|
||||
private function _compareSubType($a, $b)
|
||||
{
|
||||
if ($a === '*' && $b !== '*') {
|
||||
return 1;
|
||||
} elseif ($b === '*' && $a !== '*') {
|
||||
return -1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
1027
lib/router.php
1027
lib/router.php
File diff suppressed because it is too large
Load Diff
|
@ -60,12 +60,35 @@ class URLMapper
|
|||
protected $reverse = [];
|
||||
protected $allpaths = [];
|
||||
|
||||
public function connect($path, $args, $paramPatterns = array())
|
||||
/**
|
||||
* Route creation.
|
||||
* $acceptHeaders should be set to true when, for whatever reason,
|
||||
* a path is being re-connected. The $headers list is still optional,
|
||||
* in this case, given that being empty means "accept everything".
|
||||
*
|
||||
* @author Evan Prodromou <evan@status.net>
|
||||
* @author Bruno Casteleiro <brunoccast@fc.up.pt>
|
||||
* @param string $path route path
|
||||
* @param array $args route action and, if needed, action settings
|
||||
* @param array $paramPatterns regex patterns for path's parameters
|
||||
* @param bool $acceptHeaders whether a path is being re-connected
|
||||
* @param array $headers headers that should be set for route creation
|
||||
* @return void
|
||||
*/
|
||||
public function connect(string $path, array $args, array $paramPatterns = [], bool $acceptHeaders = false, array $headers = [])
|
||||
{
|
||||
if (!array_key_exists(self::ACTION, $args)) {
|
||||
throw new Exception(sprintf("Can't connect %s; path has no action.", $path));
|
||||
}
|
||||
|
||||
$should = true;
|
||||
if ($acceptHeaders) {
|
||||
// even if it shouldn't be used as a route, we still want
|
||||
// to store some information to allow common_local_url
|
||||
// to generate urls
|
||||
$should = empty($headers) || self::should($headers);
|
||||
}
|
||||
|
||||
$this->allpaths[] = $path;
|
||||
|
||||
$action = $args[self::ACTION];
|
||||
|
@ -75,15 +98,12 @@ class URLMapper
|
|||
if (empty($paramNames)) {
|
||||
$this->statics[$path] = $args;
|
||||
if (array_key_exists($action, $this->reverse)) {
|
||||
$this->reverse[$args[self::ACTION]][] = [$args, $path];
|
||||
$this->reverse[$action][] = [$args, $path];
|
||||
} else {
|
||||
$this->reverse[$args[self::ACTION]] = [[$args, $path]];
|
||||
$this->reverse[$action] = [[$args, $path]];
|
||||
}
|
||||
} else {
|
||||
|
||||
// Eff if I understand why some go here and some go there.
|
||||
// Anyways, fixup my preconceptions
|
||||
|
||||
// fix for the code that still make improper use of this function's params
|
||||
foreach ($paramNames as $name) {
|
||||
if (!array_key_exists($name, $paramPatterns) &&
|
||||
array_key_exists($name, $args)) {
|
||||
|
@ -92,16 +112,26 @@ class URLMapper
|
|||
}
|
||||
}
|
||||
|
||||
$regex = self::makeRegex($path, $paramPatterns);
|
||||
// $variables is used for path matching, so we can't store invalid routes
|
||||
if ($should) {
|
||||
$regex = self::makeRegex($path, $paramPatterns);
|
||||
|
||||
$this->variables[] = [$args, $regex, $paramNames];
|
||||
if (isset($this->variables[$regex]) || !$acceptHeaders) {
|
||||
$this->variables[$regex] = [$args, $paramNames];
|
||||
} else {
|
||||
// URLs that differ only in the attribute names will generate
|
||||
// different regexes, so in order to avoid the wrong one (oldest)
|
||||
// to be matched first, fresh regexes are stored at the front
|
||||
$this->variables = [$regex => [$args, $paramNames]] + $this->variables;
|
||||
}
|
||||
}
|
||||
|
||||
$format = $this->makeFormat($path, $paramPatterns);
|
||||
$format = $this->makeFormat($path);
|
||||
|
||||
if (array_key_exists($action, $this->reverse)) {
|
||||
$this->reverse[$args[self::ACTION]][] = [$args, $format, $paramNames];
|
||||
$this->reverse[$action][] = [$args, $format, $paramNames];
|
||||
} else {
|
||||
$this->reverse[$args[self::ACTION]] = [[$args, $format, $paramNames]];
|
||||
$this->reverse[$action] = [[$args, $format, $paramNames]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -112,8 +142,8 @@ class URLMapper
|
|||
return $this->statics[$path];
|
||||
}
|
||||
|
||||
foreach ($this->variables as $pattern) {
|
||||
list($args, $regex, $paramNames) = $pattern;
|
||||
foreach ($this->variables as $regex => $pattern) {
|
||||
list($args, $paramNames) = $pattern;
|
||||
if (preg_match($regex, $path, $match)) {
|
||||
$results = $args;
|
||||
foreach ($paramNames as $name) {
|
||||
|
@ -220,7 +250,7 @@ class URLMapper
|
|||
return $regex;
|
||||
}
|
||||
|
||||
protected function makeFormat($path, $paramPatterns)
|
||||
protected function makeFormat($path)
|
||||
{
|
||||
$format = preg_replace('/(:\w+)/', '%s', $path);
|
||||
|
||||
|
@ -229,7 +259,33 @@ class URLMapper
|
|||
|
||||
public function getPaths()
|
||||
{
|
||||
return $this->allpaths;
|
||||
return array_unique($this->allpaths);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the route should or not be overwrited.
|
||||
* If ACCEPT header isn't set, false will be returned.
|
||||
*
|
||||
* @author Diogo Cordeiro <diogo@fc.up.pt>
|
||||
* @param array $headers accept-headers that should be set to
|
||||
* mark the route for overwrite. This array must be associative
|
||||
* and contain the headers in the value-set.
|
||||
* @return bool true if should overwrite, false otherwise
|
||||
*/
|
||||
public static function should(array $headers): bool
|
||||
{
|
||||
if (!isset($_SERVER['HTTP_ACCEPT'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$acceptHeader = new AcceptHeader($_SERVER['HTTP_ACCEPT']);
|
||||
foreach ($acceptHeader as $ah) {
|
||||
if (isset($headers[$ah['raw']])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -52,9 +52,9 @@ class AccountManagerPlugin extends Plugin
|
|||
{
|
||||
// Discovery actions
|
||||
$m->connect('main/amcd.json',
|
||||
array('action' => 'AccountManagementControlDocument'));
|
||||
['action' => 'AccountManagementControlDocument']);
|
||||
$m->connect('main/amsessionstatus',
|
||||
array('action' => 'AccountManagementSessionStatus'));
|
||||
['action' => 'AccountManagementSessionStatus']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -185,11 +185,13 @@ class ActivitySpamPlugin extends Plugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('main/train/spam',
|
||||
array('action' => 'train', 'category' => 'spam'));
|
||||
['action' => 'train',
|
||||
'category' => 'spam']);
|
||||
$m->connect('main/train/ham',
|
||||
array('action' => 'train', 'category' => 'ham'));
|
||||
['action' => 'train',
|
||||
'category' => 'ham']);
|
||||
$m->connect('main/spam',
|
||||
array('action' => 'spam'));
|
||||
['action' => 'spam']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ class AutocompletePlugin extends Plugin
|
|||
|
||||
function onRouterInitialized($m)
|
||||
{
|
||||
$m->connect('main/autocomplete/suggest', array('action'=>'autocomplete'));
|
||||
$m->connect('main/autocomplete/suggest',
|
||||
['action' => 'autocomplete']);
|
||||
}
|
||||
|
||||
function onPluginVersion(array &$versions)
|
||||
|
|
|
@ -169,7 +169,7 @@ class BitlyUrlPlugin extends UrlShortenerPlugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('panel/bitly',
|
||||
array('action' => 'bitlyadminpanel'));
|
||||
['action' => 'bitlyadminpanel']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -251,7 +251,8 @@ class BlacklistPlugin extends Plugin
|
|||
*/
|
||||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('panel/blacklist', array('action' => 'blacklistadminpanel'));
|
||||
$m->connect('panel/blacklist',
|
||||
['action' => 'blacklistadminpanel']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,43 +114,44 @@ class BookmarkPlugin extends MicroAppPlugin
|
|||
if (common_config('singleuser', 'enabled')) {
|
||||
$nickname = User::singleUserNickname();
|
||||
$m->connect('bookmarks',
|
||||
array('action' => 'bookmarks', 'nickname' => $nickname));
|
||||
['action' => 'bookmarks',
|
||||
'nickname' => $nickname]);
|
||||
$m->connect('bookmarks/rss',
|
||||
array('action' => 'bookmarksrss', 'nickname' => $nickname));
|
||||
['action' => 'bookmarksrss',
|
||||
'nickname' => $nickname]);
|
||||
} else {
|
||||
$m->connect(':nickname/bookmarks',
|
||||
array('action' => 'bookmarks'),
|
||||
array('nickname' => Nickname::DISPLAY_FMT));
|
||||
['action' => 'bookmarks'],
|
||||
['nickname' => Nickname::DISPLAY_FMT]);
|
||||
$m->connect(':nickname/bookmarks/rss',
|
||||
array('action' => 'bookmarksrss'),
|
||||
array('nickname' => Nickname::DISPLAY_FMT));
|
||||
['action' => 'bookmarksrss'],
|
||||
['nickname' => Nickname::DISPLAY_FMT]);
|
||||
}
|
||||
|
||||
$m->connect('api/bookmarks/:id.:format',
|
||||
array('action' => 'ApiTimelineBookmarks',
|
||||
'id' => Nickname::INPUT_FMT,
|
||||
'format' => '(xml|json|rss|atom|as)'));
|
||||
['action' => 'ApiTimelineBookmarks'],
|
||||
['id' => Nickname::INPUT_FMT,
|
||||
'format' => '(xml|json|rss|atom|as)']);
|
||||
|
||||
$m->connect('main/bookmark/new',
|
||||
array('action' => 'newbookmark'),
|
||||
array('id' => '[0-9]+'));
|
||||
['action' => 'newbookmark']);
|
||||
|
||||
$m->connect('main/bookmark/popup',
|
||||
array('action' => 'bookmarkpopup'));
|
||||
['action' => 'bookmarkpopup']);
|
||||
|
||||
$m->connect('main/bookmark/import',
|
||||
array('action' => 'importdelicious'));
|
||||
['action' => 'importdelicious']);
|
||||
|
||||
$m->connect('main/bookmark/forurl',
|
||||
array('action' => 'bookmarkforurl'));
|
||||
['action' => 'bookmarkforurl']);
|
||||
|
||||
$m->connect('bookmark/:id',
|
||||
array('action' => 'showbookmark'),
|
||||
array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'));
|
||||
['action' => 'showbookmark'],
|
||||
['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']);
|
||||
|
||||
$m->connect('notice/by-url/:id',
|
||||
array('action' => 'noticebyurl'),
|
||||
array('id' => '[0-9]+'));
|
||||
['action' => 'noticebyurl'],
|
||||
['id' => '[0-9]+']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ class ChooseThemePlugin extends Plugin {
|
|||
const PLUGIN_VERSION = '0.1.0';
|
||||
|
||||
public function onRouterInitialized(URLMapper $m) {
|
||||
$m->connect('main/choosethemesettings', array('action' => 'choosethemesettings'));
|
||||
$m->connect('main/choosethemesettings', ['action' => 'choosethemesettings']);
|
||||
}
|
||||
|
||||
public function onPluginVersion(array &$versions) {
|
||||
|
|
|
@ -51,7 +51,8 @@ class ClientSideShortenPlugin extends Plugin
|
|||
function onRouterInitialized($m)
|
||||
{
|
||||
if (common_logged_in()) {
|
||||
$m->connect('plugins/ClientSideShorten/shorten', array('action'=>'shorten'));
|
||||
$m->connect('plugins/ClientSideShorten/shorten',
|
||||
['action'=>'shorten']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,23 +36,25 @@ class DirectMessagePlugin extends Plugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
// web front-end actions
|
||||
$m->connect('message/new', array('action' => 'newmessage'));
|
||||
$m->connect('message/new?to=:to', array('action' => 'newmessage'), array('to' => Nickname::DISPLAY_FMT));
|
||||
$m->connect('message/new', ['action' => 'newmessage']);
|
||||
$m->connect('message/new?to=:to',
|
||||
['action' => 'newmessage'],
|
||||
['to' => Nickname::DISPLAY_FMT]);
|
||||
$m->connect('message/:message',
|
||||
array('action' => 'showmessage'),
|
||||
array('message' => '[0-9]+'));
|
||||
['action' => 'showmessage'],
|
||||
['message' => '[0-9]+']);
|
||||
|
||||
// direct messages
|
||||
$m->connect('api/direct_messages.:format',
|
||||
array('action' => 'ApiDirectMessage',
|
||||
'format' => '(xml|json|rss|atom)'));
|
||||
['action' => 'ApiDirectMessage'],
|
||||
['format' => '(xml|json|rss|atom)']);
|
||||
$m->connect('api/direct_messages/sent.:format',
|
||||
array('action' => 'ApiDirectMessage',
|
||||
'format' => '(xml|json|rss|atom)',
|
||||
'sent' => true));
|
||||
['action' => 'ApiDirectMessage',
|
||||
'sent' => true],
|
||||
['format' => '(xml|json|rss|atom)']);
|
||||
$m->connect('api/direct_messages/new.:format',
|
||||
array('action' => 'ApiDirectMessageNew',
|
||||
'format' => '(xml|json)'));
|
||||
['action' => 'ApiDirectMessageNew'],
|
||||
['format' => '(xml|json)']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -81,62 +81,42 @@ class DirectoryPlugin extends Plugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
|
||||
$m->connect(
|
||||
'directory/users/:filter/sort_by/:sort/reverse/:reverse',
|
||||
array('action' => 'userdirectory'),
|
||||
array('filter' => '[0-9a-zA-Z]|(0-9)'),
|
||||
array('sort' => '[a-z]+'),
|
||||
array('reverse' => '[0-9]')
|
||||
);
|
||||
$m->connect('directory/users/:filter/sort_by/:sort/reverse/:reverse',
|
||||
['action' => 'userdirectory'],
|
||||
['filter' => '[0-9a-zA-Z]|(0-9)',
|
||||
'sort' => '[a-z]+',
|
||||
'reverse' => '[0-9]']);
|
||||
|
||||
$m->connect(
|
||||
'directory/users/:filter/sort_by/:sort',
|
||||
array('action' => 'userdirectory'),
|
||||
array('filter' => '[0-9a-zA-Z]|(0-9)'),
|
||||
array('sort' => '[a-z]+')
|
||||
);
|
||||
$m->connect('directory/users/:filter/sort_by/:sort',
|
||||
['action' => 'userdirectory'],
|
||||
['filter' => '[0-9a-zA-Z]|(0-9)',
|
||||
'sort' => '[a-z]+']);
|
||||
|
||||
|
||||
$m->connect(
|
||||
'directory/users/:filter',
|
||||
array('action' => 'userdirectory'),
|
||||
array('filter' => '[0-9a-zA-Z]|(0-9)')
|
||||
);
|
||||
$m->connect('directory/users/:filter',
|
||||
['action' => 'userdirectory'],
|
||||
['filter' => '[0-9a-zA-Z]|(0-9)']);
|
||||
|
||||
$m->connect(
|
||||
'directory/users/sort_by/:sort/reverse/:reverse',
|
||||
array('action' => 'userdirectory'),
|
||||
array('sort' => '[a-z]+'),
|
||||
array('reverse' => '[0-9]')
|
||||
);
|
||||
$m->connect('directory/users/sort_by/:sort/reverse/:reverse',
|
||||
['action' => 'userdirectory'],
|
||||
['sort' => '[a-z]+',
|
||||
'reverse' => '[0-9]']);
|
||||
|
||||
$m->connect(
|
||||
'directory/users/sort_by/:sort',
|
||||
array('action' => 'userdirectory'),
|
||||
array('sort' => '[a-z]+')
|
||||
);
|
||||
$m->connect('directory/users/sort_by/:sort',
|
||||
['action' => 'userdirectory'],
|
||||
['sort' => '[a-z]+']);
|
||||
|
||||
$m->connect(
|
||||
'directory/users',
|
||||
array('action' => 'userdirectory')
|
||||
);
|
||||
$m->connect('directory/users',
|
||||
['action' => 'userdirectory']);
|
||||
|
||||
$m->connect(
|
||||
'groups/:filter',
|
||||
array('action' => 'groupdirectory'),
|
||||
array('filter' => '[0-9a-zA-Z]|(0-9)')
|
||||
);
|
||||
$m->connect('groups/:filter',
|
||||
['action' => 'groupdirectory'],
|
||||
['filter' => '[0-9a-zA-Z]|(0-9)']);
|
||||
|
||||
$m->connect(
|
||||
'groups',
|
||||
array('action' => 'groupdirectory')
|
||||
);
|
||||
|
||||
$m->connect(
|
||||
'groups/all',
|
||||
array('action' => 'groupdirectory')
|
||||
);
|
||||
$m->connect('groups',
|
||||
['action' => 'groupdirectory']);
|
||||
|
||||
$m->connect('groups/all',
|
||||
['action' => 'groupdirectory']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -131,7 +131,7 @@ class DomainStatusNetworkPlugin extends Plugin
|
|||
if (common_config('globalapi', 'enabled')) {
|
||||
foreach (array('register', 'login', 'recover') as $method) {
|
||||
$m->connect('api/statusnet/global/'.$method,
|
||||
array('action' => 'global'.$method));
|
||||
['action' => 'global'.$method]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -78,24 +78,24 @@ class EventPlugin extends ActivityVerbHandlerPlugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('main/event/new',
|
||||
array('action' => 'newevent'));
|
||||
['action' => 'newevent']);
|
||||
$m->connect('main/event/rsvp',
|
||||
array('action' => 'rsvp'));
|
||||
['action' => 'rsvp']);
|
||||
$m->connect('main/event/rsvp/:rsvp', // this will probably change to include event notice id
|
||||
array('action' => 'rsvp'),
|
||||
array('rsvp' => '[a-z]+'));
|
||||
['action' => 'rsvp'],
|
||||
['rsvp' => '[a-z]+']);
|
||||
$m->connect('event/:id',
|
||||
array('action' => 'showevent'),
|
||||
array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'));
|
||||
['action' => 'showevent'],
|
||||
['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']);
|
||||
$m->connect('rsvp/:id',
|
||||
array('action' => 'showrsvp'),
|
||||
array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'));
|
||||
['action' => 'showrsvp'],
|
||||
['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']);
|
||||
$m->connect('main/event/updatetimes',
|
||||
array('action' => 'timelist'));
|
||||
['action' => 'timelist']);
|
||||
|
||||
$m->connect(':nickname/events',
|
||||
array('action' => 'events'),
|
||||
array('nickname' => Nickname::DISPLAY_FMT));
|
||||
['action' => 'events'],
|
||||
['nickname' => Nickname::DISPLAY_FMT]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -114,72 +114,77 @@ class FavoritePlugin extends ActivityVerbHandlerPlugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
// Web UI actions
|
||||
$m->connect('main/favor', array('action' => 'favor'));
|
||||
$m->connect('main/disfavor', array('action' => 'disfavor'));
|
||||
$m->connect('main/favor',
|
||||
['action' => 'favor']);
|
||||
$m->connect('main/disfavor',
|
||||
['action' => 'disfavor']);
|
||||
|
||||
if (common_config('singleuser', 'enabled')) {
|
||||
$nickname = User::singleUserNickname();
|
||||
|
||||
$m->connect('favorites',
|
||||
array('action' => 'showfavorites',
|
||||
'nickname' => $nickname));
|
||||
['action' => 'showfavorites',
|
||||
'nickname' => $nickname]);
|
||||
$m->connect('favoritesrss',
|
||||
array('action' => 'favoritesrss',
|
||||
'nickname' => $nickname));
|
||||
['action' => 'favoritesrss',
|
||||
'nickname' => $nickname]);
|
||||
} else {
|
||||
$m->connect('favoritedrss', array('action' => 'favoritedrss'));
|
||||
$m->connect('favorited/', array('action' => 'favorited'));
|
||||
$m->connect('favorited', array('action' => 'favorited'));
|
||||
$m->connect('favoritedrss',
|
||||
['action' => 'favoritedrss']);
|
||||
$m->connect('favorited/',
|
||||
['action' => 'favorited']);
|
||||
$m->connect('favorited',
|
||||
['action' => 'favorited']);
|
||||
|
||||
$m->connect(':nickname/favorites',
|
||||
array('action' => 'showfavorites'),
|
||||
array('nickname' => Nickname::DISPLAY_FMT));
|
||||
['action' => 'showfavorites'],
|
||||
['nickname' => Nickname::DISPLAY_FMT]);
|
||||
$m->connect(':nickname/favorites/rss',
|
||||
array('action' => 'favoritesrss'),
|
||||
array('nickname' => Nickname::DISPLAY_FMT));
|
||||
['action' => 'favoritesrss'],
|
||||
['nickname' => Nickname::DISPLAY_FMT]);
|
||||
}
|
||||
|
||||
// Favorites for API
|
||||
$m->connect('api/favorites/create.:format',
|
||||
array('action' => 'ApiFavoriteCreate'),
|
||||
array('format' => '(xml|json)'));
|
||||
['action' => 'ApiFavoriteCreate'],
|
||||
['format' => '(xml|json)']);
|
||||
$m->connect('api/favorites/destroy.:format',
|
||||
array('action' => 'ApiFavoriteDestroy'),
|
||||
array('format' => '(xml|json)'));
|
||||
['action' => 'ApiFavoriteDestroy'],
|
||||
['format' => '(xml|json)']);
|
||||
$m->connect('api/favorites/list.:format',
|
||||
array('action' => 'ApiTimelineFavorites'),
|
||||
array('format' => '(xml|json|rss|atom|as)'));
|
||||
['action' => 'ApiTimelineFavorites'],
|
||||
['format' => '(xml|json|rss|atom|as)']);
|
||||
$m->connect('api/favorites/:id.:format',
|
||||
array('action' => 'ApiTimelineFavorites'),
|
||||
array('id' => Nickname::INPUT_FMT,
|
||||
'format' => '(xml|json|rss|atom|as)'));
|
||||
['action' => 'ApiTimelineFavorites'],
|
||||
['id' => Nickname::INPUT_FMT,
|
||||
'format' => '(xml|json|rss|atom|as)']);
|
||||
$m->connect('api/favorites.:format',
|
||||
array('action' => 'ApiTimelineFavorites'),
|
||||
array('format' => '(xml|json|rss|atom|as)'));
|
||||
['action' => 'ApiTimelineFavorites'],
|
||||
['format' => '(xml|json|rss|atom|as)']);
|
||||
$m->connect('api/favorites/create/:id.:format',
|
||||
array('action' => 'ApiFavoriteCreate'),
|
||||
array('id' => '[0-9]+',
|
||||
'format' => '(xml|json)'));
|
||||
['action' => 'ApiFavoriteCreate'],
|
||||
['id' => '[0-9]+',
|
||||
'format' => '(xml|json)']);
|
||||
$m->connect('api/favorites/destroy/:id.:format',
|
||||
array('action' => 'ApiFavoriteDestroy'),
|
||||
array('id' => '[0-9]+',
|
||||
'format' => '(xml|json)'));
|
||||
['action' => 'ApiFavoriteDestroy'],
|
||||
['id' => '[0-9]+',
|
||||
'format' => '(xml|json)']);
|
||||
|
||||
// AtomPub API
|
||||
$m->connect('api/statusnet/app/favorites/:profile/:notice.atom',
|
||||
array('action' => 'AtomPubShowFavorite'),
|
||||
array('profile' => '[0-9]+',
|
||||
'notice' => '[0-9]+'));
|
||||
['action' => 'AtomPubShowFavorite'],
|
||||
['profile' => '[0-9]+',
|
||||
'notice' => '[0-9]+']);
|
||||
|
||||
$m->connect('api/statusnet/app/favorites/:profile.atom',
|
||||
array('action' => 'AtomPubFavoriteFeed'),
|
||||
array('profile' => '[0-9]+'));
|
||||
['action' => 'AtomPubFavoriteFeed'],
|
||||
['profile' => '[0-9]+']);
|
||||
|
||||
// Required for qvitter API
|
||||
$m->connect('api/statuses/favs/:id.:format',
|
||||
array('action' => 'ApiStatusesFavs'),
|
||||
array('id' => '[0-9]+',
|
||||
'format' => '(xml|json)'));
|
||||
['action' => 'ApiStatusesFavs'],
|
||||
['id' => '[0-9]+',
|
||||
'format' => '(xml|json)']);
|
||||
}
|
||||
|
||||
// FIXME: Set this to abstract public in lib/activityhandlerplugin.php ddwhen all plugins have migrated!
|
||||
|
|
|
@ -46,8 +46,8 @@ class GNUsocialPhotoPlugin extends MicroAppPlugin
|
|||
|
||||
function onRouterInitialized($m)
|
||||
{
|
||||
$m->connect('main/photo/new', array('action' => 'newphoto'));
|
||||
$m->connect('main/photo/:id', array('action' => 'showphoto'));
|
||||
$m->connect('main/photo/new', ['action' => 'newphoto']);
|
||||
$m->connect('main/photo/:id', ['action' => 'showphoto']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,11 +46,11 @@ class GNUsocialPhotosPlugin extends Plugin
|
|||
|
||||
function onRouterInitialized($m)
|
||||
{
|
||||
$m->connect(':nickname/photos', array('action' => 'photos'));
|
||||
$m->connect(':nickname/photos/:albumid', array('action' => 'photos'));
|
||||
$m->connect('main/uploadphoto', array('action' => 'photoupload'));
|
||||
$m->connect('photo/:photoid', array('action' => 'photo'));
|
||||
$m->connect('editphoto/:photoid', array('action' => 'editphoto'));
|
||||
$m->connect(':nickname/photos', ['action' => 'photos']);
|
||||
$m->connect(':nickname/photos/:albumid', ['action' => 'photos']);
|
||||
$m->connect('main/uploadphoto', ['action' => 'photoupload']);
|
||||
$m->connect('photo/:photoid', ['action' => 'photo']);
|
||||
$m->connect('editphoto/:photoid', ['action' => 'editphoto']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -45,9 +45,9 @@ class GNUsocialProfileExtensionsPlugin extends Plugin
|
|||
|
||||
function onRouterInitialized($m)
|
||||
{
|
||||
$m->connect(':nickname/bio', array('action' => 'bio'));
|
||||
$m->connect('admin/profilefields', array('action' => 'profilefieldsAdminPanel'));
|
||||
$m->connect('notice/respond', array('action' => 'newresponse'));
|
||||
$m->connect(':nickname/bio', ['action' => 'bio']);
|
||||
$m->connect('admin/profilefields', ['action' => 'profilefieldsAdminPanel']);
|
||||
$m->connect('notice/respond', ['action' => 'newresponse']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ class GNUsocialVideoPlugin extends MicroAppPlugin
|
|||
|
||||
function onRouterInitialized($m)
|
||||
{
|
||||
$m->connect('main/postvideo', array('action' => 'postvideo'));
|
||||
$m->connect('showvideo/:id', array('action' => 'showvideo'));
|
||||
$m->connect('main/postvideo', ['action' => 'postvideo']);
|
||||
$m->connect('showvideo/:id', ['action' => 'showvideo']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,8 +37,8 @@ class GroupFavoritedPlugin extends Plugin
|
|||
function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('group/:nickname/favorited',
|
||||
array('action' => 'groupfavorited'),
|
||||
array('nickname' => '[a-zA-Z0-9]+'));
|
||||
['action' => 'groupfavorited'],
|
||||
['nickname' => '[a-zA-Z0-9]+']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -79,16 +79,16 @@ class GroupPrivateMessagePlugin extends Plugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('group/:nickname/inbox',
|
||||
array('action' => 'groupinbox'),
|
||||
array('nickname' => Nickname::DISPLAY_FMT));
|
||||
['action' => 'groupinbox'],
|
||||
['nickname' => Nickname::DISPLAY_FMT]);
|
||||
|
||||
$m->connect('group/message/:id',
|
||||
array('action' => 'showgroupmessage'),
|
||||
array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}'));
|
||||
['action' => 'showgroupmessage'],
|
||||
['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']);
|
||||
|
||||
$m->connect('group/:nickname/message/new',
|
||||
array('action' => 'newgroupmessage'),
|
||||
array('nickname' => Nickname::DISPLAY_FMT));
|
||||
['action' => 'newgroupmessage'],
|
||||
['nickname' => Nickname::DISPLAY_FMT]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -338,8 +338,10 @@ class LinkbackPlugin extends Plugin
|
|||
|
||||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('main/linkback/webmention', array('action' => 'webmention'));
|
||||
$m->connect('main/linkback/pingback', array('action' => 'pingback'));
|
||||
$m->connect('main/linkback/webmention',
|
||||
['action' => 'webmention']);
|
||||
$m->connect('main/linkback/pingback',
|
||||
['action' => 'pingback']);
|
||||
}
|
||||
|
||||
public function onStartShowHTML($action)
|
||||
|
|
|
@ -66,11 +66,11 @@ class MapstractionPlugin extends Plugin
|
|||
function onRouterInitialized($m)
|
||||
{
|
||||
$m->connect(':nickname/all/map',
|
||||
array('action' => 'allmap'),
|
||||
array('nickname' => Nickname::DISPLAY_FMT));
|
||||
['action' => 'allmap'],
|
||||
['nickname' => Nickname::DISPLAY_FMT]);
|
||||
$m->connect(':nickname/map',
|
||||
array('action' => 'usermap'),
|
||||
array('nickname' => Nickname::DISPLAY_FMT));
|
||||
['action' => 'usermap'],
|
||||
['nickname' => Nickname::DISPLAY_FMT]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,19 +10,11 @@ class NodeinfoPlugin extends Plugin
|
|||
|
||||
public function onRouterInitialized($m)
|
||||
{
|
||||
$m->connect(
|
||||
'.well-known/nodeinfo',
|
||||
array(
|
||||
'action' => 'nodeinfojrd'
|
||||
)
|
||||
);
|
||||
$m->connect('.well-known/nodeinfo',
|
||||
['action' => 'nodeinfojrd']);
|
||||
|
||||
$m->connect(
|
||||
'main/nodeinfo/2.0',
|
||||
array(
|
||||
'action' => 'nodeinfo_2_0'
|
||||
)
|
||||
);
|
||||
$m->connect('main/nodeinfo/2.0',
|
||||
['action' => 'nodeinfo_2_0']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -42,44 +42,48 @@ class OStatusPlugin extends Plugin
|
|||
{
|
||||
// Discovery actions
|
||||
$m->connect('main/ostatustag',
|
||||
array('action' => 'ostatustag'));
|
||||
['action' => 'ostatustag']);
|
||||
$m->connect('main/ostatustag?nickname=:nickname',
|
||||
array('action' => 'ostatustag'), array('nickname' => '[A-Za-z0-9_-]+'));
|
||||
['action' => 'ostatustag'],
|
||||
['nickname' => '[A-Za-z0-9_-]+']);
|
||||
$m->connect('main/ostatus/nickname/:nickname',
|
||||
array('action' => 'ostatusinit'), array('nickname' => '[A-Za-z0-9_-]+'));
|
||||
['action' => 'ostatusinit'],
|
||||
['nickname' => '[A-Za-z0-9_-]+']);
|
||||
$m->connect('main/ostatus/group/:group',
|
||||
array('action' => 'ostatusinit'), array('group' => '[A-Za-z0-9_-]+'));
|
||||
['action' => 'ostatusinit'],
|
||||
['group' => '[A-Za-z0-9_-]+']);
|
||||
$m->connect('main/ostatus/peopletag/:peopletag/tagger/:tagger',
|
||||
array('action' => 'ostatusinit'), array('tagger' => '[A-Za-z0-9_-]+',
|
||||
'peopletag' => '[A-Za-z0-9_-]+'));
|
||||
['action' => 'ostatusinit'],
|
||||
['tagger' => '[A-Za-z0-9_-]+',
|
||||
'peopletag' => '[A-Za-z0-9_-]+']);
|
||||
$m->connect('main/ostatus',
|
||||
array('action' => 'ostatusinit'));
|
||||
['action' => 'ostatusinit']);
|
||||
|
||||
// Remote subscription actions
|
||||
$m->connect('main/ostatussub',
|
||||
array('action' => 'ostatussub'));
|
||||
['action' => 'ostatussub']);
|
||||
$m->connect('main/ostatusgroup',
|
||||
array('action' => 'ostatusgroup'));
|
||||
['action' => 'ostatusgroup']);
|
||||
$m->connect('main/ostatuspeopletag',
|
||||
array('action' => 'ostatuspeopletag'));
|
||||
['action' => 'ostatuspeopletag']);
|
||||
|
||||
// WebSub actions
|
||||
$m->connect('main/push/hub', array('action' => 'pushhub'));
|
||||
$m->connect('main/push/hub', ['action' => 'pushhub']);
|
||||
|
||||
$m->connect('main/push/callback/:feed',
|
||||
array('action' => 'pushcallback'),
|
||||
array('feed' => '[0-9]+'));
|
||||
['action' => 'pushcallback'],
|
||||
['feed' => '[0-9]+']);
|
||||
|
||||
// Salmon endpoint
|
||||
$m->connect('main/salmon/user/:id',
|
||||
array('action' => 'usersalmon'),
|
||||
array('id' => '[0-9]+'));
|
||||
['action' => 'usersalmon'],
|
||||
['id' => '[0-9]+']);
|
||||
$m->connect('main/salmon/group/:id',
|
||||
array('action' => 'groupsalmon'),
|
||||
array('id' => '[0-9]+'));
|
||||
['action' => 'groupsalmon'],
|
||||
['id' => '[0-9]+']);
|
||||
$m->connect('main/salmon/peopletag/:id',
|
||||
array('action' => 'peopletagsalmon'),
|
||||
array('id' => '[0-9]+'));
|
||||
['action' => 'peopletagsalmon'],
|
||||
['id' => '[0-9]+']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ class OembedPlugin extends Plugin
|
|||
*/
|
||||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('main/oembed', array('action' => 'oembed'));
|
||||
$m->connect('main/oembed', ['action' => 'oembed']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -54,7 +54,7 @@ class OfflineBackupPlugin extends Plugin
|
|||
function onRouterInitialized($m)
|
||||
{
|
||||
$m->connect('main/backupaccount',
|
||||
array('action' => 'offlinebackup'));
|
||||
['action' => 'offlinebackup']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -178,7 +178,7 @@ ENDOFSCRIPT;
|
|||
function onRouterInitialized($m)
|
||||
{
|
||||
$m->connect('panel/openx',
|
||||
array('action' => 'openxadminpanel'));
|
||||
['action' => 'openxadminpanel']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ class OpportunisticQMPlugin extends Plugin {
|
|||
|
||||
public function onRouterInitialized($m)
|
||||
{
|
||||
$m->connect('main/runqueue', array('action' => 'runqueue'));
|
||||
$m->connect('main/runqueue',
|
||||
['action' => 'runqueue']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -92,33 +92,23 @@ class PollPlugin extends MicroAppPlugin
|
|||
*/
|
||||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect(
|
||||
'main/poll/new',
|
||||
array('action' => 'newpoll')
|
||||
);
|
||||
$m->connect('main/poll/new',
|
||||
['action' => 'newpoll']);
|
||||
|
||||
$m->connect(
|
||||
'main/poll/:id',
|
||||
array('action' => 'showpoll'),
|
||||
array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')
|
||||
);
|
||||
$m->connect('main/poll/:id',
|
||||
['action' => 'showpoll'],
|
||||
['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']);
|
||||
|
||||
$m->connect(
|
||||
'main/poll/response/:id',
|
||||
array('action' => 'showpollresponse'),
|
||||
array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')
|
||||
);
|
||||
$m->connect('main/poll/response/:id',
|
||||
['action' => 'showpollresponse'],
|
||||
['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']);
|
||||
|
||||
$m->connect(
|
||||
'main/poll/:id/respond',
|
||||
array('action' => 'respondpoll'),
|
||||
array('id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}')
|
||||
);
|
||||
$m->connect('main/poll/:id/respond',
|
||||
['action' => 'respondpoll'],
|
||||
['id' => '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}']);
|
||||
|
||||
$m->connect(
|
||||
'settings/poll',
|
||||
array('action' => 'pollsettings')
|
||||
);
|
||||
$m->connect('settings/poll',
|
||||
['action' => 'pollsettings']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -85,42 +85,35 @@ class QnAPlugin extends MicroAppPlugin
|
|||
{
|
||||
$UUIDregex = '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}';
|
||||
|
||||
$m->connect(
|
||||
'main/qna/newquestion',
|
||||
array('action' => 'qnanewquestion')
|
||||
);
|
||||
$m->connect(
|
||||
'answer/qna/closequestion',
|
||||
array('action' => 'qnaclosequestion')
|
||||
);
|
||||
$m->connect(
|
||||
'main/qna/newanswer',
|
||||
array('action' => 'qnanewanswer')
|
||||
);
|
||||
$m->connect(
|
||||
'main/qna/reviseanswer',
|
||||
array('action' => 'qnareviseanswer')
|
||||
);
|
||||
$m->connect(
|
||||
'question/vote/:id',
|
||||
array('action' => 'qnavote', 'type' => 'question'),
|
||||
array('id' => $UUIDregex)
|
||||
);
|
||||
$m->connect(
|
||||
'question/:id',
|
||||
array('action' => 'qnashowquestion'),
|
||||
array('id' => $UUIDregex)
|
||||
);
|
||||
$m->connect(
|
||||
'answer/vote/:id',
|
||||
array('action' => 'qnavote', 'type' => 'answer'),
|
||||
array('id' => $UUIDregex)
|
||||
);
|
||||
$m->connect(
|
||||
'answer/:id',
|
||||
array('action' => 'qnashowanswer'),
|
||||
array('id' => $UUIDregex)
|
||||
);
|
||||
$m->connect('main/qna/newquestion',
|
||||
['action' => 'qnanewquestion']);
|
||||
|
||||
$m->connect('answer/qna/closequestion',
|
||||
['action' => 'qnaclosequestion']);
|
||||
|
||||
$m->connect('main/qna/newanswer',
|
||||
['action' => 'qnanewanswer']);
|
||||
|
||||
$m->connect('main/qna/reviseanswer',
|
||||
['action' => 'qnareviseanswer']);
|
||||
|
||||
$m->connect('question/vote/:id',
|
||||
['action' => 'qnavote',
|
||||
'type' => 'question'],
|
||||
['id' => $UUIDregex]);
|
||||
|
||||
$m->connect('question/:id',
|
||||
['action' => 'qnashowquestion'],
|
||||
['id' => $UUIDregex]);
|
||||
|
||||
$m->connect('answer/vote/:id',
|
||||
['action' => 'qnavote',
|
||||
'type' => 'answer'],
|
||||
['id' => $UUIDregex]);
|
||||
|
||||
$m->connect('answer/:id',
|
||||
['action' => 'qnashowanswer'],
|
||||
['id' => $UUIDregex]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -105,7 +105,7 @@ class RSSCloudPlugin extends Plugin
|
|||
function onRouterInitialized($m)
|
||||
{
|
||||
$m->connect('/main/rsscloud/request_notify',
|
||||
array('action' => 'RSSCloudRequestNotify'));
|
||||
['action' => 'RSSCloudRequestNotify']);
|
||||
|
||||
// XXX: This is just for end-to-end testing. Uncomment if you need to pretend
|
||||
// to be a cloud hub for some reason.
|
||||
|
|
|
@ -77,11 +77,11 @@ class RealtimePlugin extends Plugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('main/channel/:channelkey/keepalive',
|
||||
array('action' => 'keepalivechannel'),
|
||||
array('channelkey' => '[a-z0-9]{32}'));
|
||||
['action' => 'keepalivechannel'],
|
||||
['channelkey' => '[a-z0-9]{32}']);
|
||||
$m->connect('main/channel/:channelkey/close',
|
||||
array('action' => 'closechannel'),
|
||||
array('channelkey' => '[a-z0-9]{32}'));
|
||||
['action' => 'closechannel'],
|
||||
['channelkey' => '[a-z0-9]{32}']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -94,8 +94,8 @@ class RegisterThrottlePlugin extends Plugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('main/ipregistrations/:ipaddress',
|
||||
array('action' => 'ipregistrations'),
|
||||
array('ipaddress' => '[0-9a-f\.\:]+'));
|
||||
['action' => 'ipregistrations'],
|
||||
['ipaddress' => '[0-9a-f\.\:]+']);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -84,8 +84,8 @@ class RequireValidatedEmailPlugin extends Plugin
|
|||
|
||||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('main/confirmfirst/:code',
|
||||
array('action' => 'confirmfirstemail'));
|
||||
$m->('main/confirmfirst/:code',
|
||||
['action' => 'confirmfirstemail']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -191,7 +191,7 @@ class SamplePlugin extends Plugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('main/hello',
|
||||
array('action' => 'hello'));
|
||||
['action' => 'hello']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -70,14 +70,14 @@ class SearchSubPlugin extends Plugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('search/:search/subscribe',
|
||||
array('action' => 'searchsub'),
|
||||
array('search' => Router::REGEX_TAG));
|
||||
['action' => 'searchsub'],
|
||||
['search' => Router::REGEX_TAG]);
|
||||
$m->connect('search/:search/unsubscribe',
|
||||
array('action' => 'searchunsub'),
|
||||
array('search' => Router::REGEX_TAG));
|
||||
['action' => 'searchunsub'],
|
||||
['search' => Router::REGEX_TAG]);
|
||||
$m->connect(':nickname/search-subscriptions',
|
||||
array('action' => 'searchsubs'),
|
||||
array('nickname' => Nickname::DISPLAY_FMT));
|
||||
['action' => 'searchsubs'],
|
||||
['nickname' => Nickname::DISPLAY_FMT]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class SensitiveContentPlugin extends Plugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('settings/sensitivecontent',
|
||||
array('action' => 'sensitivecontentsettings'));
|
||||
['action' => 'sensitivecontentsettings']);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -53,30 +53,30 @@ class SharePlugin extends ActivityVerbHandlerPlugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
// Web UI actions
|
||||
$m->connect('main/repeat', array('action' => 'repeat'));
|
||||
$m->connect('main/repeat', ['action' => 'repeat']);
|
||||
|
||||
// Share for Twitter API ("Retweet")
|
||||
$m->connect('api/statuses/retweeted_by_me.:format',
|
||||
array('action' => 'ApiTimelineRetweetedByMe',
|
||||
'format' => '(xml|json|atom|as)'));
|
||||
['action' => 'ApiTimelineRetweetedByMe'],
|
||||
['format' => '(xml|json|atom|as)']);
|
||||
|
||||
$m->connect('api/statuses/retweeted_to_me.:format',
|
||||
array('action' => 'ApiTimelineRetweetedToMe',
|
||||
'format' => '(xml|json|atom|as)'));
|
||||
['action' => 'ApiTimelineRetweetedToMe'],
|
||||
['format' => '(xml|json|atom|as)']);
|
||||
|
||||
$m->connect('api/statuses/retweets_of_me.:format',
|
||||
array('action' => 'ApiTimelineRetweetsOfMe',
|
||||
'format' => '(xml|json|atom|as)'));
|
||||
['action' => 'ApiTimelineRetweetsOfMe'],
|
||||
['format' => '(xml|json|atom|as)']);
|
||||
|
||||
$m->connect('api/statuses/retweet/:id.:format',
|
||||
array('action' => 'ApiStatusesRetweet',
|
||||
'id' => '[0-9]+',
|
||||
'format' => '(xml|json)'));
|
||||
['action' => 'ApiStatusesRetweet'],
|
||||
['id' => '[0-9]+',
|
||||
'format' => '(xml|json)']);
|
||||
|
||||
$m->connect('api/statuses/retweets/:id.:format',
|
||||
array('action' => 'ApiStatusesRetweets',
|
||||
'id' => '[0-9]+',
|
||||
'format' => '(xml|json)'));
|
||||
['action' => 'ApiStatusesRetweets'],
|
||||
['id' => '[0-9]+',
|
||||
'format' => '(xml|json)']);
|
||||
}
|
||||
|
||||
// FIXME: Set this to abstract public in lib/activityhandlerplugin.php when all plugins have migrated!
|
||||
|
|
|
@ -77,24 +77,24 @@ class SitemapPlugin extends Plugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('sitemapindex.xml',
|
||||
array('action' => 'sitemapindex'));
|
||||
['action' => 'sitemapindex']);
|
||||
|
||||
$m->connect('notice-sitemap-:year-:month-:day-:index.xml',
|
||||
array('action' => 'noticesitemap'),
|
||||
array('year' => '[0-9]{4}',
|
||||
'month' => '[01][0-9]',
|
||||
'day' => '[0123][0-9]',
|
||||
'index' => '[1-9][0-9]*'));
|
||||
['action' => 'noticesitemap'],
|
||||
['year' => '[0-9]{4}',
|
||||
'month' => '[01][0-9]',
|
||||
'day' => '[0123][0-9]',
|
||||
'index' => '[1-9][0-9]*']);
|
||||
|
||||
$m->connect('user-sitemap-:year-:month-:day-:index.xml',
|
||||
array('action' => 'usersitemap'),
|
||||
array('year' => '[0-9]{4}',
|
||||
'month' => '[01][0-9]',
|
||||
'day' => '[0123][0-9]',
|
||||
'index' => '[1-9][0-9]*'));
|
||||
['action' => 'usersitemap'),
|
||||
['year' => '[0-9]{4}',
|
||||
'month' => '[01][0-9]',
|
||||
'day' => '[0123][0-9]',
|
||||
'index' => '[1-9][0-9]*']);
|
||||
|
||||
$m->connect('panel/sitemap',
|
||||
array('action' => 'sitemapadminpanel'));
|
||||
['action' => 'sitemapadminpanel']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ class SlicedFavoritesPlugin extends Plugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('favorited/:slice',
|
||||
array('action' => 'favoritedslice'),
|
||||
array('slice' => '[a-zA-Z0-9]+'));
|
||||
['action' => 'favoritedslice'],
|
||||
['slice' => '[a-zA-Z0-9]+']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -36,14 +36,14 @@ class SubMirrorPlugin extends Plugin
|
|||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('settings/mirror',
|
||||
array('action' => 'mirrorsettings'));
|
||||
['action' => 'mirrorsettings']);
|
||||
$m->connect('settings/mirror/add/:provider',
|
||||
array('action' => 'mirrorsettings'),
|
||||
array('provider' => '[A-Za-z0-9_-]+'));
|
||||
['action' => 'mirrorsettings'],
|
||||
['provider' => '[A-Za-z0-9_-]+']);
|
||||
$m->connect('settings/mirror/add',
|
||||
array('action' => 'addmirror'));
|
||||
['action' => 'addmirror']);
|
||||
$m->connect('settings/mirror/edit',
|
||||
array('action' => 'editmirror'));
|
||||
['action' => 'editmirror']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,10 +17,10 @@ class TagCloudPlugin extends Plugin {
|
|||
|
||||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('tags/', array('action' => 'publictagcloud'));
|
||||
$m->connect('tag/', array('action' => 'publictagcloud'));
|
||||
$m->connect('tags', array('action' => 'publictagcloud'));
|
||||
$m->connect('tag', array('action' => 'publictagcloud'));
|
||||
$m->connect('tags/', ['action' => 'publictagcloud']);
|
||||
$m->connect('tag/', ['action' => 'publictagcloud']);
|
||||
$m->connect('tags', ['action' => 'publictagcloud']);
|
||||
$m->connect('tag', ['action' => 'publictagcloud']);
|
||||
}
|
||||
|
||||
public function onEndPublicGroupNav(Menu $menu)
|
||||
|
|
|
@ -69,22 +69,18 @@ class TagSubPlugin extends Plugin
|
|||
*/
|
||||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect(
|
||||
'tag/:tag/subscribe',
|
||||
array('action' => 'tagsub'),
|
||||
array('tag' => Router::REGEX_TAG)
|
||||
);
|
||||
$m->connect(
|
||||
'tag/:tag/unsubscribe',
|
||||
array('action' => 'tagunsub'),
|
||||
array('tag' => Router::REGEX_TAG)
|
||||
);
|
||||
$m->connect('tag/:tag/subscribe',
|
||||
['action' => 'tagsub'],
|
||||
['tag' => Router::REGEX_TAG]);
|
||||
|
||||
$m->connect('tag/:tag/unsubscribe',
|
||||
['action' => 'tagunsub'],
|
||||
['tag' => Router::REGEX_TAG]);
|
||||
|
||||
$m->connect(':nickname/tag-subscriptions',
|
||||
['action' => 'tagsubs'],
|
||||
['nickname' => Nickname::DISPLAY_FMT]);
|
||||
|
||||
$m->connect(
|
||||
':nickname/tag-subscriptions',
|
||||
array('action' => 'tagsubs'),
|
||||
array('nickname' => Nickname::DISPLAY_FMT)
|
||||
);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -111,23 +111,17 @@ class TwitterBridgePlugin extends Plugin
|
|||
*/
|
||||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('panel/twitter', array('action' => 'twitteradminpanel'));
|
||||
$m->connect('panel/twitter', ['action' => 'twitteradminpanel']);
|
||||
|
||||
if (self::hasKeys()) {
|
||||
$m->connect(
|
||||
'twitter/authorization',
|
||||
array('action' => 'twitterauthorization')
|
||||
);
|
||||
$m->connect(
|
||||
'settings/twitter', array(
|
||||
'action' => 'twittersettings'
|
||||
)
|
||||
);
|
||||
$m->connect('twitter/authorization',
|
||||
['action' => 'twitterauthorization']);
|
||||
$m->connect('settings/twitter',
|
||||
['action' => 'twittersettings']);
|
||||
|
||||
if (common_config('twitter', 'signin')) {
|
||||
$m->connect(
|
||||
'main/twitterlogin',
|
||||
array('action' => 'twitterlogin')
|
||||
);
|
||||
$m->connect('main/twitterlogin',
|
||||
['action' => 'twitterlogin']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -75,9 +75,9 @@ class UserFlagPlugin extends Plugin
|
|||
*/
|
||||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('main/flag/profile', array('action' => 'flagprofile'));
|
||||
$m->connect('main/flag/clear', array('action' => 'clearflag'));
|
||||
$m->connect('panel/profile/flag', array('action' => 'adminprofileflag'));
|
||||
$m->connect('main/flag/profile', ['action' => 'flagprofile']);
|
||||
$m->connect('main/flag/clear', ['action' => 'clearflag']);
|
||||
$m->connect('panel/profile/flag', ['action' => 'adminprofileflag']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,16 +39,16 @@ class WebFingerPlugin extends Plugin
|
|||
|
||||
public function onRouterInitialized(URLMapper $m)
|
||||
{
|
||||
$m->connect('.well-known/host-meta', array('action' => 'hostmeta'));
|
||||
$m->connect('.well-known/host-meta', ['action' => 'hostmeta']);
|
||||
$m->connect('.well-known/host-meta.:format',
|
||||
array('action' => 'hostmeta',
|
||||
'format' => '(xml|json)'));
|
||||
['action' => 'hostmeta'],
|
||||
['format' => '(xml|json)']);
|
||||
// the resource GET parameter can be anywhere, so don't mention it here
|
||||
$m->connect('.well-known/webfinger', array('action' => 'webfinger'));
|
||||
$m->connect('.well-known/webfinger', ['action' => 'webfinger']);
|
||||
$m->connect('.well-known/webfinger.:format',
|
||||
array('action' => 'webfinger',
|
||||
'format' => '(xml|json)'));
|
||||
$m->connect('main/ownerxrd', array('action' => 'ownerxrd'));
|
||||
['action' => 'webfinger'],
|
||||
['format' => '(xml|json)']);
|
||||
$m->connect('main/ownerxrd', ['action' => 'ownerxrd']);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user