General tidying up
This commit is contained in:
@@ -10,14 +10,37 @@
|
||||
* @copyright (c) 2010 Deon George
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Admin_Module extends Controller_Module {
|
||||
class Controller_Admin_Module extends Controller_TemplateDefault_Admin {
|
||||
protected $secure_actions = array(
|
||||
'edit'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
);
|
||||
|
||||
/**
|
||||
* Our menu method
|
||||
*
|
||||
* We need this method, otherwise we have redirect from our parent
|
||||
* Get the list of methods for a class
|
||||
*/
|
||||
public function action_menu() {
|
||||
$this->template->content = _('See menu on tree');
|
||||
protected function _methods($class) {
|
||||
// Get a list of methods this module has
|
||||
$ch = 'Controller_%s';
|
||||
$methods = array();
|
||||
|
||||
// List of classes where all our methods are, including this one.
|
||||
$classes = Kohana::config('config.method_directory');
|
||||
array_unshift($classes,'');
|
||||
|
||||
foreach ($classes as $c) {
|
||||
$cn = sprintf($ch,$c ? $c.'_'.$class : $class);
|
||||
|
||||
if (class_exists($cn)) {
|
||||
$r = new ReflectionClass($cn);
|
||||
|
||||
foreach ($r->getMethods() as $method)
|
||||
if (preg_match('/^Controller_(.*_)?'.$class.'$/i',$method->class) AND ! preg_match('/^_/',$method->name))
|
||||
array_push($methods,str_replace('action_',($c ? $c.'_' : $c),$method->name));
|
||||
}
|
||||
}
|
||||
|
||||
return $methods;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -11,42 +11,5 @@
|
||||
* @license http://dev.leenooks.net/license.html
|
||||
*/
|
||||
class Controller_Module extends Controller_TemplateDefault {
|
||||
public $secure_actions = array(
|
||||
'edit'=>TRUE,
|
||||
'list'=>TRUE,
|
||||
'menu'=>TRUE,
|
||||
);
|
||||
|
||||
public function action_menu() {
|
||||
// Redirect us to the admin menu, no user facilities here!
|
||||
Request::current()->redirect('/admin/module/menu');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of methods for a class
|
||||
*/
|
||||
protected function _methods($class) {
|
||||
// Get a list of methods this module has
|
||||
$ch = 'Controller_%s';
|
||||
$methods = array();
|
||||
|
||||
// List of classes where all our methods are, including this one.
|
||||
$classes = Kohana::config('config.method_directory');
|
||||
array_unshift($classes,'');
|
||||
|
||||
foreach ($classes as $c) {
|
||||
$cn = sprintf($ch,$c ? $c.'_'.$class : $class);
|
||||
|
||||
if (class_exists($cn)) {
|
||||
$r = new ReflectionClass($cn);
|
||||
|
||||
foreach ($r->getMethods() as $method)
|
||||
if (preg_match('/^Controller_(.*_)?'.$class.'$/i',$method->class) AND ! preg_match('/^_/',$method->name))
|
||||
array_push($methods,str_replace('action_',($c ? $c.'_' : $c),$method->name));
|
||||
}
|
||||
}
|
||||
|
||||
return $methods;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user