-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.php
69 lines (56 loc) · 2.74 KB
/
plugin.php
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
<?php
class pluginAds4U extends Plugin {
private $enable;
private function ads4u()
{
$ret = '<!-- Ads4U BEGIN -->'.PHP_EOL;
$ret .= ' '.Sanitize::htmlDecode($this->getValue('ads4uCode')).PHP_EOL;
$ret .= '<!-- Ads4U END -->'.PHP_EOL;
return $ret;
}
public function init()
{
$this->dbFields = array(
'enablePages'=>false,
'enablePosts'=>false,
'ads4uCode'=>''
);
}
public function form()
{
global $L;
$html = '<div>';
$html .= '<label for="ads4uenablepages">'.$L->get('enable-ads4u-on-pages').'</label>';
$html .= '<select id="ads4uenablepages" name="enablePages">';
$html .= '<option value="true" '.($this->getValue('enablePages')===true?'selected':'').'>'.$L->get('enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('enablePages')===false?'selected':'').'>'.$L->get('disabled').'</option>';
$html .= '</select>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label for="ads4uenableposts">'.$L->get('enable-ads4u-on-posts').'</label>';
$html .= '<select id="ads4uenableposts" name="enablePosts">';
$html .= '<option value="true" '.($this->getValue('enablePosts')===true?'selected':'').'>'.$L->get('enabled').'</option>';
$html .= '<option value="false" '.($this->getValue('enablePosts')===false?'selected':'').'>'.$L->get('disabled').'</option>';
$html .= '</select>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label for="ads4ucode">'.$L->get('ads4u-html-code').'</label>';
$html .= '<textarea id="ads4ucode" type="text" name="ads4uCode">'.$this->getValue('ads4uCode').'</textarea>';
$html .= '<span class="tip">'.$L->get('complete-this-field-with-html-code').'</span>';
$html .= '</div>';
return $html;
}
public function pageEnd()
{
global $url, $page;
if( $this->getValue('ads4uCode') != '' ) {
if( $url->whereAmI()=='page' ) {
if( ($this->getValue('enablePosts') && $page->published()) ||
($this->getValue('enablePages') && $page->static()) ) {
return $this->ads4u();
}
}
}
return false;
}
}