]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/uapplugin.php
make uapplugin an abstract class
[quix0rs-gnu-social.git] / lib / uapplugin.php
1 <?php
2 /**
3  * StatusNet, the distributed open-source microblogging tool
4  *
5  * UAP (Universal Ad Package) plugin
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  Action
23  * @package   StatusNet
24  * @author    Sarven Capadisli <csarven@status.net>
25  * @author    Evan Prodromou <evan@status.net>
26  * @copyright 2010 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 /**
36  * Abstract superclass for advertising plugins
37  *
38  * Plugins for showing ads should derive from this plugin.
39  *
40  * Outputs the following ad types (based on UAP):
41  *
42  * Medium Rectangle 300x250
43  * Rectangle        180x150
44  * Leaderboard      728x90
45  * Wide Skyscraper  160x600
46  *
47  * @category Plugin
48  * @package  StatusNet
49  * @author   Sarven Capadisli <csarven@status.net>
50  * @author   Evan Prodromou <evan@status.net>
51  * @license  http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
52  * @link     http://status.net/
53  */
54
55 abstract class UAPPlugin extends Plugin
56 {
57     public $MediumRectangle = null;
58     public $Rectangle       = null;
59     public $Leaderboard     = null;
60     public $WideSkyscraper  = null;
61
62     /**
63      * Output our dedicated stylesheet
64      *
65      * @param Action $action Action being shown
66      *
67      * @return boolean hook flag
68      */
69
70     function onEndShowStatusNetStyles($action)
71     {
72         // XXX: allow override by theme
73         $action->cssLink('css/uap.css', 'base', 'screen, projection, tv');
74         return true;
75     }
76
77     /**
78      * Add a medium rectangle ad at the beginning of sidebar
79      *
80      * @param Action $action Action being shown
81      *
82      * @return boolean hook flag
83      */
84
85     function onStartShowAside($action)
86     {
87         if (!is_null($this->mediumRectangle)) {
88
89             $action->elementStart('div',
90                                   array('class' => 'ad_medium-rectangle ad'));
91
92             $this->showMediumRectangle($action);
93
94             $action->elementEnd('div');
95         }
96
97         return true;
98     }
99
100     /**
101      * Add a leaderboard and/or rectangle in the header
102      *
103      * @param Action $action Action being shown
104      *
105      * @return boolean hook flag
106      */
107
108     function onStartShowHeader($action)
109     {
110         if (!is_null($this->leaderboard)) {
111             $action->elementStart('div',
112                                   array('class' => 'ad_leaderboard ad'));
113             $this->showLeaderboard($action);
114             $action->elementEnd('div');
115         }
116
117         if (!is_null($this->rectangle)) {
118             $action->elementStart('div',
119                                   array('class' => 'ad_rectangle ad'));
120             $this->showRectangle($action);
121             $action->elementEnd('div');
122         }
123
124         return true;
125     }
126
127     /**
128      * Add a wide skyscraper after the aside
129      *
130      * @param Action $action Action being shown
131      *
132      * @return boolean hook flag
133      */
134
135     function onEndShowAside($action)
136     {
137         if (!is_null($this->wideSkyscraper)) {
138             $action->elementStart('div',
139                                   array('class' => 'ad_wide-skyscraper ad'));
140
141             $this->showWideSkyscraper($action);
142
143             $action->elementEnd('div');
144         }
145         return true;
146     }
147
148     /**
149      * Show a medium rectangle ad
150      *
151      * @param Action $action Action being shown
152      *
153      * @return void
154      */
155
156     abstract protected function showMediumRectangle($action);
157
158     /**
159      * Show a rectangle ad
160      *
161      * @param Action $action Action being shown
162      *
163      * @return void
164      */
165
166     abstract protected function showRectangle($action);
167
168     /**
169      * Show a wide skyscraper ad
170      *
171      * @param Action $action Action being shown
172      *
173      * @return void
174      */
175
176     abstract protected function showWideSkyscraper($action);
177
178     /**
179      * Show a leaderboard ad
180      *
181      * @param Action $action Action being shown
182      *
183      * @return void
184      */
185
186     abstract protected function showLeaderboard($action);
187 }