|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
You may not change or alter any portion of this comment or credits |
|
5
|
|
|
of supporting developers from this source code or any supporting source code |
|
6
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
7
|
|
|
|
|
8
|
|
|
This program is distributed in the hope that it will be useful, |
|
9
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
11
|
|
|
*/ |
|
12
|
|
|
/** |
|
13
|
|
|
* tdmcreate module. |
|
14
|
|
|
* |
|
15
|
|
|
* @copyright The XOOPS Project http://sourceforge.net/projects/xoops/ |
|
16
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
17
|
|
|
* |
|
18
|
|
|
* @since 2.5.0 |
|
19
|
|
|
* |
|
20
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
|
21
|
|
|
* |
|
22
|
|
|
* @version $Id: TemplatesUserPagesList.php 12258 2014-01-02 09:33:29Z timgno $ |
|
23
|
|
|
*/ |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* Class TemplatesUserPagesList. |
|
27
|
|
|
*/ |
|
28
|
|
|
class TemplatesUserPagesList extends TDMCreateFile |
|
|
|
|
|
|
29
|
|
|
{ |
|
30
|
|
|
/* |
|
31
|
|
|
* @public function constructor |
|
32
|
|
|
* @param null |
|
33
|
|
|
*/ |
|
34
|
|
|
|
|
35
|
|
|
public function __construct() |
|
36
|
|
|
{ |
|
37
|
|
|
parent::__construct(); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/* |
|
41
|
|
|
* @static function getInstance |
|
42
|
|
|
* @param null |
|
43
|
|
|
*/ |
|
44
|
|
|
/** |
|
45
|
|
|
* @return TemplatesUserPagesList |
|
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
|
|
|
/** |
|
64
|
|
|
* @param $module |
|
65
|
|
|
* @param $table |
|
66
|
|
|
*/ |
|
67
|
|
|
public function write($module, $table, $tables, $filename) |
|
68
|
|
|
{ |
|
69
|
|
|
$this->setModule($module); |
|
70
|
|
|
$this->setTable($table); |
|
71
|
|
|
$this->setTables($tables); |
|
72
|
|
|
$this->setFileName($filename); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/* |
|
76
|
|
|
* @private function getTemplatesUserPagesListPanel |
|
77
|
|
|
* @param string $moduleDirname |
|
78
|
|
|
* @param string $table |
|
79
|
|
|
* @param string $language |
|
80
|
|
|
*/ |
|
81
|
|
|
/** |
|
82
|
|
|
* @param $moduleDirname |
|
83
|
|
|
* @param $table |
|
84
|
|
|
* @param $language |
|
85
|
|
|
* |
|
86
|
|
|
* @return string |
|
87
|
|
|
*/ |
|
88
|
|
|
private function getTemplatesUserPagesListPanel($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language) |
|
89
|
|
|
{ |
|
90
|
|
|
$hc = TDMCreateHtmlSmartyCodes::getInstance(); |
|
91
|
|
|
$fields = $this->getTableFields($tableMid, $tableId); |
|
92
|
|
|
$ret = ''; |
|
93
|
|
|
$retNumb = ''; |
|
94
|
|
|
foreach (array_keys($fields) as $f) { |
|
95
|
|
|
$fieldElement = $fields[$f]->getVar('field_element'); |
|
96
|
|
|
if (1 == $fields[$f]->getVar('field_user')) { |
|
97
|
|
|
if (1 == $fields[$f]->getVar('field_thead')) { |
|
98
|
|
|
switch ($fieldElement) { |
|
99
|
|
|
default: |
|
100
|
|
|
case 2: |
|
101
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
|
102
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
|
103
|
|
|
$doubleVar = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
|
104
|
|
|
$retNumb = $hc->getHtmlHNumb($doubleVar, '3', 'panel-title'); |
|
105
|
|
|
break; |
|
106
|
|
|
} |
|
107
|
|
|
} |
|
108
|
|
|
} |
|
109
|
|
|
} |
|
110
|
|
|
$ret .= $hc->getHtmlDiv($retNumb, 'panel-heading').PHP_EOL; |
|
111
|
|
|
$retElem = ''; |
|
112
|
|
|
foreach (array_keys($fields) as $f) { |
|
113
|
|
|
$fieldElement = $fields[$f]->getVar('field_element'); |
|
114
|
|
|
if (1 == $fields[$f]->getVar('field_user')) { |
|
115
|
|
|
if (1 == $fields[$f]->getVar('field_tbody')) { |
|
116
|
|
|
switch ($fieldElement) { |
|
117
|
|
|
default: |
|
118
|
|
|
case 3: |
|
119
|
|
|
case 4: |
|
120
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
|
121
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
|
122
|
|
|
$doubleVar = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
|
123
|
|
|
$retElem .= $hc->getHtmlSpan($doubleVar, 'col-sm-9 justify').PHP_EOL; |
|
124
|
|
|
break; |
|
125
|
|
|
case 10: |
|
126
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
|
127
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
|
128
|
|
|
$singleVar = $hc->getSmartySingleVar('xoops_icons32_url'); |
|
129
|
|
|
$doubleVar = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
|
130
|
|
|
$img = $hc->getHtmlImage($singleVar.'/'.$doubleVar, "{$tableName}"); |
|
131
|
|
|
$retElem .= $hc->getHtmlSpan($img, 'col-sm-3').PHP_EOL; |
|
132
|
|
|
unset($img); |
|
133
|
|
|
break; |
|
134
|
|
|
case 13: |
|
135
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
|
136
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
|
137
|
|
|
$singleVar = $hc->getSmartySingleVar($moduleDirname.'_upload_url'); |
|
138
|
|
|
$doubleVar = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
|
139
|
|
|
$img = $hc->getHtmlImage($singleVar."/images/{$tableName}/".$doubleVar, "{$tableName}"); |
|
140
|
|
|
$retElem .= $hc->getHtmlSpan($img, 'col-sm-3').PHP_EOL; |
|
141
|
|
|
unset($img); |
|
142
|
|
|
break; |
|
143
|
|
|
} |
|
144
|
|
|
} |
|
145
|
|
|
} |
|
146
|
|
|
} |
|
147
|
|
|
$ret .= $hc->getHtmlDiv($retElem, 'panel-body').PHP_EOL; |
|
148
|
|
|
$retFoot = ''; |
|
149
|
|
|
foreach (array_keys($fields) as $f) { |
|
150
|
|
|
if (1 == $fields[$f]->getVar('field_user')) { |
|
151
|
|
|
if (1 == $fields[$f]->getVar('field_tfoot')) { |
|
152
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
|
153
|
|
|
$rpFieldName = $this->getRightString($fieldName); |
|
154
|
|
|
$langConst = strtoupper($tableSoleName).'_'.strtoupper($rpFieldName); |
|
155
|
|
|
$lang = $hc->getSmartyConst($language, $langConst); |
|
156
|
|
|
$doubleVar = $hc->getSmartyDoubleVar($tableSoleName, $rpFieldName); |
|
157
|
|
|
$retFoot .= $hc->getHtmlSpan($lang.': '.$doubleVar, 'block-pie justify').PHP_EOL; |
|
158
|
|
|
} |
|
159
|
|
|
} |
|
160
|
|
|
} |
|
161
|
|
|
$ret .= $hc->getHtmlDiv($retFoot, 'panel-foot').PHP_EOL; |
|
162
|
|
|
|
|
163
|
|
|
return $ret; |
|
164
|
|
|
} |
|
165
|
|
|
|
|
166
|
|
|
/* |
|
167
|
|
|
* @public function render |
|
168
|
|
|
* @param string $filename |
|
169
|
|
|
*/ |
|
170
|
|
|
/** |
|
171
|
|
|
* @param $filename |
|
172
|
|
|
* |
|
173
|
|
|
* @return bool|string |
|
174
|
|
|
*/ |
|
175
|
|
|
public function render() |
|
176
|
|
|
{ |
|
177
|
|
|
$module = $this->getModule(); |
|
178
|
|
|
$table = $this->getTable(); |
|
179
|
|
|
//$tables = $this->getTables(); |
|
|
|
|
|
|
180
|
|
|
$tables = $this->getTableTables($module->getVar('mod_id'), 'table_order'); |
|
|
|
|
|
|
181
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
182
|
|
|
$filename = $this->getFileName(); |
|
183
|
|
|
$language = $this->getLanguage($moduleDirname, 'MA'); |
|
184
|
|
|
$content = ''; |
|
185
|
|
|
//foreach (array_keys($tables) as $t) { |
|
|
|
|
|
|
186
|
|
|
$tableId = $table/*s[$t]*/->getVar('table_id'); |
|
187
|
|
|
$tableMid = $table/*s[$t]*/->getVar('table_mid'); |
|
188
|
|
|
$tableName = $table/*s[$t]*/->getVar('table_name'); |
|
189
|
|
|
$tableSoleName = $table/*s[$t]*/->getVar('table_solename'); |
|
190
|
|
|
$tableCategory[] = $table/*s[$t]*/->getVar('table_category'); |
|
|
|
|
|
|
191
|
|
|
$tableIndex = $table/*s[$t]*/->getVar('table_index'); |
|
|
|
|
|
|
192
|
|
|
if (in_array(0, $tableCategory)) { |
|
193
|
|
|
$content .= $this->getTemplatesUserPagesListPanel($moduleDirname, $tableId, $tableMid, $tableName, $tableSoleName, $language); |
|
194
|
|
|
} |
|
195
|
|
|
//} |
|
196
|
|
|
//$content = $this->getTemplatesUserPagesListPanel($moduleDirname, $table); |
|
|
|
|
|
|
197
|
|
|
|
|
198
|
|
|
$this->create($moduleDirname, 'templates', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
|
199
|
|
|
|
|
200
|
|
|
return $this->renderFile(); |
|
201
|
|
|
} |
|
202
|
|
|
} |
|
203
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.