]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - plugins/ExtendedProfile/ExtendedProfilePlugin.php
Merge branch 'jqueryui' into 1.0.x
[quix0rs-gnu-social.git] / plugins / ExtendedProfile / ExtendedProfilePlugin.php
1 <?php
2 /*
3  * StatusNet - the distributed open-source microblogging tool
4  * Copyright (C) 2011, StatusNet, 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('STATUSNET')) {
21     exit(1);
22 }
23
24 /**
25  * Extra profile bio-like fields
26  *
27  * @package ExtendedProfilePlugin
28  * @maintainer Brion Vibber <brion@status.net>
29  */
30 class ExtendedProfilePlugin extends Plugin
31 {
32
33     function onPluginVersion(&$versions)
34     {
35         $versions[] = array('name' => 'ExtendedProfile',
36                             'version' => STATUSNET_VERSION,
37                             'author' => 'Brion Vibber',
38                             'homepage' => 'http://status.net/wiki/Plugin:ExtendedProfile',
39                             'rawdescription' =>
40                             _m('UI extensions for additional profile fields.'));
41
42         return true;
43     }
44
45     /**
46      * Autoloader
47      *
48      * Loads our classes if they're requested.
49      *
50      * @param string $cls Class requested
51      *
52      * @return boolean hook return
53      */
54     function onAutoload($cls)
55     {
56         $lower = strtolower($cls);
57
58         switch ($lower)
59         {
60         case 'extendedprofile':
61         case 'extendedprofilewidget':
62         case 'profiledetailaction':
63         case 'profiledetailsettingsaction':
64             require_once dirname(__FILE__) . '/' . $lower . '.php';
65             return false;
66         case 'userautocompleteaction':
67             require_once dirname(__FILE__) . '/action/' . mb_substr($lower, 0, -6) . '.php';
68             return false;
69         case 'profile_detail':
70             require_once dirname(__FILE__) . '/' . ucfirst($lower) . '.php';
71             return false;
72         default:
73             return true;
74         }
75     }
76
77     /**
78      * Add paths to the router table
79      *
80      * Hook for RouterInitialized event.
81      *
82      * @param Net_URL_Mapper $m URL mapper
83      *
84      * @return boolean hook return
85      */
86     function onStartInitializeRouter($m)
87     {
88         $m->connect(
89             ':nickname/detail',
90             array('action' => 'profiledetail'),
91             array('nickname' => Nickname::DISPLAY_FMT)
92         );
93         $m->connect(
94             '/settings/profile/finduser',
95             array('action' => 'Userautocomplete')
96         );
97         $m->connect(
98             'settings/profile/detail',
99             array('action' => 'profiledetailsettings')
100         );
101
102         return true;
103     }
104
105     function onCheckSchema()
106     {
107         $schema = Schema::get();
108         $schema->ensureTable('profile_detail', Profile_detail::schemaDef());
109
110         return true;
111     }
112
113     function onEndAccountSettingsProfileMenuItem($widget, $menu)
114     {
115         // TRANS: Link title attribute in user account settings menu.
116         $title = _('Change additional profile settings');
117         // TRANS: Link description in user account settings menu.
118         $widget->showMenuItem('profiledetailsettings',_m('Details'),$title);
119         return true;
120     }
121
122     function onEndProfilePageProfileElements(HTMLOutputter $out, Profile $profile) {
123         $user = User::staticGet('id', $profile->id);
124         if ($user) {
125             $url = common_local_url('profiledetail', array('nickname' => $user->nickname));
126             $out->element('a', array('href' => $url), _m('More details...'));
127         }
128         return;
129     }
130
131 }