1<?php 2/** 3 * Google Ads for DokuWiki 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author Dirk Moeller, based on code by Bernd Zeimetz <bernd@bzed.de> and Terence J. Grant<tjgrant@tatewake.com> 7 */ 8 9if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); 10if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 11require_once(DOKU_PLUGIN.'admin.php'); 12 13//--- Exported code 14include_once(DOKU_PLUGIN.'googleads/code.php'); 15//--- Exported code 16 17/** 18 * All DokuWiki plugins to extend the admin function 19 * need to inherit from this class 20 */ 21class admin_plugin_googleads extends DokuWiki_Admin_Plugin 22{ 23var $state = 0; 24var $googleads = ''; 25 26 /** 27 * Constructor 28 */ 29 function admin_plugin_googleads() 30 { 31 $this->setupLocale(); 32 } 33 34 /** 35 * return some info 36 */ 37 function getInfo() 38 { 39 return array( 40 'author' => 'Dirk Moeller', 41 'email' => 'dirk@systemengineers.de', 42 'date' => '2007-08-14', 43 'name' => 'Google Adsense Plugin', 44 'desc' => 'Plugin to embed your Google Adsense code in your site. Based on code from Bernd Zeimetz and Terence J.', 45 'url' => 'http://www.systemengineers.de/plugins/googleads', 46 ); 47 } 48 49 /** 50 * return sort order for position in admin menu 51 */ 52 function getMenuSort() 53 { 54 return 888; 55 } 56 57 58 /** 59 * handle user request 60 */ 61 function handle() 62 { 63 $this->state = 0; 64 65 if (!isset($_REQUEST['cmd'])) return; // first time - nothing to do 66 67 if (!is_array($_REQUEST['cmd'])) return; 68 69 $this->googleads = $_REQUEST['googleads']; 70 71 if (is_array($this->googleads)) 72 { 73 $this->state = 1; 74 } 75 } 76 77 /** 78 * output appropriate html 79 */ 80 function html() 81 { 82 global $conf; 83 global $gads_loaded, $gads_settings; 84 85 if ($this->state != 0) //If we are to save now... 86 { 87 $gads_settings['enabled'] = $this->googleads['enabled'] == 'on' ? 'checked' : ''; 88 $gads_settings['debug'] = $this->googleads['debug'] == 'on' ? 'checked' : ''; 89 $gads_settings['dontcountadmin'] = $this->googleads['dontcountadmin'] == 'on' ? 'checked' : ''; 90 $gads_settings['dontcountusers'] = $this->googleads['dontcountusers'] == 'on' ? 'checked' : ''; 91 92 $gads_settings['google_ad_client'] = $this->googleads['google_ad_client']; 93 $gads_settings['google_color_border'] = $this->googleads['google_color_border']; 94 $gads_settings['google_color_bg'] = $this->googleads['google_color_bg']; 95 $gads_settings['google_color_link'] = $this->googleads['google_color_link']; 96 $gads_settings['google_color_url'] = $this->googleads['google_color_url']; 97 $gads_settings['google_color_text'] = $this->googleads['google_color_text']; 98 99 gads_save(); 100 } 101 102 print $this->plugin_locale_xhtml('intro'); 103 104 ptln("<form action=\"".wl($ID)."\" method=\"post\">"); 105 ptln(' <input type="hidden" name="do" value="admin" />'); 106 ptln(' <input type="hidden" name="page" value="'.$this->getPluginName().'" />'); 107 ptln(' <input type="hidden" name="cmd[googleads]" value="true" />'); 108 print '<center><table class="inline">'; 109 print ' <tr><th> '.$this->getLang('gads_item_type').' </th><th> '.$this->getLang('gads_item_option').' </th></tr>'; 110// print ' <tr><td> '.$this->getLang('gads_googleads_code').' </td><td><TEXTAREA rows="15" cols="40" name="googleads[code]">' . stripslashes($gads_settings['code']) . '</TEXTAREA></td></tr>'; 111 112 print ' <tr><td> '.$this->getLang('gads_enabled').' </td><td><input type="checkbox" name="googleads[enabled]" '.$gads_settings['enabled'].'/></td></tr>'; 113 print ' <tr><td> '.$this->getLang('gads_debug').' </td><td><input type="checkbox" name="googleads[debug]" '.$gads_settings['debug'].'/></td></tr>'; 114 print ' <tr><td> '.$this->getLang('gads_dont_count_admin').' </td><td><input type="checkbox" name="googleads[dontcountadmin]" '.$gads_settings['dontcountadmin'].'/></td></tr>'; 115 print ' <tr><td> '.$this->getLang('gads_dont_count_users').' </td><td><input type="checkbox" name="googleads[dontcountusers]" '.$gads_settings['dontcountusers'].'/></td></tr>'; 116 117 118 print ' <tr><td> '.$this->getLang('google_ad_client').' </td><td><input type="text" name="googleads[google_ad_client]" value="'.$gads_settings['google_ad_client'].'"/></td></tr>'; 119 print ' <tr><td> '.$this->getLang('google_color_border').' </td><td><input type="text" name="googleads[google_color_border]" value="'.$gads_settings['google_color_border'].'"/></td></tr>'; 120 121 print ' <tr><td> '.$this->getLang('google_color_bg').' </td><td><input type="text" name="googleads[google_color_bg]" value="'.$gads_settings['google_color_bg'].'"/></td></tr>'; 122 123 print ' <tr><td> '.$this->getLang('google_color_link').' </td><td><input type="text" name="googleads[google_color_link]" value="'.$gads_settings['google_color_link'].'"/></td></tr>'; 124 125 print ' <tr><td> '.$this->getLang('google_color_url').' </td><td><input type="text" name="googleads[google_color_url]" value="'.$gads_settings['google_color_url'].'"/></td></tr>'; 126 127 print ' <tr><td> '.$this->getLang('google_color_text').' </td><td><input type="text" name="googleads[google_color_text]" value="'.$gads_settings['google_color_text'].'"/></td></tr>'; 128 129 130 print '</table>'; 131 print '<br />'; 132 print '<p><input type="submit" value="'.$this->getLang('gads_save').'"></p></center>'; 133 print '</form>'; 134 } 135} 136 137