Automaticly Modular Admin Panel

Hi!

This is my structure of app:

s6.ifotos.pl/img/skrinjpg_eanpqae.jpg

I want to automatize my admin panel.

Let’s explain when I add module to modules folder, in my Admin Panel Menu (backendController) automaticly see the name of module with links.

I thought to use $this->forward but is not good idea because in admins controller must use $this->renderPartial (same $this->render create assets in html code, so js and css code is doubled) to return page.

My backendController.php


<?php

class BackendController extends AdminMainController

{

	public $layout='//layouts/admin';

		

	public function actionIndex($route='')

	{

		if ( $route == '' )

		{

			$this->render('index');

		}

		else

		{

			$this->execute($route);	

		}		

	}

	

	//HMVC ADMIN MODULE

	private function execute($route)

	{

		ob_start();

        $this->forward($route, false);

		$out = ob_get_clean();

		$this->render('index', array('adminka'=>$out));

	}

	

	public function actionChangeAdminLang()

	{

		Yii::app()->user->setState('admin_lang', $_GET['val']);

		$this->redirect(array('index', 'route'=> $_GET['route']));

	}


}

?>

AdminMainController.php


<?php

class AdminMainController extends CController

{

	public $menu = array();

	public $tabs = array();

	public $breadcrumbs;

	public $langs = array();

	public $check_select;

	/**

	* @return array action filters

	*/

	public function filters()

	{

		return CMap::mergeArray(parent::filters(),array(

			'accessControl', // perform access control for CRUD operations

		));

	}


	public function beforeControllerAction($controller, $action)

	{

		if(parent::beforeControllerAction($controller, $action))

		{

			// this method is called before any module controller action is performed

			// you may place customized code here

			return true;

		}

		else

			return false;

	}

	

	public function init()

	{

			$order = array();

			

			if ( Yii::app()->user->getState('admin_lang') == null )

				Yii::app()->user->setState('admin_lang', 'pl');

			

			$this->check_select = Yii::app()->user->getState('admin_lang');

			

			$route = explode('/', $_GET['route']);

			$this_module = strtolower($route[0]);

			

			foreach (Yii::app()->getModules() as $key => $value) 

			{

	                $key = strtolower($key);

	                $module = Yii::app()->getModule($key);

	                if ( $module !== null && method_exists($module, 'getCategory')) 

	                {

	                	$order[$key] = $module->getCategory();

						//$this->tabs[] = array( 'label' => TbHtml::icon(TbHtml::ICON_PLAY).$module->getCategory(), 'url' => array('backend/index', 'route'=>$key.'/admin/admin') );

	                } 

					if ( $this_module == $key &&  $module !== null && method_exists($module, 'getOptions')) 

	                {

	                	ksort($module->getOptions());

						

	                	foreach ( $module->getOptions() as $k => $v )

						{

							$explode = explode('/', $v);

							$count_explode = count($explode);

							$url = $count_explode == 1 ? 'admin/'.$v : $v;

							$this->tabs[] = array( 'label' => $k, 'url' => array('backend/index', 'route'=>$key.'/'.$url) );

						}

						

	                } 

	       	}


			foreach ( $order as $key => $value)

			{

				$this->menu[] = array( 'label' => $value, 'url' => array('backend/index', 'route'=>$key.'/admin/admin') );

			}

			asort($this->menu);

			

			foreach (Yii::app()->UrlManager->listLanguage() as $language => $languageUrl)

			{

				$this->langs[$language] = $language;

			}

			

			

	}

	

}

?>

I don’t want to my urls look like that’s:

//content/admin

//gallery/admin

Should be looks:

//admin/content

//admin/content/new/id/2

//admin/gallery

in my version url:

backend?route=gallery/admin/admin

backend?route=gallery/admin/view/id/10

but this version does not suit me

Have any ideas to create automaticly modular Panel admin ??

Thanks