|
1
|
|
|
<?php namespace XoopsModules\Tdmcreate\Files\Templates\User; |
|
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: TemplatesUserPages.php 12258 2014-01-02 09:33:29Z timgno $ |
|
26
|
|
|
*/ |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* class Pages. |
|
30
|
|
|
*/ |
|
31
|
|
|
class Pages extends Files\CreateFile |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @public function constructor |
|
35
|
|
|
* @param null |
|
36
|
|
|
*/ |
|
37
|
|
|
public function __construct() |
|
38
|
|
|
{ |
|
39
|
|
|
parent::__construct(); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @static function getInstance |
|
44
|
|
|
* @param null |
|
45
|
|
|
* @return Pages |
|
46
|
|
|
*/ |
|
47
|
|
|
public static function getInstance() |
|
48
|
|
|
{ |
|
49
|
|
|
static $instance = false; |
|
50
|
|
|
if (!$instance) { |
|
51
|
|
|
$instance = new self(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
return $instance; |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @public function write |
|
59
|
|
|
* @param string $module |
|
60
|
|
|
* @param string $table |
|
61
|
|
|
* @param string $filename |
|
62
|
|
|
*/ |
|
63
|
|
|
public function write($module, $table, $filename) |
|
64
|
|
|
{ |
|
65
|
|
|
$this->setModule($module); |
|
66
|
|
|
$this->setTable($table); |
|
67
|
|
|
$this->setFileName($filename); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* @private function getTemplatesUserPagesHeader |
|
72
|
|
|
* @param string $moduleDirname |
|
73
|
|
|
* @return string |
|
74
|
|
|
*/ |
|
75
|
|
|
private function getTemplatesUserPagesHeader($moduleDirname) |
|
76
|
|
|
{ |
|
77
|
|
|
$hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance(); |
|
78
|
|
|
|
|
79
|
|
|
return $hc->getSmartyIncludeFile($moduleDirname, 'header') . PHP_EOL; |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @private function getTemplatesUserPagesTable |
|
84
|
|
|
* @param string $moduleDirname |
|
85
|
|
|
* @param string $tableName |
|
86
|
|
|
* @param $tableSoleName |
|
87
|
|
|
* @param string $language |
|
88
|
|
|
* @return string |
|
89
|
|
|
*/ |
|
90
|
|
|
private function getTemplatesUserPagesTable($moduleDirname, $tableName, $tableSoleName, $language) |
|
91
|
|
|
{ |
|
92
|
|
|
$hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance(); |
|
93
|
|
|
$tbody = $this->getTemplatesUserPagesTableThead($tableName, $language); |
|
94
|
|
|
$tbody .= $this->getTemplatesUserPagesTableTbody($moduleDirname, $tableName, $tableSoleName, $language); |
|
95
|
|
|
$tbody .= $this->getTemplatesUserPagesTableTfoot(); |
|
96
|
|
|
$single = $hc->getSmartySingleVar('table_type'); |
|
97
|
|
|
|
|
98
|
|
|
return $hc->getHtmlTable($tbody, 'table table-' . $single) . PHP_EOL; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* @private function getTemplatesUserPagesThead |
|
103
|
|
|
* @param string $language |
|
104
|
|
|
* @param $tableName |
|
105
|
|
|
* @return string |
|
106
|
|
|
*/ |
|
107
|
|
|
private function getTemplatesUserPagesTableThead($tableName, $language) |
|
108
|
|
|
{ |
|
109
|
|
|
$hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance(); |
|
110
|
|
|
$stuTableName = mb_strtoupper($tableName); |
|
111
|
|
|
$single = $hc->getSmartySingleVar('divideby'); |
|
112
|
|
|
$lang = $hc->getSmartyConst($language, $stuTableName . '_TITLE'); |
|
113
|
|
|
$th = $hc->getHtmlTableHead($lang, '', $single) . PHP_EOL; |
|
114
|
|
|
$tr = $hc->getHtmlTableRow($th, 'head') . PHP_EOL; |
|
115
|
|
|
|
|
116
|
|
|
return $hc->getHtmlTableThead($tr) . PHP_EOL; |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* @private function getTemplatesUserPagesTbody |
|
121
|
|
|
* @param string $moduleDirname |
|
122
|
|
|
* @param string $language |
|
123
|
|
|
* @param $tableName |
|
124
|
|
|
* @param $tableSoleName |
|
125
|
|
|
* @return string |
|
126
|
|
|
*/ |
|
127
|
|
|
private function getTemplatesUserPagesTableTbody($moduleDirname, $tableName, $tableSoleName, $language) |
|
|
|
|
|
|
128
|
|
|
{ |
|
129
|
|
|
$hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance(); |
|
130
|
|
|
$single = $hc->getSmartySingleVar('panel_type'); |
|
131
|
|
|
$include = $hc->getSmartyIncludeFileListForeach($moduleDirname, $tableName, $tableSoleName); |
|
132
|
|
|
$div = $hc->getHtmlDiv($include, 'panel panel-' . $single); |
|
133
|
|
|
$cont = $hc->getHtmlTableData($div) . PHP_EOL; |
|
134
|
|
|
$html = $hc->getHtmlEmpty('</tr><tr>') . PHP_EOL; |
|
135
|
|
|
$cont .= $hc->getSmartyConditions($tableSoleName . '.count', ' is div by ', '$divideby', $html) . PHP_EOL; |
|
136
|
|
|
$foreach = $hc->getSmartyForeach($tableSoleName, $tableName, $cont) . PHP_EOL; |
|
137
|
|
|
$tr = $hc->getHtmlTableRow($foreach) . PHP_EOL; |
|
138
|
|
|
|
|
139
|
|
|
return $hc->getHtmlTableTbody($tr) . PHP_EOL; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
/** |
|
143
|
|
|
* @private function getTemplatesUserPagesTfoot |
|
144
|
|
|
* @param null |
|
145
|
|
|
* @return string |
|
146
|
|
|
*/ |
|
147
|
|
|
private function getTemplatesUserPagesTableTfoot() |
|
148
|
|
|
{ |
|
149
|
|
|
$hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance(); |
|
150
|
|
|
$td = $hc->getHtmlTableData(' ') . PHP_EOL; |
|
151
|
|
|
$tr = $hc->getHtmlTableRow($td) . PHP_EOL; |
|
152
|
|
|
|
|
153
|
|
|
return $hc->getHtmlTableTfoot($tr) . PHP_EOL; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
/** |
|
157
|
|
|
* @private function getTemplatesUserPages |
|
158
|
|
|
* @param $moduleDirname |
|
159
|
|
|
* @param $tableName |
|
160
|
|
|
* @param $tableSoleName |
|
161
|
|
|
* @param $language |
|
162
|
|
|
* @return string |
|
163
|
|
|
*/ |
|
164
|
|
|
private function getTemplatesUserPages($moduleDirname, $tableName, $tableSoleName, $language) |
|
165
|
|
|
{ |
|
166
|
|
|
$hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance(); |
|
167
|
|
|
$table = $this->getTemplatesUserPagesTable($moduleDirname, $tableName, $tableSoleName, $language) . PHP_EOL; |
|
168
|
|
|
$div = $hc->getHtmlDiv($table, 'table-responsive') . PHP_EOL; |
|
169
|
|
|
|
|
170
|
|
|
return $hc->getSmartyConditions($tableName, ' > ', '0', $div, false, true, true) . PHP_EOL; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* @private function getTemplatesUserPagesFooter |
|
175
|
|
|
* @param string $moduleDirname |
|
176
|
|
|
* |
|
177
|
|
|
* @return string |
|
178
|
|
|
*/ |
|
179
|
|
|
private function getTemplatesUserPagesFooter($moduleDirname) |
|
180
|
|
|
{ |
|
181
|
|
|
$hc = Tdmcreate\Files\CreateHtmlSmartyCodes::getInstance(); |
|
182
|
|
|
|
|
183
|
|
|
return $hc->getSmartyIncludeFile($moduleDirname, 'footer'); |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* @public function render |
|
188
|
|
|
* @param null |
|
189
|
|
|
* |
|
190
|
|
|
* @return bool|string |
|
191
|
|
|
*/ |
|
192
|
|
|
public function render() |
|
193
|
|
|
{ |
|
194
|
|
|
$module = $this->getModule(); |
|
195
|
|
|
$table = $this->getTable(); |
|
196
|
|
|
$filename = $this->getFileName(); |
|
197
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
198
|
|
|
$tableName = $table->getVar('table_name'); |
|
199
|
|
|
$tableSoleName = $table->getVar('table_solename'); |
|
200
|
|
|
$language = $this->getLanguage($moduleDirname, 'MA'); |
|
201
|
|
|
$content = $this->getTemplatesUserPagesHeader($moduleDirname); |
|
202
|
|
|
$content .= $this->getTemplatesUserPages($moduleDirname, $tableName, $tableSoleName, $language); |
|
203
|
|
|
$content .= $this->getTemplatesUserPagesFooter($moduleDirname); |
|
204
|
|
|
|
|
205
|
|
|
$this->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
|
206
|
|
|
|
|
207
|
|
|
return $this->renderFile(); |
|
208
|
|
|
} |
|
209
|
|
|
} |
|
210
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.