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