return $text ? 'true' : 'false'; } function text2text($text) { return $text ? $text : 'false'; } function js2bool2text($function) { return '<script type="text/javascript"> document.write(' . $function . '() ? "true" : "false"); </script>'; } function js2text($function) { return '<script type="text/javascript"> var t; if(t = ' . $function . '()) document.write(t); else document.write("false"); </script>'; } echo HTML_Decorator::html_start()->render(); echo Site_Decorator::head()->set_title('MWF About')->render(); echo HTML_Decorator::body_start()->render(); echo Site_Decorator::header()->set_title('MWF Device')->render(); echo Site_Decorator::content_full()->set_padded()->add_header('The Framework')->add_subheader('Server Info')->add_section(label('User Agent') . $_SERVER['HTTP_USER_AGENT'])->add_section(label('IP Address') . $_SERVER['REMOTE_ADDR'])->add_subheader('JS Classification')->add_section(label('mwf.classification.isMobile()') . js2bool2text('mwf.classification.isMobile'))->add_section(label('mwf.classification.isBasic()') . js2bool2text('mwf.classification.isBasic'))->add_section(label('mwf.classification.isStandard()') . js2bool2text('mwf.classification.isStandard'))->add_section(label('mwf.classification.isFull()') . js2bool2text('mwf.classification.isFull'))->add_section(label('mwf.classification.isOverride()') . js2bool2text('mwf.classification.isOverride'))->add_section(label('mwf.classification.isPreview()') . js2bool2text('mwf.classification.isPreview'))->add_subheader('PHP Classification')->add_section(label('Classification::is_mobile()') . bool2text(Classification::is_mobile()))->add_section(label('Classification::is_basic()') . bool2text(Classification::is_basic()))->add_section(label('Classification::is_standard()') . bool2text(Classification::is_standard()))->add_section(label('Classification::is_full()') . bool2text(Classification::is_full()))->add_section(label('Classification::is_override()') . bool2text(Classification::is_override()))->add_section(label('Classification::is_preview()') . bool2text(Classification::is_preview()))->add_subheader('JS User Agent')->add_section(label('mwf.userAgent.getOS()') . js2text('mwf.userAgent.getOS'))->add_section(label('mwf.userAgent.getOSVersion()') . js2text('mwf.userAgent.getOSVersion'))->add_section(label('mwf.userAgent.getBrowser()') . js2text('mwf.userAgent.getBrowser'))->add_section(label('mwf.userAgent.getBrowserEngine()') . js2text('mwf.userAgent.getBrowserEngine'))->add_section(label('mwf.userAgent.getBrowserEngineVersion()') . js2text('mwf.userAgent.getBrowserEngineVersion'))->add_subheader('PHP User Agent')->add_section(label('User_Agent::get_os()') . text2text(User_Agent::get_os()))->add_section(label('User_Agent::get_os_version()') . text2text(User_Agent::get_os_version()))->add_section(label('User_Agent::get_browser()') . text2text(User_Agent::get_browser()))->add_section(label('User_Agent::get_browser_engine()') . text2text(User_Agent::get_browser_engine()))->add_section(label('User_Agent::get_browser_engine_version()') . text2text(User_Agent::get_browser_engine_version()))->add_subheader('JS Screen')->add_section(label('mwf.screen.getHeight()') . js2text('mwf.screen.getHeight'))->add_section(label('mwf.screen.getWidth()') . js2text('mwf.screen.getWidth'))->add_section(label('mwf.screen.getPixelRatio()') . js2text('mwf.screen.getPixelRatio'))->add_subheader('PHP Screen')->add_section(label('Screen::get_height()') . text2text(Screen::get_height()))->add_section(label('Screen::get_width()') . text2text(Screen::get_width()))->add_section(label('Screen::get_pixel_ratio()') . text2text(Screen::get_pixel_ratio()))->render(); echo Site_Decorator::button_full()->set_padded()->add_option(Config::get('global', 'back_to_home_text'), Config::get('global', 'site_url'))->render(); echo Site_Decorator::default_footer()->render(); echo HTML_Decorator::body_end()->render(); echo HTML_Decorator::html_end()->render();
if (isset($_GET['basic']) || isset($_GET['paths'])) { $loadarr = isset($_GET['basic']) ? explode(' ', $_GET['basic']) : array(); // Support for deprecated PATHS parameter. if (isset($_GET['paths'])) { $loadarr = array_merge(explode(' ', $_GET['paths']), $loadarr); } foreach ($loadarr as $file) { if (Path_Validator::is_safe($file, 'css') && ($contents = Path::get_contents($file))) { echo CSSMin::minify($contents); } } } /** * Scripts that will be minified and included at the STANDARD level and above. */ if (Classification::is_standard() && (isset($_GET['standard']) || isset($_GET['touch']))) { $loadarr = isset($_GET['standard']) ? explode(' ', $_GET['standard']) : array(); // Support for deprecated TOUCH parameter. if (isset($_GET['touch'])) { $loadarr = array_merge(explode(' ', $_GET['touch']), $loadarr); } foreach ($loadarr as $file) { if (Path_Validator::is_safe($file, 'css') && ($contents = Path::get_contents($file))) { echo CSSMin::minify($contents); } } } /** * Scripts that will be minified and included at the FULL level only. */ if (Classification::is_full() && (isset($_GET['full']) || isset($_GET['webkit']))) {
if (isset($_GET['webkit_libs'])) { $loadarr = array_merge(explode(' ', $_GET['webkit_libs']), $loadarr); } foreach ($loadarr as $load) { JS::load_from_key($load); } } /** * Load custom JS files (minified) based on user agent. */ if (isset($_GET['basic'])) { foreach (explode(' ', $_GET['basic']) as $file) { if (Path_Validator::is_safe($file, 'js') && ($contents = Path::get_contents($file))) { echo ' ' . JSMin::minify($contents); } } } if (Classification::is_standard() && isset($_GET['standard'])) { foreach (explode(' ', $_GET['standard']) as $file) { if (Path_Validator::is_safe($file, 'js') && ($contents = Path::get_contents($file))) { echo ' ' . JSMin::minify($contents); } } } if (Classification::is_full() && isset($_GET['full'])) { foreach (explode(' ', $_GET['full']) as $file) { if (Path_Validator::is_safe($file, 'js') && ($contents = Path::get_contents($file))) { echo ' ' . JSMin::minify($contents); } } }
/** * Imports a Javascript file (live DOM write of a new script tag) for a * given $key based on device classification. If full, then $key may be * assets/js/full/{$key}{$ext} for any extension $ext in the array $_exts. * If standard, or if full and not in assets/js/full, this it may under * assets/js/standard/{$key}{$ext} for any extension $ext in $_exts. This * returns false if no matching file found. * * * @param string $key * @return bool */ public static function import_key($key) { /** * If full device, check each $_exts as assets/js/full/{$key}{$ext}. * If found, then use import_file() to write a script tag via a live * DOM write. */ if (Classification::is_full()) { foreach (self::$_exts as $ext) { if (self::import_file('full/' . $key . $ext)) { return true; } } } /** * If standard device, or if full device and not already returned, check * each $_exts as assets/js/full/{$key}{$ext}. If found, then use * import_file() to write a script tag via a live DOM write. */ if (Classification::is_standard()) { foreach (self::$_exts as $ext) { if (self::import_file('standard/' . $key . $ext)) { return true; } } } return false; }