|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Modulebuilder\Files\User; |
|
4
|
|
|
|
|
5
|
|
|
use XoopsModules\Modulebuilder; |
|
6
|
|
|
use XoopsModules\Modulebuilder\Files; |
|
7
|
|
|
|
|
8
|
|
|
/* |
|
9
|
|
|
You may not change or alter any portion of this comment or credits |
|
10
|
|
|
of supporting developers from this source code or any supporting source code |
|
11
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
12
|
|
|
|
|
13
|
|
|
This program is distributed in the hope that it will be useful, |
|
14
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
15
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
16
|
|
|
*/ |
|
17
|
|
|
/** |
|
18
|
|
|
* modulebuilder module. |
|
19
|
|
|
* |
|
20
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
21
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
22
|
|
|
* |
|
23
|
|
|
* @since 2.5.0 |
|
24
|
|
|
* |
|
25
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
|
26
|
|
|
* |
|
27
|
|
|
*/ |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Class UserHeader. |
|
31
|
|
|
*/ |
|
32
|
|
|
class UserHeader extends Files\CreateFile |
|
33
|
|
|
{ |
|
34
|
|
|
/** |
|
35
|
|
|
* @var mixed |
|
36
|
|
|
*/ |
|
37
|
|
|
private $uxc = null; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var mixed |
|
41
|
|
|
*/ |
|
42
|
|
|
private $xc = null; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var mixed |
|
46
|
|
|
*/ |
|
47
|
|
|
private $pc = null; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @public function constructor |
|
51
|
|
|
* @param null |
|
52
|
|
|
*/ |
|
53
|
|
|
public function __construct() |
|
54
|
|
|
{ |
|
55
|
|
|
parent::__construct(); |
|
56
|
|
|
$this->xc = Modulebuilder\Files\CreateXoopsCode::getInstance(); |
|
57
|
|
|
$this->pc = Modulebuilder\Files\CreatePhpCode::getInstance(); |
|
58
|
|
|
$this->uxc = Modulebuilder\Files\User\UserXoopsCode::getInstance(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @static function getInstance |
|
63
|
|
|
* @param null |
|
64
|
|
|
* @return UserHeader |
|
65
|
|
|
*/ |
|
66
|
|
|
public static function getInstance() |
|
67
|
|
|
{ |
|
68
|
|
|
static $instance = false; |
|
69
|
|
|
if (!$instance) { |
|
70
|
|
|
$instance = new self(); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
return $instance; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
/** |
|
77
|
|
|
* @public function write |
|
78
|
|
|
* @param string $module |
|
79
|
|
|
* @param mixed $table |
|
80
|
|
|
* @param array $tables |
|
81
|
|
|
* @param string $filename |
|
82
|
|
|
*/ |
|
83
|
|
|
public function write($module, $table, $tables, $filename) |
|
84
|
|
|
{ |
|
85
|
|
|
$this->setModule($module); |
|
86
|
|
|
$this->setTable($table); |
|
87
|
|
|
$this->setTables($tables); |
|
88
|
|
|
$this->setFileName($filename); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/** |
|
92
|
|
|
* @private function getUserHeader |
|
93
|
|
|
* @param $moduleDirname |
|
94
|
|
|
* |
|
95
|
|
|
* @return string |
|
96
|
|
|
*/ |
|
97
|
|
|
private function getUserHeader($moduleDirname) |
|
98
|
|
|
{ |
|
99
|
|
|
$stuModuleDirname = \mb_strtoupper($moduleDirname); |
|
100
|
|
|
$tables = $this->getTables(); |
|
101
|
|
|
$language = $this->getLanguage($moduleDirname, 'MA'); |
|
102
|
|
|
|
|
103
|
|
|
$ret = $this->pc->getPhpCodeIncludeDir('\dirname(\dirname(__DIR__))', 'mainfile'); |
|
104
|
|
|
$ret .= $this->pc->getPhpCodeIncludeDir('__DIR__', 'include/common'); |
|
105
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$moduleDirName', '\basename(__DIR__)'); |
|
106
|
|
|
$ret .= $this->uxc->getUserBreadcrumbsHeaderFile($moduleDirname, $language); |
|
107
|
|
|
$ret .= $this->xc->getXcHelperGetInstance($moduleDirname); |
|
108
|
|
|
$permissions = 0; |
|
109
|
|
|
$ratings = 0; |
|
110
|
|
|
if (\is_array($tables)) { |
|
111
|
|
|
foreach (\array_keys($tables) as $i) { |
|
112
|
|
|
$tableName = $tables[$i]->getVar('table_name'); |
|
113
|
|
|
$ret .= $this->xc->getXcHandlerLine($tableName); |
|
114
|
|
|
if (1 == $tables[$i]->getVar('table_permissions')) { |
|
115
|
|
|
$permissions = 1; |
|
116
|
|
|
} |
|
117
|
|
|
if (1 == $tables[$i]->getVar('table_rate')) { |
|
118
|
|
|
$ratings = 1; |
|
119
|
|
|
} |
|
120
|
|
|
} |
|
121
|
|
|
} |
|
122
|
|
|
if (1 == $permissions) { |
|
123
|
|
|
$ret .= $this->xc->getXcHandlerLine('permissions'); |
|
124
|
|
|
} |
|
125
|
|
|
if (1 == $ratings) { |
|
126
|
|
|
$ret .= $this->xc->getXcHandlerLine('ratings'); |
|
127
|
|
|
} |
|
128
|
|
|
$ret .= $this->pc->getPhpCodeCommentLine(); |
|
129
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$myts', 'MyTextSanitizer::getInstance()'); |
|
130
|
|
|
$ret .= $this->pc->getPhpCodeCommentLine('Default Css Style'); |
|
131
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$style', "{$stuModuleDirname}_URL . '/assets/css/style.css'"); |
|
132
|
|
|
$ret .= $this->pc->getPhpCodeCommentLine('Smarty Default'); |
|
133
|
|
|
$ret .= $this->xc->getXcXoopsModuleGetInfo('sysPathIcon16', 'sysicons16'); |
|
134
|
|
|
$ret .= $this->xc->getXcXoopsModuleGetInfo('sysPathIcon32', 'sysicons32'); |
|
135
|
|
|
$ret .= $this->xc->getXcXoopsModuleGetInfo('pathModuleAdmin', 'dirmoduleadmin'); |
|
136
|
|
|
$ret .= $this->xc->getXcXoopsModuleGetInfo('modPathIcon16', 'modicons16'); |
|
137
|
|
|
$ret .= $this->xc->getXcXoopsModuleGetInfo('modPathIcon32', 'modicons16'); |
|
138
|
|
|
$ret .= $this->pc->getPhpCodeCommentLine('Load Languages'); |
|
139
|
|
|
$ret .= $this->xc->getXcXoopsLoadLanguage('main'); |
|
140
|
|
|
$ret .= $this->xc->getXcXoopsLoadLanguage('modinfo'); |
|
141
|
|
|
|
|
142
|
|
|
return $ret; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* @public function render |
|
147
|
|
|
* @param null |
|
148
|
|
|
* @return bool|string |
|
149
|
|
|
*/ |
|
150
|
|
|
public function render() |
|
151
|
|
|
{ |
|
152
|
|
|
$module = $this->getModule(); |
|
153
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
154
|
|
|
$filename = $this->getFileName(); |
|
155
|
|
|
$content = $this->getHeaderFilesComments($module); |
|
156
|
|
|
$content .= $this->getUserHeader($moduleDirname); |
|
157
|
|
|
|
|
158
|
|
|
$this->create($moduleDirname, '/', $filename, $content, _AM_MODULEBUILDER_FILE_CREATED, _AM_MODULEBUILDER_FILE_NOTCREATED); |
|
159
|
|
|
|
|
160
|
|
|
return $this->renderFile(); |
|
161
|
|
|
} |
|
162
|
|
|
} |
|
163
|
|
|
|