/** * Creates a link to an application view * * @param sting $view * @param string $index * @return string */ function buildLink($view, $index = false) { if (\Xily\Config::get('app.seo') == 1) { return \Xily\Config::getDir('app.url') . $view . ($index ? '/' . $index : ''); } else { return 'index.php?view=' . $view . ($index ? '&index=' . $index : ''); } }
public function load_view() { $view = array_key_exists('view', $_REQUEST) ? $_REQUEST['view'] : 'login'; if (!in_array($view, $noauth) && !array_key_exists('user', $_SESSION) && !(isset($_REQUEST['user']) && API::validateUser($_REQUEST['user'], isset($_REQUEST['password']) ? $_REQUEST['password'] : ''))) { $view = 'login'; } elseif ($view == 'login') { // If logged-in go directly to the home screen $view = 'home'; } // Check, if there is a controller for the view if (file_exists('controllers/' . $view . '.php')) { include 'controllers/' . $view . '.php'; } $controllerClass = $view . 'Controller'; if (class_exists($controllerClass)) { $controller = new $controllerClass($locator); $xlyPage = $controller->getView(); } else { $file = 'views/' . $view . '.xml'; if (!file_exists($file)) { $file = 'views/404.xml'; } $xlyPage = \Xily\Bean::create($locator->insert(file_get_contents($file))); } if (!$xlyPage->hasAttribute('id')) { $xlyPage->setAttribute('id', $view); } $xlyPage->setDataset($_GET, 'get'); $xlyPage->setDataset(\Xily\Config::getDir('app.url'), 'url'); $xlyPage->setDataset($_POST, 'post'); $xlyPage->setDataset($_REQUEST, 'request'); $xlyPage->locator = $locator; echo $xlyPage->run(); }
// Check if the module has a controller if (file_exists(MODULE_DIR . $view . '/' . $view . '.php')) { include_once MODULE_DIR . $view . '/' . $view . '.php'; } if (class_exists($controllerClass)) { $controller = new $controllerClass($locale); $xlyPage = $controller->getView(); } else { if (file_exists(MODULE_DIR . $view . '/' . $view . '.xml')) { $xlyPage = \Xily\Bean::create($locale->replace(file_get_contents(MODULE_DIR . $view . '/' . $view . '.xml'))); } } } if (!isset($xlyPage)) { $xlyPage = \Xily\Bean::create($locale->replace(file_get_contents(VIEW_DIR . (file_exists(VIEW_DIR . $view . '.xml') ? $view : '404') . '.xml'))); } } if (!$xlyPage->id()) { $xlyPage->setAttribute('id', $view); } $xlyPage->setDataset($_GET, 'get'); $xlyPage->setDataset(\Xily\Config::getDir('app.url'), 'url'); $xlyPage->setDataset($_POST, 'post'); $xlyPage->setDataset($_REQUEST, 'request'); $xlyPage->setAttribute('lang', $locale->getCurrent()); echo $xlyPage->run($xmlMeta); } } catch (Exception $e) { $xlyError = \Xily\Bean::create($locale->replace(file_get_contents(VIEW_DIR . 'error.xml'))); echo $xlyError->run(array('message' => $e->getMessage(), 'file' => $e->getFile(), 'line' => $e->getLine(), 'code' => $e->getCode(), 'trace' => str_replace("\n", '<br />', htmlentities(KickstartErrorTrace($e))))); }