123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- <?php
- if (!defined('STATUSNET')) {
- exit(1);
- }
- class AdsensePlugin extends UAPPlugin
- {
- public $adScript = 'http://pagead2.googlesyndication.com/pagead/show_ads.js';
- public $client = null;
- function initialize()
- {
- parent::initialize();
-
-
- foreach (array('mediumRectangle', 'rectangle', 'leaderboard', 'wideSkyscraper', 'adScript', 'client') as $setting) {
- $value = common_config('adsense', strtolower($setting));
- if (!empty($value)) {
- $this->$setting = $value;
- }
- }
- }
-
- protected function showMediumRectangle($action)
- {
- $this->showAdsenseCode($action, 300, 250, $this->mediumRectangle);
- }
-
- protected function showRectangle($action)
- {
- $this->showAdsenseCode($action, 180, 150, $this->rectangle);
- }
-
- protected function showWideSkyscraper($action)
- {
- $this->showAdsenseCode($action, 160, 600, $this->wideSkyscraper);
- }
-
- protected function showLeaderboard($action)
- {
- $this->showAdsenseCode($action, 728, 90, $this->leaderboard);
- }
-
- protected function showAdsenseCode($action, $width, $height, $slot)
- {
- $code = 'google_ad_client = "'.$this->client.'"; ';
- $code .= 'google_ad_slot = "'.$slot.'"; ';
- $code .= 'google_ad_width = '.$width.'; ';
- $code .= 'google_ad_height = '.$height.'; ';
- $action->inlineScript($code);
- $action->script($this->adScript);
- }
- function onRouterInitialized($m)
- {
- $m->connect('panel/adsense',
- array('action' => 'adsenseadminpanel'));
- return true;
- }
- function onEndAdminPanelNav($menu) {
- if (AdminPanelAction::canAdmin('adsense')) {
-
- $menu_title = _m('AdSense configuration');
-
- $menu->out->menuItem(common_local_url('adsenseadminpanel'), _m('MENU','AdSense'),
- $menu_title, $action_name == 'adsenseadminpanel', 'nav_adsense_admin_panel');
- }
- return true;
- }
- function onPluginVersion(&$versions)
- {
- $versions[] = array('name' => 'BlankAdPlugin',
- 'version' => GNUSOCIAL_VERSION,
- 'author' => 'Evan Prodromou',
- 'homepage' => 'http://status.net/wiki/Plugin:Adsense',
- 'rawdescription' =>
-
- _m('Plugin to add Google AdSense to StatusNet sites.'));
- return true;
- }
- }
|