引导程序:
$uri = explode('/',$_SERVER['REQUEST_URI']);
if($uri['1'] == 'flok'){
$flok = new Zend_Controller_Router_Route('flok/:controller/:action/:id/*', array('module' => 'flok', 'controller' => 'index', 'action' => 'index', 'id' =>null));
$router->addRoute('flok', $flok);
$resourceLoader = new Zend_Application_Module_Autoloader(array(
'basePath' => APPLICATION_PATH . "/flok/flok",
'namespace' => 'Flok',
));
//Init
$frontController->registerPlugin(new Flok_Plugin_Init(),'flok');
//Auth
$frontController->registerPlugin(new Flok_Plugin_Auth(),'flok');
// dynamic modules
$ruta = APPLICATION_PATH.'/flok';
foreach(scandir($ruta) as $mod) {
if(!is_dir($mod) and $mod != '.DS_Store'){
$Modululflok = new Zend_Controller_Router_Route('flok/'.$mod.'/:controller/:action/:id/*', array('submodules' => 'flok','module' => $mod , 'controller' => 'index', 'action' => 'index', 'id' =>null));
$router->addRoute($mod, $Modululflok);
$resourceLoader = new Zend_Application_Module_Autoloader(array(
'basePath' => APPLICATION_PATH . "/flok/".$mod,
'namespace' => ucfirst($mod),
));
}
}
$layout = Zend_Layout::getMvcInstance();
$layout
->setLayout('layout')
->setLayoutPath(APPLICATION_PATH . '/flok/flok/views/scripts');
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
$viewRenderer->initView();
$viewRenderer->view->addHelperPath(APPLICATION_PATH . '/flok/flok/helpers');
} else {
$default = new Zend_Controller_Router_Route('*', array('module' => 'default', 'controller' => 'index', 'action' => 'index'));
$router->addRoute('default', $default);
}
这个助手在核心模块中插入数据(菜单、视图等):
class Zend_View_Helper_Models
{
public function Models($tipo)
{
// load modules
$ruta = APPLICATION_PATH.'/flok';
foreach(scandir($ruta) as $mod) {
if(!is_dir($mod) and $mod != '.DS_Store'){
$rutaphp = $ruta.'/'.$mod.'/'.$mod.'.php';
if(file_exists($rutaphp)){
include_once($rutaphp);
$modul = new $mod;
if(isset($modul->$tipo) and $modul->$tipo === true){
$data = $tipo.'Data';
$m[] = $modul->$data;
}
}
}
}
return $m;
}
}