function parseLayouts($layouts) { if (empty($layouts)) { return; } $tempLayouts = array(); $targetController = CSR::get('controllerName'); $viewsDirWithControllerName = VIEWS_DIR . $targetController . '/'; $layouts = explode('/', $layouts); $layoutsLength = count($layouts); CSR::define('VIEW_FILE_EXTENSION', '.html'); for ($i = 0; $i < $layoutsLength; $i++) { $layout = $layouts[$i]; if ($layout === '') { continue; } if ($layout === '*') { $layout = $this->_defaultLayouts[$i]; } if (file_exists($viewsDirWithControllerName . $layout . VIEW_FILE_EXTENSION)) { $layoutPath = $viewsDirWithControllerName . $layout . VIEW_FILE_EXTENSION; } else { if (file_exists($layout . VIEW_FILE_EXTENSION)) { $layoutPath = $layout . VIEW_FILE_EXTENSION; } else { if (CSR_DEVELOP_MODE) { if ($layout[0] === '/' || $layout[0] === '.') { trigger_error(sprintf('Target view file <em>%s</em> does not exist.', realpath($layout . VIEW_FILE_EXTENSION)), E_USER_WARNING); continue; } else { trigger_error(sprintf('Target view file <em>%s</em> does not exist.', $viewsDirWithControllerName . $layout . VIEW_FILE_EXTENSION), E_USER_WARNING); continue; } } else { continue; } } } $tempLayouts[] = $layoutPath; } return $tempLayouts; }