diff --git a/e107_handlers/admin_handler.php b/e107_handlers/admin_handler.php
index 2bbafb0e9..11eda6e47 100644
--- a/e107_handlers/admin_handler.php
+++ b/e107_handlers/admin_handler.php
@@ -9,8 +9,8 @@
* Administration UI handlers, admin helper functions
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/admin_handler.php,v $
- * $Revision: 1.34 $
- * $Date: 2009-11-18 19:57:07 $
+ * $Revision: 1.35 $
+ * $Date: 2009-11-21 11:15:29 $
* $Author: secretr $
*/
@@ -2552,29 +2552,34 @@ class e_admin_controller_ui extends e_admin_controller
*/
protected function convertToData(&$data)
{
+ $model = new e_model($data);
foreach ($this->getFields() as $key => $attributes)
{
- if(!isset($data[$key]))
+ $value = vartrue($attributes['dataPath']) ? $model->getData($attributes['dataPath']) : $model->get($data[$key]);
+ if(null === $value)
{
continue;
}
switch($attributes['type'])
{
case 'datestamp':
- if(!is_numeric($data[$key]))
+ if(!is_numeric($value))
{
- $data[$key] = trim($data[$key]) ? e107::getDateConvert()->toTime($data[$key], 'input') : 0;
+ $value = trim($value) ? e107::getDateConvert()->toTime($value, 'input') : 0;
}
break;
case 'ip': // TODO - ask Steve if this check is required
- if(strpos($data[$key], '.') !== FALSE)
+ if(strpos($value, '.') !== FALSE)
{
- $data[$key] = trim($data[$key]) ? e107::getInstance()->ipEncode($data[$key]) : '';
+ $value = trim($value) ? e107::getInstance()->ipEncode($value) : '';
}
break;
}
}
+ $data = $model->getData();
+ unset($model);
+
$this->toData($data);
}
@@ -3620,7 +3625,7 @@ class e_admin_form_ui extends e_form
);
$models[] = $controller->getModel();
- return $this->createForm($forms, $models, e_AJAX_REQUEST);
+ return $this->renderCreateForm($forms, $models, e_AJAX_REQUEST);
}
/**
@@ -3651,7 +3656,7 @@ class e_admin_form_ui extends e_form
);
$models[] = $controller->getConfig();
- return $this->createForm($forms, $models, e_AJAX_REQUEST);
+ return $this->renderCreateForm($forms, $models, e_AJAX_REQUEST);
}
/**
@@ -3667,8 +3672,10 @@ class e_admin_form_ui extends e_form
$controller = $this->getController();
$request = $controller->getRequest();
- $tree = $controller->getTreeModel();
- $options = array(
+ $id = $this->getElementId();
+ $tree = $options = array();
+ $tree[$id] = $controller->getTreeModel();
+ $options[$id] = array(
'id' => $this->getElementId(), // unique string used for building element ids, REQUIRED
'pid' => $controller->getPrimaryName(), // primary field name, REQUIRED
//'url' => e_SELF, default
@@ -3681,7 +3688,7 @@ class e_admin_form_ui extends e_form
'fields' => $controller->getFields(), // see e_admin_ui::$fields
'fieldpref' => $controller->getFieldPref(), // see e_admin_ui::$fieldpref
'table_pre' => '', // markup to be added before opening table element
- 'table_post' => !$tree->isEmpty() ? $this->renderBatch($controller->getBatchDelete()) : '',
+ 'table_post' => !$tree[$id]->isEmpty() ? $this->renderBatch($controller->getBatchDelete()) : '',
'fieldset_pre' => '', // markup to be added before opening fieldset element
'fieldset_post' => '', // markup to be added after closing fieldset element
'perPage' => $controller->getPerPage(), // if 0 - no next/prev navigation
@@ -3689,7 +3696,7 @@ class e_admin_form_ui extends e_form
'field' => $controller->getQuery('field'), //current order field name, default - primary field
'asc' => $controller->getQuery('asc', 'desc'), //current 'order by' rule, default 'asc'
);
- return $this->listForm($options, $tree, $ajax);
+ return $this->renderListForm($options, $tree, $ajax);
}
function renderFilter($current_query = array(), $location = '', $input_options = array())
diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php
index 588126682..7d6e7009a 100644
--- a/e107_handlers/form_handler.php
+++ b/e107_handlers/form_handler.php
@@ -9,9 +9,9 @@
* Form Handler
*
* $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $
- * $Revision: 1.88 $
- * $Date: 2009-11-20 05:01:31 $
- * $Author: e107coders $
+ * $Revision: 1.89 $
+ * $Date: 2009-11-21 11:15:28 $
+ * $Author: secretr $
*
*/
@@ -1367,7 +1367,7 @@ class e_form
* Expected options array format:
*
* 'myplugin', // unique string used for building element ids, REQUIRED
* 'pid' => 'primary_id', // primary field name, REQUIRED
* 'url' => '{e_PLUGIN}myplug/admin_config.php', // if not set, e_SELF is used
@@ -1388,82 +1388,88 @@ class e_form
* 'field' => 'field_name', //current order field name, default - primary field
* 'asc' => 'desc', //current 'order by' rule, default 'asc'
* );
- * $list = new e_admin_tree_model($data);
+ * $tree_models['myplugin'] = new e_admin_tree_model($data);
*
* TODO - move fieldset & table generation in separate methods, needed for ajax calls
- * @param array $options
- * @param e_admin_tree_model $list
+ * @param array $form_options
+ * @param e_admin_tree_model $tree_model
* @param boolean $nocontainer don't enclose form in div container
* @return string
*/
- public function listForm($options, $list, $nocontainer = false)
+ public function renderListForm($form_options, $tree_models, $nocontainer = false)
{
$tp = e107::getParser();
- $tree = $list->getTree();
- $total = $list->getTotal();
- $amount = $options['perPage'];
- $from = vartrue($options['from'], 0);
- $field = vartrue($options['field'], $options['pid']);
- $asc = strtoupper(vartrue($options['asc'], 'asc'));
- $elid = $options['id'];
- $query = isset($options['query']) ? $options['query'] : e_QUERY ;
- $url = (isset($options['url']) ? $tp->replaceConstants($options['url'], 'abs') : e_SELF);
- $formurl = $url.($query ? '?'.$query : '');
- $fields = $options['fields'];
- $current_fields = varset($options['fieldpref']) ? $options['fieldpref'] : array_keys($options['fields']);
-
- $text = "
-