mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 13:47:31 +02:00
Fixes #3695 Added e_admin interface and method to load data for 'list' view of admin-ui. (subject to change)
This commit is contained in:
@@ -4723,6 +4723,8 @@ class e_admin_ui extends e_admin_controller_ui
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$opts = null;
|
||||||
|
|
||||||
foreach($tmp as $plug=>$config)
|
foreach($tmp as $plug=>$config)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -4730,11 +4732,18 @@ class e_admin_ui extends e_admin_controller_ui
|
|||||||
|
|
||||||
if(!empty($config['fields']))
|
if(!empty($config['fields']))
|
||||||
{
|
{
|
||||||
|
if(!empty($this->fields['options']))
|
||||||
|
{
|
||||||
|
$opts = $this->fields['options'];
|
||||||
|
unset($this->fields['options']);
|
||||||
|
}
|
||||||
|
|
||||||
foreach($config['fields'] as $k=>$v)
|
foreach($config['fields'] as $k=>$v)
|
||||||
{
|
{
|
||||||
$v['data'] = false; // disable data-saving to db table. .
|
$v['data'] = false; // disable data-saving to db table. .
|
||||||
|
|
||||||
$fieldName = 'x_'.$plug.'_'.$k;
|
$fieldName = 'x_'.$plug.'_'.$k;
|
||||||
|
e107::getDebug()->log($fieldName." initiated by ".$plug);
|
||||||
|
|
||||||
if($v['type'] === 'method' && method_exists($form,$fieldName))
|
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
|
$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']))
|
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();
|
$request = $controller->getRequest();
|
||||||
$id = $this->getElementId();
|
$id = $this->getElementId();
|
||||||
|
$pid = $controller->getPrimaryName();
|
||||||
$tree = $options = array();
|
$tree = $options = array();
|
||||||
$tree[$id] = $controller->getTreeModel();
|
$tree[$id] = $controller->getTreeModel();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if(deftrue('e_DEBUG_TREESORT') && $view === 'default')
|
if(deftrue('e_DEBUG_TREESORT') && $view === 'default')
|
||||||
{
|
{
|
||||||
$controller->getTreeModelSorted();
|
$controller->getTreeModelSorted();
|
||||||
@@ -6597,6 +6678,8 @@ class e_admin_form_ui extends e_form
|
|||||||
|
|
||||||
$fields = $controller->getFields();
|
$fields = $controller->getFields();
|
||||||
|
|
||||||
|
$this->setAdminAddonModel($tree[$id], array_keys($fields), $pid);
|
||||||
|
|
||||||
// checks dispatcher acess/perms for create/edit/delete access in list mode.
|
// checks dispatcher acess/perms for create/edit/delete access in list mode.
|
||||||
$mode = $controller->getMode();
|
$mode = $controller->getMode();
|
||||||
$deleteRoute = $mode."/delete";
|
$deleteRoute = $mode."/delete";
|
||||||
@@ -6658,7 +6741,7 @@ class e_admin_form_ui extends e_form
|
|||||||
|
|
||||||
$options[$id] = array(
|
$options[$id] = array(
|
||||||
'id' => $this->getElementId(), // unique string used for building element ids, REQUIRED
|
'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)
|
'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
|
'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
|
'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'));
|
include_once(e107::coreTemplatePath('admin_icons'));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -6412,6 +6412,7 @@ var_dump($select_options);*/
|
|||||||
|
|
||||||
foreach ($form_options as $fid => $options)
|
foreach ($form_options as $fid => $options)
|
||||||
{
|
{
|
||||||
|
/** @var e_tree_model $tree_model */
|
||||||
$tree_model = $tree_models[$fid];
|
$tree_model = $tree_models[$fid];
|
||||||
$tree = $tree_model->getTree();
|
$tree = $tree_model->getTree();
|
||||||
$total = $tree_model->getTotal();
|
$total = $tree_model->getTotal();
|
||||||
@@ -6457,9 +6458,11 @@ var_dump($select_options);*/
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
/** @var e_model $model */
|
||||||
foreach($tree as $model)
|
foreach($tree as $model)
|
||||||
{
|
{
|
||||||
|
// $model->set('x_canonical_url', 'whatever');
|
||||||
|
// var_dump($model);
|
||||||
e107::setRegistry('core/adminUI/currentListModel', $model);
|
e107::setRegistry('core/adminUI/currentListModel', $model);
|
||||||
$text .= $this->renderTableRow($fields, $current_fields, $model->getData(), $options['pid']);
|
$text .= $this->renderTableRow($fields, $current_fields, $model->getData(), $options['pid']);
|
||||||
}
|
}
|
||||||
|
@@ -134,7 +134,7 @@ define("LAN_RELATED", "Related");
|
|||||||
define("LAN_CLOSE", "Close");
|
define("LAN_CLOSE", "Close");
|
||||||
define("LAN_EXPAND", "Expand");
|
define("LAN_EXPAND", "Expand");
|
||||||
define("LAN_LIST", "List");
|
define("LAN_LIST", "List");
|
||||||
define("LAN_DATESTAMP","Datestamp");
|
define("LAN_DATESTAMP","Date stamp");
|
||||||
define("LAN_SUBJECT","Subject");
|
define("LAN_SUBJECT","Subject");
|
||||||
|
|
||||||
define("LAN_ENTER_USRNAME_EMAIL", "Please enter your username or email"); // admin php hover field admin name
|
define("LAN_ENTER_USRNAME_EMAIL", "Please enter your username or email"); // admin php hover field admin name
|
||||||
|
@@ -330,7 +330,7 @@ define("LAN_LINE","Line");
|
|||||||
define("LAN_SHORTCODES","Shortcodes");
|
define("LAN_SHORTCODES","Shortcodes");
|
||||||
define("LAN_DISPLAYOPT", "Edit Display Options");
|
define("LAN_DISPLAYOPT", "Edit Display Options");
|
||||||
// define("LAN_GOPAGE", "Go to page:");
|
// 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_TIMESTAMP","Timestamp");
|
||||||
|
|
||||||
define("LAN_PAGE","PAGE");
|
define("LAN_PAGE","PAGE");
|
||||||
@@ -428,7 +428,7 @@ define("LAN_TEMPLATE","Template");
|
|||||||
define("LAN_TEMPLATES","Templates");
|
define("LAN_TEMPLATES","Templates");
|
||||||
|
|
||||||
// define("LAN_NONE", "None");
|
// 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_DEMO_FORBIDDEN", "Changes on this page are not possible in demo mode.");
|
||||||
define("LAN_COPYRIGHT", "Copyright");
|
define("LAN_COPYRIGHT", "Copyright");
|
||||||
define("LAN_MANAGEPERMS", "Manage Permissions");
|
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_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_ITEM", "Item");
|
||||||
define("LAN_LOCK", "Lock");
|
define("LAN_LOCK", "Lock");
|
||||||
define("LAN_SYSTEM_USER", "System user");
|
define("LAN_SYSTEM_USER", "System user");
|
||||||
|
@@ -4,8 +4,38 @@
|
|||||||
//v2.x Standard for extending admin areas.
|
//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
|
* Extend Admin-ui Parameters
|
||||||
* @param $ui admin-ui object
|
* @param $ui admin-ui object
|
||||||
|
Reference in New Issue
Block a user