From 88ca00ec12a499f79c81fee8309a2191b4000ae7 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 29 Jul 2016 15:22:47 -0700 Subject: [PATCH] Allow plugins to add tabs to core admin pages. --- e107_handlers/admin_ui.php | 32 ++++++++++++++++++++++++++++++-- e107_handlers/form_handler.php | 16 +++++++++++++--- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index e36597212..84199675f 100644 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -2583,7 +2583,8 @@ class e_admin_controller_ui extends e_admin_controller { return $this->tabs; } - + + /** * Get Tab data * @return array @@ -4321,11 +4322,38 @@ class e_admin_ui extends e_admin_controller_ui foreach($tmp as $plug=>$config) { + + $form = e107::getAddon($plug, 'e_admin', $plug."_admin_form"); // class | false. + foreach($config['fields'] as $k=>$v) { $v['data'] = false; // disable data-saving to db table. . - $this->fields['x_'.$plug.'_'.$k] = $v; // ie. x_plugin_key + + $fieldName = 'x_'.$plug.'_'.$k; + + if($v['type'] == 'method' && method_exists($form,$fieldName)) + { + $v['method'] = $plug."_admin_form::".$fieldName; + //echo "Found method ".$fieldName." in ".$plug."_menu_form"; + //echo $form->$fieldName(); + } + + + $this->fields[$fieldName] = $v; // ie. x_plugin_key + + + } + + if(!empty($config['tabs'])) + { + foreach($config['tabs'] as $t=>$tb) + { + $this->tabs[$t] = $tb; + } + } + + } diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index 4cb13d7f5..fb5d53c31 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -5213,7 +5213,17 @@ class e_form $meth = (!empty($attributes['method'])) ? $attributes['method'] : $key; $parms['field'] = $key; - $ret = call_user_func_array(array($this, $meth), array($value, 'write', $parms)); + if(strpos($meth,'::')!==false) + { + list($className,$meth) = explode('::', $meth); + $cls = new $className; + } + else + { + $cls = $this; + } + + $ret = call_user_func_array(array($cls, $meth), array($value, 'write', $parms)); break; case 'upload': //TODO - from method @@ -5482,14 +5492,14 @@ class e_form $text .= '
'; foreach($data['tabs'] as $tabId=>$label) { - $active = ($tabId == $curTab) ? 'active' : ''; + $active = ($tabId === $curTab) ? 'active' : ''; $text .= '
'; $text .= $this->renderCreateFieldset($elid, $data, $model, $tabId); $text .= "
";