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

@@ 338-360 (lines=23) @@
335
    *  @param string $fieldMain
336
    *  @return string
337
    */
338
    private function getAdminPagesDelete($tableName, $language, $fieldId, $fieldMain)
339
    {
340
        $ccFieldId = $this->tdmcfile->getCamelCase($fieldId, false, true);
341
        $ret = $this->getSimpleString("case 'delete':");
342
        $ret .= <<<EOT
343
        \${$tableName}Obj =& \${$tableName}Handler->get(\${$ccFieldId});
344
        if (isset(\$_REQUEST['ok']) && 1 == \$_REQUEST['ok']) {
345
            if ( !\$GLOBALS['xoopsSecurity']->check() ) {
346
                redirect_header('{$tableName}.php', 3, implode(', ', \$GLOBALS['xoopsSecurity']->getErrors()));
347
            }
348
            if (\${$tableName}Handler->delete(\${$tableName}Obj)) {
349
                redirect_header('{$tableName}.php', 3, {$language}FORM_DELETE_OK);
350
            } else {
351
                \$GLOBALS['xoopsTpl']->assign('error', \${$tableName}Obj->getHtmlErrors());
352
            }
353
        } else {
354
            xoops_confirm(array('ok' => 1, '{$fieldId}' => \${$ccFieldId}, 'op' => 'delete'), \$_SERVER['REQUEST_URI'], sprintf({$language}FORM_SURE_DELETE, \${$tableName}Obj->getVar('{$fieldMain}')));
355
        }
356
    break;\n
357
EOT;
358
359
        return $ret;
360
    }
361
362
    /*
363
    *  @private function getAdminPagesUpdate
@@ 370-388 (lines=19) @@
367
    *  @param string $fieldName
368
    *  @return string
369
    */
370
    private function getAdminPagesUpdate($moduleDirname, $tableName, $fieldId, $fieldName)
371
    {
372
        $stuModuleName = strtoupper($moduleDirname);
373
        $ccFieldId = $this->tdmcfile->getCamelCase($fieldId, false, true);
374
        $ret = $this->getSimpleString("case 'update':");
375
        $ret .= <<<EOT
376
        if (isset(\${$ccFieldId})) {
377
            \${$tableName}Obj =& \${$tableName}Handler->get(\${$ccFieldId});
378
        }
379
        \${$tableName}Obj->setVar('{$fieldName}', \$_POST['{$fieldName}']);
380
        if (\${$tableName}Handler->insert(\${$tableName}Obj)) {
381
            redirect_header('{$tableName}.php', 3, _AM_{$stuModuleName}_FORM_OK);
382
        }
383
		\$GLOBALS['xoopsTpl']->assign('error', \${$tableName}Obj->getHtmlErrors());
384
    break;\n
385
EOT;
386
387
        return $ret;
388
    }
389
    
390
    /*
391
    *  @public function render