Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require_once(APPPATH.'/libraries/LayoutParser'.EXT);
- class Layout {
- protected static $layoutParser;
- protected $layoutBlock;
- protected $controllerObject;
- protected $controllerActionName;
- public function _setControllerActionName($controllerActionName = ''){
- $controllerActionName = preg_replace('/\//', '_', $controllerActionName);
- $controllerActionName = trim($controllerActionName , '_');
- $this->controllerActionName = $controllerActionName;
- echo var_dump($controllerActionName);
- $this->layoutBlock = &self::$layoutParser->getActionLayout( $this->controllerActionName );
- }
- public function _getControllerLayout(){
- return var_dump($this->layoutBlock);
- }
- public function _getTemplate(){
- return $this->layoutBlock['template'];
- }
- public function _getChildController($childName){
- if(!is_array($this->layoutBlock['child_blocks']))
- return null;
- $childLayout = null;
- foreach( $this->layoutBlock['child_blocks'] as &$val ){
- if( strcmp($val['name'], $childName) === 0){
- $childLayout = &$val;
- break;
- }
- }
- if($childLayout === null)
- return null;
- require_once APPPATH . 'controllers/' . strtolower($childLayout['controller']) . EXT;
- $childController = New $childLayout['controller']();
- $childController->_setLayout($childLayout);
- return $childController;
- }
- public function _appendChild($childName){
- $childController = &$this->_getChildController($childName);
- if($childController !== null)
- $childController->_doAction();
- }
- public function _doAction(){
- $this->layoutBlock;
- $this->{ $this->layoutBlock['action'] }();
- }
- public function __construct(&$controllerObject = NULL , &$layout = NULL){
- if($layout === NULL){
- self::$layoutParser = LayoutParser::getInstance();
- $this->layoutBlock = &self::$layoutParser->getLayout();
- }
- else {
- $this->layoutBlock = &$layout;
- }
- if($controllerObject !== NULL){
- $this->controllerObject = $controllerObject;
- }
- }
- public function _setLayout(&$layout){
- $this->layoutBlock = &$layout;
- }
- public function _initControllerLayout(){
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement