From f5c6e866a23fa9a382f937e2c39e76e37eddf2a7 Mon Sep 17 00:00:00 2001 From: Cameron Date: Sat, 18 May 2013 18:23:24 -0700 Subject: [PATCH] Issue #306 - Plugin Builder LANs. Also added preferences option. --- e107_admin/plugin.php | 144 +++++++++++++++++++++++++++++++++++------- 1 file changed, 121 insertions(+), 23 deletions(-) diff --git a/e107_admin/plugin.php b/e107_admin/plugin.php index e6af8b66b..71dff2af5 100644 --- a/e107_admin/plugin.php +++ b/e107_admin/plugin.php @@ -1806,8 +1806,29 @@ class pluginBuilder function prefs() { - //TODO Preferences - return "Coming Soon"; + $frm = e107::getForm(); + + $text = ''; + + $options = array( + 'text' => "Text Box", + 'bbarea' => "Rich-Text Area", + 'boolean' => "Text Area", + "method" => "Custom Function", + "image" => "Image", + ); + + + for ($i=0; $i < 10; $i++) + { + $text .= "
". + $frm->text("pluginPrefs[".$i."][index]", '',40,'placeholder=Preference Name')." ". + $frm->text("pluginPrefs[".$i."][value]", '',40,'placeholder=Default Value')." ". + $frm->select("pluginPrefs[".$i."][type]", $options, '', 'class=null', 'Field Type...'). + "
"; + } + + return $text; } @@ -2045,7 +2066,7 @@ class pluginBuilder function createXml($data) { - //print_a($_POST); + // print_a($_POST); $ns = e107::getRender(); $mes = e107::getMessage(); $tp = e107::getParser(); @@ -2058,6 +2079,30 @@ class pluginBuilder } $newArray['DESCRIPTION_DESCRIPTION'] = strip_tags($tp->toHtml($newArray['DESCRIPTION_DESCRIPTION'],true)); + + foreach($_POST['pluginPrefs'] as $val) + { + if(vartrue($val['index'])) + { + $id = $val['index']; + $plugPref[$id] = $val['value']; + } + } + + // print_a($_POST['pluginPrefs']); + + if(count($plugPref)) + { + $xmlPref = "\n"; + foreach($plugPref as $k=>$v) + { + $xmlPref .= " ".$v."\n"; + } + + $xmlPref .= " "; + $newArray['PLUGINPREFS'] = $xmlPref; + } + // print_a($newArray); // print_a($this); @@ -2076,8 +2121,16 @@ $template = <<