|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Modulebuilder\Files\User; |
|
4
|
|
|
|
|
5
|
|
|
use XoopsModules\Modulebuilder; |
|
6
|
|
|
|
|
7
|
|
|
/* |
|
8
|
|
|
You may not change or alter any portion of this comment or credits |
|
9
|
|
|
of supporting developers from this source code or any supporting source code |
|
10
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
11
|
|
|
|
|
12
|
|
|
This program is distributed in the hope that it will be useful, |
|
13
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
14
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
15
|
|
|
*/ |
|
16
|
|
|
/** |
|
17
|
|
|
* modulebuilder module. |
|
18
|
|
|
* |
|
19
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
20
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
21
|
|
|
* |
|
22
|
|
|
* @since 2.5.0 |
|
23
|
|
|
* |
|
24
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
|
25
|
|
|
* |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class UserXoopsCode. |
|
30
|
|
|
*/ |
|
31
|
|
|
class UserXoopsCode |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @var mixed |
|
35
|
|
|
*/ |
|
36
|
|
|
private $xc = null; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @var mixed |
|
40
|
|
|
*/ |
|
41
|
|
|
private $pc = null; |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* @public function constructor |
|
45
|
|
|
* @param null |
|
46
|
|
|
*/ |
|
47
|
|
|
public function __construct() |
|
48
|
|
|
{ |
|
49
|
|
|
$this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
|
50
|
|
|
$this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/* |
|
54
|
|
|
* @static function getInstance |
|
55
|
|
|
* @param null |
|
56
|
|
|
*/ |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @return UserXoopsCode |
|
60
|
|
|
*/ |
|
61
|
|
|
public static function getInstance() |
|
62
|
|
|
{ |
|
63
|
|
|
static $instance = false; |
|
64
|
|
|
if (!$instance) { |
|
65
|
|
|
$instance = new self(); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
return $instance; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* @public function getUserTplMain |
|
73
|
|
|
* |
|
74
|
|
|
* @param $moduleDirname |
|
75
|
|
|
* @param string $tableName |
|
76
|
|
|
* |
|
77
|
|
|
* @return string |
|
78
|
|
|
*/ |
|
79
|
|
|
public function getUserTplMain($moduleDirname, $tableName = 'index') |
|
80
|
|
|
{ |
|
81
|
|
|
return "\$GLOBALS['xoopsOption']['template_main'] = '{$moduleDirname}_{$tableName}.tpl';\n"; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @public function getUserAddMeta |
|
86
|
|
|
* |
|
87
|
|
|
* @param string $type |
|
88
|
|
|
* @param $language |
|
89
|
|
|
* @param $tableName |
|
90
|
|
|
* |
|
91
|
|
|
* @param string $t |
|
92
|
|
|
* @return string |
|
93
|
|
|
*/ |
|
94
|
|
|
public function getUserAddMeta($type, $language, $tableName, $t = '') |
|
95
|
|
|
{ |
|
96
|
|
|
$stuTableName = \mb_strtoupper($tableName); |
|
97
|
|
|
$stripTags = $this->pc->getPhpCodeStripTags('', $language . $stuTableName, true); |
|
98
|
|
|
|
|
99
|
|
|
return "{$t}\$GLOBALS['xoTheme']->addMeta('meta', '{$type}', {$stripTags});\n"; |
|
100
|
|
|
} |
|
101
|
|
|
|
|
102
|
|
|
/** |
|
103
|
|
|
* @public function getUserMetaKeywords |
|
104
|
|
|
* |
|
105
|
|
|
* @param $moduleDirname |
|
106
|
|
|
* |
|
107
|
|
|
* @return string |
|
108
|
|
|
*/ |
|
109
|
|
|
public function getUserMetaKeywords($moduleDirname) |
|
110
|
|
|
{ |
|
111
|
|
|
$implode = $this->pc->getPhpCodeImplode(',', '$keywords'); |
|
112
|
|
|
|
|
113
|
|
|
return "{$moduleDirname}MetaKeywords(\$helper->getConfig('keywords') . ', ' . {$implode});\n"; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
/** |
|
117
|
|
|
* @public function getUserMetaDesc |
|
118
|
|
|
* |
|
119
|
|
|
* @param $moduleDirname |
|
120
|
|
|
* @param $language |
|
121
|
|
|
* @param string $file |
|
122
|
|
|
* |
|
123
|
|
|
* @return string |
|
124
|
|
|
*/ |
|
125
|
|
|
public function getUserMetaDesc($moduleDirname, $language, $file = 'INDEX') |
|
126
|
|
|
{ |
|
127
|
|
|
return "{$moduleDirname}MetaDescription({$language}{$file}_DESC);\n"; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @public function getUserBreadcrumbs |
|
132
|
|
|
* |
|
133
|
|
|
* @param $language |
|
134
|
|
|
* @param string $tableName |
|
135
|
|
|
* @param string $op |
|
136
|
|
|
* @param string $link |
|
137
|
|
|
* @param string $t |
|
138
|
|
|
* |
|
139
|
|
|
* @return string |
|
140
|
|
|
*/ |
|
141
|
|
|
public function getUserBreadcrumbs($language, $tableName = 'index', $op = '', $link = '', $t = '') |
|
142
|
|
|
{ |
|
143
|
|
|
$stuTableName = \mb_strtoupper($tableName); |
|
144
|
|
|
$stuOp = ''; |
|
145
|
|
|
$ret = $this->pc->getPhpCodeCommentLine('Breadcrumbs', '', $t); |
|
146
|
|
|
if ('' !== $op) { |
|
147
|
|
|
$stuOp = ''; |
|
148
|
|
|
if ('' !== $tableName) { |
|
149
|
|
|
$stuOp .= '_'; |
|
150
|
|
|
} |
|
151
|
|
|
$stuOp .= \mb_strtoupper($op); |
|
152
|
|
|
} |
|
153
|
|
|
if ('' === $link) { |
|
154
|
|
|
$arrBCrumb = ["'title'" => "{$language}{$stuTableName}{$stuOp}"]; |
|
155
|
|
|
} else { |
|
156
|
|
|
$arrBCrumb = ["'title'" => "{$language}{$stuTableName}{$stuOp}", "'link'" => "'{$link}'"]; |
|
157
|
|
|
} |
|
158
|
|
|
$ret .= $this->pc->getPhpCodeArray('xoBreadcrumbs[]', $arrBCrumb, false, $t); |
|
159
|
|
|
|
|
160
|
|
|
return $ret; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* @public function getUserBreadcrumbs |
|
165
|
|
|
* |
|
166
|
|
|
* @return string |
|
167
|
|
|
*/ |
|
168
|
|
|
public function getUserBreadcrumbsFooterFile() |
|
169
|
|
|
{ |
|
170
|
|
|
$cond = $this->xc->getXcXoopsTplAssign('xoBreadcrumbs', '$xoBreadcrumbs'); |
|
171
|
|
|
$ret = $this->pc->getPhpCodeConditions('\count($xoBreadcrumbs)', ' > ', '1', $cond, false, "\t\t"); |
|
172
|
|
|
|
|
173
|
|
|
return $ret; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
/** |
|
177
|
|
|
* @public function getUserModVersionArray |
|
178
|
|
|
* |
|
179
|
|
|
* @param int $eleArray |
|
180
|
|
|
* @param $descriptions |
|
181
|
|
|
* @param null $name |
|
|
|
|
|
|
182
|
|
|
* @param null $index |
|
|
|
|
|
|
183
|
|
|
* @param bool $num |
|
184
|
|
|
* @param string $t |
|
185
|
|
|
* |
|
186
|
|
|
* @return string |
|
187
|
|
|
*/ |
|
188
|
|
|
public function getUserModVersionArray($eleArray, $descriptions, $name = null, $index = null, $num = false, $t = '') |
|
189
|
|
|
{ |
|
190
|
|
|
$ret = $t . '$modversion'; |
|
191
|
|
|
$isArray = false; |
|
192
|
|
|
$n = ''; |
|
193
|
|
|
if (!\is_array($descriptions)) { |
|
194
|
|
|
$descs = [$descriptions]; |
|
195
|
|
|
} else { |
|
196
|
|
|
$descs = $descriptions; |
|
197
|
|
|
$isArray = true; |
|
198
|
|
|
$n = "\n"; |
|
199
|
|
|
} |
|
200
|
|
|
if (0 === $eleArray) { |
|
201
|
|
|
$ret .= " = "; |
|
202
|
|
|
} elseif (1 === $eleArray || 11 === $eleArray) { |
|
203
|
|
|
$ret .= "['{$name}'] = "; |
|
204
|
|
|
} elseif (2 === $eleArray) { |
|
205
|
|
|
$ret .= "['{$name}'][{$index}] = "; |
|
206
|
|
|
} elseif (3 === $eleArray) { |
|
207
|
|
|
$ret .= "['{$name}'][{$index}][{$num}] = "; |
|
208
|
|
|
} |
|
209
|
|
|
if ($isArray) { |
|
210
|
|
|
$ret .= "["; |
|
211
|
|
|
} |
|
212
|
|
|
$ret .= $n; |
|
213
|
|
|
//search for longest key |
|
214
|
|
|
$len = 0; |
|
215
|
|
|
foreach ($descs as $key => $desc) { |
|
216
|
|
|
$len = \strlen($key) > $len ? \strlen($key) : $len; |
|
217
|
|
|
} |
|
218
|
|
|
|
|
219
|
|
|
foreach ($descs as $key => $desc) { |
|
220
|
|
|
$space = str_repeat ( ' ' , $len - \strlen($key)); |
|
221
|
|
|
if ($eleArray < 4) { |
|
222
|
|
|
$ret .= $t . "\t'{$key}'{$space} => {$desc},{$n}"; |
|
223
|
|
|
} elseif (11 === $eleArray) { |
|
224
|
|
|
if ('/' === \substr($desc, 1, 1)) { |
|
225
|
|
|
$ret .= $t . "\t{$desc}"; |
|
226
|
|
|
} else { |
|
227
|
|
|
$ret .= $t . "\t{$desc},{$n}"; |
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
} elseif (12 === $eleArray) { |
|
231
|
|
|
$ret .= $t . "\t{$desc}{$n}"; |
|
232
|
|
|
} |
|
233
|
|
|
} |
|
234
|
|
|
$ret .= $t; |
|
235
|
|
|
if ($isArray) { |
|
236
|
|
|
$ret .= "]"; |
|
237
|
|
|
} |
|
238
|
|
|
$ret .= ";\n"; |
|
239
|
|
|
return $ret; |
|
240
|
|
|
} |
|
241
|
|
|
|
|
242
|
|
|
/** |
|
243
|
|
|
* @public function getUserModVersionText |
|
244
|
|
|
* |
|
245
|
|
|
* @param int $eleArray |
|
246
|
|
|
* @param $text |
|
247
|
|
|
* @param null $name |
|
|
|
|
|
|
248
|
|
|
* @param null $index |
|
|
|
|
|
|
249
|
|
|
* @param bool $num |
|
250
|
|
|
* @param string $t |
|
251
|
|
|
* |
|
252
|
|
|
* @return string |
|
253
|
|
|
*/ |
|
254
|
|
|
public function getUserModVersionText($eleArray, $text, $name = null, $index = null, $num = false, $t = '') |
|
255
|
|
|
{ |
|
256
|
|
|
$ret = $t . '$modversion'; |
|
257
|
|
|
|
|
258
|
|
|
if (0 === $eleArray) { |
|
259
|
|
|
$ret .= " = "; |
|
260
|
|
|
} elseif (1 === $eleArray) { |
|
261
|
|
|
$ret .= "['{$name}'] = "; |
|
262
|
|
|
} elseif (2 === $eleArray) { |
|
263
|
|
|
$ret .= "['{$name}'][{$index}] = "; |
|
264
|
|
|
} elseif (3 === $eleArray) { |
|
265
|
|
|
$ret .= "['{$name}'][{$index}][{$num}] = "; |
|
266
|
|
|
} |
|
267
|
|
|
|
|
268
|
|
|
$ret .= $t . "{$text};\n"; |
|
269
|
|
|
return $ret; |
|
270
|
|
|
} |
|
271
|
|
|
} |
|
272
|
|
|
|