]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/Favorite/FavoritePlugin.php
9fbaf258c4e6498e543f59c08febe83c69c11301
[quix0rs-gnu-social.git] / plugins / Favorite / FavoritePlugin.php
1 <?php
2 /*
3  * GNU Social - a federating social network
4  * Copyright (C) 2014, Free Software Foundation, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 if (!defined('GNUSOCIAL')) { exit(1); }
21
22 /**
23  * @package     UI
24  * @maintainer  Mikael Nordfeldth <mmn@hethane.se>
25  */
26 class FavoritePlugin extends Plugin
27 {
28     public function onRouterInitialized(URLMapper $m)
29     {
30         // Web UI actions
31         $m->connect('main/favor', array('action' => 'favor'));
32         $m->connect('main/disfavor', array('action' => 'disfavor'));
33
34         if (common_config('singleuser', 'enabled')) {
35             $nickname = User::singleUserNickname();
36
37             $m->connect('favorites',
38                         array('action' => 'showfavorites',
39                               'nickname' => $nickname));
40             $m->connect('favoritesrss',
41                         array('action' => 'favoritesrss',
42                               'nickname' => $nickname));
43         } else {
44             $m->connect('favoritedrss', array('action' => 'favoritedrss'));
45             $m->connect('favorited/', array('action' => 'favorited'));
46             $m->connect('favorited', array('action' => 'favorited'));
47
48             $m->connect(':nickname/favorites',
49                         array('action' => 'showfavorites'),
50                         array('nickname' => Nickname::DISPLAY_FMT));
51             $m->connect(':nickname/favorites/rss',
52                         array('action' => 'favoritesrss'),
53                         array('nickname' => Nickname::DISPLAY_FMT));
54         }
55
56         // Favorites for API
57         $m->connect('api/favorites/create.:format',
58                     array('action' => 'ApiFavoriteCreate',
59                           'format' => '(xml|json)'));
60         $m->connect('api/favorites/destroy.:format',
61                     array('action' => 'ApiFavoriteDestroy',
62                           'format' => '(xml|json)'));
63         $m->connect('api/favorites/list.:format',
64                     array('action' => 'ApiTimelineFavorites',
65                           'format' => '(xml|json|rss|atom|as)'));
66         $m->connect('api/favorites/:id.:format',
67                     array('action' => 'ApiTimelineFavorites',
68                           'id' => Nickname::INPUT_FMT,
69                           'format' => '(xml|json|rss|atom|as)'));
70         $m->connect('api/favorites.:format',
71                     array('action' => 'ApiTimelineFavorites',
72                           'format' => '(xml|json|rss|atom|as)'));
73         $m->connect('api/favorites/create/:id.:format',
74                     array('action' => 'ApiFavoriteCreate',
75                           'id' => '[0-9]+',
76                           'format' => '(xml|json)'));
77         $m->connect('api/favorites/destroy/:id.:format',
78                     array('action' => 'ApiFavoriteDestroy',
79                           'id' => '[0-9]+',
80                           'format' => '(xml|json)'));
81
82         // AtomPub API
83         $m->connect('api/statusnet/app/favorites/:profile/:notice.atom',
84                     array('action' => 'AtomPubShowFavorite'),
85                     array('profile' => '[0-9]+',
86                           'notice' => '[0-9]+'));
87
88         $m->connect('api/statusnet/app/favorites/:profile.atom',
89                     array('action' => 'AtomPubFavoriteFeed'),
90                     array('profile' => '[0-9]+'));
91
92         // Required for qvitter API
93         $m->connect('api/statuses/favs/:id.:format',
94                     array('action' => 'ApiStatusesFavs',
95                           'id' => '[0-9]+',
96                           'format' => '(xml|json)'));
97     }
98
99     public function onPluginVersion(array &$versions)
100     {
101         $versions[] = array('name' => 'Favorite',
102                             'version' => GNUSOCIAL_VERSION,
103                             'author' => 'Mikael Nordfeldth',
104                             'homepage' => 'http://gnu.io/',
105                             'rawdescription' =>
106                             // TRANS: Plugin description.
107                             _m('Favorites (likes) using ActivityStreams.'));
108
109         return true;
110     }
111 }