From 1758ed453bcf2abd11bc2fde8768632099fe0de3 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 27 Jan 2010 06:25:22 -0500 Subject: move UAP plugin to core --- lib/uapplugin.php | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 176 insertions(+) create mode 100644 lib/uapplugin.php (limited to 'lib/uapplugin.php') diff --git a/lib/uapplugin.php b/lib/uapplugin.php new file mode 100644 index 000000000..f3b16548d --- /dev/null +++ b/lib/uapplugin.php @@ -0,0 +1,176 @@ +. + * + * @category Action + * @package StatusNet + * @author Sarven Capadisli + * @copyright 2010 StatusNet, Inc. + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +if (!defined('STATUSNET') && !defined('LACONICA')) { + exit(1); +} + +/** + * Outputs the following ad types (based on UAP): + * Medium Rectangle 300x250 + * Rectangle 180x150 + * Leaderboard 728x90 + * Wide Skyscraper 160x600 + * + * Any number of ad types can be used. Enable all using example: + * addPlugin('UAP', array( + * 'MediumRectangle' => '', + * 'Rectangle' => '', + * 'Leaderboard' => '', + * 'WideSkyscraper' => '' + * ) + * ); + * + * @category Plugin + * @package StatusNet + * @author Sarven Capadisli + * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 + * @link http://status.net/ + */ + +class UAPPlugin extends Plugin +{ + public $MediumRectangle = null; + public $Rectangle = null; + public $Leaderboard = null; + public $WideSkyscraper = null; + + function __construct($uap = array()) + { + $this->uap = $uap; + + parent::__construct(); + } + + function onInitializePlugin() + { + foreach($this->uap as $key => $value) { + switch(strtolower($key)) { + case 'mediumrectangle': default: + $this->MediumRectangle = $value; + break; + case 'rectangle': + $this->Rectangle = $value; + break; + case 'leaderboard': + $this->Leaderboard = $value; + break; + case 'wideskyscraper': + $this->WideSkyscraper = $value; + break; + } + } + } + + function onEndShowStatusNetStyles($action) + { + $action->cssLink(common_path('plugins/UAP/uap.css'), + null, 'screen, projection, tv'); + return true; + } + + //MediumRectangle ad + function onStartShowAside($action) + { + if (!$this->MediumRectangle) { + return true; + } + + $this->showAd($action, array('id' => 'ad_medium-rectangle'), + $this->MediumRectangle); + + return true; + } + +/* + //Rectangle ad + function onEndShowSiteNotice($action) + { + if (!$this->Rectangle) { + return true; + } + + $this->showAd($action, array('id' => 'ad_rectangle'), + $this->Rectangle); + + return true; + } +*/ + + //Leaderboard and Rectangle ad + function onStartShowHeader($action) + { + if ($this->Leaderboard) { + $this->showAd($action, array('id' => 'ad_leaderboard'), + $this->Leaderboard); + } + + if ($this->Rectangle) { + $this->showAd($action, array('id' => 'ad_rectangle'), + $this->Rectangle); + } + + return true; + } + + //WideSkyscraper ad + function onEndShowAside($action) + { + if (!$this->WideSkyscraper) { + return true; + } + + $this->showAd($action, array('id' => 'ad_wide-skyscraper'), + $this->WideSkyscraper); + + return true; + } + + //Output ad container + function showAd($action, $attr=array(), $value) + { + $classes = ($attr['class']) ? $attr['class'].' ' : ''; + + $action->elementStart('div', array('id' => $attr['id'], + 'class' => $classes.'ad')); + $action->raw($value); + $action->elementEnd('div'); + } + + function onPluginVersion(&$versions) + { + $versions[] = array('name' => 'UAP', + 'version' => STATUSNET_VERSION, + 'author' => 'Sarven Capadisli', + 'homepage' => 'http://status.net/wiki/Plugin:UAP', + 'rawdescription' => + _m('Outputs ad placements based on Universal Ad Package')); + return true; + } +} -- cgit v1.2.3-54-g00ecf From 7c54591472b4ff997ea099792c95d40b98798381 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 27 Jan 2010 07:19:36 -0500 Subject: make uapplugin an abstract class --- lib/uapplugin.php | 199 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 105 insertions(+), 94 deletions(-) (limited to 'lib/uapplugin.php') diff --git a/lib/uapplugin.php b/lib/uapplugin.php index f3b16548d..5160d9662 100644 --- a/lib/uapplugin.php +++ b/lib/uapplugin.php @@ -22,6 +22,7 @@ * @category Action * @package StatusNet * @author Sarven Capadisli + * @author Evan Prodromou * @copyright 2010 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ @@ -32,145 +33,155 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { } /** + * Abstract superclass for advertising plugins + * + * Plugins for showing ads should derive from this plugin. + * * Outputs the following ad types (based on UAP): + * * Medium Rectangle 300x250 * Rectangle 180x150 * Leaderboard 728x90 * Wide Skyscraper 160x600 * - * Any number of ad types can be used. Enable all using example: - * addPlugin('UAP', array( - * 'MediumRectangle' => '', - * 'Rectangle' => '', - * 'Leaderboard' => '', - * 'WideSkyscraper' => '' - * ) - * ); - * * @category Plugin * @package StatusNet * @author Sarven Capadisli + * @author Evan Prodromou * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 * @link http://status.net/ */ -class UAPPlugin extends Plugin +abstract class UAPPlugin extends Plugin { public $MediumRectangle = null; - public $Rectangle = null; - public $Leaderboard = null; - public $WideSkyscraper = null; - - function __construct($uap = array()) - { - $this->uap = $uap; - - parent::__construct(); - } - - function onInitializePlugin() - { - foreach($this->uap as $key => $value) { - switch(strtolower($key)) { - case 'mediumrectangle': default: - $this->MediumRectangle = $value; - break; - case 'rectangle': - $this->Rectangle = $value; - break; - case 'leaderboard': - $this->Leaderboard = $value; - break; - case 'wideskyscraper': - $this->WideSkyscraper = $value; - break; - } - } - } + public $Rectangle = null; + public $Leaderboard = null; + public $WideSkyscraper = null; + + /** + * Output our dedicated stylesheet + * + * @param Action $action Action being shown + * + * @return boolean hook flag + */ function onEndShowStatusNetStyles($action) { - $action->cssLink(common_path('plugins/UAP/uap.css'), - null, 'screen, projection, tv'); + // XXX: allow override by theme + $action->cssLink('css/uap.css', 'base', 'screen, projection, tv'); return true; } - //MediumRectangle ad + /** + * Add a medium rectangle ad at the beginning of sidebar + * + * @param Action $action Action being shown + * + * @return boolean hook flag + */ + function onStartShowAside($action) { - if (!$this->MediumRectangle) { - return true; - } + if (!is_null($this->mediumRectangle)) { - $this->showAd($action, array('id' => 'ad_medium-rectangle'), - $this->MediumRectangle); + $action->elementStart('div', + array('class' => 'ad_medium-rectangle ad')); - return true; - } + $this->showMediumRectangle($action); -/* - //Rectangle ad - function onEndShowSiteNotice($action) - { - if (!$this->Rectangle) { - return true; + $action->elementEnd('div'); } - $this->showAd($action, array('id' => 'ad_rectangle'), - $this->Rectangle); - return true; } -*/ - //Leaderboard and Rectangle ad + /** + * Add a leaderboard and/or rectangle in the header + * + * @param Action $action Action being shown + * + * @return boolean hook flag + */ + function onStartShowHeader($action) { - if ($this->Leaderboard) { - $this->showAd($action, array('id' => 'ad_leaderboard'), - $this->Leaderboard); + if (!is_null($this->leaderboard)) { + $action->elementStart('div', + array('class' => 'ad_leaderboard ad')); + $this->showLeaderboard($action); + $action->elementEnd('div'); } - if ($this->Rectangle) { - $this->showAd($action, array('id' => 'ad_rectangle'), - $this->Rectangle); + if (!is_null($this->rectangle)) { + $action->elementStart('div', + array('class' => 'ad_rectangle ad')); + $this->showRectangle($action); + $action->elementEnd('div'); } return true; } - //WideSkyscraper ad + /** + * Add a wide skyscraper after the aside + * + * @param Action $action Action being shown + * + * @return boolean hook flag + */ + function onEndShowAside($action) { - if (!$this->WideSkyscraper) { - return true; - } + if (!is_null($this->wideSkyscraper)) { + $action->elementStart('div', + array('class' => 'ad_wide-skyscraper ad')); - $this->showAd($action, array('id' => 'ad_wide-skyscraper'), - $this->WideSkyscraper); + $this->showWideSkyscraper($action); + $action->elementEnd('div'); + } return true; } - //Output ad container - function showAd($action, $attr=array(), $value) - { - $classes = ($attr['class']) ? $attr['class'].' ' : ''; - - $action->elementStart('div', array('id' => $attr['id'], - 'class' => $classes.'ad')); - $action->raw($value); - $action->elementEnd('div'); - } - - function onPluginVersion(&$versions) - { - $versions[] = array('name' => 'UAP', - 'version' => STATUSNET_VERSION, - 'author' => 'Sarven Capadisli', - 'homepage' => 'http://status.net/wiki/Plugin:UAP', - 'rawdescription' => - _m('Outputs ad placements based on Universal Ad Package')); - return true; - } + /** + * Show a medium rectangle ad + * + * @param Action $action Action being shown + * + * @return void + */ + + abstract protected function showMediumRectangle($action); + + /** + * Show a rectangle ad + * + * @param Action $action Action being shown + * + * @return void + */ + + abstract protected function showRectangle($action); + + /** + * Show a wide skyscraper ad + * + * @param Action $action Action being shown + * + * @return void + */ + + abstract protected function showWideSkyscraper($action); + + /** + * Show a leaderboard ad + * + * @param Action $action Action being shown + * + * @return void + */ + + abstract protected function showLeaderboard($action); } -- cgit v1.2.3-54-g00ecf From e9feafc3ca4641bf5c51bbced3454962ed89b8ef Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 27 Jan 2010 08:13:24 -0500 Subject: CSS ids and classes fixed in UAPPlugin --- lib/uapplugin.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'lib/uapplugin.php') diff --git a/lib/uapplugin.php b/lib/uapplugin.php index 5160d9662..4364b1e19 100644 --- a/lib/uapplugin.php +++ b/lib/uapplugin.php @@ -87,7 +87,8 @@ abstract class UAPPlugin extends Plugin if (!is_null($this->mediumRectangle)) { $action->elementStart('div', - array('class' => 'ad_medium-rectangle ad')); + array('id' => 'ad_medium-rectangle', + 'class' => 'ad')); $this->showMediumRectangle($action); @@ -109,14 +110,16 @@ abstract class UAPPlugin extends Plugin { if (!is_null($this->leaderboard)) { $action->elementStart('div', - array('class' => 'ad_leaderboard ad')); + array('id' => 'ad_leaderboard', + 'class' => 'ad')); $this->showLeaderboard($action); $action->elementEnd('div'); } if (!is_null($this->rectangle)) { $action->elementStart('div', - array('class' => 'ad_rectangle ad')); + array('id' => 'ad_rectangle', + 'class' => 'ad')); $this->showRectangle($action); $action->elementEnd('div'); } @@ -136,7 +139,8 @@ abstract class UAPPlugin extends Plugin { if (!is_null($this->wideSkyscraper)) { $action->elementStart('div', - array('class' => 'ad_wide-skyscraper ad')); + array('id' => 'ad_wide-skyscraper', + 'class' => 'ad')); $this->showWideSkyscraper($action); -- cgit v1.2.3-54-g00ecf From 1c875a53952506ca95716992511421d110a37d4d Mon Sep 17 00:00:00 2001 From: Sarven Capadisli Date: Wed, 27 Jan 2010 15:32:59 +0100 Subject: Moved rectangle ad into aside and leaderboard to the right in header. Intention for this layout was to reduce whitespace in header area --- lib/uapplugin.php | 15 ++++++++++++++- theme/base/css/uap.css | 9 ++++++--- 2 files changed, 20 insertions(+), 4 deletions(-) (limited to 'lib/uapplugin.php') diff --git a/lib/uapplugin.php b/lib/uapplugin.php index 4364b1e19..69b68f936 100644 --- a/lib/uapplugin.php +++ b/lib/uapplugin.php @@ -99,7 +99,7 @@ abstract class UAPPlugin extends Plugin } /** - * Add a leaderboard and/or rectangle in the header + * Add a leaderboard in the header * * @param Action $action Action being shown * @@ -116,6 +116,19 @@ abstract class UAPPlugin extends Plugin $action->elementEnd('div'); } + return true; + } + + /** + * Add a rectangle before aside sections + * + * @param Action $action Action being shown + * + * @return boolean hook flag + */ + + function onStartShowSections($action) + { if (!is_null($this->rectangle)) { $action->elementStart('div', array('id' => 'ad_rectangle', diff --git a/theme/base/css/uap.css b/theme/base/css/uap.css index b95e9b2ce..d7fa02c7f 100644 --- a/theme/base/css/uap.css +++ b/theme/base/css/uap.css @@ -29,15 +29,18 @@ margin-bottom:18px; width:180px; height:150px; -float:right; -margin-right:18px; +float:none; +clear:both; +margin:0 auto; +margin-bottom:29px; } #ad_leaderboard { width:728px; height:90px; -margin:29px 18px 0 0; +margin:11px 18px 0 0; +float:right; clear:both; } -- cgit v1.2.3-54-g00ecf From ea123800e991352d862c05a2f81e82ef53e72eeb Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 27 Jan 2010 10:44:49 -0500 Subject: move leaderboard to after the header --- lib/uapplugin.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/uapplugin.php') diff --git a/lib/uapplugin.php b/lib/uapplugin.php index 69b68f936..e3801f08a 100644 --- a/lib/uapplugin.php +++ b/lib/uapplugin.php @@ -106,7 +106,7 @@ abstract class UAPPlugin extends Plugin * @return boolean hook flag */ - function onStartShowHeader($action) + function onEndShowHeader($action) { if (!is_null($this->leaderboard)) { $action->elementStart('div', -- cgit v1.2.3-54-g00ecf From 760be76fc000c546ac38e96fa1cc5f822b7e6993 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Wed, 27 Jan 2010 10:45:44 -0500 Subject: camelcase the uap param names --- lib/uapplugin.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/uapplugin.php') diff --git a/lib/uapplugin.php b/lib/uapplugin.php index e3801f08a..ef35bafbf 100644 --- a/lib/uapplugin.php +++ b/lib/uapplugin.php @@ -54,10 +54,10 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { abstract class UAPPlugin extends Plugin { - public $MediumRectangle = null; - public $Rectangle = null; - public $Leaderboard = null; - public $WideSkyscraper = null; + public $mediumRectangle = null; + public $rectangle = null; + public $leaderboard = null; + public $wideSkyscraper = null; /** * Output our dedicated stylesheet -- cgit v1.2.3-54-g00ecf