Code Duplication    Length = 16-23 lines in 3 locations

class/files/classes/ClassFormElements.php 1 location

@@ 479-494 (lines=16) @@
476
     *
477
     * @return string
478
     */
479
    private function getXoopsFormSelectBox($language, $moduleDirname, $tableName, $fieldName, $required = 'false')
480
    {
481
        $ucfTableName = ucfirst($tableName);
482
        $ccFieldName = $this->tdmcfile->getCamelCase($fieldName, false, true);
483
        $ret = <<<EOT
484
        // {$ucfTableName} handler
485
		\${$tableName}Handler =& \$this->{$moduleDirname}->getHandler('{$tableName}');
486
		// Form Select
487
        \${$ccFieldName}Select = new XoopsFormSelect({$language}, '{$fieldName}', \$this->getVar('{$fieldName}'));
488
        \${$ccFieldName}Select->addOption('Empty');
489
        \${$ccFieldName}Select->addOptionArray(\${$tableName}Handler->getList());
490
        \$form->addElement( \${$ccFieldName}Select{$required} );\n
491
EOT;
492
493
        return $ret;
494
    }
495
496
    /*
497
    *  @private function getXoopsFormSelectUser

class/files/admin/AdminPages.php 2 locations

@@ 318-340 (lines=23) @@
315
    *  @param string $fieldMain
316
    *  @return string
317
    */
318
    private function getAdminPagesDelete($tableName, $language, $fieldId, $fieldMain)
319
    {
320
        $ccFieldId = $this->tdmcfile->getCamelCase($fieldId, false, true);
321
        $ret = $this->getSimpleString("case 'delete':");
322
        $ret .= <<<EOT
323
        \${$tableName}Obj =& \${$tableName}Handler->get(\${$ccFieldId});
324
        if (isset(\$_REQUEST['ok']) && 1 == \$_REQUEST['ok']) {
325
            if ( !\$GLOBALS['xoopsSecurity']->check() ) {
326
                redirect_header('{$tableName}.php', 3, implode(', ', \$GLOBALS['xoopsSecurity']->getErrors()));
327
            }
328
            if (\${$tableName}Handler->delete(\${$tableName}Obj)) {
329
                redirect_header('{$tableName}.php', 3, {$language}FORM_DELETE_OK);
330
            } else {
331
                \$GLOBALS['xoopsTpl']->assign('error', \${$tableName}Obj->getHtmlErrors());
332
            }
333
        } else {
334
            xoops_confirm(array('ok' => 1, '{$fieldId}' => \${$ccFieldId}, 'op' => 'delete'), \$_SERVER['REQUEST_URI'], sprintf({$language}FORM_SURE_DELETE, \${$tableName}Obj->getVar('{$fieldMain}')));
335
        }
336
    break;\n
337
EOT;
338
339
        return $ret;
340
    }
341
342
    /*
343
    *  @private function getAdminPagesUpdate
@@ 350-368 (lines=19) @@
347
    *  @param string $fieldName
348
    *  @return string
349
    */
350
    private function getAdminPagesUpdate($moduleDirname, $tableName, $fieldId, $fieldName)
351
    {
352
        $stuModuleName = strtoupper($moduleDirname);
353
        $ccFieldId = $this->tdmcfile->getCamelCase($fieldId, false, true);
354
        $ret = $this->getSimpleString("case 'update':");
355
        $ret .= <<<EOT
356
        if (isset(\${$ccFieldId})) {
357
            \${$tableName}Obj =& \${$tableName}Handler->get(\${$ccFieldId});
358
        }
359
        \${$tableName}Obj->setVar('{$fieldName}', \$_POST['{$fieldName}']);
360
        if (\${$tableName}Handler->insert(\${$tableName}Obj)) {
361
            redirect_header('{$tableName}.php', 3, _AM_{$stuModuleName}_FORM_OK);
362
        }
363
		\$GLOBALS['xoopsTpl']->assign('error', \${$tableName}Obj->getHtmlErrors());
364
    break;\n
365
EOT;
366
367
        return $ret;
368
    }
369
370
    /*
371
    *  @private function getAdminPagesFooter