]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/applicationlist.php
Workflow for registering new OAuth apps pretty much done.
[quix0rs-gnu-social.git] / lib / applicationlist.php
1 <?php
2
3 /**
4  * StatusNet, the distributed open-source microblogging tool
5  *
6  * Widget to show a list of OAuth applications
7  *
8  * PHP version 5
9  *
10  * LICENCE: This program is free software: you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License as published by
12  * the Free Software Foundation, either version 3 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Affero General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
22  *
23  * @category  Application
24  * @package   StatusNet
25  * @author    Zach Copley <zach@status.net>
26  * @copyright 2008-2009 StatusNet, Inc.
27  * @license   http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
28  * @link      http://status.net/
29  */
30
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
32     exit(1);
33 }
34
35 require_once INSTALLDIR . '/lib/widget.php';
36
37 define('APPS_PER_PAGE', 20);
38
39 /**
40  * Widget to show a list of OAuth applications
41  *
42  * @category Application
43  * @package  StatusNet
44  * @author   Zach Copley <zach@status.net>
45  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
46  * @link     http://status.net/
47  */
48
49 class ApplicationList extends Widget
50 {
51     /** Current application, application query */
52     var $application = null;
53
54     /** Owner of this list */
55     var $owner = null;
56
57     /** Action object using us. */
58     var $action = null;
59
60     function __construct($application, $owner=null, $action=null)
61     {
62         parent::__construct($action);
63
64         $this->application = $application;
65         $this->owner       = $owner;
66         $this->action      = $action;
67     }
68
69     function show()
70     {
71         $this->out->elementStart('ul', 'applications xoxo');
72
73         $cnt = 0;
74
75         while ($this->application->fetch()) {
76             $cnt++;
77             if($cnt > APPS_PER_PAGE) {
78                 break;
79             }
80             $this->showapplication();
81         }
82
83         $this->out->elementEnd('ul');
84
85         return $cnt;
86     }
87
88     function showApplication()
89     {
90
91         $user = common_current_user();
92
93         $this->out->elementStart('li', array('class' => 'application',
94                                              'id' => 'oauthclient-' . $this->application->id));
95
96         $this->out->elementStart('a',
97             array('href' => common_local_url(
98                     'showapplication',
99                     array(
100                         'nickname' => $user->nickname,
101                         'id' => $this->application->id
102                         )
103                     ),
104                 'class' => 'url')
105             );
106
107             $this->out->raw($this->application->name);
108             $this->out->elementEnd('a');
109
110             $this->out->raw(' by ');
111
112             $this->out->elementStart('a',
113             array(
114                 'href' => $this->application->homepage,
115                 'class' => 'url'
116                 )
117             );
118             $this->out->raw($this->application->organization);
119             $this->out->elementEnd('a');
120
121             $this->out->elementStart('p', 'note');
122         $this->out->raw($this->application->description);
123         $this->out->elementEnd('p');
124
125             $this->out->elementEnd('li');
126     }
127
128     /* Override this in subclasses. */
129
130     function showOwnerControls()
131     {
132         return;
133     }
134
135     function highlight($text)
136     {
137         return htmlspecialchars($text);
138     }
139 }