|
1
|
|
|
<?php namespace XoopsModules\Tdmcreate\Files\Admin; |
|
2
|
|
|
|
|
3
|
|
|
use XoopsModules\Tdmcreate; |
|
4
|
|
|
use XoopsModules\Tdmcreate\Files; |
|
5
|
|
|
|
|
6
|
|
|
/* |
|
7
|
|
|
You may not change or alter any portion of this comment or credits |
|
8
|
|
|
of supporting developers from this source code or any supporting source code |
|
9
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
10
|
|
|
|
|
11
|
|
|
This program is distributed in the hope that it will be useful, |
|
12
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
14
|
|
|
*/ |
|
15
|
|
|
/** |
|
16
|
|
|
* tdmcreate module. |
|
17
|
|
|
* |
|
18
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
19
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
20
|
|
|
* |
|
21
|
|
|
* @since 2.5.0 |
|
22
|
|
|
* |
|
23
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
|
24
|
|
|
* |
|
25
|
|
|
* @version $Id: admin_header.php 12258 2014-01-02 09:33:29Z timgno $ |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Class AdminHeader. |
|
30
|
|
|
*/ |
|
31
|
|
|
class AdminHeader extends Files\CreateFile |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @var mixed |
|
35
|
|
|
*/ |
|
36
|
|
|
private $xc = null; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @public function constructor |
|
40
|
|
|
* @param null |
|
41
|
|
|
*/ |
|
42
|
|
|
public function __construct() |
|
43
|
|
|
{ |
|
44
|
|
|
parent::__construct(); |
|
45
|
|
|
$this->xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
|
46
|
|
|
$this->phpcode = Tdmcreate\Files\CreatePhpCode::getInstance(); |
|
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @static function getInstance |
|
51
|
|
|
* @param null |
|
52
|
|
|
* @return AdminHeader |
|
53
|
|
|
*/ |
|
54
|
|
|
public static function getInstance() |
|
55
|
|
|
{ |
|
56
|
|
|
static $instance = false; |
|
57
|
|
|
if (!$instance) { |
|
58
|
|
|
$instance = new self(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
return $instance; |
|
62
|
|
|
} |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @public function write |
|
66
|
|
|
* @param string $module |
|
67
|
|
|
* @param mixed $table |
|
68
|
|
|
* @param array $tables |
|
69
|
|
|
* @param string $filename |
|
70
|
|
|
*/ |
|
71
|
|
|
public function write($module, $table, $tables, $filename) |
|
72
|
|
|
{ |
|
73
|
|
|
$this->setModule($module); |
|
74
|
|
|
$this->setTable($table); |
|
75
|
|
|
$this->setTables($tables); |
|
76
|
|
|
$this->setFileName($filename); |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @private function getAdminPagesHeader |
|
81
|
|
|
* @param $moduleDirname |
|
82
|
|
|
* |
|
83
|
|
|
* @return string |
|
84
|
|
|
*/ |
|
85
|
|
|
private function getAdminHeader($moduleDirname) |
|
86
|
|
|
{ |
|
87
|
|
|
$ucfModuleDirname = ucfirst($moduleDirname); |
|
88
|
|
|
$stuModuleDirname = mb_strtoupper($moduleDirname); |
|
89
|
|
|
$table = $this->getTable(); |
|
90
|
|
|
$tables = $this->getTables(); |
|
91
|
|
|
$ret = $this->phpcode->getPhpCodeIncludeDir('dirname(dirname(dirname(__DIR__)))', 'include/cp_header'); |
|
92
|
|
|
$ret .= $this->phpcode->getPhpCodeIncludeDir('dirname(__DIR__)', 'include/common', true); |
|
93
|
|
|
$sysicons16 = $this->xc->getXcGetInfo('', 'sysicons16', true); |
|
94
|
|
|
$sysicons32 = $this->xc->getXcGetInfo('', 'sysicons32', true); |
|
95
|
|
|
$dirmoduleadmin = $this->xc->getXcGetInfo('', 'dirmoduleadmin', true); |
|
96
|
|
|
$modicons16 = $this->xc->getXcGetInfo('', 'modicons16', true); |
|
97
|
|
|
$modicons32 = $this->xc->getXcGetInfo('', 'modicons32', true); |
|
98
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$sysPathIcon16 ', "'../' . {$sysicons16}"); |
|
99
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$sysPathIcon32 ', "'../' . {$sysicons32}"); |
|
100
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$pathModuleAdmin ', $dirmoduleadmin); |
|
101
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$modPathIcon16 ', $modicons16); |
|
102
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$modPathIcon32 ', $modicons32); |
|
103
|
|
|
if (is_object($table) && '' != $table->getVar('table_name')) { |
|
104
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Get instance of module'); |
|
105
|
|
|
$ret .= $this->xc->getXcEqualsOperator("\${$moduleDirname}", "{$ucfModuleDirname}Helper::getInstance()"); |
|
106
|
|
|
} |
|
107
|
|
|
if (is_array($tables)) { |
|
108
|
|
|
foreach (array_keys($tables) as $i) { |
|
109
|
|
|
$tableName = $tables[$i]->getVar('table_name'); |
|
110
|
|
|
$ret .= $this->xc->getXcEqualsOperator("\${$tableName}Handler", "\${$moduleDirname}->getHandler('{$tableName}')", null, true); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$myts', 'MyTextSanitizer::getInstance()', null, false); |
|
114
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine(); |
|
115
|
|
|
$template = $this->phpcode->getPhpCodeIncludeDir('XOOPS_ROOT_PATH', 'class/template', true, false, 'include', "\t"); |
|
116
|
|
|
$template .= $this->xc->getXcEqualsOperator('$xoopsTpl', 'new \XoopsTpl()', null, false, "\t"); |
|
117
|
|
|
$ret .= $this->phpcode->getPhpCodeConditions('!isset($xoopsTpl)', ' || ', '!is_object($xoopsTpl)', $template, false); |
|
118
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('System icons path'); |
|
119
|
|
|
$ret .= $this->xc->getXcTplAssign('sysPathIcon16', '$sysPathIcon16'); |
|
120
|
|
|
$ret .= $this->xc->getXcTplAssign('sysPathIcon32', '$sysPathIcon32'); |
|
121
|
|
|
$ret .= $this->xc->getXcTplAssign('modPathIcon16', '$modPathIcon16'); |
|
122
|
|
|
$ret .= $this->xc->getXcTplAssign('modPathIcon32', '$modPathIcon32'); |
|
123
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Load languages'); |
|
124
|
|
|
$ret .= $this->xc->getXcLoadLanguage('admin'); |
|
125
|
|
|
$ret .= $this->xc->getXcLoadLanguage('modinfo'); |
|
126
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Local admin menu class'); |
|
127
|
|
|
$xoopsPathCond = $this->xc->getXcPath('$pathModuleAdmin', 'moduleadmin', true); |
|
128
|
|
|
$fileExists = $this->phpcode->getPhpCodeFileExists($xoopsPathCond); |
|
129
|
|
|
$moduleadmin = $this->phpcode->getPhpCodeIncludeDir($xoopsPathCond, '', true, true, 'include', "\t"); |
|
130
|
|
|
$redirectHeader = $this->xc->getXcRedirectHeader('../../../admin.php', '', '5', '_AM_MODULEADMIN_MISSING', true, "\t"); |
|
131
|
|
|
|
|
132
|
|
|
$ret .= $this->phpcode->getPhpCodeConditions($fileExists, '', '', $moduleadmin, $redirectHeader); |
|
133
|
|
|
$ret .= $this->xc->getXcCPHeader(); |
|
134
|
|
|
$ret .= $this->xc->getXcEqualsOperator('$adminObject', '\Xmf\Module\Admin::getInstance()'); |
|
135
|
|
|
$ret .= $this->getSimpleString("\$style = {$stuModuleDirname}_URL . '/assets/css/admin/style.css';"); |
|
136
|
|
|
|
|
137
|
|
|
return $ret; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
|
|
/** |
|
141
|
|
|
* @public function render |
|
142
|
|
|
* @param null |
|
143
|
|
|
* @return bool|string |
|
144
|
|
|
*/ |
|
145
|
|
|
public function render() |
|
146
|
|
|
{ |
|
147
|
|
|
$module = $this->getModule(); |
|
148
|
|
|
$filename = $this->getFileName(); |
|
149
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
150
|
|
|
$content = $this->getHeaderFilesComments($module, $filename); |
|
151
|
|
|
$content .= $this->getAdminHeader($moduleDirname); |
|
152
|
|
|
|
|
153
|
|
|
$this->create($moduleDirname, 'admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
|
154
|
|
|
|
|
155
|
|
|
return $this->renderFile(); |
|
156
|
|
|
} |
|
157
|
|
|
} |
|
158
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..