Skip to content

Commit

Permalink
Issue #3695 e_admin addon - list mode with custom methods fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
CaMer0n committed Mar 4, 2019
1 parent 037c7c6 commit b5032c2
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 38 deletions.
33 changes: 0 additions & 33 deletions e107_handlers/admin_ui.php
Original file line number Diff line number Diff line change
Expand Up @@ -7564,39 +7564,6 @@ public function getController()
}


/**
* 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);



}



Expand Down
39 changes: 38 additions & 1 deletion e107_handlers/e107_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -2394,6 +2394,7 @@ public static function getAdminUI()
* @param string $pluginName e.g. faq, page
* @param string $addonName eg. e_cron, e_url, e_module
* @param mixed $className [optional] true - use default name, false - no object is returned (include only), any string will be used as class name
* @param mixed $param [optional] construct() param
* @return object
*/
public static function getAddon($pluginName, $addonName, $className = true)
Expand Down Expand Up @@ -5175,4 +5176,40 @@ public static function coreUpdateAvailable()

}

e107::autoload_register(array(e107::class, 'autoload'));
e107::autoload_register(array(e107::class, 'autoload'));



/**
* 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);



}
16 changes: 13 additions & 3 deletions e107_handlers/form_handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -5559,15 +5559,25 @@ function renderValue($field, $value, $attributes, $id = 0)

$meth = (!empty($attributes['method'])) ? $attributes['method'] : $method;

if(method_exists($this,$meth))
if(strpos($meth,'::')!==false)
{
list($className,$meth) = explode('::', $meth);
$cls = new $className();
}
else
{
$cls = $this;
}

if(method_exists($cls,$meth))
{
$parms['field'] = $field;
$mode = (!empty($attributes['mode'])) ? $attributes['mode'] :'read';
$value = call_user_func_array(array($this, $meth), array($value, $mode, $parms));
$value = call_user_func_array(array($cls, $meth), array($value, $mode, $parms));
}
else
{
$className = get_class($this);
$className = get_class($cls);
e107::getDebug()->log("Missing Method: ".$className."::".$meth." ".print_a($attributes,true));
return "<span class='label label-important label-danger'>Missing Method</span>";
}
Expand Down
3 changes: 2 additions & 1 deletion e107_handlers/plugin_class.php
Original file line number Diff line number Diff line change
Expand Up @@ -5040,4 +5040,5 @@ function parse_plugin_xml($plugName, $where = null)
}

}
?>


0 comments on commit b5032c2

Please sign in to comment.