/
maintain.class.php
101 lines (86 loc) · 2.42 KB
/
maintain.class.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
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
<?php
defined('PHPWG_ROOT_PATH') or die('Hacking attempt!');
class Fotorama_maintain extends PluginMaintain
{
private $installed = false;
private $default_conf = array(
'mobile_backend' => 'fotorama',
'desktop_backend' => 'fotorama',
'allowfullscreen' => 'native',
'photoswipe_allowfullscreen' => true,
'fit' => 'scaledown',
'transition' => 'slide',
'shadows' => false,
'autoplay' => true,
'stopautoplayontouch' => false,
'loop' => true,
'nav' => 'false',
'fullscreen_nav' => 'false',
'only_fullscreen' => false,
'enable_caption' => false,
'enable_caption_with' => 'title',
'thumbheight' => 64,
'replace_picture' => false,
'replace_picture_only_users' => false,
'clicktransition_crossfade' => true,
'close_button' => false,
'resize' => false,
'period' => 4000,
'info_button' => false,
'photoswipe_info_button' => false,
'square_thumb' => true,
);
function __construct($plugin_id)
{
parent::__construct($plugin_id);
}
function install($plugin_version, &$errors=array())
{
global $conf;
if (empty($conf['Fotorama']))
{
$conf['Fotorama'] = serialize($this->default_conf);
conf_update_param('Fotorama', $conf['Fotorama']);
}
else
{
$new_conf = is_string($conf['Fotorama']) ? unserialize($conf['Fotorama']) : $conf['Fotorama'];
foreach ($this->default_conf as $conf_key => $conf_value)
{
if (!isset($new_conf[$conf_key]))
{
$new_conf[$conf_key] = $conf_value;
}
}
$conf['Fotorama'] = serialize($new_conf);
conf_update_param('Fotorama', $conf['Fotorama']);
}
// add a new column to existing table
$result = pwg_query('SHOW COLUMNS FROM `'.HISTORY_TABLE.'` LIKE "is_slideshow";');
if (!pwg_db_num_rows($result))
{
pwg_query('ALTER TABLE `' . HISTORY_TABLE . '` ADD `is_slideshow` enum(\'true\',\'false\') NOT NULL DEFAULT \'false\';');
}
$this->installed = true;
}
function activate($plugin_version, &$errors=array())
{
if (!$this->installed)
{
$this->install($plugin_version, $errors);
}
}
function deactivate()
{
}
function update($old_version, $new_version, &$errors=array())
{
$this->install($new_version, $errors);
}
function uninstall()
{
conf_delete_param('Fotorama');
pwg_query('ALTER TABLE `'. HISTORY_TABLE .'` DROP `is_slideshow`;');
}
}
?>