/** * Page loading function * --------------------- * $options = array( * 'title' => string, - Page title * 'no-robots', - Disable crawlers (that respect meta tags) * 'no-default-css', - Disable loading of default CSS files * 'no-default-js' - Disable loading of default JS files * 'css' => string|array, - Specify a single/multiple CSS files to load * 'js' => string|array, - Specify a single/multiple JS files to load * 'view' => string, - Which view file to open (defaults to $do) * 'do-css', - Load the CSS file whose name matches $do * 'do-js', - Load the JS file whose name matches $do * 'url' => string, - A URL which will replace the one sent to the browser * ); * * @param array $options */ static function loadPage($options) { // Page <title> if (isset($options['title'])) { $GLOBALS['title'] = $options['title']; } // Page heading if (isset($options['heading'])) { $GLOBALS['heading'] = $options['heading']; } // SE crawling disable if (in_array('no-robots', $options)) { $norobots = true; } // Set new URL option if (!empty($options['url'])) { $redirectto = $options['url']; } # CSS $DEFAULT_CSS = array('theme'); $customCSS = array(); // Only add defaults when needed if (array_search('no-default-css', $options) === false) { $customCSS = array_merge($customCSS, $DEFAULT_CSS); } # JavaScript $DEFAULT_JS = array('moment', 'global', 'dialog'); $customJS = array(); // Only add defaults when needed if (array_search('no-default-js', $options) === false) { $customJS = array_merge($customJS, $DEFAULT_JS); } # Check assests self::_checkAssets($options, $customCSS, 'scss/min', 'css'); self::_checkAssets($options, $customJS, 'js/min', 'js'); # Import global variables foreach ($GLOBALS as $k => $v) { if (!isset(${$k})) { ${$k} = $v; } } # Putting it together $view = empty($options['view']) ? $GLOBALS['do'] : $options['view']; $viewPath = INCPATH . "views/{$view}.php"; header('Content-Type: text/html; charset=utf-8;'); if (empty($_GET['via-js'])) { ob_start(); require INCPATH . 'views/header.php'; require $viewPath; require INCPATH . 'views/footer.php'; $content = ob_get_clean(); echo self::_clearIndentation($content); die; } else { $_SERVER['REQUEST_URI'] = rtrim(str_replace('via-js=true', '', CSRFProtection::removeParamFromURL($_SERVER['REQUEST_URI'])), '?&'); ob_start(); require INCPATH . 'views/sidebar.php'; $sidebar = ob_get_clean(); ob_start(); require $viewPath; $content = ob_get_clean(); Response::done(array('css' => $customCSS, 'js' => $customJS, 'title' => (isset($GLOBALS['title']) ? $GLOBALS['title'] . ' - ' : '') . SITE_TITLE, 'content' => self::_clearIndentation($content), 'sidebar' => self::_clearIndentation($sidebar), 'footer' => CoreUtils::getFooter(WITH_GIT_INFO), 'avatar' => $GLOBALS['signedIn'] ? $GLOBALS['currentUser']->avatar_url : GUEST_AVATAR, 'responseURL' => $_SERVER['REQUEST_URI'], 'signedIn' => $GLOBALS['signedIn'])); } }
<?php use App\CoreUtils; ?> </div> <footer><?php echo CoreUtils::getFooter(); ?> </footer> <script src="https://code.jquery.com/jquery-3.1.0.min.js" integrity="sha256-cCueBR6CsyA4/9szpPfrX3s49M9vUU5BgtiJj06wt/s=" crossorigin="anonymous"></script> <script>if(!window.jQuery)document.write('\x3Cscript src="/js/min/jquery-3.1.0.js">\x3C/script>');</script> <?php echo CoreUtils::exportVars(array('PRINTABLE_ASCII_PATTERN' => PRINTABLE_ASCII_PATTERN, 'DocReady' => array(), 'signedIn' => $signedIn)); if (isset($customJS)) { foreach ($customJS as $js) { echo "<script src='{$js}'></script>\n"; } } ?> </body> </html>