|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace XoopsModules\Modulebuilder\Files\Templates\User\Defstyle; |
|
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 (https://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
22
|
|
|
* |
|
23
|
|
|
* @since 2.5.0 |
|
24
|
|
|
* |
|
25
|
|
|
* @author Txmod Xoops https://xoops.org |
|
26
|
|
|
* Goffy https://myxoops.org |
|
27
|
|
|
* |
|
28
|
|
|
*/ |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* class Index. |
|
32
|
|
|
*/ |
|
33
|
|
|
class Index extends Files\CreateFile |
|
34
|
|
|
{ |
|
35
|
|
|
/** |
|
36
|
|
|
* @var mixed |
|
37
|
|
|
*/ |
|
38
|
|
|
private $hc = null; |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @var mixed |
|
42
|
|
|
*/ |
|
43
|
|
|
private $sc = null; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @public function constructor |
|
47
|
|
|
* @param null |
|
48
|
|
|
*/ |
|
49
|
|
|
public function __construct() |
|
50
|
|
|
{ |
|
51
|
|
|
parent::__construct(); |
|
52
|
|
|
$this->hc = Modulebuilder\Files\CreateHtmlCode::getInstance(); |
|
53
|
|
|
$this->sc = Modulebuilder\Files\CreateSmartyCode::getInstance(); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* @static function getInstance |
|
58
|
|
|
* @param null |
|
59
|
|
|
* @return Index |
|
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 write |
|
73
|
|
|
* @param $module |
|
74
|
|
|
* @param $table |
|
75
|
|
|
* @param $tables |
|
76
|
|
|
* @param $filename |
|
77
|
|
|
*/ |
|
78
|
|
|
public function write($module, $table, $tables, $filename) |
|
79
|
|
|
{ |
|
80
|
|
|
$this->setModule($module); |
|
81
|
|
|
$this->setTable($table); |
|
82
|
|
|
$this->setTables($tables); |
|
83
|
|
|
$this->setFileName($filename); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
/** |
|
87
|
|
|
* @public function getTemplateUserIndexHeader |
|
88
|
|
|
* @param $moduleDirname |
|
89
|
|
|
* @return bool|string |
|
90
|
|
|
*/ |
|
91
|
|
|
public function getTemplateUserIndexHeader($moduleDirname) |
|
92
|
|
|
{ |
|
93
|
|
|
|
|
94
|
|
|
return $this->sc->getSmartyIncludeFile($moduleDirname, 'header', false, false, '', "\n"); |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @public function getTemplatesUserIndexBodyDefault |
|
99
|
|
|
* @param $module |
|
100
|
|
|
* @param $language |
|
101
|
|
|
* @return bool|string |
|
102
|
|
|
*/ |
|
103
|
|
|
public function getTemplatesUserIndexIntro($module, $language) |
|
104
|
|
|
{ |
|
105
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
106
|
|
|
$ret = $this->hc->getHtmlEmpty('','',"\n"); |
|
107
|
|
|
$ret .= $this->hc->getHtmlComment('Start index list','', "\n"); |
|
108
|
|
|
//Table head |
|
109
|
|
|
$th = $this->hc->getHtmlTableHead("<{\$smarty.const.{$language}TITLE}> - <{\$smarty.const.{$language}DESC}>", '', '',"\t\t\t"); |
|
110
|
|
|
$tr = $this->hc->getHtmlTableRow($th,'center',"\t\t"); |
|
111
|
|
|
$thead = $this->hc->getHtmlTableThead($tr,'', "\t"); |
|
112
|
|
|
$contTable = $thead; |
|
113
|
|
|
//Table body |
|
114
|
|
|
$li = $this->hc->getHtmlLi("<a href='<{\${$moduleDirname}_url}>'><{\$smarty.const.{$language}INDEX}></a>",'',"\t\t\t\t\t"); |
|
115
|
|
|
$tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
|
116
|
|
|
foreach (\array_keys($tables) as $i) { |
|
117
|
|
|
if (1 == $tables[$i]->getVar('table_index')) { |
|
118
|
|
|
$tableNameLi = $tables[$i]->getVar('table_name'); |
|
119
|
|
|
$tableName = $tables[$i]->getVar('table_name'); |
|
120
|
|
|
$stuTableNameLi = \mb_strtoupper($tableName); |
|
121
|
|
|
$li .= $this->hc->getHtmlLi("<a href='<{\${$moduleDirname}_url}>/{$tableNameLi}.php'><{\$smarty.const.{$language}{$stuTableNameLi}}></a>", '', "\t\t\t\t\t"); |
|
122
|
|
|
} |
|
123
|
|
|
} |
|
124
|
|
|
$ul = $this->hc->getHtmlUl($li,'menu text-center',"\t\t\t\t"); |
|
125
|
|
|
$td = $this->hc->getHtmlTableData($ul, 'bold pad5','',"\t\t\t", "\n", true); |
|
126
|
|
|
$tr = $this->hc->getHtmlTablerow($td, 'center',"\t\t"); |
|
127
|
|
|
$tbody = $this->hc->getHtmlTableTbody($tr,'', "\t"); |
|
128
|
|
|
$contTable .= $tbody; |
|
129
|
|
|
//Table foot |
|
130
|
|
|
$single = $this->sc->getSmartySingleVar('adv'); |
|
131
|
|
|
$cond = $this->sc->getSmartyConditions('adv','','', $single, false, '','', "\t\t\t\t", "\n", false); |
|
132
|
|
|
$td = $this->hc->getHtmlTableData($cond, 'bold pad5','',"\t\t\t", "\n", true); |
|
133
|
|
|
$tr = $this->hc->getHtmlTablerow($td, 'center',"\t\t"); |
|
134
|
|
|
$tfoot = $this->hc->getHtmlTableTfoot($tr,'', "\t"); |
|
135
|
|
|
$contTable .= $tfoot; |
|
136
|
|
|
|
|
137
|
|
|
$ret .= $this->hc->getHtmlTable($contTable); |
|
138
|
|
|
$ret .= $this->hc->getHtmlComment('End index list','', "\n"); |
|
139
|
|
|
$ret .= $this->hc->getHtmlEmpty('','',"\n"); |
|
140
|
|
|
|
|
141
|
|
|
return $ret; |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* @public function getTemplateUserIndexTable |
|
146
|
|
|
* @param $moduleDirname |
|
147
|
|
|
* @param $tableName |
|
148
|
|
|
* @param $tableSoleName |
|
149
|
|
|
* @param $language |
|
150
|
|
|
* @param string $t |
|
151
|
|
|
* @return bool|string |
|
152
|
|
|
*/ |
|
153
|
|
|
public function getTemplateUserIndexTable($moduleDirname, $tableName, $tableSoleName, $language, $t = '') |
|
154
|
|
|
{ |
|
155
|
|
|
$double = $this->sc->getSmartyConst($language, 'INDEX_LATEST_LIST'); |
|
156
|
|
|
$ret = $this->hc->getHtmlDiv($double, "{$moduleDirname}-linetitle", $t, "\n", false); |
|
157
|
|
|
$table = $this->hc->getHtmlComment("Start show new {$tableName} in index",$t . "\t", "\n"); |
|
158
|
|
|
$include = $this->sc->getSmartyIncludeFileListForeach($moduleDirname, $tableName, $tableSoleName, $t . "\t\t\t\t\t", "\n"); |
|
159
|
|
|
$td = $this->hc->getHtmlTableData($include, "col_width<{\$numb_col}> top center", '', $t . "\t\t\t\t", "\n", true); |
|
160
|
|
|
$tr = $this->hc->getHtmlEmpty('</tr><tr>', $t . "\t\t\t\t\t", "\n"); |
|
161
|
|
|
$td .= $this->sc->getSmartyConditions('smarty.foreach.' . $tableSoleName . '.iteration', ' is div by ', '$divideby', $tr, false, false, false, $t . "\t\t\t\t", "\n", true, false); |
|
162
|
|
|
$foreach = $this->hc->getHtmlComment('Start new link loop',$t . "\t\t\t", "\n"); |
|
163
|
|
|
$foreach .= $this->sc->getSmartyForeach($tableSoleName, $tableName, $td, $tableSoleName,'',"\t\t\t"); |
|
164
|
|
|
$foreach .= $this->hc->getHtmlComment('End new link loop',$t . "\t\t\t", "\n"); |
|
165
|
|
|
$tr .= $this->hc->getHtmlTableRow($foreach, '',$t . "\t\t"); |
|
166
|
|
|
|
|
167
|
|
|
$table .= $this->hc->getHtmlTable($tr, 'table table-<{$table_type}>', $t . "\t"); |
|
168
|
|
|
$ret .= $this->sc->getSmartyConditions($tableName . 'Count', ' > ','0', $table, false, false, false, '', "\n", true, 'int'); |
|
169
|
|
|
|
|
170
|
|
|
return $ret; |
|
171
|
|
|
} |
|
172
|
|
|
|
|
173
|
|
|
/** |
|
174
|
|
|
* @public function getTemplateUserIndexFooter |
|
175
|
|
|
* @param $moduleDirname |
|
176
|
|
|
* @return bool|string |
|
177
|
|
|
*/ |
|
178
|
|
|
public function getTemplateUserIndexFooter($moduleDirname) |
|
179
|
|
|
{ |
|
180
|
|
|
return $this->sc->getSmartyIncludeFile($moduleDirname, 'footer'); |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
/** |
|
184
|
|
|
* @public function render |
|
185
|
|
|
* @param null |
|
186
|
|
|
* @return bool|string |
|
187
|
|
|
*/ |
|
188
|
|
|
public function render() |
|
189
|
|
|
{ |
|
190
|
|
|
$module = $this->getModule(); |
|
191
|
|
|
$tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
|
192
|
|
|
$filename = $this->getFileName(); |
|
193
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
194
|
|
|
$language = $this->getLanguage($moduleDirname, 'MA', '', false); |
|
|
|
|
|
|
195
|
|
|
$content = $this->getTemplateUserIndexHeader($moduleDirname); |
|
196
|
|
|
$content .= $this->getTemplatesUserIndexIntro($module, $language); |
|
197
|
|
|
foreach (\array_keys($tables) as $t) { |
|
198
|
|
|
$tableName = $tables[$t]->getVar('table_name'); |
|
199
|
|
|
$tableSoleName = $tables[$t]->getVar('table_solename'); |
|
200
|
|
|
$tableIndex = $tables[$t]->getVar('table_index'); |
|
201
|
|
|
if (1 == $tableIndex) { |
|
202
|
|
|
$content .= $this->getTemplateUserIndexTable($moduleDirname, $tableName, $tableSoleName, $language); |
|
203
|
|
|
} |
|
204
|
|
|
} |
|
205
|
|
|
$content .= $this->getTemplateUserIndexFooter($moduleDirname); |
|
206
|
|
|
|
|
207
|
|
|
$this->create($moduleDirname, 'templates', $filename, $content, \_AM_MODULEBUILDER_FILE_CREATED, \_AM_MODULEBUILDER_FILE_NOTCREATED); |
|
208
|
|
|
|
|
209
|
|
|
return $this->renderFile(); |
|
210
|
|
|
} |
|
211
|
|
|
} |
|
212
|
|
|
|