summaryrefslogtreecommitdiff
path: root/plugins/data.adsense.php
blob: 698a691aec3576758e414454503910cfe2aef196 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php

namespace Bitweaver\Liberty;

use Bitweaver\KernelTools;

/**
 * @version  $Revision$
 * @package  liberty
 * @subpackage plugins_data
 */
// +----------------------------------------------------------------------+
// | Copyright (c) 2004, bitweaver.org
// +----------------------------------------------------------------------+
// | All Rights Reserved. See below for details and a complete list of authors.
// | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
// |
// | For comments, please use phpdocu.sourceforge.net documentation standards!!!
// | -> see http://phpdocu.sourceforge.net/
// +----------------------------------------------------------------------+
// | Author:  xing
// +----------------------------------------------------------------------+
// $Id$

/**
 * definitions
 */

/******************
* Initialization *
******************/
global $gLibertySystem;
define( 'PLUGIN_GUID_DATAADSENSE', 'dataadsense' );
$pluginParams =  [
	'tag' => 'ADSENSE',
	'auto_activate' => false,
	'requires_pair' => false,
	'load_function' => '\data_adsense',
	'title' => 'Adsense',
	'help_page' => 'DataPluginAdsense',
	'description' => KernelTools::tra("This plugin adds Adsense Code to page."),
	'help_function' => '\data_adsense_help',
	'syntax' => "{ADSENSE}",
	'plugin_type' => DATA_PLUGIN,
];
$gLibertySystem->registerPlugin( PLUGIN_GUID_DATAADSENSE, $pluginParams );
$gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATAADSENSE );

/*****************
* Help Function *
*****************/
function data_adsense_help() {
	return 'NO HELP WRITTEN FOR {ADSENSE} YET. You can set: client, width, height, format, type and channel.';
}

/****************
* Load Function *
****************/
function data_adsense( $pData, $pParams ) {
	extract( $pParams );
	$width   = !empty( $width )   ? $width   : "728";
	$height  = !empty( $height )  ? $height  : "90";
	$client  = !empty( $client )  ? $client  : "pub-xxxxxxxxxxxxxxxx";
	$format  = !empty( $format )  ? $format  : "728x90_as";
	$type    = !empty( $type )    ? $type    : "text_image";
	$channel = !empty( $channel ) ? $channel : "";

	return "<!--~np~--><script type=\"text/javascript\">/* <![CDATA[ */
		google_ad_width   = $width;
		google_ad_height  = $height;
		google_ad_client  = \"$client\";
		google_ad_format  = \"$format\";
		google_ad_type    = \"$type\";
		google_ad_channel = \"$channel\";
	/* ]]> */</script>
	<script type=\"text/javascript\" src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\"></script><!--~/np~-->";
}