123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class Router
- {
- var $m = null;
- static $inst = null;
- const REGEX_TAG = '[^\/]+';
- static function get()
- {
- if (!Router::$inst) {
- Router::$inst = new Router();
- }
- return Router::$inst;
- }
-
- static function clear()
- {
- Router::$inst = null;
- }
- function __construct()
- {
- if (empty($this->m)) {
- $this->m = $this->initialize();
- }
- }
-
- static function cacheKey()
- {
- $parts = array('router');
-
- if (common_config('singleuser', 'enabled')) {
- $parts[] = '1user';
- } else {
- $parts[] = 'multi';
- }
- return Cache::codeKey(implode(':', $parts));
- }
- function initialize()
- {
- $m = new URLMapper();
- if (Event::handle('StartInitializeRouter', [&$m])) {
-
- $m->connect('', ['action' => 'top']);
-
- $m->connect('robots.txt', ['action' => 'robotstxt']);
- $m->connect('opensearch/people',
- ['action' => 'opensearch',
- 'type' => 'people']);
- $m->connect('opensearch/notice',
- ['action' => 'opensearch',
- 'type' => 'notice']);
-
- $m->connect('doc/:title', ['action' => 'doc']);
- $m->connect('main/otp/:user_id/:token',
- ['action' => 'otp'],
- ['user_id' => '[0-9]+',
- 'token' => '.+']);
-
- foreach (['register', 'confirmaddress', 'recoverpassword'] as $c) {
- $m->connect('main/'.$c.'/:code', ['action' => $c]);
- }
-
- $m->connect('main/block/:profileid',
- ['action' => 'block'],
- ['profileid' => '[0-9]+']);
- $m->connect('main/sup/:seconds',
- ['action' => 'sup'],
- ['seconds' => '[0-9]+']);
-
- $main = ['login', 'logout', 'register', 'subscribe',
- 'unsubscribe', 'cancelsubscription', 'approvesub',
- 'confirmaddress', 'recoverpassword',
- 'invite', 'sup',
- 'block', 'unblock', 'subedit',
- 'groupblock', 'groupunblock',
- 'sandbox', 'unsandbox',
- 'silence', 'unsilence',
- 'grantrole', 'revokerole',
- 'deleteuser',
- 'geocode',
- 'version',
- 'backupaccount',
- 'deleteaccount',
- 'restoreaccount',
- 'top',
- 'public'];
- foreach ($main as $a) {
- $m->connect('main/'.$a, ['action' => $a]);
- }
- $m->connect('main/all', ['action' => 'networkpublic']);
- $m->connect('main/tagprofile/:id',
- ['action' => 'tagprofile'],
- ['id' => '[0-9]+']);
- $m->connect('main/tagprofile', ['action' => 'tagprofile']);
- $m->connect('main/xrds',
- ['action' => 'publicxrds']);
-
- foreach (['profile', 'avatar', 'password', 'im', 'oauthconnections',
- 'oauthapps', 'email', 'sms', 'url'] as $s) {
- $m->connect('settings/'.$s, ['action' => $s.'settings']);
- }
- if (common_config('oldschool', 'enabled')) {
- $m->connect('settings/oldschool', ['action' => 'oldschoolsettings']);
- }
- $m->connect('settings/oauthapps/show/:id',
- ['action' => 'showapplication'],
- ['id' => '[0-9]+']);
- $m->connect('settings/oauthapps/new',
- ['action' => 'newapplication']);
- $m->connect('settings/oauthapps/edit/:id',
- ['action' => 'editapplication'],
- ['id' => '[0-9]+']);
- $m->connect('settings/oauthapps/delete/:id',
- ['action' => 'deleteapplication'],
- ['id' => '[0-9]+']);
-
- foreach (['group', 'people', 'notice'] as $s) {
- $m->connect('search/'.$s.'?q=:q',
- ['action' => $s.'search'],
- ['q' => '.+']);
- $m->connect('search/'.$s, ['action' => $s.'search']);
- }
-
-
-
- $m->connect('search/notice/rss?q=:q',
- ['action' => 'noticesearchrss'],
- ['q' => '.+']);
- $m->connect('search/notice/rss', ['action' => 'noticesearchrss']);
- foreach (['' => 'attachment',
- '/view' => 'attachment_view',
- '/download' => 'attachment_download',
- '/thumbnail' => 'attachment_thumbnail'] as $postfix => $action) {
- foreach (['filehash' => '[A-Za-z0-9._-]{64}',
- 'attachment' => '[0-9]+'] as $type => $match) {
- $m->connect("attachment/:{$type}{$postfix}",
- ['action' => $action],
- [$type => $match]);
- }
- }
- $m->connect('notice/new?replyto=:replyto&inreplyto=:inreplyto',
- ['action' => 'newnotice'],
- ['replyto' => Nickname::DISPLAY_FMT,
- 'inreplyto' => '[0-9]+']);
- $m->connect('notice/new?replyto=:replyto',
- ['action' => 'newnotice'],
- ['replyto' => Nickname::DISPLAY_FMT]);
- $m->connect('notice/new', ['action' => 'newnotice']);
- $m->connect('notice/:notice',
- ['action' => 'shownotice'],
- ['notice' => '[0-9]+']);
- $m->connect('notice/:notice/delete',
- ['action' => 'deletenotice'],
- ['notice' => '[0-9]+']);
-
- $m->connect('conversation/:id',
- ['action' => 'conversation'],
- ['id' => '[0-9]+']);
- $m->connect('user/:id',
- ['action' => 'userbyid'],
- ['id' => '[0-9]+']);
- $m->connect('tag/:tag/rss',
- ['action' => 'tagrss'],
- ['tag' => self::REGEX_TAG]);
- $m->connect('tag/:tag',
- ['action' => 'tag'],
- ['tag' => self::REGEX_TAG]);
-
- $m->connect('group/new', ['action' => 'newgroup']);
- foreach (['edit', 'join', 'leave', 'delete', 'cancel', 'approve'] as $v) {
- $m->connect('group/:nickname/'.$v,
- ['action' => $v.'group'],
- ['nickname' => Nickname::DISPLAY_FMT]);
- $m->connect('group/:id/id/'.$v,
- ['action' => $v.'group'],
- ['id' => '[0-9]+']);
- }
- foreach (['members', 'logo', 'rss'] as $n) {
- $m->connect('group/:nickname/'.$n,
- ['action' => 'group'.$n],
- ['nickname' => Nickname::DISPLAY_FMT]);
- }
- $m->connect('group/:nickname/foaf',
- ['action' => 'foafgroup'],
- ['nickname' => Nickname::DISPLAY_FMT]);
- $m->connect('group/:nickname/blocked',
- ['action' => 'blockedfromgroup'],
- ['nickname' => Nickname::DISPLAY_FMT]);
- $m->connect('group/:nickname/makeadmin',
- ['action' => 'makeadmin'],
- ['nickname' => Nickname::DISPLAY_FMT]);
- $m->connect('group/:nickname/members/pending',
- ['action' => 'groupqueue'],
- ['nickname' => Nickname::DISPLAY_FMT]);
- $m->connect('group/:id/id',
- ['action' => 'groupbyid'],
- ['id' => '[0-9]+']);
- $m->connect('group/:nickname',
- ['action' => 'showgroup'],
- ['nickname' => Nickname::DISPLAY_FMT]);
- $m->connect('group/:nickname/',
- ['action' => 'showgroup'],
- ['nickname' => Nickname::DISPLAY_FMT]);
- $m->connect('group/', ['action' => 'groups']);
- $m->connect('group', ['action' => 'groups']);
- $m->connect('groups/', ['action' => 'groups']);
- $m->connect('groups', ['action' => 'groups']);
-
-
- $m->connect('api',
- ['action' => 'Redirect',
- 'nextAction' => 'doc',
- 'args' => ['title' => 'api']]);
- $m->connect('api/statuses/public_timeline.:format',
- ['action' => 'ApiTimelinePublic'],
- ['format' => '(xml|json|rss|atom|as)']);
-
- $m->connect('api/statuses/networkpublic_timeline.:format',
- ['action' => 'ApiTimelineNetworkPublic'],
- ['format' => '(xml|json|rss|atom|as)']);
- $m->connect('api/statuses/friends_timeline/:id.:format',
- ['action' => 'ApiTimelineFriends'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json|rss|atom|as)']);
- $m->connect('api/statuses/friends_timeline.:format',
- ['action' => 'ApiTimelineFriends'],
- ['format' => '(xml|json|rss|atom|as)']);
- $m->connect('api/statuses/home_timeline/:id.:format',
- ['action' => 'ApiTimelineHome'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json|rss|atom|as)']);
- $m->connect('api/statuses/home_timeline.:format',
- ['action' => 'ApiTimelineHome'],
- ['format' => '(xml|json|rss|atom|as)']);
- $m->connect('api/statuses/user_timeline/:id.:format',
- ['action' => 'ApiTimelineUser'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json|rss|atom|as)']);
- $m->connect('api/statuses/user_timeline.:format',
- ['action' => 'ApiTimelineUser'],
- ['format' => '(xml|json|rss|atom|as)']);
- $m->connect('api/statuses/mentions/:id.:format',
- ['action' => 'ApiTimelineMentions'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json|rss|atom|as)']);
- $m->connect('api/statuses/mentions.:format',
- ['action' => 'ApiTimelineMentions'],
- ['format' => '(xml|json|rss|atom|as)']);
- $m->connect('api/statuses/replies/:id.:format',
- ['action' => 'ApiTimelineMentions'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json|rss|atom|as)']);
- $m->connect('api/statuses/replies.:format',
- ['action' => 'ApiTimelineMentions'],
- ['format' => '(xml|json|rss|atom|as)']);
-
- $m->connect('api/statuses/mentions_timeline/:id.:format',
- ['action' => 'ApiTimelineMentions'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json|rss|atom|as)']);
- $m->connect('api/statuses/mentions_timeline.:format',
- ['action' => 'ApiTimelineMentions'],
- ['format' => '(xml|json|rss|atom|as)']);
- $m->connect('api/statuses/friends/:id.:format',
- ['action' => 'ApiUserFriends'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json)']);
- $m->connect('api/statuses/friends.:format',
- ['action' => 'ApiUserFriends'],
- ['format' => '(xml|json)']);
- $m->connect('api/statuses/followers/:id.:format',
- ['action' => 'ApiUserFollowers'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json)']);
- $m->connect('api/statuses/followers.:format',
- ['action' => 'ApiUserFollowers'],
- ['format' => '(xml|json)']);
- $m->connect('api/statuses/show/:id.:format',
- ['action' => 'ApiStatusesShow'],
- ['id' => '[0-9]+',
- 'format' => '(xml|json|atom)']);
- $m->connect('api/statuses/show.:format',
- ['action' => 'ApiStatusesShow'],
- ['format' => '(xml|json|atom)']);
- $m->connect('api/statuses/update.:format',
- ['action' => 'ApiStatusesUpdate'],
- ['format' => '(xml|json|atom)']);
- $m->connect('api/statuses/destroy/:id.:format',
- ['action' => 'ApiStatusesDestroy'],
- ['id' => '[0-9]+',
- 'format' => '(xml|json)']);
- $m->connect('api/statuses/destroy.:format',
- ['action' => 'ApiStatusesDestroy'],
- ['format' => '(xml|json)']);
-
-
- $m->connect('api/attachment/:id.:format',
- ['action' => 'ApiAttachment'],
- ['id' => '[0-9]+',
- 'format' => '(xml|json)']);
-
- $m->connect('api/checkhub.:format',
- ['action' => 'ApiCheckHub'],
- ['format' => '(xml|json)']);
-
- $m->connect('api/externalprofile/show.:format',
- ['action' => 'ApiExternalProfileShow'],
- ['format' => '(xml|json)']);
- $m->connect('api/statusnet/groups/admins/:id.:format',
- ['action' => 'ApiGroupAdmins'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json)']);
-
- $m->connect('api/account/update_link_color.:format',
- ['action' => 'ApiAccountUpdateLinkColor'],
- ['format' => '(xml|json)']);
-
- $m->connect('api/account/update_background_color.:format',
- ['action' => 'ApiAccountUpdateBackgroundColor'],
- ['format' => '(xml|json)']);
- $m->connect('api/account/register.:format',
- ['action' => 'ApiAccountRegister'],
- ['format' => '(xml|json)']);
-
- $m->connect('api/check_nickname.:format',
- ['action' => 'ApiCheckNickname'],
- ['format' => '(xml|json)']);
-
-
- $m->connect('api/users/show/:id.:format',
- ['action' => 'ApiUserShow'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json)']);
- $m->connect('api/users/show.:format',
- ['action' => 'ApiUserShow'],
- ['format' => '(xml|json)']);
- $m->connect('api/users/profile_image/:screen_name.:format',
- ['action' => 'ApiUserProfileImage'],
- ['screen_name' => Nickname::DISPLAY_FMT,
- 'format' => '(xml|json)']);
-
- $m->connect('api/friendships/show.:format',
- ['action' => 'ApiFriendshipsShow'],
- ['format' => '(xml|json)']);
- $m->connect('api/friendships/exists.:format',
- ['action' => 'ApiFriendshipsExists'],
- ['format' => '(xml|json)']);
- $m->connect('api/friendships/create/:id.:format',
- ['action' => 'ApiFriendshipsCreate'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json)']);
- $m->connect('api/friendships/create.:format',
- ['action' => 'ApiFriendshipsCreate'],
- ['format' => '(xml|json)']);
- $m->connect('api/friendships/destroy/:id.:format',
- ['action' => 'ApiFriendshipsDestroy'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json)']);
- $m->connect('api/friendships/destroy.:format',
- ['action' => 'ApiFriendshipsDestroy'],
- ['format' => '(xml|json)']);
-
- $m->connect('api/friends/ids/:id.:format',
- ['action' => 'ApiUserFriends',
- 'ids_only' => true],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json)']);
- $m->connect('api/followers/ids/:id.:format',
- ['action' => 'ApiUserFollowers',
- 'ids_only' => true],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json)']);
- $m->connect('api/friends/ids.:format',
- ['action' => 'ApiUserFriends',
- 'ids_only' => true],
- ['format' => '(xml|json)']);
- $m->connect('api/followers/ids.:format',
- ['action' => 'ApiUserFollowers',
- 'ids_only' => true],
- ['format' => '(xml|json)']);
-
- $m->connect('api/account/verify_credentials.:format',
- ['action' => 'ApiAccountVerifyCredentials'],
- ['format' => '(xml|json)']);
- $m->connect('api/account/update_profile.:format',
- ['action' => 'ApiAccountUpdateProfile'],
- ['format' => '(xml|json)']);
- $m->connect('api/account/update_profile_image.:format',
- ['action' => 'ApiAccountUpdateProfileImage'],
- ['format' => '(xml|json)']);
- $m->connect('api/account/update_delivery_device.:format',
- ['action' => 'ApiAccountUpdateDeliveryDevice'],
- ['format' => '(xml|json)']);
-
- $m->connect('api/account/verify_credentials',
- ['action' => 'ApiAccountVerifyCredentials']);
- $m->connect('api/account/rate_limit_status.:format',
- ['action' => 'ApiAccountRateLimitStatus'],
- ['format' => '(xml|json)']);
-
- $m->connect('api/blocks/create/:id.:format',
- ['action' => 'ApiBlockCreate'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json)']);
- $m->connect('api/blocks/create.:format',
- ['action' => 'ApiBlockCreate'],
- ['format' => '(xml|json)']);
- $m->connect('api/blocks/destroy/:id.:format',
- ['action' => 'ApiBlockDestroy'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json)']);
- $m->connect('api/blocks/destroy.:format',
- ['action' => 'ApiBlockDestroy'],
- ['format' => '(xml|json)']);
-
- $m->connect('api/help/test.:format',
- ['action' => 'ApiHelpTest'],
- ['format' => '(xml|json)']);
-
- $m->connect('api/statusnet/version.:format',
- ['action' => 'ApiGNUsocialVersion'],
- ['format' => '(xml|json)']);
- $m->connect('api/statusnet/config.:format',
- ['action' => 'ApiGNUsocialConfig'],
- ['format' => '(xml|json)']);
-
- $m->connect('api/gnusocial/version.:format',
- ['action' => 'ApiGNUsocialVersion'],
- ['format' => '(xml|json)']);
- $m->connect('api/gnusocial/config.:format',
- ['action' => 'ApiGNUsocialConfig'],
- ['format' => '(xml|json)']);
-
-
-
-
- $m->connect('api/statusnet/groups/timeline/:id.:format',
- ['action' => 'ApiTimelineGroup'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json|rss|atom|as)']);
- $m->connect('api/statusnet/groups/show/:id.:format',
- ['action' => 'ApiGroupShow'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json)']);
- $m->connect('api/statusnet/groups/show.:format',
- ['action' => 'ApiGroupShow'],
- ['format' => '(xml|json)']);
- $m->connect('api/statusnet/groups/join/:id.:format',
- ['action' => 'ApiGroupJoin'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json)']);
- $m->connect('api/statusnet/groups/join.:format',
- ['action' => 'ApiGroupJoin'],
- ['format' => '(xml|json)']);
- $m->connect('api/statusnet/groups/leave/:id.:format',
- ['action' => 'ApiGroupLeave'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json)']);
- $m->connect('api/statusnet/groups/leave.:format',
- ['action' => 'ApiGroupLeave'],
- ['format' => '(xml|json)']);
- $m->connect('api/statusnet/groups/is_member.:format',
- ['action' => 'ApiGroupIsMember'],
- ['format' => '(xml|json)']);
- $m->connect('api/statusnet/groups/list/:id.:format',
- ['action' => 'ApiGroupList'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json|rss|atom)']);
- $m->connect('api/statusnet/groups/list.:format',
- ['action' => 'ApiGroupList'],
- ['format' => '(xml|json|rss|atom)']);
- $m->connect('api/statusnet/groups/list_all.:format',
- ['action' => 'ApiGroupListAll'],
- ['format' => '(xml|json|rss|atom)']);
- $m->connect('api/statusnet/groups/membership/:id.:format',
- ['action' => 'ApiGroupMembership'],
- ['id' => Nickname::INPUT_FMT,
- 'format' => '(xml|json)']);
- $m->connect('api/statusnet/groups/membership.:format',
- ['action' => 'ApiGroupMembership'],
- ['format' => '(xml|json)']);
- $m->connect('api/statusnet/groups/create.:format',
- ['action' => 'ApiGroupCreate'],
- ['format' => '(xml|json)']);
- $m->connect('api/statusnet/groups/update/:id.:format',
- ['action' => 'ApiGroupProfileUpdate'],
- ['id' => '[a-zA-Z0-9]+',
- 'format' => '(xml|json)']);
-
- $m->connect('api/statusnet/conversation/:id.:format',
- ['action' => 'apiconversation'],
- ['id' => '[0-9]+',
- 'format' => '(xml|json|rss|atom|as)']);
-
- $m->connect('api/lists/list.:format',
- ['action' => 'ApiListSubscriptions'],
- ['format' => '(xml|json)']);
- $m->connect('api/lists/memberships.:format',
- ['action' => 'ApiListMemberships'],
- ['format' => '(xml|json)']);
- $m->connect('api/:user/lists/memberships.:format',
- ['action' => 'ApiListMemberships'],
- ['user' => '[a-zA-Z0-9]+',
- 'format' => '(xml|json)']);
- $m->connect('api/lists/subscriptions.:format',
- ['action' => 'ApiListSubscriptions'],
- ['format' => '(xml|json)']);
- $m->connect('api/:user/lists/subscriptions.:format',
- ['action' => 'ApiListSubscriptions'],
- ['user' => '[a-zA-Z0-9]+',
- 'format' => '(xml|json)']);
- $m->connect('api/lists.:format',
- ['action' => 'ApiLists'],
- ['format' => '(xml|json)']);
- $m->connect('api/:user/lists/:id.:format',
- ['action' => 'ApiList'],
- ['user' => '[a-zA-Z0-9]+',
- 'id' => '[a-zA-Z0-9]+',
- 'format' => '(xml|json)']);
- $m->connect('api/:user/lists.:format',
- ['action' => 'ApiLists'],
- ['user' => '[a-zA-Z0-9]+',
- 'format' => '(xml|json)']);
- $m->connect('api/:user/lists/:id/statuses.:format',
- ['action' => 'ApiTimelineList'],
- ['user' => '[a-zA-Z0-9]+',
- 'id' => '[a-zA-Z0-9]+',
- 'format' => '(xml|json|rss|atom)']);
- $m->connect('api/:user/:list_id/members/:id.:format',
- ['action' => 'ApiListMember'],
- ['user' => '[a-zA-Z0-9]+',
- 'list_id' => '[a-zA-Z0-9]+',
- 'id' => '[a-zA-Z0-9]+',
- 'format' => '(xml|json)']);
- $m->connect('api/:user/:list_id/members.:format',
- ['action' => 'ApiListMembers'],
- ['user' => '[a-zA-Z0-9]+',
- 'list_id' => '[a-zA-Z0-9]+',
- 'format' => '(xml|json)']);
- $m->connect('api/:user/:list_id/subscribers/:id.:format',
- ['action' => 'ApiListSubscriber'],
- ['user' => '[a-zA-Z0-9]+',
- 'list_id' => '[a-zA-Z0-9]+',
- 'id' => '[a-zA-Z0-9]+',
- 'format' => '(xml|json)']);
- $m->connect('api/:user/:list_id/subscribers.:format',
- ['action' => 'ApiListSubscribers'],
- ['user' => '[a-zA-Z0-9]+',
- 'list_id' => '[a-zA-Z0-9]+',
- 'format' => '(xml|json)']);
-
- $m->connect('api/statusnet/tags/timeline/:tag.:format',
- ['action' => 'ApiTimelineTag'],
- ['tag' => self::REGEX_TAG,
- 'format' => '(xml|json|rss|atom|as)']);
-
- $m->connect('api/statusnet/media/upload',
- ['action' => 'ApiMediaUpload']);
- $m->connect('api/statuses/update_with_media.json',
- ['action' => 'ApiMediaUpload']);
-
- $m->connect('api/media/upload.:format',
- ['action' => 'ApiMediaUpload'],
- ['format' => '(xml|json)']);
-
- $m->connect('api/search.atom', ['action' => 'ApiSearchAtom']);
- $m->connect('api/search.json', ['action' => 'ApiSearchJSON']);
- $m->connect('api/trends.json', ['action' => 'ApiTrends']);
- $m->connect('api/oauth/request_token',
- ['action' => 'ApiOAuthRequestToken']);
- $m->connect('api/oauth/access_token',
- ['action' => 'ApiOAuthAccessToken']);
- $m->connect('api/oauth/authorize',
- ['action' => 'ApiOAuthAuthorize']);
-
- $m->connect('panel/site', ['action' => 'siteadminpanel']);
- $m->connect('panel/user', ['action' => 'useradminpanel']);
- $m->connect('panel/access', ['action' => 'accessadminpanel']);
- $m->connect('panel/paths', ['action' => 'pathsadminpanel']);
- $m->connect('panel/sessions', ['action' => 'sessionsadminpanel']);
- $m->connect('panel/sitenotice', ['action' => 'sitenoticeadminpanel']);
- $m->connect('panel/license', ['action' => 'licenseadminpanel']);
- $m->connect('panel/plugins', ['action' => 'pluginsadminpanel']);
- $m->connect('panel/plugins/enable/:plugin',
- ['action' => 'pluginenable'],
- ['plugin' => '[A-Za-z0-9_]+']);
- $m->connect('panel/plugins/disable/:plugin',
- ['action' => 'plugindisable'],
- ['plugin' => '[A-Za-z0-9_]+']);
- $m->connect('panel/plugins/delete/:plugin',
- ['action' => 'plugindelete'],
- ['plugin' => '[A-Za-z0-9_]+']);
- $m->connect('panel/plugins/install',
- ['action' => 'plugininstall']);
-
- $m->connect('peopletag/:tag',
- ['action' => 'peopletag'],
- ['tag' => self::REGEX_TAG]);
- $m->connect('selftag/:tag',
- ['action' => 'selftag'],
- ['tag' => self::REGEX_TAG]);
- $m->connect('main/addpeopletag', ['action' => 'addpeopletag']);
- $m->connect('main/removepeopletag', ['action' => 'removepeopletag']);
- $m->connect('main/profilecompletion', ['action' => 'profilecompletion']);
- $m->connect('main/peopletagautocomplete', ['action' => 'peopletagautocomplete']);
-
- if (common_config('singleuser', 'enabled')) {
- $nickname = User::singleUserNickname();
- foreach (['subscriptions', 'subscribers', 'all', 'foaf', 'replies'] as $a) {
- $m->connect($a,
- ['action' => $a,
- 'nickname' => $nickname]);
- }
- foreach (['subscriptions', 'subscribers'] as $a) {
- $m->connect($a.'/:tag',
- ['action' => $a,
- 'nickname' => $nickname],
- ['tag' => self::REGEX_TAG]);
- }
- $m->connect('subscribers/pending',
- ['action' => 'subqueue',
- 'nickname' => $nickname]);
- foreach (['rss', 'groups'] as $a) {
- $m->connect($a,
- ['action' => 'user'.$a,
- 'nickname' => $nickname]);
- }
- foreach (['all', 'replies'] as $a) {
- $m->connect($a.'/rss',
- ['action' => $a.'rss',
- 'nickname' => $nickname]);
- }
- $m->connect('avatar',
- ['action' => 'avatarbynickname',
- 'nickname' => $nickname]);
- $m->connect('avatar/:size',
- ['action' => 'avatarbynickname',
- 'nickname' => $nickname],
- ['size' => '(|original|\d+)']);
- $m->connect('tag/:tag/rss',
- ['action' => 'userrss',
- 'nickname' => $nickname],
- ['tag' => self::REGEX_TAG]);
- $m->connect('tag/:tag',
- ['action' => 'showstream',
- 'nickname' => $nickname],
- ['tag' => self::REGEX_TAG]);
- $m->connect('rsd.xml',
- ['action' => 'rsd',
- 'nickname' => $nickname]);
-
- $m->connect('peopletags',
- ['action' => 'peopletagsbyuser']);
- $m->connect('peopletags/private',
- ['action' => 'peopletagsbyuser',
- 'private' => 1]);
- $m->connect('peopletags/public',
- ['action' => 'peopletagsbyuser',
- 'public' => 1]);
- $m->connect('othertags',
- ['action' => 'peopletagsforuser']);
- $m->connect('peopletagsubscriptions',
- ['action' => 'peopletagsubscriptions']);
- $m->connect('all/:tag/subscribers',
- ['action' => 'peopletagsubscribers'],
- ['tag' => self::REGEX_TAG]);
- $m->connect('all/:tag/tagged',
- ['action' => 'peopletagged'],
- ['tag' => self::REGEX_TAG]);
- $m->connect('all/:tag/edit',
- ['action' => 'editpeopletag'],
- ['tag' => self::REGEX_TAG]);
- foreach (['subscribe', 'unsubscribe'] as $v) {
- $m->connect('peopletag/:id/'.$v,
- ['action' => $v.'peopletag'],
- ['id' => '[0-9]{1,64}']);
- }
- $m->connect('user/:tagger_id/profiletag/:id/id',
- ['action' => 'profiletagbyid'],
- ['tagger_id' => '[0-9]+',
- 'id' => '[0-9]+']);
- $m->connect('all/:tag',
- ['action' => 'showprofiletag',
- 'tagger' => $nickname],
- ['tag' => self::REGEX_TAG]);
- foreach (['subscriptions', 'subscribers'] as $a) {
- $m->connect($a.'/:tag',
- ['action' => $a],
- ['tag' => self::REGEX_TAG]);
- }
- }
- $m->connect('rss', ['action' => 'publicrss']);
- $m->connect('featuredrss', ['action' => 'featuredrss']);
- $m->connect('featured/', ['action' => 'featured']);
- $m->connect('featured', ['action' => 'featured']);
- $m->connect('rsd.xml', ['action' => 'rsd']);
- foreach (['subscriptions', 'subscribers',
- 'nudge', 'all', 'foaf', 'replies',
- 'inbox', 'outbox'] as $a) {
- $m->connect(':nickname/'.$a,
- ['action' => $a],
- ['nickname' => Nickname::DISPLAY_FMT]);
- }
-
- $m->connect(':nickname/subscribers/pending',
- ['action' => 'subqueue'],
- ['nickname' => Nickname::DISPLAY_FMT]);
-
- foreach (['all', 'replies'] as $a) {
- $m->connect(':nickname/'.$a.'/rss',
- ['action' => $a.'rss'],
- ['nickname' => Nickname::DISPLAY_FMT]);
- }
-
- $m->connect(':nickname/peopletags',
- ['action' => 'peopletagsbyuser'],
- ['nickname' => Nickname::DISPLAY_FMT]);
- $m->connect(':nickname/peopletags/private',
- ['action' => 'peopletagsbyuser',
- 'private' => 1],
- ['nickname' => Nickname::DISPLAY_FMT]);
- $m->connect(':nickname/peopletags/public',
- ['action' => 'peopletagsbyuser',
- 'public' => 1],
- ['nickname' => Nickname::DISPLAY_FMT]);
- $m->connect(':nickname/othertags',
- ['action' => 'peopletagsforuser'],
- ['nickname' => Nickname::DISPLAY_FMT]);
- $m->connect(':nickname/peopletagsubscriptions',
- ['action' => 'peopletagsubscriptions'],
- ['nickname' => Nickname::DISPLAY_FMT]);
- $m->connect(':tagger/all/:tag/subscribers',
- ['action' => 'peopletagsubscribers'],
- ['tagger' => Nickname::DISPLAY_FMT,
- 'tag' => self::REGEX_TAG]);
- $m->connect(':tagger/all/:tag/tagged',
- ['action' => 'peopletagged'],
- ['tagger' => Nickname::DISPLAY_FMT,
- 'tag' => self::REGEX_TAG]);
- $m->connect(':tagger/all/:tag/edit',
- ['action' => 'editpeopletag'],
- ['tagger' => Nickname::DISPLAY_FMT,
- 'tag' => self::REGEX_TAG]);
- foreach (['subscribe', 'unsubscribe'] as $v) {
- $m->connect('peopletag/:id/'.$v,
- ['action' => $v.'peopletag'],
- ['id' => '[0-9]{1,64}']);
- }
-
- $m->connect('user/:tagger_id/profiletag/:id/id',
- ['action' => 'profiletagbyid'],
- ['tagger_id' => '[0-9]+',
- 'id' => '[0-9]+']);
- $m->connect(':nickname/all/:tag',
- ['action' => 'showprofiletag'],
- ['nickname' => Nickname::DISPLAY_FMT,
- 'tag' => self::REGEX_TAG]);
- foreach (['subscriptions', 'subscribers'] as $a) {
- $m->connect(':nickname/'.$a.'/:tag',
- ['action' => $a],
- ['tag' => self::REGEX_TAG,
- 'nickname' => Nickname::DISPLAY_FMT]);
- }
- foreach (['rss', 'groups'] as $a) {
- $m->connect(':nickname/'.$a,
- ['action' => 'user'.$a],
- ['nickname' => Nickname::DISPLAY_FMT]);
- }
- $m->connect(':nickname/avatar',
- ['action' => 'avatarbynickname'],
- ['nickname' => Nickname::DISPLAY_FMT]);
-
- $m->connect(':nickname/avatar/:size',
- ['action' => 'avatarbynickname'],
- ['size' => '(|original|\d+)',
- 'nickname' => Nickname::DISPLAY_FMT]);
- $m->connect(':nickname/tag/:tag/rss',
- ['action' => 'userrss'],
- ['nickname' => Nickname::DISPLAY_FMT,
- 'tag' => self::REGEX_TAG]);
- $m->connect(':nickname/tag/:tag',
- ['action' => 'showstream'],
- ['nickname' => Nickname::DISPLAY_FMT,
- 'tag' => self::REGEX_TAG]);
- $m->connect(':nickname/rsd.xml',
- ['action' => 'rsd'],
- ['nickname' => Nickname::DISPLAY_FMT]);
- $m->connect(':nickname',
- ['action' => 'showstream'],
- ['nickname' => Nickname::DISPLAY_FMT]);
- $m->connect(':nickname/',
- ['action' => 'showstream'],
- ['nickname' => Nickname::DISPLAY_FMT]);
-
- $m->connect('api/statusnet/app/service/:id.xml',
- ['action' => 'ApiAtomService'],
- ['id' => Nickname::DISPLAY_FMT]);
- $m->connect('api/statusnet/app/service.xml',
- ['action' => 'ApiAtomService']);
- $m->connect('api/statusnet/app/subscriptions/:subscriber/:subscribed.atom',
- ['action' => 'AtomPubShowSubscription'],
- ['subscriber' => '[0-9]+',
- 'subscribed' => '[0-9]+']);
- $m->connect('api/statusnet/app/subscriptions/:subscriber.atom',
- ['action' => 'AtomPubSubscriptionFeed'],
- ['subscriber' => '[0-9]+']);
- $m->connect('api/statusnet/app/memberships/:profile/:group.atom',
- ['action' => 'AtomPubShowMembership'],
- ['profile' => '[0-9]+',
- 'group' => '[0-9]+']);
- $m->connect('api/statusnet/app/memberships/:profile.atom',
- ['action' => 'AtomPubMembershipFeed'],
- ['profile' => '[0-9]+']);
-
- $m->connect('url/:id',
- ['action' => 'redirecturl'],
- ['id' => '[0-9]+']);
-
- Event::handle('RouterInitialized', [$m]);
- }
- return $m;
- }
- function map($path)
- {
- try {
- return $this->m->match($path);
- } catch (NoRouteMapException $e) {
- common_debug($e->getMessage());
-
- throw new ClientException(_('Page not found.'), 404);
- }
- }
- function build($action, $args=null, $params=null, $fragment=null)
- {
- $action_arg = array('action' => $action);
- if ($args) {
- $args = array_merge($action_arg, $args);
- } else {
- $args = $action_arg;
- }
- $url = $this->m->generate($args, $params, $fragment);
-
-
-
- $qpos = strpos($url, '?');
- if ($qpos !== false) {
- $url = substr($url, 0, $qpos+1) .
- str_replace('?', '&', substr($url, $qpos+1));
-
-
-
-
- $url = substr($url, 0, $qpos+1) .
- str_replace('&', '&', substr($url, $qpos+1));
- }
- return $url;
- }
- }
|