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 * @copyright 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/
30 if (!defined('STATUSNET') && !defined('LACONICA')) {
35 * Outputs the following ad types (based on UAP):
36 * Medium Rectangle 300x250
39 * Wide Skyscraper 160x600
41 * Any number of ad types can be used. Enable all using example:
42 * addPlugin('UAP', array(
43 * 'MediumRectangle' => '<script type="text/javascript">var foo = 1;</script>',
44 * 'Rectangle' => '<script type="text/javascript">var bar = 2;</script>',
45 * 'Leaderboard' => '<script type="text/javascript">var baz = 2;</script>',
46 * 'WideSkyscraper' => '<script type="text/javascript">var bbq = 4;</script>'
52 * @author Sarven Capadisli <csarven@status.net>
53 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
54 * @link http://status.net/
57 class UAPPlugin extends Plugin
59 public $MediumRectangle = null;
60 public $Rectangle = null;
61 public $Leaderboard = null;
62 public $WideSkyscraper = null;
64 function __construct($uap = array())
68 parent::__construct();
71 function onInitializePlugin()
73 foreach($this->uap as $key => $value) {
74 switch(strtolower($key)) {
75 case 'mediumrectangle': default:
76 $this->MediumRectangle = $value;
79 $this->Rectangle = $value;
82 $this->Leaderboard = $value;
84 case 'wideskyscraper':
85 $this->WideSkyscraper = $value;
91 function onEndShowStatusNetStyles($action)
93 $action->cssLink(common_path('plugins/UAP/uap.css'),
94 null, 'screen, projection, tv');
99 function onStartShowAside($action)
101 if (!$this->MediumRectangle) {
105 $this->showAd($action, array('id' => 'ad_medium-rectangle'),
106 $this->MediumRectangle);
113 function onEndShowSiteNotice($action)
115 if (!$this->Rectangle) {
119 $this->showAd($action, array('id' => 'ad_rectangle'),
126 //Leaderboard and Rectangle ad
127 function onStartShowHeader($action)
129 if ($this->Leaderboard) {
130 $this->showAd($action, array('id' => 'ad_leaderboard'),
134 if ($this->Rectangle) {
135 $this->showAd($action, array('id' => 'ad_rectangle'),
143 function onEndShowAside($action)
145 if (!$this->WideSkyscraper) {
149 $this->showAd($action, array('id' => 'ad_wide-skyscraper'),
150 $this->WideSkyscraper);
155 //Output ad container
156 function showAd($action, $attr=array(), $value)
158 $classes = ($attr['class']) ? $attr['class'].' ' : '';
160 $action->elementStart('div', array('id' => $attr['id'],
161 'class' => $classes.'ad'));
162 $action->raw($value);
163 $action->elementEnd('div');
166 function onPluginVersion(&$versions)
168 $versions[] = array('name' => 'UAP',
169 'version' => STATUSNET_VERSION,
170 'author' => 'Sarven Capadisli',
171 'homepage' => 'http://status.net/wiki/Plugin:UAP',
173 _m('Outputs ad placements based on Universal Ad Package'));