3 * StatusNet, the distributed open-source microblogging tool
5 * UAP (Universal Ad Package) plugin
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.
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.
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/>.
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/
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
36 * Abstract superclass for advertising plugins
38 * Plugins for showing ads should derive from this plugin.
40 * Outputs the following ad types (based on UAP):
42 * Medium Rectangle 300x250
45 * Wide Skyscraper 160x600
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/
54 abstract class UAPPlugin extends Plugin
56 public $mediumRectangle = null;
57 public $rectangle = null;
58 public $leaderboard = null;
59 public $wideSkyscraper = null;
62 * Output our dedicated stylesheet
64 * @param Action $action Action being shown
66 * @return boolean hook flag
68 function onEndShowStatusNetStyles($action)
70 // XXX: allow override by theme
71 $action->cssLink('css/uap.css', 'base', 'screen, projection, tv');
76 * Add a medium rectangle ad at the beginning of sidebar
78 * @param Action $action Action being shown
80 * @return boolean hook flag
82 function onStartShowAside($action)
84 if (!is_null($this->mediumRectangle)) {
86 $action->elementStart('div',
87 array('id' => 'ad_medium-rectangle',
90 $this->showMediumRectangle($action);
92 $action->elementEnd('div');
95 // XXX: Hack to force ads to show on single-notice pages
97 if (!is_null($this->rectangle) &&
98 $action->trimmed('action') == 'shownotice') {
100 $action->elementStart('div', array('id' => 'aside_primary',
101 'class' => 'aside'));
103 if (Event::handle('StartShowSections', array($action))) {
104 $action->showSections();
105 Event::handle('EndShowSections', array($action));
108 $action->elementEnd('div');
117 * Add a leaderboard in the header
119 * @param Action $action Action being shown
121 * @return boolean hook flag
124 function onEndShowHeader($action)
126 if (!is_null($this->leaderboard)) {
127 $action->elementStart('div',
128 array('id' => 'ad_leaderboard',
130 $this->showLeaderboard($action);
131 $action->elementEnd('div');
138 * Add a rectangle before aside sections
140 * @param Action $action Action being shown
142 * @return boolean hook flag
144 function onStartShowSections($action)
146 if (!is_null($this->rectangle)) {
147 $action->elementStart('div',
148 array('id' => 'ad_rectangle',
150 $this->showRectangle($action);
151 $action->elementEnd('div');
158 * Add a wide skyscraper after the aside
160 * @param Action $action Action being shown
162 * @return boolean hook flag
164 function onEndShowAside($action)
166 if (!is_null($this->wideSkyscraper)) {
167 $action->elementStart('div',
168 array('id' => 'ad_wide-skyscraper',
171 $this->showWideSkyscraper($action);
173 $action->elementEnd('div');
179 * Show a medium rectangle ad
181 * @param Action $action Action being shown
185 abstract protected function showMediumRectangle($action);
188 * Show a rectangle ad
190 * @param Action $action Action being shown
194 abstract protected function showRectangle($action);
197 * Show a wide skyscraper ad
199 * @param Action $action Action being shown
203 abstract protected function showWideSkyscraper($action);
206 * Show a leaderboard ad
208 * @param Action $action Action being shown
212 abstract protected function showLeaderboard($action);