/** * Initialization */ public function init() { parent::init(); $this->app->jquery = $this; if (!$this->app->template) { return; } if (!$this->app->template->is_set('js_include')) { throw $this->exception('Tag js_include must be defined in shared.html'); } if (!$this->app->template->is_set('document_ready')) { throw $this->exception('Tag document_ready must be defined in shared.html'); } $this->app->template->del('js_include'); /* $config['js']['jquery']='https://code.jquery.com/jquery-2.1.4.min.js'; // to use CDN */ if ($v = $this->app->getConfig('js/versions/jquery', null)) { $v = 'jquery-' . $v; } else { $v = $this->app->getConfig('js/jquery', 'jquery-2.2.1.min'); // bundled jQuery version } $this->addInclude($v); // Controllers are not rendered, but we need to do some stuff manually $this->app->addHook('pre-render-output', array($this, 'postRender')); $this->app->addHook('cut-output', array($this, 'cutRender')); }
public function isCurrent($href) { // returns true if item being added is current if (!is_object($href)) { $href = str_replace('/', '_', $href); } return $href == $this->app->page || $href == ';' . $this->app->page || $href . $this->app->getConfig('url_postfix', '') == $this->app->page || (string) $href == (string) $this->app->url(); }
/** * Adds default includes */ public function addDefaultIncludes() { $this->addInclude('start-atk4'); /* $config['js']['jqueryui']='https://code.jquery.com/ui/1.11.4/jquery-ui.min.js'; // to use CDN */ if ($v = $this->app->getConfig('js/versions/jqueryui', null)) { $v = 'jquery-ui-' . $v; } else { $v = $this->app->getConfig('js/jqueryui', 'jquery-ui-1.11.4.min'); // bundled jQueryUI version } $this->addInclude($v); $this->addInclude('ui.atk4_loader'); $this->addInclude('ui.atk4_notify'); $this->addInclude('atk4_univ_basic'); $this->addInclude('atk4_univ_jui'); }
public function initializeSession($create = true) { if ($this->_is_session_initialized || session_id()) { return; } // Change settings if defined in settings file $params = session_get_cookie_params(); $params['httponly'] = true; // true by default foreach ($params as $key => $default) { $params[$key] = $this->app->getConfig('session/' . $key, $default); } if ($create === false && !isset($_COOKIE[$this->name])) { return; } $this->_is_session_initialized = true; session_set_cookie_params($params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']); session_name($this->name); session_start(); }
/** * Detect server environment and tries to guess absolute and relative * URLs to your application. * * See docs: doc/application/routing/parsing */ public function parseRequestedURL() { // This is the re-constructions of teh proper URL. // 1. Schema $url = $this->app->getConfig('atk/base_url', null); if (is_null($url)) { // Detect it $url = 'http'; $https = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' || $_SERVER['SERVER_PORT'] == 443; if ($https) { $url .= 's'; } // 2. Continue building. We are adding hostname next and port. $url .= '://' . $_SERVER['SERVER_NAME']; //if($_SERVER["SERVER_PORT"]!="80")$url .= ":".$_SERVER['SERVER_PORT']; if ($_SERVER['SERVER_PORT'] == '80' && !$https || $_SERVER['SERVER_PORT'] == '443' && $https) { } else { $url .= ':' . $_SERVER['SERVER_PORT']; } } // We have now arrived at base_url as defined $this->base_url = $url; // 3. Next we need a base_part of our URL. There are many different // variables and approaches we tried it, REDIRECT_URL_ROOT, REDIRECT_URL, // etc, however most reliable is $this->unix_dirname(SCRIPT_NAME) $path = $this->unix_dirname($_SERVER['SCRIPT_NAME']); if (substr($path, -1) != '/') { $path .= '/'; } // We have now arrived at base_path as defined $this->base_path = $path; // 4. We now look at RequestURI and extract base_path from the beginning if (isset($_GET['page'])) { $page = $_GET['page']; $this->page = $page; } else { $request_uri = $this->getRequestURI(); if (strpos($request_uri, $path) !== 0) { throw $this->exception('URL matching problem')->addMoreInfo('RequestURI', $request_uri)->addMoreInfo('BasePath', $path); } $page = substr($request_uri, strlen($path)); if (!$page) { $page = 'index'; } // Preserve actual page $this->page = $page; // Remove postfix from page if any $page = preg_replace('/\\..*$/', '', $page); $page = preg_replace('/\\/$/', '', $page); $page = str_replace('/', '_', $page); if (substr($page, -1) == '_') { $page = substr($page, 0, -1); } } if (strpos($page, '.') !== false) { throw $this->exception('Page may not contain periods (.)')->addMoreInfo('page', $page); } // We have now arrived at the page as per specification. $this->app->page = str_replace('/', '_', $page); $this->template_filename = $this->app->page; if (substr($this->template_filename, -1) == '/') { $this->template_filename .= 'index'; } }
public function isCurrent($href) { // returns true if item being added is current $href = str_replace('/', '_', $href); return $href == $this->app->page || $href == ';' . $this->app->page || $href . $this->app->getConfig('url_postfix', '') == $this->app->page; }