diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index be481a735..69450fe94 100755 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -4723,6 +4723,8 @@ class e_admin_ui extends e_admin_controller_ui return; } + $opts = null; + foreach($tmp as $plug=>$config) { @@ -4730,11 +4732,18 @@ class e_admin_ui extends e_admin_controller_ui if(!empty($config['fields'])) { + if(!empty($this->fields['options'])) + { + $opts = $this->fields['options']; + unset($this->fields['options']); + } + foreach($config['fields'] as $k=>$v) { $v['data'] = false; // disable data-saving to db table. . $fieldName = 'x_'.$plug.'_'.$k; + e107::getDebug()->log($fieldName." initiated by ".$plug); if($v['type'] === 'method' && method_exists($form,$fieldName)) { @@ -4747,6 +4756,11 @@ class e_admin_ui extends e_admin_controller_ui $this->fields[$fieldName] = $v; // ie. x_plugin_key } + + if(!empty($opts)) // move options field to the end. + { + $this->fields['options'] = $opts; + } } if(!empty($config['batchOptions'])) @@ -6565,7 +6579,71 @@ class e_admin_form_ui extends e_form } + /** + * Integrate e_addon data into the list model. + * @param e_tree_model $tree + * @param array $fields + * @param string $pid + * @return null + */ + private function setAdminAddonModel(e_tree_model $tree, $fields, $pid) + { + $event= $this->getController()->getEventName(); + + $arr = array(); + + /** @var e_tree_model $model */ + foreach($tree->getTree() as $model) + { + foreach($fields as $fld) + { + + if(strpos($fld,'x_') !== 0) + { + continue; + } + + list($prefix,$plug,$field) = explode("_",$fld,3); + + if($prefix !== 'x' || empty($field) || empty($plug)) + { + continue; + } + + $id = $model->get($pid); + + if(!empty($id)) + { + $arr[$plug][$field][$id] = $model; + } + } + + + } + + + foreach($arr as $plug=>$field) + { + + if($obj = e107::getAddon($plug, 'e_admin')) + { + foreach($field as $fld=>$var) + { + $ids = implode(",", array_keys($var)); + + $value = (array) $obj->load($event, $ids); + + foreach($var as $id=>$model) + { + $model->set("x_".$plug."_".$fld, varset($value[$id][$fld],null)); + } + } + } + + } + + } /** @@ -6583,10 +6661,13 @@ class e_admin_form_ui extends e_form $request = $controller->getRequest(); $id = $this->getElementId(); + $pid = $controller->getPrimaryName(); $tree = $options = array(); $tree[$id] = $controller->getTreeModel(); + + if(deftrue('e_DEBUG_TREESORT') && $view === 'default') { $controller->getTreeModelSorted(); @@ -6597,6 +6678,8 @@ class e_admin_form_ui extends e_form $fields = $controller->getFields(); + $this->setAdminAddonModel($tree[$id], array_keys($fields), $pid); + // checks dispatcher acess/perms for create/edit/delete access in list mode. $mode = $controller->getMode(); $deleteRoute = $mode."/delete"; @@ -6658,7 +6741,7 @@ class e_admin_form_ui extends e_form $options[$id] = array( 'id' => $this->getElementId(), // unique string used for building element ids, REQUIRED - 'pid' => $controller->getPrimaryName(), // primary field name, REQUIRED + 'pid' => $pid, // primary field name, REQUIRED 'query' => $controller->getFormQuery(), // work around - see form in newspost.php (submitted news) 'head_query' => $request->buildQueryString('field=[FIELD]&asc=[ASC]&from=[FROM]', false), // without field, asc and from vars, REQUIRED 'np_query' => $request->buildQueryString(array(), false, 'from'), // without from var, REQUIRED for next/prev functionality @@ -7479,6 +7562,42 @@ class e_admin_form_ui extends e_form } +/** + * Interface e_admin_addon_interface @move to separate addons file? + */ +interface e_admin_addon_interface +{ + + /** + * Return a list of values for the currently viewed list page. + * @param string $event + * @param string $ids comma separated primary ids to return in the array. + * @return array with primary id as keys and array of fields key/pair values. + */ + public function load($event, $ids); + + + /** + * Extend Admin-ui Parameters + * @param $ui admin-ui object + * @return array + */ + public function config(e_admin_ui $ui); + + + /** + * Process Posted Data. + * @param $ui admin-ui object + * @param int $id + */ + public function process(e_admin_ui $ui, $id=0); + + + +} + + + include_once(e107::coreTemplatePath('admin_icons')); /** diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index ec4b2391a..c362b6dd0 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -6412,6 +6412,7 @@ var_dump($select_options);*/ foreach ($form_options as $fid => $options) { + /** @var e_tree_model $tree_model */ $tree_model = $tree_models[$fid]; $tree = $tree_model->getTree(); $total = $tree_model->getTotal(); @@ -6457,9 +6458,11 @@ var_dump($select_options);*/ } else { - + /** @var e_model $model */ foreach($tree as $model) { + // $model->set('x_canonical_url', 'whatever'); + // var_dump($model); e107::setRegistry('core/adminUI/currentListModel', $model); $text .= $this->renderTableRow($fields, $current_fields, $model->getData(), $options['pid']); } diff --git a/e107_languages/English/English.php b/e107_languages/English/English.php index c6e633937..7ebb1ee17 100644 --- a/e107_languages/English/English.php +++ b/e107_languages/English/English.php @@ -134,7 +134,7 @@ define("LAN_RELATED", "Related"); define("LAN_CLOSE", "Close"); define("LAN_EXPAND", "Expand"); define("LAN_LIST", "List"); -define("LAN_DATESTAMP","Datestamp"); +define("LAN_DATESTAMP","Date stamp"); define("LAN_SUBJECT","Subject"); define("LAN_ENTER_USRNAME_EMAIL", "Please enter your username or email"); // admin php hover field admin name diff --git a/e107_languages/English/admin/lan_admin.php b/e107_languages/English/admin/lan_admin.php index 41f5f64f0..667500764 100644 --- a/e107_languages/English/admin/lan_admin.php +++ b/e107_languages/English/admin/lan_admin.php @@ -330,7 +330,7 @@ define("LAN_LINE","Line"); define("LAN_SHORTCODES","Shortcodes"); define("LAN_DISPLAYOPT", "Edit Display Options"); // define("LAN_GOPAGE", "Go to page:"); -define("LAN_DATESTAMP","Date stamp"); +// define("LAN_DATESTAMP","Date stamp"); // moved to English.php define("LAN_TIMESTAMP","Timestamp"); define("LAN_PAGE","PAGE"); @@ -428,7 +428,7 @@ define("LAN_TEMPLATE","Template"); define("LAN_TEMPLATES","Templates"); // define("LAN_NONE", "None"); -define("LAN_CATEGORIES", "Categories"); +// define("LAN_CATEGORIES", "Categories"); // moved to English.php define("LAN_DEMO_FORBIDDEN", "Changes on this page are not possible in demo mode."); define("LAN_COPYRIGHT", "Copyright"); define("LAN_MANAGEPERMS", "Manage Permissions"); @@ -537,7 +537,7 @@ define("LAN_CHANGE_LANGUAGE", "Change Language"); define("LAN_NEWER_VERSION_OF_X", "A newer version of the [x] [y] is available for download."); // x= Name y = Theme | Plugin -define("LAN_SUBJECT", "Subject"); +// define("LAN_SUBJECT", "Subject"); // moved to English.php define("LAN_ITEM", "Item"); define("LAN_LOCK", "Lock"); define("LAN_SYSTEM_USER", "System user"); diff --git a/e107_plugins/_blank/e_admin.php b/e107_plugins/_blank/e_admin.php index 0d0b489ba..fb71ff962 100644 --- a/e107_plugins/_blank/e_admin.php +++ b/e107_plugins/_blank/e_admin.php @@ -4,8 +4,38 @@ //v2.x Standard for extending admin areas. -class _blank_admin +class _blank_admin implements e_admin_addon_interface { + + + public function load($event, $ids) + { + + // $data = e107::getDb()->retrieve("blank","*", "blank_table='".$event."' AND blank_pid IN(".$ids.")",true); + + /* $ret = array(); + + foreach($data as $row) + { + $id = (int) $row['can_pid']; + $ret[$id]['url'] = $row['can_url']; + + } + + return $ret; + */ + + + + return array( + 3 => array('url'=>'http://myurl.com'), + ); + + + } + + + /** * Extend Admin-ui Parameters * @param $ui admin-ui object