-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdetails.php
More file actions
281 lines (244 loc) · 8.46 KB
/
Copy pathdetails.php
File metadata and controls
281 lines (244 loc) · 8.46 KB
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
<?php defined('BASEPATH') or exit('No direct script access allowed');
/*
* @dodo: make it also page orientated. select which banner one wants associated with a page. evert time i add a page i need to go into each banner and associate it.
* @dodo: use caching
* @dodo: add is_slider/is_marquee
* @dodo: this plugin can be hooked into other modules to show banners on a modules sub-pagess - document it...
* @dodo: flag as warning if $config['index_page'] <> '' - 'index.php' seems to break it
*/
class Module_Banners extends Module {
public $version = '1.886';
var $tables = array(
'page_banners'=> 'page_banners',
'page_banners_areas'=> 'page_banners_areas',
'page_banners_link'=> 'page_banners_link'
);
public function info()
{
return array(
'name' => array(
'en' => 'Banners',
),
'description' => array(
'en' => 'Manage images and button links on your pages.',
),
'author' => 'dathwa@gmail.com',
'frontend' => FALSE,
'backend' => TRUE,
'skip_xss' => true,
'menu' => 'content',
'roles' => array('admin_banners', 'admin_areas', 'view_areas'),
'sections' => array(
'banners' => array(
'name' => 'banners_banners',
'uri' => 'admin/banners',
'shortcuts' => array(
array(
'name' => 'banners_create',
'uri' => 'admin/banners/edit',
'class' => 'add'
),
),
),
'areas' => array(
'name' => 'banners_areas',
'uri' => 'admin/banners/areas',
'shortcuts' => array(
array(
'name' => 'banners_areas_create',
'uri' => 'admin/banners/areas/edit',
'class' => 'add'
),
),
),
),
);
}
public function install()
{
if(! $this->uninstall())
{
return FALSE;
}
$tables= array(
"CREATE TABLE ".$this->db->dbprefix('page_banners')." (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) DEFAULT NULL,
`link_img` varchar(255) DEFAULT NULL,
`status` int(4) DEFAULT '0',
`update_time` bigint(20) DEFAULT NULL,
`banner_link_type` int(4) DEFAULT '0',
`banner_link` varchar(255) DEFAULT NULL,
`banner_target` varchar(255) DEFAULT NULL,
`banner_area` varchar(255) DEFAULT NULL,
`alt` varchar(255) DEFAULT NULL,
`the_order` int(4) DEFAULT '0',
`clicks` bigint(20) DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
",
"CREATE TABLE ".$this->db->dbprefix('page_banners_link')." (
`id` int(11) NOT NULL AUTO_INCREMENT,
`from_id` bigint(15) DEFAULT NULL,
`to_id` bigint(15) DEFAULT NULL,
`type` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8
",
"CREATE TABLE ".$this->db->dbprefix('page_banners_areas')." (
`id` int(11) NOT NULL AUTO_INCREMENT,
`slug` varchar(255) NOT NULL,
`title` varchar(255) DEFAULT NULL,
`width` int(11) NOT NULL,
`height` int(11) NOT NULL,
`is_default` tinyint(4) DEFAULT '0',
) ENGINE=MyISAM DEFAULT CHARSET=utf8"
);
$ok= TRUE;
foreach ($tables as $table) {
if (! $this->db->query($table))
{
$ok= FALSE;
}
}
$sql= "INSERT INTO ".$this->db->dbprefix('settings')." (`slug`, `title`, `description`, `type`, `default`, `value`, `options`, `is_required`, `is_gui`, `module`, `order`) VALUES
('banners_modules', 'Modules to use in the links', 'Comma separated list of modules to include for links', 'text', '', '', '', '0', '1', 'page_banners', '1')
;";
$this->db->query($sql);
if ($ok)
{
return TRUE;
}
else
{
return FALSE;
}
}
public function uninstall()
{
$result = array();
foreach ($this->tables as $table) {
$result[] = ($this->dbforge->drop_table($table)) ? TRUE : FALSE;
}
$result[]= $this->db->query("DELETE FROM `".$this->db->dbprefix('settings')."` WHERE slug='banners_modules';");
if (!in_array(FALSE, $result))
{
return TRUE;
}
}
public function upgrade($old_version)
{
if ($old_version < '1.6')
{
#add link
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners_areas')."` CHANGE `name` `title` varchar(255)
");
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners_areas')."` ADD COLUMN `width` int(11) default NULL AFTER title
");
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners_areas')."` ADD COLUMN `height` int(11) default NULL AFTER width
");
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners_areas')."`.`default_page_banners_areas` CHANGE `id` `id` INT(11) NOT NULL AUTO_INCREMENT;
");
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners_areas')."` DROP PRIMARY KEY
");
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners_areas')."` ADD COLUMN `id` INT NOT NULL FIRST, ADD PRIMARY KEY (`id`)
");
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners_areas')."`.`default_page_banners_areas` CHANGE `id` `id` INT(11) NOT NULL AUTO_INCREMENT;
");
#?????????????
#add link
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners_areas')."` ADD COLUMN `is_default` TINYINT DEFAULT 0 NULL AFTER `height`;
");
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners_areas')."` ADD COLUMN `ststus` TINYINT DEFAULT 1 AFTER `link_img`;
");
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners_areas')."`.`default_page_banners_areas` CHANGE `id` `id` INT(11) NOT NULL AUTO_INCREMENT;
");
}
if ($old_version < '1.72')
{
#add link
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners_areas')."` CHANGE `width` `width` INT(11) DEFAULT 0 NULL, CHANGE `height` `height` INT(11) DEFAULT 0 NULL;
");
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners')."` ADD COLUMN `banner_area_id` INT DEFAULT 0 NULL AFTER `banner_target`;
");
$this->db->query("
DELETE FROM `".$this->db->dbprefix('page_banners')."` WHERE status < 0;
");
}
#????????
if ($old_version < '1.73')
{
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners')."` ADD COLUMN `banner_link_type` INT DEFAULT 0 NULL AFTER `update_time`;
");
}
#?????????
if ($old_version < '1.74')
{
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners')."` DROP COLUMN `clicks`
");
}
if ($old_version < '1.75')
{
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners_areas')."` CHANGE `is_default` `is_default` TINYINT(4) DEFAULT 0 NOT NULL
");
}
#??????
if ($old_version < '1.76')
{
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners')."` CHANGE `alt` `alt` TEXT
");
}
if ($old_version < '1.76')
{
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners')."` CHANGE `alt` `alt` TEXT
");
}
if ($old_version < '1.86')
$this->db->query("
ALTER TABLE `".$this->db->dbprefix('page_banners')."` ADD COLUMN `the_order` INT(4) DEFAULT 0 NULL AFTER `alt`;
");
if ($old_version < '1.87')
$this->db->query("
UPDATE `".$this->db->dbprefix('settings')."` SET `is_required` = 0 WHERE slug='banners_modules';
");
if ($old_version < '1.88')
$this->db->query("
UPDATE `".$this->db->dbprefix('settings')."` SET `module` = 'banners' WHERE module='page_banners';
");
return TRUE;
}
private function settings_sql()
{
/*
return "
INSERT INTO ".$this->db->dbprefix('page_banners')." (`slug`, `title`, `description`, `type`, `default`, `value`, `options`, `is_required`, `is_gui`, `module`, `order`) VALUES
('pb_default_area', 'People per page', 'How many people should we show per page?', 'text', '25', '25', '', '1', '1', 'people', '1')
;
";
*/
}
public function help()
{
// Return a string containing help info
// You could include a file and return it here.
return "No documentation has been added for this module.<br/>Contact the module developer for assistance.";
}
}
/* End of file details.php */