public function render() { global $uri, $browser; $context = \CADB\Model\Context::instance(); /** * @brief settting gloabl variables to be used in themes **/ global $user; $this->breadcrumbs = ltrim(substr($uri->uri['appPath'], strlen(CADB_PATH)), '/'); if ($uri->uri['appFile'] != 'index') { $this->breadcrumbs .= "/" . $uri->uri['appFile']; } $this->MyAppClass(); if (isset($this->owner) && !$this->owner) { $this->owner = Acl::imMaster(); } if (!$this->user) { if ($_SESSION['user']) { $user = array_merge($user, $_SESSION['user']); } } else { $user = $this->user; } if ($this->total_cnt) { $this->PageNavigation(); } if ($this->contentType == "redirect") { header("Location: {$this->redirectURI}"); } else { if ($this->params['output'] == "xml" || $this->contentType == "xml") { extract((array) $this); if (file_exists($this->params['controller']['path'] . "/" . $this->params['controller']['file'] . ".xml.php")) { include $this->params['controller']['path'] . "/" . $this->params['controller']['file'] . ".xml.php"; } else { if (file_exists($this->params['controller']['path'] . "/" . $this->params['controller']['process'] . ".xml.php")) { include $this->params['controller']['path'] . "/" . $this->params['controller']['process'] . ".xml.php"; } else { \CADB\Respond::NotFoundPage(true); } } } else { if ($this->params['browserType'] == 'api' || $this->params['output'] == 'json' || $this->contentType == "json") { extract((array) $this); header("Content-Type: application/json; charset=utf-8"); if (file_exists($this->params['controller']['path'] . "/" . $this->params['controller']['file'] . ".json.php")) { include $this->params['controller']['path'] . "/" . $this->params['controller']['file'] . ".json.php"; } else { if (file_exists($this->params['controller']['path'] . "/" . $this->params['controller']['process'] . ".json.php")) { include $this->params['controller']['path'] . "/" . $this->params['controller']['process'] . ".json.php"; } else { print json_encode(array()); } } } else { if (!$this->themes) { $this->themes = $context->getProperty('service.themes'); } if ($this->params['output'] != "nolayout") { /** * @brief default javascript 를 호출. ex jquery **/ // \CADB\View\Resource::addScript("jquery.min.js"); $this->initJs($this->initscript); // \CADB\View\Resource::addScript("defaults.js",-100,array('compress'=>true)); // \CADB\View\Resource::addCss("defaults.css",-100,array('compress'=>true)); /** * @brief resource/css에서 불러오도록 지정된 css들의 경로를 잡아준다. **/ if (@count($this->css)) { foreach ($this->css as $css) { \CADB\View\Resource::addCss($css, 0, array('compress' => true)); } } /** * @brief 해당 controller 경로에 style.css가 있으면 이 경로 밑에 있는 모는 페이지는 이 style.css를 포함한다. **/ if (file_exists($this->params['controller']['path'] . "/style.css")) { \CADB\View\Resource::addCssURI($this->params['controller']['uri'] . "/style.css", 0, array('compress' => true)); } /** * @brief 해당 controller에 매치되는 controller.css가 있으면 포함한다. **/ if (file_exists($this->params['controller']['path'] . "/" . $this->params['controller']['file'] . ".css")) { \CADB\View\Resource::addCssURI($this->params['controller']['uri'] . "/" . $this->params['controller']['file'] . ".css", 0, array('compress' => true)); } /** * @brief resource/script에서 불러오도록 지정된 script들의 경로를 잡아준다. **/ if (@count($this->js)) { foreach ($this->js as $js) { \CADB\View\Resource::addJs($js, 0, array('compress' => true)); } } if (@count($this->react)) { foreach ($this->react as $script) { \CADB\View\Resource::addReact($script, 0, array('compress' => false, 'position' => 'footer')); } } if (@count($this->babel)) { \CADB\Lib\importResource('babel'); foreach ($this->babel as $script) { \CADB\View\Resource::addScript($script, 0, array('compress' => true, 'type' => 'babel')); } } if (@count($this->script)) { foreach ($this->script as $script) { \CADB\View\Resource::addScript($script, 0, array('compress' => true)); } } /** * @brief 해당 controller 경로에 script.js가 있으면 이 경로 밑에 있는 모는 페이지는 이 script.js를 포함한다. **/ if (file_exists($this->params['controller']['path'] . "/script.js")) { \CADB\View\Resource::addJsURI($this->params['controller']['uri'] . "/script.js", 0, array('compress' => true)); } /** * @brief 해당 controller에 매치되는 controller.js가 있으면 포함한다. **/ if (file_exists($this->params['controller']['path'] . "/" . $this->params['controller']['file'] . ".js")) { \CADB\View\Resource::addJsURI($this->params['controller']['uri'] . "/" . $this->params['controller']['file'] . ".js", 0, array('compress' => true)); } /** * @brief themes에 있는 기본 css와 script 들을 가장 먼저 포함한다. **/ $this->initTheme(); if ($this->layout == "admin") { \CADB\Lib\importResource('app-admin'); } if ($html_file = $this->appPath()) { $this->themeCssJs($html_file); } /* FaceBook plugin */ $this->body_start = ''; } extract((array) $this); if ($html_file = $this->appPath()) { ob_start(); include $this->renderPath($html_file); $content = ob_get_contents(); ob_end_clean(); $layout_file = $this->LayoutFile(); } else { \CADB\Respond::NotFoundPage(); } if ($this->params['output'] == "nolayout") { header("Content-Type:text/html; charset=utf-8"); echo $content; } else { /** * @brief make admin theme **/ if ($this->layout == 'admin' && file_exists(CADB_APP_PATH . "/admin/layout.html.php")) { ob_start(); include CADB_APP_PATH . "/admin/layout.html.php"; $content = ob_get_contents(); ob_end_clean(); } /** * @brief make html result using theme layout **/ if ($layout_file) { ob_start(); include $layout_file; $html = ob_get_contents(); ob_end_clean(); print $html; } } } } } }