mambax7 /
tdmcreate-1.91
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
| 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: AdminPages.php 12258 2014-01-02 09:33:29Z timgno $ |
||||||||
| 26 | */ |
||||||||
| 27 | |||||||||
| 28 | /** |
||||||||
| 29 | * Class AdminPages. |
||||||||
| 30 | */ |
||||||||
| 31 | class AdminPages 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 | * |
||||||||
| 46 | * @return AdminPages |
||||||||
| 47 | */ |
||||||||
| 48 | public static function getInstance() |
||||||||
| 49 | { |
||||||||
| 50 | static $instance = false; |
||||||||
| 51 | if (!$instance) { |
||||||||
| 52 | $instance = new self(); |
||||||||
| 53 | } |
||||||||
| 54 | |||||||||
| 55 | return $instance; |
||||||||
| 56 | } |
||||||||
| 57 | |||||||||
| 58 | /** |
||||||||
| 59 | * @public function write |
||||||||
| 60 | * @param $module |
||||||||
| 61 | * @param $table |
||||||||
| 62 | * @param $filename |
||||||||
| 63 | */ |
||||||||
| 64 | public function write($module, $table, $filename) |
||||||||
| 65 | { |
||||||||
| 66 | $this->setModule($module); |
||||||||
| 67 | $this->setTable($table); |
||||||||
| 68 | $this->setFileName($filename); |
||||||||
| 69 | } |
||||||||
| 70 | |||||||||
| 71 | /** |
||||||||
| 72 | * @private function getAdminPagesHeader |
||||||||
| 73 | * @param $moduleDirname |
||||||||
| 74 | * @param $tableName |
||||||||
| 75 | * @param $fieldId |
||||||||
| 76 | * @return string |
||||||||
| 77 | */ |
||||||||
| 78 | private function getAdminPagesHeader($moduleDirname, $tableName, $fieldId) |
||||||||
|
0 ignored issues
–
show
The parameter
$tableName is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||||
| 79 | { |
||||||||
| 80 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||||||||
| 81 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||||||||
| 82 | $ccFieldId = $this->getCamelCase($fieldId, false, true); |
||||||||
| 83 | $ret = $this->getInclude(); |
||||||||
| 84 | $ret .= $pc->getPhpCodeCommentLine('It recovered the value of argument op in URL$'); |
||||||||
| 85 | $ret .= $xc->getXcXoopsRequest('op', 'op', 'list'); |
||||||||
| 86 | $ret .= $pc->getPhpCodeCommentLine("Request {$fieldId}"); |
||||||||
| 87 | $ret .= $xc->getXcXoopsRequest($ccFieldId, $fieldId, '', 'Int'); |
||||||||
| 88 | |||||||||
| 89 | return $ret; |
||||||||
| 90 | } |
||||||||
| 91 | |||||||||
| 92 | /** |
||||||||
| 93 | * @private function getAdminPagesSwitch |
||||||||
| 94 | * @param $cases |
||||||||
| 95 | * |
||||||||
| 96 | * @return string |
||||||||
| 97 | */ |
||||||||
| 98 | private function getAdminPagesSwitch($cases = []) |
||||||||
| 99 | { |
||||||||
| 100 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||||||||
| 101 | $contentSwitch = $pc->getPhpCodeCaseSwitch($cases, true, false, "\t"); |
||||||||
| 102 | |||||||||
| 103 | return $pc->getPhpCodeSwitch('op', $contentSwitch); |
||||||||
| 104 | } |
||||||||
| 105 | |||||||||
| 106 | /** |
||||||||
| 107 | * @private function getAdminPagesList |
||||||||
| 108 | * @param $moduleDirname |
||||||||
| 109 | * @param $table |
||||||||
| 110 | * @param $language |
||||||||
| 111 | * @param $fields |
||||||||
| 112 | * @param $fieldId |
||||||||
| 113 | * @param $fieldInForm |
||||||||
| 114 | * @param $fieldMain |
||||||||
| 115 | * @param string $t |
||||||||
| 116 | * @return string |
||||||||
| 117 | */ |
||||||||
| 118 | private function getAdminPagesList($moduleDirname, $table, $language, $fields, $fieldId, $fieldInForm, $fieldMain, $t = '') |
||||||||
|
0 ignored issues
–
show
The parameter
$fieldId is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$fields is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$fieldMain is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||||
| 119 | { |
||||||||
| 120 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||||||||
| 121 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||||||||
| 122 | $axc = Tdmcreate\Files\Admin\AdminXoopsCode::getInstance(); |
||||||||
| 123 | |||||||||
| 124 | $stuModuleDirname = mb_strtoupper($moduleDirname); |
||||||||
| 125 | $tableName = $table->getVar('table_name'); |
||||||||
| 126 | $tableSoleName = $table->getVar('table_solename'); |
||||||||
| 127 | $stuTableName = mb_strtoupper($tableName); |
||||||||
| 128 | $stuTableSoleName = mb_strtoupper($tableSoleName); |
||||||||
| 129 | |||||||||
| 130 | $ret = $pc->getPhpCodeCommentLine('Define Stylesheet'); |
||||||||
| 131 | $ret .= $xc->getXcAddStylesheet('style', $t); |
||||||||
| 132 | $ret .= $xc->getXcXoopsRequest('start', 'start', '0', 'Int', false, $t); |
||||||||
| 133 | $adminpager = $xc->getXcGetConfig($moduleDirname, 'adminpager'); |
||||||||
| 134 | $ret .= $xc->getXcXoopsRequest('limit', 'limit', $adminpager, 'Int', false, $t); |
||||||||
| 135 | $ret .= $axc->getAdminTemplateMain($moduleDirname, $tableName, $t); |
||||||||
| 136 | $navigation = $axc->getAdminDisplayNavigation($tableName); |
||||||||
| 137 | $ret .= $xc->getXcTplAssign('navigation', $navigation, true, $t); |
||||||||
| 138 | |||||||||
| 139 | if (in_array(1, $fieldInForm)) { |
||||||||
| 140 | $ret .= $axc->getAdminItemButton($language, $tableName, $stuTableSoleName, '?op=new', 'add', $t); |
||||||||
| 141 | $ret .= $xc->getXcTplAssign('buttons', '$adminObject->displayButton(\'left\')', true, $t); |
||||||||
| 142 | } |
||||||||
| 143 | |||||||||
| 144 | $ret .= $xc->getXcObjHandlerCount($tableName, $t); |
||||||||
| 145 | $ret .= $xc->getXcObjHandlerAll($tableName, '', '$start', '$limit', $t); |
||||||||
| 146 | $ret .= $xc->getXcTplAssign("{$tableName}_count", "\${$tableName}Count", true, $t); |
||||||||
| 147 | $ret .= $xc->getXcTplAssign("{$moduleDirname}_url", "{$stuModuleDirname}_URL", true, $t); |
||||||||
| 148 | $ret .= $xc->getXcTplAssign("{$moduleDirname}_upload_url", "{$stuModuleDirname}_UPLOAD_URL", true, $t); |
||||||||
| 149 | |||||||||
| 150 | $ret .= $pc->getPhpCodeCommentLine('Table view', $tableName, $t); |
||||||||
| 151 | $contentForeach = $xc->getXcGetValues($tableName, $tableSoleName, 'i', false, "\t"); |
||||||||
| 152 | $contentForeach .= $xc->getXcXoopsTplAppend("{$tableName}_list", "\${$tableSoleName}", $t . "\t\t"); |
||||||||
| 153 | $contentForeach .= $pc->getPhpCodeUnset($tableSoleName, $t . "\t\t"); |
||||||||
| 154 | $condIf = $pc->getPhpCodeForeach("{$tableName}All", true, false, 'i', $contentForeach, $t . "\t"); |
||||||||
| 155 | $condIf .= $xc->getXcPageNav($tableName, $t . "\t"); |
||||||||
| 156 | $condElse = $xc->getXcTplAssign('error', "{$language}THEREARENT_{$stuTableName}", true, $t . "\t"); |
||||||||
| 157 | $ret .= $pc->getPhpCodeConditions("\${$tableName}Count", ' > ', '0', $condIf, $condElse, $t); |
||||||||
| 158 | |||||||||
| 159 | return $ret; |
||||||||
| 160 | } |
||||||||
| 161 | |||||||||
| 162 | /** |
||||||||
| 163 | * @private function getAdminPagesNew |
||||||||
| 164 | * @param $moduleDirname |
||||||||
| 165 | * @param $tableName |
||||||||
| 166 | * @param $fieldInForm |
||||||||
| 167 | * @param $language |
||||||||
| 168 | * @param string $t |
||||||||
| 169 | * @return string |
||||||||
| 170 | */ |
||||||||
| 171 | private function getAdminPagesNew($moduleDirname, $tableName, $fieldInForm, $language, $t = '') |
||||||||
| 172 | { |
||||||||
| 173 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||||||||
| 174 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||||||||
| 175 | $axc = Tdmcreate\Files\Admin\AdminXoopsCode::getInstance(); |
||||||||
| 176 | |||||||||
| 177 | $stuTableName = mb_strtoupper($tableName); |
||||||||
| 178 | $ret = $axc->getAdminTemplateMain($moduleDirname, $tableName); |
||||||||
| 179 | $navigation = $axc->getAdminDisplayNavigation($tableName); |
||||||||
| 180 | $ret .= $xc->getXcTplAssign('navigation', $navigation, true, $t); |
||||||||
| 181 | |||||||||
| 182 | if (in_array(1, $fieldInForm)) { |
||||||||
| 183 | $ret .= $axc->getAdminItemButton($language, $tableName, $stuTableName, '', 'list', $t); |
||||||||
| 184 | $ret .= $xc->getXcTplAssign('buttons', '$adminObject->displayButton(\'left\')', true, $t); |
||||||||
| 185 | } |
||||||||
| 186 | $ret .= $pc->getPhpCodeCommentLine('Get Form', null, $t); |
||||||||
| 187 | $ret .= $xc->getXcObjHandlerCreate($tableName, $t); |
||||||||
| 188 | $ret .= $xc->getXcGetForm('form', $tableName, 'Obj', $t); |
||||||||
| 189 | $ret .= $xc->getXcTplAssign('form', '$form->render()', true, $t); |
||||||||
| 190 | |||||||||
| 191 | return $ret; |
||||||||
| 192 | } |
||||||||
| 193 | |||||||||
| 194 | /** |
||||||||
| 195 | * @private function getPermissionsSave |
||||||||
| 196 | * @param $moduleDirname |
||||||||
| 197 | * @param $fieldId |
||||||||
| 198 | * @param $ccFieldId |
||||||||
| 199 | * @param $newFieldId |
||||||||
| 200 | * @param $perm |
||||||||
| 201 | * |
||||||||
| 202 | * @return string |
||||||||
| 203 | */ |
||||||||
| 204 | private function getPermissionsSave($moduleDirname, $fieldId, $ccFieldId, $newFieldId, $perm = 'view') |
||||||||
|
0 ignored issues
–
show
The parameter
$fieldId is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$newFieldId is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
The parameter
$ccFieldId is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. Loading history...
|
|||||||||
| 205 | { |
||||||||
| 206 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||||||||
| 207 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||||||||
| 208 | |||||||||
| 209 | $ret = $pc->getPhpCodeCommentLine('Permission to', $perm, "\t\t\t"); |
||||||||
| 210 | $content = $xc->getXcAddRight('gpermHandler', "{$moduleDirname}_{$perm}", '$permId', '$onegroupId', "\$GLOBALS['xoopsModule']->getVar('mid')", false, "\t"); |
||||||||
| 211 | $foreach = $pc->getPhpCodeForeach("_POST['groups_{$perm}']", false, false, 'onegroupId', $content, "\t\t\t\t"); |
||||||||
| 212 | $ret .= $pc->getPhpCodeConditions("isset(\$_POST['groups_{$perm}'])", null, null, $foreach, false, "\t\t\t"); |
||||||||
| 213 | |||||||||
| 214 | return $ret; |
||||||||
| 215 | } |
||||||||
| 216 | |||||||||
| 217 | /** |
||||||||
| 218 | * @private function getAdminPagesSave |
||||||||
| 219 | * @param $moduleDirname |
||||||||
| 220 | * @param $tableName |
||||||||
| 221 | * @param $tableCategory |
||||||||
| 222 | * @param $tableSoleName |
||||||||
| 223 | * @param $language |
||||||||
| 224 | * @param $fields |
||||||||
| 225 | * @param $fieldId |
||||||||
| 226 | * @param $fieldMain |
||||||||
| 227 | * @param string $t |
||||||||
| 228 | * @return string |
||||||||
| 229 | */ |
||||||||
| 230 | private function getAdminPagesSave($moduleDirname, $tableName, $tableCategory, $tableSoleName, $language, $fields, $fieldId, $fieldMain, $t = '') |
||||||||
| 231 | { |
||||||||
| 232 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||||||||
| 233 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||||||||
| 234 | $axc = Tdmcreate\Files\Admin\AdminXoopsCode::getInstance(); |
||||||||
| 235 | |||||||||
| 236 | $ccFieldId = $this->getCamelCase($fieldId, false, true); |
||||||||
| 237 | $ret = $pc->getPhpCodeCommentLine('Security Check'); |
||||||||
| 238 | $xoopsSecurityCheck = $xc->getXcSecurityCheck('!'); |
||||||||
| 239 | $securityError = $xc->getXcSecurityErrors(); |
||||||||
| 240 | $implode = $pc->getPhpCodeImplode(',', $securityError); |
||||||||
| 241 | $redirectError = $xc->getXcRedirectHeader($tableName, '', '3', $implode, true, $t . "\t"); |
||||||||
| 242 | $ret .= $pc->getPhpCodeConditions($xoopsSecurityCheck, '', '', $redirectError, false, $t); |
||||||||
| 243 | |||||||||
| 244 | $isset = $pc->getPhpCodeIsset($ccFieldId); |
||||||||
| 245 | $contentIf = $xc->getXcGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', false, $t . "\t"); |
||||||||
| 246 | $contentElse = $xc->getXcObjHandlerCreate($tableName, "\t\t\t"); |
||||||||
| 247 | $ret .= $pc->getPhpCodeConditions($isset, '', '', $contentIf, $contentElse, $t); |
||||||||
| 248 | $ret .= $pc->getPhpCodeCommentLine('Set Vars', null, "\t\t"); |
||||||||
| 249 | foreach (array_keys($fields) as $f) { |
||||||||
| 250 | $fieldName = $fields[$f]->getVar('field_name'); |
||||||||
| 251 | $fieldType = $fields[$f]->getVar('field_type'); |
||||||||
| 252 | $fieldElement = $fields[$f]->getVar('field_element'); |
||||||||
| 253 | if ($f > 0) { // If we want to hide field id |
||||||||
| 254 | switch ($fieldElement) { |
||||||||
| 255 | case 5: |
||||||||
| 256 | case 6: |
||||||||
| 257 | $ret .= $xc->getXcCheckBoxOrRadioYNSetVar($tableName, $fieldName, $t); |
||||||||
| 258 | break; |
||||||||
| 259 | case 10: |
||||||||
| 260 | $ret .= $axc->getAxcImageListSetVar($moduleDirname, $tableName, $fieldName, $t); |
||||||||
| 261 | break; |
||||||||
| 262 | case 12: |
||||||||
| 263 | $ret .= $axc->getAxcUploadFileSetVar($moduleDirname, $tableName, $fieldName, true, $t); |
||||||||
| 264 | break; |
||||||||
| 265 | case 13: |
||||||||
| 266 | if (1 == $fields[$f]->getVar('field_main')) { |
||||||||
| 267 | $fieldMain = $fieldName; |
||||||||
| 268 | } |
||||||||
| 269 | $ret .= $axc->getAxcUploadImageSetVar($moduleDirname, $tableName, $fieldName, $fieldMain, $t); |
||||||||
| 270 | break; |
||||||||
| 271 | case 14: |
||||||||
| 272 | $ret .= $axc->getAxcUploadFileSetVar($moduleDirname, $tableName, $fieldName, false, $t); |
||||||||
| 273 | break; |
||||||||
| 274 | case 15: |
||||||||
| 275 | $ret .= $xc->getXcTextDateSelectSetVar($tableName, $tableSoleName, $fieldName, $t); |
||||||||
| 276 | break; |
||||||||
| 277 | default: |
||||||||
| 278 | if (2 == $fieldType || 7 == $fieldType || 8 == $fieldType) { |
||||||||
| 279 | $ret .= $xc->getXcSetVar($tableName, $fieldName, "isset(\$_POST['{$fieldName}']) ? \$_POST['{$fieldName}'] : 0", $t); |
||||||||
| 280 | } else { |
||||||||
| 281 | $ret .= $xc->getXcSetVar($tableName, $fieldName, "\$_POST['{$fieldName}']", $t); |
||||||||
| 282 | } |
||||||||
| 283 | break; |
||||||||
| 284 | } |
||||||||
| 285 | } |
||||||||
| 286 | } |
||||||||
| 287 | $ret .= $pc->getPhpCodeCommentLine('Insert Data', null, "\t\t"); |
||||||||
| 288 | $insert = $xc->getXcInsert($tableName, $tableName, 'Obj'); |
||||||||
| 289 | $contentInsert = ''; |
||||||||
| 290 | if (1 == $tableCategory) { |
||||||||
| 291 | $ucfTableName = ucfirst($tableName); |
||||||||
| 292 | $contentInsert = $xc->getXcEqualsOperator('$newCatId', "\${$tableName}Obj->getNewInsertedId{$ucfTableName}()", null, false, $t . "\t"); |
||||||||
| 293 | $ucfFieldId = $this->getCamelCase($fieldId, true); |
||||||||
| 294 | $contentInsert .= $pc->getPhpCodeTernaryOperator('permId', "isset(\$_REQUEST['{$fieldId}'])", "\${$ccFieldId}", "\$new{$ucfFieldId}", $t . "\t"); |
||||||||
| 295 | $contentInsert .= $xc->getXcEqualsOperator('$gpermHandler', "xoops_getHandler('groupperm')", null, false, $t . "\t"); |
||||||||
| 296 | $contentInsert .= $this->getPermissionsSave($moduleDirname, $fieldId, $ccFieldId, 'new' . $ucfFieldId); |
||||||||
| 297 | $contentInsert .= $this->getPermissionsSave($moduleDirname, $fieldId, $ccFieldId, 'new' . $ucfFieldId, 'submit'); |
||||||||
| 298 | $contentInsert .= $this->getPermissionsSave($moduleDirname, $fieldId, $ccFieldId, 'new' . $ucfFieldId, 'approve'); |
||||||||
| 299 | } |
||||||||
| 300 | $contentInsert .= $xc->getXcRedirectHeader($tableName . '', '?op=list', '2', "{$language}FORM_OK", true, $t . "\t"); |
||||||||
| 301 | $ret .= $pc->getPhpCodeConditions($insert, '', '', $contentInsert, false, $t); |
||||||||
| 302 | $ret .= $pc->getPhpCodeCommentLine('Get Form', null, "\t\t"); |
||||||||
| 303 | $ret .= $xc->getXcTplAssign('error', "\${$tableName}Obj->getHtmlErrors()", true, $t); |
||||||||
| 304 | $ret .= $xc->getXcGetForm('form', $tableName, 'Obj', $t); |
||||||||
| 305 | $ret .= $xc->getXcTplAssign('form', '$form->render()', true, $t); |
||||||||
| 306 | |||||||||
| 307 | return $ret; |
||||||||
| 308 | } |
||||||||
| 309 | |||||||||
| 310 | /** |
||||||||
| 311 | * @private function getAdminPagesEdit |
||||||||
| 312 | * @param $moduleDirname |
||||||||
| 313 | * @param $table |
||||||||
| 314 | * @param $language |
||||||||
| 315 | * @param $fieldId |
||||||||
| 316 | * @param $fieldInForm |
||||||||
| 317 | * @param string $t |
||||||||
| 318 | * @return string |
||||||||
| 319 | */ |
||||||||
| 320 | private function getAdminPagesEdit($moduleDirname, $table, $language, $fieldId, $fieldInForm, $t = '') |
||||||||
| 321 | { |
||||||||
| 322 | $pc = Tdmcreate\Files\CreatePhpCode::getInstance(); |
||||||||
| 323 | $xc = Tdmcreate\Files\CreateXoopsCode::getInstance(); |
||||||||
| 324 | $axc = Tdmcreate\Files\Admin\AdminXoopsCode::getInstance(); |
||||||||
| 325 | |||||||||
| 326 | $tableName = $table->getVar('table_name'); |
||||||||
| 327 | $tableSoleName = $table->getVar('table_solename'); |
||||||||
| 328 | $tableFieldname = $table->getVar('table_fieldname'); |
||||||||
| 329 | $stuTableName = mb_strtoupper($tableName); |
||||||||
| 330 | $ucfTableName = ucfirst($tableName); |
||||||||
|
0 ignored issues
–
show
|
|||||||||
| 331 | $stuTableSoleName = mb_strtoupper($tableSoleName); |
||||||||
| 332 | $stuTableFieldname = mb_strtoupper($tableFieldname); |
||||||||
|
0 ignored issues
–
show
|
|||||||||
| 333 | $ccFieldId = $this->getCamelCase($fieldId, false, true); |
||||||||
| 334 | |||||||||
| 335 | $ret = $axc->getAdminTemplateMain($moduleDirname, $tableName); |
||||||||
| 336 | $navigation = $axc->getAdminDisplayNavigation($tableName); |
||||||||
| 337 | $ret .= $xc->getXcTplAssign('navigation', $navigation, true, $t); |
||||||||
| 338 | |||||||||
| 339 | if (in_array(1, $fieldInForm)) { |
||||||||
| 340 | $ret .= $axc->getAdminItemButton($language, $tableName, $stuTableSoleName, '?op=new', 'add', $t); |
||||||||
| 341 | $ret .= $axc->getAdminItemButton($language, $tableName, $stuTableName, '', 'list', $t); |
||||||||
| 342 | $ret .= $xc->getXcTplAssign('buttons', '$adminObject->displayButton(\'left\')', true, $t); |
||||||||
| 343 | } |
||||||||
| 344 | $ret .= $pc->getPhpCodeCommentLine('Get Form', null, "\t\t"); |
||||||||
| 345 | $ret .= $xc->getXcGet($tableName, $ccFieldId, 'Obj', $tableName . 'Handler', false, $t); |
||||||||
| 346 | $ret .= $xc->getXcGetForm('form', $tableName, 'Obj', $t); |
||||||||
| 347 | $ret .= $xc->getXcTplAssign('form', '$form->render()', true, $t); |
||||||||
| 348 | |||||||||
| 349 | return $ret; |
||||||||
| 350 | } |
||||||||
| 351 | |||||||||
| 352 | /** |
||||||||
| 353 | * @private function getAdminPagesDelete |
||||||||
| 354 | * @param $tableName |
||||||||
| 355 | * @param $language |
||||||||
| 356 | * @param $fieldId |
||||||||
| 357 | * @param $fieldMain |
||||||||
| 358 | * @param string $t |
||||||||
| 359 | * @return string |
||||||||
| 360 | */ |
||||||||
| 361 | private function getAdminPagesDelete($tableName, $language, $fieldId, $fieldMain, $t = '') |
||||||||
| 362 | { |
||||||||
| 363 | $axc = Tdmcreate\Files\Admin\AdminXoopsCode::getInstance(); |
||||||||
| 364 | |||||||||
| 365 | return $axc->getAdminCodeCaseDelete($language, $tableName, $fieldId, $fieldMain, $t); |
||||||||
| 366 | } |
||||||||
| 367 | |||||||||
| 368 | /** |
||||||||
| 369 | * @public function render |
||||||||
| 370 | * @param null |
||||||||
| 371 | * |
||||||||
| 372 | * @return bool|string |
||||||||
| 373 | */ |
||||||||
| 374 | public function render() |
||||||||
| 375 | { |
||||||||
| 376 | $tf = Tdmcreate\Files\CreateFile::getInstance(); |
||||||||
| 377 | $new = $save = $edit = ''; |
||||||||
| 378 | |||||||||
| 379 | $module = $this->getModule(); |
||||||||
| 380 | $table = $this->getTable(); |
||||||||
| 381 | $filename = $this->getFileName(); |
||||||||
| 382 | $moduleDirname = $module->getVar('mod_dirname'); |
||||||||
| 383 | $tableName = $table->getVar('table_name'); |
||||||||
| 384 | $tableCategory = $table->getVar('table_category'); |
||||||||
| 385 | $tableSoleName = $table->getVar('table_solename'); |
||||||||
| 386 | $language = $this->getLanguage($moduleDirname, 'AM'); |
||||||||
| 387 | $fields = $tf->getTableFields($table->getVar('table_mid'), $table->getVar('table_id')); |
||||||||
| 388 | $fieldInForm = null; |
||||||||
| 389 | foreach (array_keys($fields) as $f) { |
||||||||
| 390 | $fieldName = $fields[$f]->getVar('field_name'); |
||||||||
| 391 | $fieldInForm[] = $fields[$f]->getVar('field_inform'); |
||||||||
| 392 | if (0 == $f) { |
||||||||
| 393 | $fieldId = $fieldName; |
||||||||
| 394 | } |
||||||||
| 395 | if (1 == $fields[$f]->getVar('field_main')) { |
||||||||
| 396 | $fieldMain = $fieldName; |
||||||||
| 397 | } |
||||||||
| 398 | } |
||||||||
| 399 | $content = $this->getHeaderFilesComments($module, $filename); |
||||||||
| 400 | $content .= $this->getAdminPagesHeader($moduleDirname, $tableName, $fieldId); |
||||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||||
| 401 | $list = $this->getAdminPagesList($moduleDirname, $table, $language, $fields, $fieldId, $fieldInForm, $fieldMain, "\t\t"); |
||||||||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||||||||
| 402 | if (in_array(1, $fieldInForm)) { |
||||||||
| 403 | $new = $this->getAdminPagesNew($moduleDirname, $tableName, $fieldInForm, $language, "\t\t"); |
||||||||
| 404 | $save = $this->getAdminPagesSave($moduleDirname, $tableName, $tableCategory, $tableSoleName, $language, $fields, $fieldId, $fieldMain, "\t\t"); |
||||||||
| 405 | $edit = $this->getAdminPagesEdit($moduleDirname, $table, $language, $fieldId, $fieldInForm, "\t\t"); |
||||||||
| 406 | } |
||||||||
| 407 | $delete = $this->getAdminPagesDelete($tableName, $language, $fieldId, $fieldMain, "\t\t"); |
||||||||
| 408 | |||||||||
| 409 | $cases = [ |
||||||||
| 410 | 'list' => [$list], |
||||||||
| 411 | 'new' => [$new], |
||||||||
| 412 | 'save' => [$save], |
||||||||
| 413 | 'edit' => [$edit], |
||||||||
| 414 | 'delete' => [$delete], |
||||||||
| 415 | ]; |
||||||||
| 416 | $content .= $this->getAdminPagesSwitch($cases); |
||||||||
| 417 | $content .= $this->getInclude('footer'); |
||||||||
| 418 | |||||||||
| 419 | $tf->create($moduleDirname, 'admin', $filename, $content, _AM_TDMCREATE_FILE_CREATED, _AM_TDMCREATE_FILE_NOTCREATED); |
||||||||
| 420 | |||||||||
| 421 | return $tf->renderFile(); |
||||||||
| 422 | } |
||||||||
| 423 | } |
||||||||
| 424 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.