|
1
|
|
|
<?php namespace XoopsModules\Tdmcreate\Files\User; |
|
2
|
|
|
|
|
3
|
|
|
use XoopsModules\Tdmcreate; |
|
4
|
|
|
use XoopsModules\Tdmcreate\Files; |
|
5
|
|
|
/* |
|
6
|
|
|
You may not change or alter any portion of this comment or credits |
|
7
|
|
|
of supporting developers from this source code or any supporting source code |
|
8
|
|
|
which is considered copyrighted (c) material of the original comment or credit authors. |
|
9
|
|
|
|
|
10
|
|
|
This program is distributed in the hope that it will be useful, |
|
11
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
|
13
|
|
|
*/ |
|
14
|
|
|
/** |
|
15
|
|
|
* tdmcreate module. |
|
16
|
|
|
* |
|
17
|
|
|
* @copyright XOOPS Project (https://xoops.org) |
|
18
|
|
|
* @license GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html) |
|
19
|
|
|
* |
|
20
|
|
|
* @since 2.5.0 |
|
21
|
|
|
* |
|
22
|
|
|
* @author Txmod Xoops http://www.txmodxoops.org |
|
23
|
|
|
* |
|
24
|
|
|
* @version $Id: UserPrint.php 12258 2014-01-02 09:33:29Z timgno $ |
|
25
|
|
|
*/ |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Class UserPrint. |
|
29
|
|
|
*/ |
|
30
|
|
|
class UserPrint extends Files\CreateFile |
|
31
|
|
|
{ |
|
32
|
|
|
/** |
|
33
|
|
|
* @var mixed |
|
34
|
|
|
*/ |
|
35
|
|
|
private $uc = null; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
private $xc = null; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* @public function constructor |
|
44
|
|
|
* @param null |
|
45
|
|
|
*/ |
|
46
|
|
|
public function __construct() |
|
47
|
|
|
{ |
|
48
|
|
|
parent::__construct(); |
|
49
|
|
|
$this->xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
|
|
|
|
|
|
50
|
|
|
$this->phpcode = Tdmcreate\Files\CreatePhpCode::getInstance(); |
|
|
|
|
|
|
51
|
|
|
$this->uc = UserXoopsCode::getInstance(); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @static function getInstance |
|
56
|
|
|
* @param null |
|
57
|
|
|
* @return UserPrint |
|
58
|
|
|
*/ |
|
59
|
|
|
public static function getInstance() |
|
60
|
|
|
{ |
|
61
|
|
|
static $instance = false; |
|
62
|
|
|
if (!$instance) { |
|
63
|
|
|
$instance = new self(); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
return $instance; |
|
67
|
|
|
} |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @public function write |
|
71
|
|
|
* @param string $module |
|
72
|
|
|
* @param mixed $table |
|
73
|
|
|
* @param string $filename |
|
74
|
|
|
*/ |
|
75
|
|
|
public function write($module, $table, $filename) |
|
76
|
|
|
{ |
|
77
|
|
|
$this->setModule($module); |
|
78
|
|
|
$this->setTable($table); |
|
79
|
|
|
$this->setFileName($filename); |
|
80
|
|
|
} |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* @public function getUserPrint |
|
84
|
|
|
* @param string $moduleDirname |
|
85
|
|
|
* @param string $language |
|
86
|
|
|
* |
|
87
|
|
|
* @return string |
|
88
|
|
|
*/ |
|
89
|
|
|
public function getUserPrint($moduleDirname, $language) |
|
90
|
|
|
{ |
|
91
|
|
|
$stuModuleDirname = mb_strtoupper($moduleDirname); |
|
92
|
|
|
$table = $this->getTable(); |
|
93
|
|
|
$tableName = $table->getVar('table_name'); |
|
94
|
|
|
$tableSoleName = $table->getVar('table_solename'); |
|
95
|
|
|
$ucfModuleDirname = ucfirst($moduleDirname); |
|
|
|
|
|
|
96
|
|
|
$ucfTableName = ucfirst($tableName); |
|
|
|
|
|
|
97
|
|
|
$fields = $this->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); |
|
98
|
|
|
foreach (array_keys($fields) as $f) { |
|
99
|
|
|
$fieldName = $fields[$f]->getVar('field_name'); |
|
100
|
|
|
$rpFieldName = $fieldName; |
|
|
|
|
|
|
101
|
|
|
if (mb_strpos($fieldName, '_')) { |
|
102
|
|
|
$str = mb_strpos($fieldName, '_'); |
|
103
|
|
|
if (false !== $str) { |
|
104
|
|
|
$rpFieldName = mb_substr($fieldName, $str + 1, mb_strlen($fieldName)); |
|
105
|
|
|
} |
|
106
|
|
|
} |
|
107
|
|
|
if ((0 == $f) && (1 == $this->table->getVar('table_autoincrement'))) { |
|
108
|
|
|
$fieldId = $fieldName; |
|
109
|
|
|
} else { |
|
110
|
|
|
if (1 == $fields[$f]->getVar('field_main')) { |
|
111
|
|
|
$fieldMain = $fieldName; // fieldMain = fields parameters main field |
|
112
|
|
|
} |
|
113
|
|
|
} |
|
114
|
|
|
$ucfFieldName = ucfirst($fieldName); |
|
115
|
|
|
} |
|
116
|
|
|
$ccFieldId = $this->getCamelCase($fieldId, false, true); |
|
|
|
|
|
|
117
|
|
|
$stuLpFieldName = mb_strtoupper($ccFieldId); |
|
118
|
|
|
$ret = $this->getInclude(); |
|
119
|
|
|
$ret .= $this->xc->getXcXoopsRequest($ccFieldId, (string)$fieldId, '', 'Int'); |
|
120
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Define Stylesheet'); |
|
121
|
|
|
$ret .= $this->xc->getXcAddStylesheet(); |
|
122
|
|
|
$redirectHeader = $this->xc->getXcRedirectHeader("{$stuModuleDirname}_URL . '/index.php'", '', '2', "{$language}NO{$stuLpFieldName}", false, "\t"); |
|
123
|
|
|
$ret .= $this->phpcode->getPhpCodeConditions("empty(\${$ccFieldId})", '', '', $redirectHeader); |
|
124
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Verify that the article is published'); |
|
125
|
|
|
if (false !== mb_strpos($fieldName, 'published')) { |
|
|
|
|
|
|
126
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Not yet', $fieldName); |
|
127
|
|
|
$redirectHeader .= $this->getSimpleString('exit();'); |
|
128
|
|
|
$ret .= $this->phpcode->getPhpCodeConditions("\${$ccFieldId}->getVar('{$fieldName}') == 0 || \${$ccFieldId}->getVar('{$fieldName}') > time()", '', '', $redirectHeader); |
|
129
|
|
|
} |
|
130
|
|
|
if (false !== mb_strpos($fieldName, 'expired')) { |
|
131
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Expired', $ucfFieldName); |
|
|
|
|
|
|
132
|
|
|
$redirectHeader .= $this->getSimpleString('exit();'); |
|
133
|
|
|
$ret .= $this->phpcode->getPhpCodeConditions("\${$ccFieldId}->getVar('{$fieldName}') != 0 && \${$ccFieldId}->getVar('{$fieldName}') < time()", '', '', $redirectHeader); |
|
134
|
|
|
} |
|
135
|
|
|
if (false !== mb_strpos($fieldName, 'date')) { |
|
136
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Date', $ucfFieldName); |
|
137
|
|
|
$redirectHeader .= $this->getSimpleString('exit();'); |
|
138
|
|
|
$ret .= $this->phpcode->getPhpCodeConditions("\${$ccFieldId}->getVar('{$fieldName}') != 0 && \${$ccFieldId}->getVar('{$fieldName}') < time()", '', '', $redirectHeader); |
|
139
|
|
|
} |
|
140
|
|
|
if (false !== mb_strpos($fieldName, 'time')) { |
|
141
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Time', $ucfFieldName); |
|
142
|
|
|
$redirectHeader .= $this->getSimpleString('exit();'); |
|
143
|
|
|
$ret .= $this->phpcode->getPhpCodeConditions("\${$ccFieldId}->getVar('{$fieldName}') != 0 && \${$ccFieldId}->getVar('{$fieldName}') < time()", '', '', $redirectHeader); |
|
144
|
|
|
} |
|
145
|
|
|
$ret .= $this->xc->getXcGet($tableName, $ccFieldId, '', true); |
|
146
|
|
|
$gperm = $this->xc->getXcCheckRight('!$gpermHandler', "{$moduleDirname}_view", "\${$ccFieldId}->getVar('{$fieldId}')", '$groups', "\$GLOBALS['xoopsModule']->getVar('mid')", true); |
|
147
|
|
|
$ret .= $this->phpcode->getPhpCodeCommentLine('Verify permissions'); |
|
148
|
|
|
$noPerm = $this->xc->getXcRedirectHeader("{$stuModuleDirname}_URL . '/index.php'", '', '3', '_NOPERM', false, "\t"); |
|
149
|
|
|
$noPerm .= $this->getSimpleString('exit();', "\t"); |
|
150
|
|
|
$ret .= $this->phpcode->getPhpCodeConditions($gperm, '', '', $noPerm); |
|
151
|
|
|
$ret .= $this->xc->getXcGetValues($tableName, $tableSoleName, '', true); |
|
152
|
|
|
$contentForeach = $this->xc->getXcXoopsTplAppend('"{$k}"', '$v', "\t"); |
|
153
|
|
|
$ret .= $this->phpcode->getPhpCodeForeach($tableSoleName, false, 'k', 'v', $contentForeach); |
|
154
|
|
|
$ret .= $this->xc->getXcTplAssign('xoops_sitename', "\$GLOBALS['xoopsConfig']['sitename']"); |
|
155
|
|
|
$getVar = $this->xc->getXcGetVar('', $tableSoleName, $fieldMain, true); |
|
|
|
|
|
|
156
|
|
|
$stripTags = $this->phpcode->getPhpCodeStripTags('', $getVar . ' - ' . "{$language}PRINT" . ' - ' . "\$GLOBALS['xoopsModule']->name()", true); |
|
157
|
|
|
$ret .= $this->xc->getXcTplAssign('xoops_pagetitle', $stripTags); |
|
158
|
|
|
$ret .= $this->xc->getXcTplDisplay($tableName . '_print.tpl', '', false); |
|
159
|
|
|
|
|
160
|
|
|
return $ret; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* @public function render |
|
165
|
|
|
* @param null |
|
166
|
|
|
* @return bool|string |
|
167
|
|
|
*/ |
|
168
|
|
|
public function render() |
|
169
|
|
|
{ |
|
170
|
|
|
$module = $this->getModule(); |
|
171
|
|
|
$filename = $this->getFileName(); |
|
172
|
|
|
$moduleDirname = $module->getVar('mod_dirname'); |
|
173
|
|
|
$language = $this->getLanguage($moduleDirname, 'MA'); |
|
174
|
|
|
$content = $this->getHeaderFilesComments($module, $filename); |
|
175
|
|
|
$content .= $this->getUserPrint($moduleDirname, $language); |
|
176
|
|
|
|
|
177
|
|
|
$this->create($moduleDirname, '/', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
|
178
|
|
|
|
|
179
|
|
|
return $this->renderFile(); |
|
180
|
|
|
} |
|
181
|
|
|
} |
|
182
|
|
|
|
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..