]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/applicationlist.php
Merge branch 'nightly' of git.gnu.io:gnu/gnu-social into nightly
[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     function __construct($application, Profile $owner, Action $out=null)
50     {
51         parent::__construct($out);
52
53         $this->application = $application;
54         $this->owner       = $owner;
55     }
56
57     function show()
58     {
59         $this->out->elementStart('ul', 'applications');
60
61         $cnt = 0;
62
63         while ($this->application->fetch()) {
64             $cnt++;
65             if($cnt > APPS_PER_PAGE) {
66                 break;
67             }
68             $this->showApplication();
69         }
70
71         $this->out->elementEnd('ul');
72
73         return $cnt;
74     }
75
76     function showApplication()
77     {
78         $this->out->elementStart('li', array('class' => 'application h-entry',
79                                              'id'    => 'oauthclient-' . $this->application->id));
80
81         $this->out->elementStart('a', array('href' => common_local_url('showapplication',
82                                                                        array('id' => $this->application->id)),
83                                             'class' => 'h-card'));
84
85         if (!empty($this->application->icon)) {
86             $this->out->element('img', array('src' => $this->application->icon,
87                                              'class' => 'avatar u-photo'));
88         }
89
90         $this->out->text($this->application->name);
91         $this->out->elementEnd('a');
92
93         $this->out->raw(' by ');
94
95         $this->out->element('a', array('href' => $this->application->homepage,
96                                        'class' => 'u-url'),
97                             $this->application->organization);
98
99         $this->out->element('p', 'note', $this->application->description);
100         $this->out->elementEnd('li');
101
102     }
103
104     /* Override this in subclasses. */
105     function showOwnerControls()
106     {
107         return;
108     }
109 }