From fb98771b8223a9eafadafa7aeadb1888f358b0d5 Mon Sep 17 00:00:00 2001 From: camer0n Date: Tue, 31 Oct 2023 12:34:28 -0700 Subject: [PATCH] Fixes #5092 - Removed example code with error and added new example. Minor cleanup of class. --- e107_handlers/e_pluginbuilder_class.php | 63 ++++++++++++++----- e107_tests/tests/unit/e_pluginbuilderTest.php | 20 ++++++ 2 files changed, 68 insertions(+), 15 deletions(-) diff --git a/e107_handlers/e_pluginbuilder_class.php b/e107_handlers/e_pluginbuilder_class.php index 3efefe0bf4..283e650a98 100644 --- a/e107_handlers/e_pluginbuilder_class.php +++ b/e107_handlers/e_pluginbuilder_class.php @@ -15,16 +15,11 @@ class e_pluginbuilder var $tableList = array(); var $createFiles = false; private $buildTable = false; - private $debug = false; + function __construct() { - if(e_DEBUG == true) - { - $this->debug = true; - } - $this->special['checkboxes'] = array('title'=> '','type' => null, 'data' => null, 'width'=>'5%', 'thclass' =>'center', 'forced'=> TRUE, 'class'=>'center', 'toggle' => 'e-multiselect', 'fieldpref'=>true); $this->special['options'] = array( 'title'=> 'LAN_OPTIONS', 'type' => null, 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced'=>TRUE, 'fieldpref'=>true); @@ -717,7 +712,7 @@ function pluginXml() $info = str_replace('[x]', $this->pluginName."_sql.php", EPL_ADLAN_132); $mes->addInfo($info,'default',true); $red = e107::getRedirect(); - $red->redirect(e_REQUEST_URL,true); + $red->redirect(e_REQUEST_URL); // $red->redirect(e_SELF."?mode=create&newplugin=".$this->pluginName."&createFiles=1&step=2",true); } else @@ -894,7 +889,7 @@ function xmlInput($name, $info, $default='') break; } - $req = ($required == true) ? "&required=1" : ""; + $req = $required ? "&required=1" : ""; $placeholder = (varset($placeholder)) ? $placeholder : $type; $pat = !empty($pattern) ? "&pattern=".$pattern : ""; $sz = !empty($xsize) ? "&size=".$xsize : ""; @@ -1067,7 +1062,7 @@ function createXml($data) } - if($this->createFiles == true || !file_exists($path)) + if($this->createFiles || !file_exists($path)) { if(file_put_contents($path,$result) ) { @@ -1103,7 +1098,7 @@ function form($table,$fieldArray) ); // echo "TABLE COUNT= ".$this->tableCount ; - + $defaultMode = []; $this->table = $table."_ui"; @@ -1321,6 +1316,9 @@ function fieldType($name, $val) "hidden" => EPL_ADLAN_215 ); break; + + default: + $array = []; } // asort($array); @@ -1334,6 +1332,7 @@ function fieldType($name, $val) function guess($data, $val=null,$mode = 'type') { $tmp = explode("_",$data); + $name = ''; if(count($tmp) == 3) // eg Link_page_title { @@ -2063,8 +2062,11 @@ public function init() $text .= " } +"; + + +$text .= <<getController()->getFieldVar('other_field_name'); + if(\$this->getPosted('custom-submit')) // after form is submitted. + { + e107::getMessage()->addSuccess('Changes made: '. \$this->getPosted('example')); + } + + \$this->addTitle('My Custom Title'); + + + \$frm = \$this->getUI(); + \$text = \$frm->open('my-form', 'post'); + + \$tab1 = " + + + + + + + + +
Label ".\$frm->help('A help tip')."".\$frm->text('example', \$this->getPosted('example'), 80, ['size'=>'xlarge'])."
"; + + // Display Tab + \$text .= \$frm->tabs([ + 'general' => ['caption'=>LAN_GENERAL, 'text' => \$tab1], + ]); + + \$text .= "
".\$frm->button('custom-submit', 'submit', 'submit', LAN_CREATE)."
"; + \$text .= \$frm->close(); + return \$text; } -"; +UICODE; + + $text .= $this->buildAdminUIBatchFilter($vars['fields'], $table, 'batch'); @@ -2151,7 +2183,7 @@ class " . str_replace("_ui", "_form_ui", $table) . " extends e_admin_form_ui // Custom Method/Function function " . $fld . "(\$curVal,\$mode) { - + \$otherField = \$this->getController()->getFieldVar('other_field_name'); switch(\$mode) { @@ -2197,6 +2229,7 @@ function " . $index . "(\$curVal,\$mode) switch(\$mode) { case 'write': // Edit Page + return \$this->text('" . $index . "',\$curVal, 255, 'size=large'); break; diff --git a/e107_tests/tests/unit/e_pluginbuilderTest.php b/e107_tests/tests/unit/e_pluginbuilderTest.php index 76a2f97ccd..a53a83020e 100644 --- a/e107_tests/tests/unit/e_pluginbuilderTest.php +++ b/e107_tests/tests/unit/e_pluginbuilderTest.php @@ -347,7 +347,27 @@ public function testBuildAdminUI() $result = $this->pb->buildAdminUI($this->posted, 'pluginfolder', 'PluginTitle'); $expected = "'example_id' => array ( 'title' => LAN_ID, 'type' => 'number', 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => [], 'writeParms' => [], 'class' => 'left', 'thclass' => 'left',)"; $this->assertStringContainsString($expected, $result); + + // file_put_contents(__DIR__."/testBuild.php", "fail("The code is not valid. Error message: $output"); + } + + return true; + + }*/ /* public function testRun() {