|
1
|
|
|
<?php |
|
2
|
|
|
// $Id$ |
|
3
|
|
|
// ------------------------------------------------------------------------ // |
|
4
|
|
|
// XOOPS - PHP Content Management System // |
|
5
|
|
|
// Copyright (c) 2000 XOOPS.org // |
|
6
|
|
|
// <https://xoops.org> // |
|
7
|
|
|
// ------------------------------------------------------------------------- // |
|
8
|
|
|
// This program is free software; you can redistribute it and/or modify // |
|
9
|
|
|
// it under the terms of the GNU General Public License as published by // |
|
10
|
|
|
// the Free Software Foundation; either version 2 of the License, or // |
|
11
|
|
|
// (at your option) any later version. // |
|
12
|
|
|
// // |
|
13
|
|
|
// You may not change or alter any portion of this comment or credits // |
|
14
|
|
|
// of supporting developers from this source code or any supporting // |
|
15
|
|
|
// source code which is considered copyrighted (c) material of the // |
|
16
|
|
|
// original comment or credit authors. // |
|
17
|
|
|
// // |
|
18
|
|
|
// This program is distributed in the hope that it will be useful, // |
|
19
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of // |
|
20
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
|
21
|
|
|
// GNU General Public License for more details. // |
|
22
|
|
|
// // |
|
23
|
|
|
// You should have received a copy of the GNU General Public License // |
|
24
|
|
|
// along with this program; if not, write to the Free Software // |
|
25
|
|
|
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
|
26
|
|
|
// ------------------------------------------------------------------------ // |
|
27
|
|
|
// |
|
28
|
|
|
|
|
29
|
|
|
//error_reporting(E_ALL); |
|
30
|
|
|
|
|
31
|
|
|
use XoopsModules\Lexikon\{ |
|
32
|
|
|
Helper, |
|
33
|
|
|
Common\Configurator, |
|
34
|
|
|
Utility |
|
35
|
|
|
}; |
|
36
|
|
|
|
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param $module |
|
40
|
|
|
* @param null $prev_version |
|
|
|
|
|
|
41
|
|
|
* @return bool|null |
|
42
|
|
|
*/ |
|
43
|
|
|
function xoops_module_update_lexikon($module, $prev_version = null) |
|
44
|
|
|
{ |
|
45
|
|
|
$moduleDirName = \basename(\dirname(__DIR__)); |
|
46
|
|
|
$moduleDirNameUpper = mb_strtoupper($moduleDirName); |
|
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
$helper = Helper::getInstance(); |
|
|
|
|
|
|
49
|
|
|
$utility = new Utility(); |
|
|
|
|
|
|
50
|
|
|
$configurator = new Configurator(); |
|
|
|
|
|
|
51
|
|
|
|
|
52
|
|
|
$ret = null; |
|
53
|
|
|
if ($prev_version < 152) { |
|
54
|
|
|
$ret = xoops_module_update_lexikon_v152($module); |
|
55
|
|
|
} |
|
56
|
|
|
$errors = $module->getErrors(); |
|
57
|
|
|
if (!empty($errors)) { |
|
58
|
|
|
print_r($errors); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
return $ret; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @param $xoopsModule |
|
66
|
|
|
* @return bool |
|
67
|
|
|
*/ |
|
68
|
|
|
function xoops_module_update_lexikon_v152($xoopsModule) |
|
|
|
|
|
|
69
|
|
|
{ |
|
70
|
|
|
/** |
|
71
|
|
|
* Create default upload directories |
|
72
|
|
|
*/ |
|
73
|
|
|
// Copy base file |
|
74
|
|
|
$indexFile = XOOPS_UPLOAD_PATH . '/index.html'; |
|
75
|
|
|
$blankFile = XOOPS_UPLOAD_PATH . '/blank.gif'; |
|
76
|
|
|
// Making of uploads/lexikon folder |
|
77
|
|
|
$p_lexikon = XOOPS_UPLOAD_PATH . '/lexikon'; |
|
78
|
|
|
if (!is_dir($p_lexikon)) { |
|
79
|
|
|
if (!mkdir($p_lexikon, 0777) && !is_dir($p_lexikon)) { |
|
80
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $p_lexikon)); |
|
81
|
|
|
} |
|
82
|
|
|
chmod($p_lexikon, 0777); |
|
83
|
|
|
} |
|
84
|
|
|
copy($indexFile, $p_lexikon . '/index.html'); |
|
85
|
|
|
// Making of categories folder |
|
86
|
|
|
$pl_categories = $p_lexikon . '/categories'; |
|
87
|
|
|
if (!is_dir($pl_categories)) { |
|
88
|
|
|
if (!mkdir($pl_categories, 0777) && !is_dir($pl_categories)) { |
|
89
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $pl_categories)); |
|
90
|
|
|
} |
|
91
|
|
|
chmod($pl_categories, 0777); |
|
92
|
|
|
} |
|
93
|
|
|
copy($indexFile, $pl_categories . '/index.html'); |
|
94
|
|
|
|
|
95
|
|
|
$plc_images = $pl_categories . '/images'; |
|
96
|
|
|
if (!is_dir($plc_images)) { |
|
97
|
|
|
if (!mkdir($plc_images, 0777) && !is_dir($plc_images)) { |
|
98
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $plc_images)); |
|
99
|
|
|
} |
|
100
|
|
|
chmod($plc_images, 0777); |
|
101
|
|
|
} |
|
102
|
|
|
copy($indexFile, $plc_images . '/index.html'); |
|
103
|
|
|
copy($blankFile, $plc_images . '/blank.gif'); |
|
104
|
|
|
// Making of entries folder |
|
105
|
|
|
$pl_entries = $p_lexikon . '/entries'; |
|
106
|
|
|
if (!is_dir($pl_entries)) { |
|
107
|
|
|
if (!mkdir($pl_entries, 0777) && !is_dir($pl_entries)) { |
|
108
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $pl_entries)); |
|
109
|
|
|
} |
|
110
|
|
|
chmod($pl_entries, 0777); |
|
111
|
|
|
} |
|
112
|
|
|
copy($indexFile, $pl_entries . '/index.html'); |
|
113
|
|
|
|
|
114
|
|
|
$ple_images = $pl_entries . '/images'; |
|
115
|
|
|
if (!is_dir($ple_images)) { |
|
116
|
|
|
if (!mkdir($ple_images, 0777) && !is_dir($ple_images)) { |
|
117
|
|
|
throw new \RuntimeException(sprintf('Directory "%s" was not created', $ple_images)); |
|
118
|
|
|
} |
|
119
|
|
|
chmod($ple_images, 0777); |
|
120
|
|
|
} |
|
121
|
|
|
copy($indexFile, $ple_images . '/index.html'); |
|
122
|
|
|
copy($blankFile, $ple_images . '/blank.gif'); |
|
123
|
|
|
|
|
124
|
|
|
return true; |
|
125
|
|
|
} |
|
126
|
|
|
|