X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FAdsense%2FAdsensePlugin.php;h=3d733e15099cdd76b4c0d7b09f5cde1c659f3f7f;hb=59119482ca34540bd7f0a2a1aa994de1d5328ea2;hp=ab2b9a6fb3b417dd8fca6d6c3bb78ee925f5d24f;hpb=84e7c7783c3a781b6dc12335371c984eca8e43d8;p=quix0rs-gnu-social.git diff --git a/plugins/Adsense/AdsensePlugin.php b/plugins/Adsense/AdsensePlugin.php index ab2b9a6fb3..3d733e1509 100644 --- a/plugins/Adsense/AdsensePlugin.php +++ b/plugins/Adsense/AdsensePlugin.php @@ -77,12 +77,25 @@ if (!defined('STATUSNET')) { * * @seeAlso UAPPlugin */ - class AdsensePlugin extends UAPPlugin { public $adScript = 'http://pagead2.googlesyndication.com/pagead/show_ads.js'; public $client = null; + function initialize() + { + parent::initialize(); + + // A little bit of chicanery so we avoid overwriting values that + // are passed in with the constructor + foreach (array('mediumRectangle', 'rectangle', 'leaderboard', 'wideSkyscraper', 'adScript', 'client') as $setting) { + $value = common_config('adsense', strtolower($setting)); + if (!empty($value)) { // not found + $this->$setting = $value; + } + } + } + /** * Show a medium rectangle 'ad' * @@ -90,7 +103,6 @@ class AdsensePlugin extends UAPPlugin * * @return void */ - protected function showMediumRectangle($action) { $this->showAdsenseCode($action, 300, 250, $this->mediumRectangle); @@ -103,7 +115,6 @@ class AdsensePlugin extends UAPPlugin * * @return void */ - protected function showRectangle($action) { $this->showAdsenseCode($action, 180, 150, $this->rectangle); @@ -116,7 +127,6 @@ class AdsensePlugin extends UAPPlugin * * @return void */ - protected function showWideSkyscraper($action) { $this->showAdsenseCode($action, 160, 600, $this->wideSkyscraper); @@ -129,7 +139,6 @@ class AdsensePlugin extends UAPPlugin * * @return void */ - protected function showLeaderboard($action) { $this->showAdsenseCode($action, 728, 90, $this->leaderboard); @@ -145,7 +154,6 @@ class AdsensePlugin extends UAPPlugin * * @return void */ - protected function showAdsenseCode($action, $width, $height, $slot) { $code = 'google_ad_client = "'.$this->client.'"; '; @@ -157,4 +165,48 @@ class AdsensePlugin extends UAPPlugin $action->script($this->adScript); } -} \ No newline at end of file + + function onRouterInitialized($m) + { + $m->connect('admin/adsense', + array('action' => 'adsenseadminpanel')); + + return true; + } + + function onAutoload($cls) + { + $dir = dirname(__FILE__); + + switch ($cls) + { + case 'AdsenseadminpanelAction': + require_once $dir . '/' . strtolower(mb_substr($cls, 0, -6)) . '.php'; + return false; + default: + return true; + } + } + + function onEndAdminPanelNav($menu) { + if (AdminPanelAction::canAdmin('adsense')) { + // TRANS: Menu item title/tooltip + $menu_title = _m('AdSense configuration'); + // TRANS: Menu item for site administration + $menu->out->menuItem(common_local_url('adsenseadminpanel'), _m('AdSense'), + $menu_title, $action_name == 'adsenseadminpanel', 'nav_adsense_admin_panel'); + } + return true; + } + + function onPluginVersion(&$versions) + { + $versions[] = array('name' => 'BlankAdPlugin', + 'version' => STATUSNET_VERSION, + 'author' => 'Evan Prodromou', + 'homepage' => 'http://status.net/wiki/Plugin:Adsense', + 'rawdescription' => + _m('Plugin to add Google Adsense to StatusNet sites.')); + return true; + } +}