use SubModule class for generalising submodules, move back to the zotlabs/module hierarchy
This commit is contained in:
parent
d7d46def9d
commit
bedc7b7b69
@ -19,6 +19,12 @@ require_once('include/account.php');
|
|||||||
|
|
||||||
class Admin extends \Zotlabs\Web\Controller {
|
class Admin extends \Zotlabs\Web\Controller {
|
||||||
|
|
||||||
|
private $sm = null;
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
$this->sm = new \\Zotlabs\Web\SubModule();
|
||||||
|
}
|
||||||
|
|
||||||
function post(){
|
function post(){
|
||||||
logger('admin_post', LOGGER_DEBUG);
|
logger('admin_post', LOGGER_DEBUG);
|
||||||
|
|
||||||
@ -99,13 +105,7 @@ class Admin extends \Zotlabs\Web\Controller {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$filename = 'Zotlabs/Admin/'. ucfirst(argv(1)) . '.php';
|
$this->sm->call('post');
|
||||||
$modname = '\\Zotlabs\\Admin\\' . ucfirst(argv(1));
|
|
||||||
if(file_exists($filename)) {
|
|
||||||
$controller = new $modname;
|
|
||||||
$controller->post();
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -165,14 +165,8 @@ class Admin extends \Zotlabs\Web\Controller {
|
|||||||
$o = $this->admin_page_queue($a);
|
$o = $this->admin_page_queue($a);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
$o = $this->sm->call('get');
|
||||||
$filename = 'Zotlabs/Admin/'. ucfirst(argv(1)) . '.php';
|
if($o === false) {
|
||||||
$modname = '\\Zotlabs\\Admin\\' . ucfirst(argv(1));
|
|
||||||
if(file_exists($filename)) {
|
|
||||||
$controller = new $modname;
|
|
||||||
$o = $controller->get();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
notice( t('Item not found.') );
|
notice( t('Item not found.') );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Zotlabs\Admin;
|
namespace Zotlabs\Module\Admin;
|
||||||
|
|
||||||
|
|
||||||
class Plugins extends \Zotlabs\Web\Controller {
|
class Plugins {
|
||||||
|
|
||||||
function get() {
|
function get() {
|
||||||
|
|
31
Zotlabs/Web/SubModule.php
Normal file
31
Zotlabs/Web/SubModule.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Zotlabs\Web;
|
||||||
|
|
||||||
|
|
||||||
|
class SubModule {
|
||||||
|
|
||||||
|
private $controller = false;
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
|
||||||
|
if(argc() < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
$filename = 'Zotlabs/Module/' . ucfirst(argv(0)) . '/'. ucfirst(argv(1)) . '.php';
|
||||||
|
$modname = '\\Zotlabs\\Module\\' . ucfirst(argv(0)) . '\\' . ucfirst(argv(1));
|
||||||
|
if(file_exists($filename)) {
|
||||||
|
$this->controller = new $modname();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function call($method) {
|
||||||
|
if(! $this->controller)
|
||||||
|
return false;
|
||||||
|
if(method_exists($this->controller,$method))
|
||||||
|
return $this->controller->$method();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
1
boot.php
1
boot.php
@ -697,6 +697,7 @@ function startup() {
|
|||||||
|
|
||||||
class ZotlabsAutoloader {
|
class ZotlabsAutoloader {
|
||||||
static public function loader($className) {
|
static public function loader($className) {
|
||||||
|
$debug = false;
|
||||||
$filename = str_replace('\\', '/', $className) . ".php";
|
$filename = str_replace('\\', '/', $className) . ".php";
|
||||||
if(file_exists($filename)) {
|
if(file_exists($filename)) {
|
||||||
include($filename);
|
include($filename);
|
||||||
|
Reference in New Issue
Block a user