/** * @dataProvider user_agents_providers */ public function test_useragent_ie($useragent, $tests) { // Setup the core_useragent instance. core_useragent::instance(true, $useragent); // IE Tests. if (isset($tests['is_ie']) && $tests['is_ie']) { $this->assertTrue(core_useragent::is_ie()); } else { $this->assertFalse(core_useragent::is_ie()); } $versions = array('0' => false, '5.0' => false, '5.5' => false, '6.0' => false, '7.0' => false, '8.0' => false, '9.0' => false, '10' => false, '11' => false, '12' => false, '13' => false, '14' => false); if (isset($tests['check_ie_version'])) { // The test provider has overwritten some of the above checks. // Must use the '+' operator, because array_merge will incorrectly rewrite the array keys for integer-based indexes. $versions = $tests['check_ie_version'] + $versions; } foreach ($versions as $version => $result) { $this->assertEquals($result, core_useragent::check_ie_version($version), "Version incorrectly determined for IE version '{$version}'"); } // IE Compatibility mode. if (isset($tests['iecompatibility']) && $tests['iecompatibility']) { $this->assertTrue(core_useragent::check_ie_compatibility_view(), "IE Compability false negative"); } else { $this->assertFalse(core_useragent::check_ie_compatibility_view(), "IE Compability false positive"); } }
protected function is_legacy_browser() { // IE8 and IE9 are the only supported browsers that do not have spellchecker. if (core_useragent::is_ie() and !core_useragent::check_ie_version(10)) { return true; } // The rest of browsers supports spellchecking or is horribly outdated and we do not care... return false; }
/** * Handles the sending of file data to the user's browser, including support for * byteranges etc. * * The $options parameter supports the following keys: * (string|null) preview - send the preview of the file (e.g. "thumb" for a thumbnail) * (string|null) filename - overrides the implicit filename * (bool) dontdie - return control to caller afterwards. this is not recommended and only used for cleanup tasks. * if this is passed as true, ignore_user_abort is called. if you don't want your processing to continue on cancel, * you must detect this case when control is returned using connection_aborted. Please not that session is closed * and should not be reopened * (string|null) cacheability - force the cacheability setting of the HTTP response, "private" or "public", * when $lifetime is greater than 0. Cacheability defaults to "private" when logged in as other than guest; otherwise, * defaults to "public". * * @category files * @param stored_file $stored_file local file object * @param int $lifetime Number of seconds before the file should expire from caches (null means $CFG->filelifetime) * @param int $filter 0 (default)=no filtering, 1=all files, 2=html files only * @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin * @param array $options additional options affecting the file serving * @return null script execution stopped unless $options['dontdie'] is true */ function send_stored_file($stored_file, $lifetime = null, $filter = 0, $forcedownload = false, array $options = array()) { global $CFG, $COURSE; if (empty($options['filename'])) { $filename = null; } else { $filename = $options['filename']; } if (empty($options['dontdie'])) { $dontdie = false; } else { $dontdie = true; } if ($lifetime === 'default' or is_null($lifetime)) { $lifetime = $CFG->filelifetime; } if (!empty($options['preview'])) { // replace the file with its preview $fs = get_file_storage(); $preview_file = $fs->get_file_preview($stored_file, $options['preview']); if (!$preview_file) { // unable to create a preview of the file, send its default mime icon instead if ($options['preview'] === 'tinyicon') { $size = 24; } else { if ($options['preview'] === 'thumb') { $size = 90; } else { $size = 256; } } $fileicon = file_file_icon($stored_file, $size); send_file($CFG->dirroot . '/pix/' . $fileicon . '.png', basename($fileicon) . '.png'); } else { // preview images have fixed cache lifetime and they ignore forced download // (they are generated by GD and therefore they are considered reasonably safe). $stored_file = $preview_file; $lifetime = DAYSECS; $filter = 0; $forcedownload = false; } } // handle external resource if ($stored_file && $stored_file->is_external_file() && !isset($options['sendcachedexternalfile'])) { $stored_file->send_file($lifetime, $filter, $forcedownload, $options); die; } if (!$stored_file or $stored_file->is_directory()) { // nothing to serve if ($dontdie) { return; } die; } if ($dontdie) { ignore_user_abort(true); } \core\session\manager::write_close(); // Unlock session during file serving. $filename = is_null($filename) ? $stored_file->get_filename() : $filename; // Use given MIME type if specified. $mimetype = $stored_file->get_mimetype(); // Otherwise guess it. if (!$mimetype || $mimetype === 'document/unknown') { $mimetype = get_mimetype_for_sending($filename); } // if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup if (core_useragent::is_ie()) { $filename = rawurlencode($filename); } if ($forcedownload) { header('Content-Disposition: attachment; filename="' . $filename . '"'); } else { if ($mimetype !== 'application/x-shockwave-flash') { // If this is an swf don't pass content-disposition with filename as this makes the flash player treat the file // as an upload and enforces security that may prevent the file from being loaded. header('Content-Disposition: inline; filename="' . $filename . '"'); } } if ($lifetime > 0) { $cacheability = ' public,'; if (!empty($options['cacheability']) && $options['cacheability'] === 'public') { // This file must be cache-able by both browsers and proxies. $cacheability = ' public,'; } else { if (!empty($options['cacheability']) && $options['cacheability'] === 'private') { // This file must be cache-able only by browsers. $cacheability = ' private,'; } else { if (isloggedin() and !isguestuser()) { $cacheability = ' private,'; } } } header('Cache-Control:' . $cacheability . ' max-age=' . $lifetime . ', no-transform'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $lifetime) . ' GMT'); header('Pragma: '); } else { // Do not cache files in proxies and browsers if (is_https()) { // HTTPS sites - watch out for IE! KB812935 and KB316431. header('Cache-Control: private, max-age=10, no-transform'); header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT'); header('Pragma: '); } else { //normal http - prevent caching at all cost header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0, no-transform'); header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT'); header('Pragma: no-cache'); } } // Allow cross-origin requests only for Web Services. // This allow to receive requests done by Web Workers or webapps in different domains. if (WS_SERVER) { header('Access-Control-Allow-Origin: *'); } if (empty($filter)) { // send the contents readfile_accel($stored_file, $mimetype, !$dontdie); } else { // Try to put the file through filters if ($mimetype == 'text/html' || $mimetype == 'application/xhtml+xml') { $options = new stdClass(); $options->noclean = true; $options->nocache = true; // temporary workaround for MDL-5136 $text = $stored_file->get_content(); $text = file_modify_html_header($text); $output = format_text($text, FORMAT_HTML, $options, $COURSE->id); readstring_accel($output, $mimetype, false); } else { if ($mimetype == 'text/plain' and $filter == 1) { // only filter text if filter all files is selected $options = new stdClass(); $options->newlines = false; $options->noclean = true; $text = $stored_file->get_content(); $output = '<pre>' . format_text($text, FORMAT_MOODLE, $options, $COURSE->id) . '</pre>'; readstring_accel($output, $mimetype, false); } else { // Just send it out raw readfile_accel($stored_file, $mimetype, !$dontdie); } } } if ($dontdie) { return; } die; //no more chars to output!!! }
/** * Handles the sending of file data to the user's browser, including support for * byteranges etc. * * The $options parameter supports the following keys: * (string|null) preview - send the preview of the file (e.g. "thumb" for a thumbnail) * (string|null) filename - overrides the implicit filename * (bool) dontdie - return control to caller afterwards. this is not recommended and only used for cleanup tasks. * if this is passed as true, ignore_user_abort is called. if you don't want your processing to continue on cancel, * you must detect this case when control is returned using connection_aborted. Please not that session is closed * and should not be reopened. * * @category files * @param stored_file $stored_file local file object * @param int $lifetime Number of seconds before the file should expire from caches (null means $CFG->filelifetime) * @param int $filter 0 (default)=no filtering, 1=all files, 2=html files only * @param bool $forcedownload If true (default false), forces download of file rather than view in browser/plugin * @param array $options additional options affecting the file serving * @return null script execution stopped unless $options['dontdie'] is true */ function send_stored_file($stored_file, $lifetime = null, $filter = 0, $forcedownload = false, array $options = array()) { global $CFG, $COURSE; if (empty($options['filename'])) { $filename = null; } else { $filename = $options['filename']; } if (empty($options['dontdie'])) { $dontdie = false; } else { $dontdie = true; } if ($lifetime === 'default' or is_null($lifetime)) { $lifetime = $CFG->filelifetime; } if (!empty($options['preview'])) { // replace the file with its preview $fs = get_file_storage(); $preview_file = $fs->get_file_preview($stored_file, $options['preview']); if (!$preview_file) { // unable to create a preview of the file, send its default mime icon instead if ($options['preview'] === 'tinyicon') { $size = 24; } else { if ($options['preview'] === 'thumb') { $size = 90; } else { $size = 256; } } $fileicon = file_file_icon($stored_file, $size); send_file($CFG->dirroot . '/pix/' . $fileicon . '.png', basename($fileicon) . '.png'); } else { // preview images have fixed cache lifetime and they ignore forced download // (they are generated by GD and therefore they are considered reasonably safe). $stored_file = $preview_file; $lifetime = DAYSECS; $filter = 0; $forcedownload = false; } } // handle external resource if ($stored_file && $stored_file->is_external_file() && !isset($options['sendcachedexternalfile'])) { $stored_file->send_file($lifetime, $filter, $forcedownload, $options); die; } if (!$stored_file or $stored_file->is_directory()) { // nothing to serve if ($dontdie) { return; } die; } if ($dontdie) { ignore_user_abort(true); } \core\session\manager::write_close(); // Unlock session during file serving. // Use given MIME type if specified, otherwise guess it using mimeinfo. // IE, Konqueror and Opera open html file directly in browser from web even when directed to save it to disk :-O // only Firefox saves all files locally before opening when content-disposition: attachment stated $filename = is_null($filename) ? $stored_file->get_filename() : $filename; $isFF = core_useragent::is_firefox(); // only FF properly tested $mimetype = ($forcedownload and !$isFF) ? 'application/x-forcedownload' : ($stored_file->get_mimetype() ? $stored_file->get_mimetype() : mimeinfo('type', $filename)); // if user is using IE, urlencode the filename so that multibyte file name will show up correctly on popup if (core_useragent::is_ie()) { $filename = rawurlencode($filename); } if ($forcedownload) { header('Content-Disposition: attachment; filename="' . $filename . '"'); } else { header('Content-Disposition: inline; filename="' . $filename . '"'); } if ($lifetime > 0) { $private = ''; if (isloggedin() and !isguestuser()) { $private = ' private,'; } header('Cache-Control:' . $private . ' max-age=' . $lifetime . ', no-transform'); header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $lifetime) . ' GMT'); header('Pragma: '); } else { // Do not cache files in proxies and browsers if (strpos($CFG->wwwroot, 'https://') === 0) { //https sites - watch out for IE! KB812935 and KB316431 header('Cache-Control: private, max-age=10, no-transform'); header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT'); header('Pragma: '); } else { //normal http - prevent caching at all cost header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0, no-transform'); header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT'); header('Pragma: no-cache'); } } if (empty($filter)) { // send the contents readfile_accel($stored_file, $mimetype, !$dontdie); } else { // Try to put the file through filters if ($mimetype == 'text/html') { $options = new stdClass(); $options->noclean = true; $options->nocache = true; // temporary workaround for MDL-5136 $text = $stored_file->get_content(); $text = file_modify_html_header($text); $output = format_text($text, FORMAT_HTML, $options, $COURSE->id); readstring_accel($output, $mimetype, false); } else { if ($mimetype == 'text/plain' and $filter == 1) { // only filter text if filter all files is selected $options = new stdClass(); $options->newlines = false; $options->noclean = true; $text = $stored_file->get_content(); $output = '<pre>' . format_text($text, FORMAT_MOODLE, $options, $COURSE->id) . '</pre>'; readstring_accel($output, $mimetype, false); } else { // Just send it out raw readfile_accel($stored_file, $mimetype, !$dontdie); } } } if ($dontdie) { return; } die; //no more chars to output!!! }
/** * Will get called before the login page is shownr. Ff NTLM SSO * is enabled, and the user is in the right network, we'll redirect * to the magic NTLM page for SSO... * */ function loginpage_hook() { global $CFG, $SESSION; // HTTPS is potentially required //httpsrequired(); - this must be used before setting the URL, it is already done on the login/index.php if (($_SERVER['REQUEST_METHOD'] === 'GET' || $_SERVER['REQUEST_METHOD'] === 'POST' && get_local_referer() != strip_querystring(qualified_me())) && !empty($this->config->ntlmsso_enabled) && !empty($this->config->ntlmsso_subnet) && empty($_GET['authldap_skipntlmsso']) && (isguestuser() || !isloggedin()) && address_in_subnet(getremoteaddr(), $this->config->ntlmsso_subnet)) { // First, let's remember where we were trying to get to before we got here if (empty($SESSION->wantsurl)) { $SESSION->wantsurl = null; $referer = get_local_referer(false); if ($referer && $referer != $CFG->wwwroot && $referer != $CFG->wwwroot . '/' && $referer != $CFG->httpswwwroot . '/login/' && $referer != $CFG->httpswwwroot . '/login/index.php') { $SESSION->wantsurl = $referer; } } // Now start the whole NTLM machinery. if ($this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESATTEMPT || $this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESFORM) { if (core_useragent::is_ie()) { $sesskey = sesskey(); redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_magic.php?sesskey=' . $sesskey); } else { if ($this->config->ntlmsso_ie_fastpath == AUTH_NTLM_FASTPATH_YESFORM) { redirect($CFG->httpswwwroot . '/login/index.php?authldap_skipntlmsso=1'); } } } redirect($CFG->wwwroot . '/auth/ldap/ntlmsso_attempt.php'); } // No NTLM SSO, Use the normal login page instead. // If $SESSION->wantsurl is empty and we have a 'Referer:' header, the login // page insists on redirecting us to that page after user validation. If // we clicked on the redirect link at the ntlmsso_finish.php page (instead // of waiting for the redirection to happen) then we have a 'Referer:' header // we don't want to use at all. As we can't get rid of it, just point // $SESSION->wantsurl to $CFG->wwwroot (after all, we came from there). if (empty($SESSION->wantsurl) && get_local_referer() == $CFG->httpswwwroot . '/auth/ldap/ntlmsso_finish.php') { $SESSION->wantsurl = $CFG->wwwroot; } }
/** * Get the stylesheet URL of this theme. * * @param moodle_page $page Not used... deprecated? * @return moodle_url[] */ public function css_urls(moodle_page $page) { global $CFG; $rev = theme_get_revision(); $urls = array(); $svg = $this->use_svg_icons(); $separate = core_useragent::is_ie() && !core_useragent::check_ie_version('10'); if ($rev > -1) { $url = new moodle_url("{$CFG->httpswwwroot}/theme/styles.php"); if (!empty($CFG->slasharguments)) { $slashargs = ''; if (!$svg) { // We add a simple /_s to the start of the path. // The underscore is used to ensure that it isn't a valid theme name. $slashargs .= '/_s' . $slashargs; } $slashargs .= '/' . $this->name . '/' . $rev . '/all'; if ($separate) { $slashargs .= '/chunk0'; } $url->set_slashargument($slashargs, 'noparam', true); } else { $params = array('theme' => $this->name, 'rev' => $rev, 'type' => 'all'); if (!$svg) { // We add an SVG param so that we know not to serve SVG images. // We do this because all modern browsers support SVG and this param will one day be removed. $params['svg'] = '0'; } if ($separate) { $params['chunk'] = '0'; } $url->params($params); } $urls[] = $url; } else { $baseurl = new moodle_url($CFG->httpswwwroot . '/theme/styles_debug.php'); $css = $this->get_css_files(true); if (!$svg) { // We add an SVG param so that we know not to serve SVG images. // We do this because all modern browsers support SVG and this param will one day be removed. $baseurl->param('svg', '0'); } if ($separate) { // We might need to chunk long files. $baseurl->param('chunk', '0'); } if (core_useragent::is_ie()) { // Lalala, IE does not allow more than 31 linked CSS files from main document. $urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'ie', 'subtype' => 'plugins')); foreach ($css['parents'] as $parent => $sheets) { // We need to serve parents individually otherwise we may easily exceed the style limit IE imposes (4096). $urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'ie', 'subtype' => 'parents', 'sheet' => $parent)); } if (!empty($this->lessfile)) { // No need to define the type as IE here. $urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'less')); } $urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'ie', 'subtype' => 'theme')); } else { foreach ($css['plugins'] as $plugin => $unused) { $urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'plugin', 'subtype' => $plugin)); } foreach ($css['parents'] as $parent => $sheets) { foreach ($sheets as $sheet => $unused2) { $urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'parent', 'subtype' => $parent, 'sheet' => $sheet)); } } foreach ($css['theme'] as $sheet => $filename) { if ($sheet === $this->lessfile) { // This is the theme LESS file. $urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'less')); } else { // Sheet first in order to make long urls easier to read. $urls[] = new moodle_url($baseurl, array('sheet' => $sheet, 'theme' => $this->name, 'type' => 'theme')); } } } } return $urls; }
* Configuration for Moodle's bootstrap theme. * * DO NOT MODIFY THIS THEME! * COPY IT FIRST, THEN RENAME THE COPY AND MODIFY IT INSTEAD. * * For full information about creating Moodle themes, see: * http://docs.moodle.org/dev/Themes_2.0 * * @package theme_bootstrapbase * @copyright 2013 Bas Brands. www.sonsbeekmedia.nl * @author Bas Brands * @author David Scotson * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ $THEME->doctype = 'html5'; $THEME->yuicssmodules = array(); $THEME->name = 'bootstrapbase'; $THEME->parents = array(); $THEME->sheets = array('moodle'); $THEME->supportscssoptimisation = false; $THEME->enable_dock = false; $THEME->editor_sheets = array('editor'); $THEME->rendererfactory = 'theme_overridden_renderer_factory'; $THEME->layouts = array('base' => array('file' => 'columns1.php', 'regions' => array()), 'standard' => array('file' => 'columns3.php', 'regions' => array('side-pre', 'side-post'), 'defaultregion' => 'side-pre'), 'course' => array('file' => 'columns3.php', 'regions' => array('side-pre', 'side-post'), 'defaultregion' => 'side-pre', 'options' => array('langmenu' => true)), 'coursecategory' => array('file' => 'columns3.php', 'regions' => array('side-pre', 'side-post'), 'defaultregion' => 'side-pre'), 'incourse' => array('file' => 'columns3.php', 'regions' => array('side-pre', 'side-post'), 'defaultregion' => 'side-pre'), 'frontpage' => array('file' => 'columns3.php', 'regions' => array('side-pre', 'side-post'), 'defaultregion' => 'side-pre', 'options' => array('nonavbar' => true)), 'admin' => array('file' => 'columns2.php', 'regions' => array('side-pre'), 'defaultregion' => 'side-pre'), 'mydashboard' => array('file' => 'columns3.php', 'regions' => array('side-pre', 'side-post'), 'defaultregion' => 'side-pre', 'options' => array('langmenu' => true)), 'mypublic' => array('file' => 'columns3.php', 'regions' => array('side-pre', 'side-post'), 'defaultregion' => 'side-pre'), 'login' => array('file' => 'columns1.php', 'regions' => array(), 'options' => array('langmenu' => true)), 'popup' => array('file' => 'popup.php', 'regions' => array(), 'options' => array('nofooter' => true, 'nonavbar' => true)), 'frametop' => array('file' => 'columns1.php', 'regions' => array(), 'options' => array('nofooter' => true, 'nocoursefooter' => true)), 'embedded' => array('file' => 'embedded.php', 'regions' => array()), 'maintenance' => array('file' => 'maintenance.php', 'regions' => array()), 'print' => array('file' => 'columns1.php', 'regions' => array(), 'options' => array('nofooter' => true, 'nonavbar' => false)), 'redirect' => array('file' => 'embedded.php', 'regions' => array()), 'report' => array('file' => 'columns2.php', 'regions' => array('side-pre'), 'defaultregion' => 'side-pre'), 'secure' => array('file' => 'secure.php', 'regions' => array('side-pre', 'side-post'), 'defaultregion' => 'side-pre')); $THEME->javascripts = array(); $THEME->javascripts_footer = array('moodlebootstrap', 'dock'); if (core_useragent::is_ie() && !core_useragent::check_ie_version('9.0')) { $THEME->javascripts[] = 'html5shiv'; } $THEME->hidefromselector = true; $THEME->blockrtlmanipulations = array('side-pre' => 'side-post', 'side-post' => 'side-pre');
public function list_supported_urls(array $urls, array $options = array()) { $extensions = $this->get_supported_extensions(); $result = array(); foreach ($urls as $url) { $ext = core_media::get_extension($url); if (in_array($ext, $extensions)) { if ($ext === 'ogg' || $ext === 'oga') { // Formats .ogg and .oga are not supported in IE, Edge, or Safari. if (core_useragent::is_ie() || core_useragent::is_edge() || core_useragent::is_safari()) { continue; } } else { // Formats .aac, .mp3, and .m4a are not supported in Opera. if (core_useragent::is_opera()) { continue; } // Formats .mp3 and .m4a were not reliably supported in Firefox before 27. // https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats // has the details. .aac is still not supported. if (core_useragent::is_firefox() && ($ext === 'aac' || !core_useragent::check_firefox_version(27))) { continue; } } // Old Android versions (pre 2.3.3) 'support' audio tag but no codecs. if (core_useragent::is_webkit_android() && !core_useragent::is_webkit_android('533.1')) { continue; } $result[] = $url; } } return $result; }
/** * Close the Moodle Workbook */ public function close() { global $CFG; foreach ($this->objPHPExcel->getAllSheets() as $sheet) { $sheet->setSelectedCells('A1'); } $this->objPHPExcel->setActiveSheetIndex(0); $filename = preg_replace('/\\.xlsx?$/i', '', $this->filename); $mimetype = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'; $filename = $filename . '.xlsx'; if (is_https()) { // HTTPS sites - watch out for IE! KB812935 and KB316431. header('Cache-Control: max-age=10'); header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT'); header('Pragma: '); } else { //normal http - prevent caching at all cost header('Cache-Control: private, must-revalidate, pre-check=0, post-check=0, max-age=0'); header('Expires: ' . gmdate('D, d M Y H:i:s', 0) . ' GMT'); header('Pragma: no-cache'); } if (core_useragent::is_ie()) { $filename = rawurlencode($filename); } else { $filename = s($filename); } header('Content-Type: ' . $mimetype); header('Content-Disposition: attachment;filename="' . $filename . '"'); $objWriter = PHPExcel_IOFactory::createWriter($this->objPHPExcel, $this->type); $objWriter->save('php://output'); }
public function list_supported_urls(array $urls, array $options = array()) { $extensions = $this->get_supported_extensions(); $result = array(); foreach ($urls as $url) { $ext = core_media::get_extension($url); if (in_array($ext, $extensions)) { if ($ext === 'ogg' || $ext === 'oga') { // Formats .ogg and .oga are not supported in IE or Safari. if (core_useragent::is_ie() || core_useragent::is_safari()) { continue; } } else { // Formats .aac, .mp3, and .m4a are not supported in Firefox or Opera. if (core_useragent::is_firefox() || core_useragent::is_opera()) { continue; } } // Old Android versions (pre 2.3.3) 'support' audio tag but no codecs. if (core_useragent::is_webkit_android() && !core_useragent::is_webkit_android('533.1')) { continue; } $result[] = $url; } } return $result; }
$PAGE->https_required(); $PAGE->set_context(context_system::instance()); $authsequence = get_enabled_auth_plugins(true); // auths, in sequence if (!in_array('ldap', $authsequence, true)) { print_error('ldap_isdisabled', 'auth'); } $authplugin = get_auth_plugin('ldap'); if (empty($authplugin->config->ntlmsso_enabled)) { print_error('ntlmsso_isdisabled', 'auth_ldap'); } $sesskey = required_param('sesskey', PARAM_RAW); $file = $CFG->dirroot . '/pix/spacer.gif'; if ($authplugin->ntlmsso_magic($sesskey) && file_exists($file)) { if (!empty($authplugin->config->ntlmsso_ie_fastpath)) { if (core_useragent::is_ie()) { // $PAGE->https_required() up above takes care of what $CFG->httpswwwroot should be. redirect($CFG->httpswwwroot . '/auth/ldap/ntlmsso_finish.php'); } } // Serve GIF // Type header('Content-Type: image/gif'); header('Content-Length: ' . filesize($file)); // Output file $handle = fopen($file, 'r'); fpassthru($handle); fclose($handle); exit; } else { print_error('ntlmsso_iwamagicnotenabled', 'auth_ldap');
/** * Creates the block's main content * * @return string */ public function get_content() { global $USER, $OUTPUT, $CFG; if (isset($this->content)) { return $this->content; } // Establish settings variables based on instance config. $showserverclock = !isset($this->config->show_clocks) || $this->config->show_clocks == B_SIMPLE_CLOCK_SHOW_BOTH || $this->config->show_clocks == B_SIMPLE_CLOCK_SHOW_SERVER_ONLY; $showuserclock = !isset($this->config->show_clocks) || $this->config->show_clocks == B_SIMPLE_CLOCK_SHOW_BOTH || $this->config->show_clocks == B_SIMPLE_CLOCK_SHOW_USER_ONLY; $showicons = !isset($this->config->show_icons) || $this->config->show_icons == 1; $showseconds = isset($this->config->show_seconds) && $this->config->show_seconds == 1; $showday = isset($this->config->show_day) && $this->config->show_day == 1; $show24hrtime = isset($this->config->twenty_four_hour_time) && $this->config->twenty_four_hour_time == 1; // Start the content, which is primarily a table. $this->content = new stdClass(); $this->content->text = ''; $this->content->footer = ''; $table = new html_table(); $table->attributes = array('class' => 'clockTable'); // First item added is the server's clock. if ($showserverclock) { $row = array(); if ($showicons) { $alt = get_string('server', 'block_simple_clock'); $usingie = false; if (class_exists('core_useragent')) { $usingie = core_useragent::is_ie(); } else { $usingie = check_browser_version('MSIE'); } if ($usingie) { $servericon = $OUTPUT->pix_icon('server', $alt, 'block_simple_clock'); } else { $servericon = $OUTPUT->pix_icon('favicon', $alt, 'theme'); } $row[] = $servericon; } $row[] = get_string('server', 'block_simple_clock') . ':'; $attributes = array(); $attributes['class'] = 'clock'; $attributes['id'] = 'block_progress_serverTime'; $attributes['value'] = get_string('loading', 'block_simple_clock'); $row[] = HTML_WRITER::empty_tag('input', $attributes); $table->data[] = $row; } // Next item is the user's clock. if ($showuserclock) { $row = array(); if ($showicons) { if ($USER->id != 0) { $userpictureparams = array('size' => 16, 'link' => false, 'alt' => 'User'); $userpicture = $OUTPUT->user_picture($USER, $userpictureparams); $row[] = $userpicture; } else { $row[] = ''; } } $row[] = get_string('you', 'block_simple_clock') . ':'; $attributes = array(); $attributes['class'] = 'clock'; $attributes['id'] = 'block_progress_youTime'; $attributes['value'] = get_string('loading', 'block_simple_clock'); $row[] = HTML_WRITER::empty_tag('input', $attributes); $table->data[] = $row; } $this->content->text .= HTML_WRITER::table($table); // Set up JavaScript code needed to keep the clock going. $noscriptstring = get_string('javascript_disabled', 'block_simple_clock'); $this->content->text .= HTML_WRITER::tag('noscript', $noscriptstring); if ($CFG->timezone != 99) { // Ensure that the Moodle timezone is set correctly. $date = new DateTime('now', new DateTimeZone(core_date::normalise_timezone($CFG->timezone))); $moodletimeoffset = $date->getOffset(); // + dst_offset_on(time(), $CFG->timezone); $servertimeoffset = date_offset_get(new DateTime()); $timearray = localtime(time() + $moodletimeoffset - $servertimeoffset, true); } else { // Ensure that the server timezone is set. // From 2.9 onwards, this should never happen. $timearray = localtime(time(), true); } $arguments = array($showserverclock, $showuserclock, $showseconds, $showday, $show24hrtime, $timearray['tm_year'] + 1900, $timearray['tm_mon'], $timearray['tm_mday'], $timearray['tm_hour'], $timearray['tm_min'], $timearray['tm_sec'] + 2); $jsmodule = array('name' => 'block_simple_clock', 'fullpath' => '/blocks/simple_clock/module.js', 'requires' => array(), 'strings' => array(array('clock_separator', 'block_simple_clock'), array('before_noon', 'block_simple_clock'), array('after_noon', 'block_simple_clock'), array('day_names', 'block_simple_clock'))); $this->page->requires->js_init_call('M.block_simple_clock.initSimpleClock', $arguments, false, $jsmodule); $this->content->footer = ''; return $this->content; }
/** * Modifies $_SERVER['HTTP_USER_AGENT'] manually to check if check_browser_version * works as expected. */ public function test_check_browser_version() { core_useragent::instance(true, $this->user_agents['Safari']['412']['Mac OS X']); $this->assertTrue(core_useragent::is_safari()); $this->assertTrue(core_useragent::check_safari_version()); $this->assertTrue(core_useragent::is_webkit()); $this->assertTrue(core_useragent::check_webkit_version()); $this->assertTrue(core_useragent::check_safari_version('312')); $this->assertFalse(core_useragent::check_safari_version('500')); $this->assertFalse(core_useragent::is_chrome()); $this->assertFalse(core_useragent::check_chrome_version()); $this->assertFalse(core_useragent::is_safari_ios()); $this->assertFalse(core_useragent::check_safari_ios_version()); core_useragent::instance(true, $this->user_agents['Safari iOS']['528']['iPhone']); $this->assertTrue(core_useragent::is_safari_ios()); $this->assertTrue(core_useragent::check_safari_ios_version()); $this->assertTrue(core_useragent::is_webkit()); $this->assertTrue(core_useragent::check_webkit_version()); $this->assertTrue(core_useragent::check_safari_ios_version('527')); $this->assertFalse(core_useragent::check_safari_ios_version(590)); $this->assertFalse(core_useragent::check_safari_version('312')); $this->assertFalse(core_useragent::check_safari_version('500')); $this->assertFalse(core_useragent::is_chrome()); $this->assertFalse(core_useragent::check_chrome_version()); core_useragent::instance(true, $this->user_agents['WebKit Android']['530']['Nexus']); $this->assertTrue(core_useragent::is_webkit()); $this->assertTrue(core_useragent::check_webkit_version()); $this->assertTrue(core_useragent::check_webkit_android_version('527')); $this->assertFalse(core_useragent::check_webkit_android_version(590)); $this->assertFalse(core_useragent::is_safari()); $this->assertFalse(core_useragent::check_safari_version()); $this->assertFalse(core_useragent::is_chrome()); $this->assertFalse(core_useragent::check_chrome_version()); core_useragent::instance(true, $this->user_agents['WebKit Android']['537']['Samsung GT-9505']); $this->assertTrue(core_useragent::is_webkit()); $this->assertTrue(core_useragent::check_webkit_version()); $this->assertTrue(core_useragent::check_webkit_android_version('527')); $this->assertTrue(core_useragent::is_chrome()); $this->assertTrue(core_useragent::check_chrome_version()); $this->assertFalse(core_useragent::check_webkit_android_version(590)); $this->assertFalse(core_useragent::is_safari()); $this->assertFalse(core_useragent::check_safari_version()); core_useragent::instance(true, $this->user_agents['WebKit Android']['537']['Nexus 5']); $this->assertTrue(core_useragent::is_webkit()); $this->assertTrue(core_useragent::check_webkit_version()); $this->assertTrue(core_useragent::check_webkit_android_version('527')); $this->assertTrue(core_useragent::is_chrome()); $this->assertTrue(core_useragent::check_chrome_version()); $this->assertFalse(core_useragent::check_webkit_android_version(590)); $this->assertFalse(core_useragent::is_safari()); $this->assertFalse(core_useragent::check_safari_version()); core_useragent::instance(true, $this->user_agents['Chrome']['8']['Mac OS X']); $this->assertTrue(core_useragent::is_chrome()); $this->assertTrue(core_useragent::check_chrome_version()); $this->assertTrue(core_useragent::is_webkit()); $this->assertTrue(core_useragent::check_webkit_version()); $this->assertTrue(core_useragent::check_chrome_version(8)); $this->assertFalse(core_useragent::check_chrome_version(10)); $this->assertFalse(core_useragent::check_safari_version('1')); core_useragent::instance(true, $this->user_agents['Opera']['9.0']['Windows XP']); $this->assertTrue(core_useragent::is_opera()); $this->assertTrue(core_useragent::check_opera_version()); $this->assertTrue(core_useragent::check_opera_version('8.0')); $this->assertFalse(core_useragent::check_opera_version('10.0')); core_useragent::instance(true, $this->user_agents['MSIE']['6.0']['Windows XP SP2']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertFalse(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('7.0')); core_useragent::instance(true, $this->user_agents['MSIE']['5.0']['Windows 98']); $this->assertFalse(core_useragent::is_ie()); $this->assertFalse(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version(0)); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertFalse(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('7.0')); core_useragent::instance(true, $this->user_agents['MSIE']['9.0']['Windows 7']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version(0)); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertTrue(core_useragent::check_ie_version('9.0')); $this->assertFalse(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('10')); core_useragent::instance(true, $this->user_agents['MSIE']['9.0i']['Windows 7']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version(0)); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertTrue(core_useragent::check_ie_version('9.0')); $this->assertTrue(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('10')); core_useragent::instance(true, $this->user_agents['MSIE']['10.0']['Windows 8']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version(0)); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertTrue(core_useragent::check_ie_version('9.0')); $this->assertTrue(core_useragent::check_ie_version('10')); $this->assertFalse(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('11')); core_useragent::instance(true, $this->user_agents['MSIE']['10.0i']['Windows 8']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version(0)); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertTrue(core_useragent::check_ie_version('9.0')); $this->assertTrue(core_useragent::check_ie_version('10')); $this->assertTrue(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('11')); core_useragent::instance(true, $this->user_agents['MSIE']['11.0']['Windows 8.1']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version(0)); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertTrue(core_useragent::check_ie_version('9.0')); $this->assertTrue(core_useragent::check_ie_version('10')); $this->assertTrue(core_useragent::check_ie_version('11')); $this->assertFalse(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('12')); core_useragent::instance(true, $this->user_agents['MSIE']['11.0i']['Windows 8.1']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version(0)); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertTrue(core_useragent::check_ie_version('9.0')); $this->assertTrue(core_useragent::check_ie_version('10')); $this->assertTrue(core_useragent::check_ie_version('11')); $this->assertTrue(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('12')); core_useragent::instance(true, $this->user_agents['Firefox']['2.0']['Windows XP']); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_firefox_version('1.5')); $this->assertFalse(core_useragent::check_firefox_version('3.0')); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); core_useragent::instance(true, $this->user_agents['Firefox']['1.0.6']['Windows XP']); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_gecko_version('1')); $this->assertFalse(core_useragent::check_gecko_version(20030516)); $this->assertFalse(core_useragent::check_gecko_version(20051106)); $this->assertFalse(core_useragent::check_gecko_version(2006010100)); $this->assertFalse(core_useragent::check_firefox_version('1.5')); $this->assertFalse(core_useragent::check_firefox_version('3.0')); $this->assertFalse(core_useragent::check_gecko_version('2')); core_useragent::instance(true, $this->user_agents['Firefox']['2.0']['Windows XP']); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_firefox_version('1.5')); $this->assertTrue(core_useragent::check_gecko_version('1')); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertFalse(core_useragent::check_firefox_version('3.0')); core_useragent::instance(true, $this->user_agents['Firefox']['3.6']['Linux']); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_firefox_version('1.5')); $this->assertTrue(core_useragent::check_firefox_version('3.0')); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version('3.6')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertFalse(core_useragent::check_firefox_version('4')); $this->assertFalse(core_useragent::check_firefox_version('10')); core_useragent::instance(true, $this->user_agents['Firefox']['3.6']['Linux']); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_firefox_version('1.5')); $this->assertTrue(core_useragent::check_firefox_version('3.0')); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version('3.6')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertFalse(core_useragent::check_firefox_version('4')); $this->assertFalse(core_useragent::check_firefox_version('10')); $this->assertFalse(core_useragent::check_firefox_version('18')); $this->assertFalse(core_useragent::check_gecko_version('4')); core_useragent::instance(true, $this->user_agents['Firefox']['15.0a2']['Windows']); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_firefox_version('1.5')); $this->assertTrue(core_useragent::check_firefox_version('3.0')); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version('3.6')); $this->assertTrue(core_useragent::check_gecko_version('15.0')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertTrue(core_useragent::check_firefox_version('4')); $this->assertTrue(core_useragent::check_firefox_version('10')); $this->assertTrue(core_useragent::check_firefox_version('15')); $this->assertFalse(core_useragent::check_firefox_version('18')); $this->assertFalse(core_useragent::check_gecko_version('18')); core_useragent::instance(true, $this->user_agents['Firefox']['18.0']['Mac OS X']); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_firefox_version('1.5')); $this->assertTrue(core_useragent::check_firefox_version('3.0')); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version('3.6')); $this->assertTrue(core_useragent::check_gecko_version('15.0')); $this->assertTrue(core_useragent::check_gecko_version('18.0')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertTrue(core_useragent::check_firefox_version('4')); $this->assertTrue(core_useragent::check_firefox_version('10')); $this->assertTrue(core_useragent::check_firefox_version('15')); $this->assertTrue(core_useragent::check_firefox_version('18')); $this->assertFalse(core_useragent::check_firefox_version('19')); $this->assertFalse(core_useragent::check_gecko_version('19')); core_useragent::instance(true, $this->user_agents['SeaMonkey']['2.0']['Windows']); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertFalse(core_useragent::check_gecko_version('3.6')); $this->assertFalse(core_useragent::check_gecko_version('4.0')); $this->assertFalse(core_useragent::is_firefox()); $this->assertFalse(core_useragent::check_firefox_version()); core_useragent::instance(true, $this->user_agents['SeaMonkey']['2.1']['Linux']); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version('3.6')); $this->assertTrue(core_useragent::check_gecko_version('4.0')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_firefox_version(4.0)); $this->assertFalse(core_useragent::check_firefox_version(5)); $this->assertFalse(core_useragent::check_gecko_version('18.0')); }
/** * Get the stylesheet URL of this theme * * @param moodle_page $page Not used... deprecated? * @return array of moodle_url */ public function css_urls(moodle_page $page) { global $CFG; $rev = theme_get_revision(); $urls = array(); $svg = $this->use_svg_icons(); if ($rev > -1) { $url = new moodle_url("{$CFG->httpswwwroot}/theme/styles.php"); $separate = core_useragent::is_ie() && !core_useragent::check_ie_version('10'); if (!empty($CFG->slasharguments)) { $slashargs = ''; if (!$svg) { // We add a simple /_s to the start of the path. // The underscore is used to ensure that it isn't a valid theme name. $slashargs .= '/_s' . $slashargs; } $slashargs .= '/' . $this->name . '/' . $rev . '/all'; if ($separate) { $slashargs .= '/chunk0'; } $url->set_slashargument($slashargs, 'noparam', true); } else { $params = array('theme' => $this->name, 'rev' => $rev, 'type' => 'all'); if (!$svg) { // We add an SVG param so that we know not to serve SVG images. // We do this because all modern browsers support SVG and this param will one day be removed. $params['svg'] = '0'; } if ($separate) { $params['chunk'] = '0'; } $url->params($params); } $urls[] = $url; } else { // find out the current CSS and cache it now for 5 seconds // the point is to construct the CSS only once and pass it through the // dataroot to the script that actually serves the sheets if (!defined('THEME_DESIGNER_CACHE_LIFETIME')) { define('THEME_DESIGNER_CACHE_LIFETIME', 4); // this can be also set in config.php } $candidatedir = "{$CFG->cachedir}/theme/{$this->name}"; if ($svg) { $candidatesheet = "{$candidatedir}/designer.ser"; } else { $candidatesheet = "{$candidatedir}/designer_nosvg.ser"; } $rebuild = true; if (file_exists($candidatesheet) and filemtime($candidatesheet) > time() - THEME_DESIGNER_CACHE_LIFETIME) { if ($css = file_get_contents($candidatesheet)) { $css = unserialize($css); if (is_array($css)) { $rebuild = false; } } } if ($rebuild) { // Prepare the CSS optimiser if it is to be used, // please note that it may be very slow and is therefore strongly discouraged in theme designer mode. $optimiser = null; if (!empty($CFG->enablecssoptimiser) && $this->supportscssoptimisation) { require_once $CFG->dirroot . '/lib/csslib.php'; $optimiser = new css_optimiser(); } $css = $this->css_content($optimiser); // We do not want any errors here because this may fail easily because of the concurrent access. $prevabort = ignore_user_abort(true); check_dir_exists($candidatedir); $tempfile = tempnam($candidatedir, 'tmpdesigner'); file_put_contents($tempfile, serialize($css)); $reporting = error_reporting(0); chmod($tempfile, $CFG->filepermissions); unlink($candidatesheet); // Do not rely on rename() deleting original, they may decide to change it at any time as usually. rename($tempfile, $candidatesheet); error_reporting($reporting); ignore_user_abort($prevabort); } $baseurl = new moodle_url($CFG->httpswwwroot . '/theme/styles_debug.php'); if (!$svg) { // We add an SVG param so that we know not to serve SVG images. // We do this because all modern browsers support SVG and this param will one day be removed. $baseurl->param('svg', '0'); } if (core_useragent::is_ie()) { // lalala, IE does not allow more than 31 linked CSS files from main document $urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'ie', 'subtype' => 'plugins')); foreach ($css['parents'] as $parent => $sheets) { // We need to serve parents individually otherwise we may easily exceed the style limit IE imposes (4096) $urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'ie', 'subtype' => 'parents', 'sheet' => $parent)); } $urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'ie', 'subtype' => 'theme')); } else { foreach ($css['plugins'] as $plugin => $unused) { $urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'plugin', 'subtype' => $plugin)); } foreach ($css['parents'] as $parent => $sheets) { foreach ($sheets as $sheet => $unused2) { $urls[] = new moodle_url($baseurl, array('theme' => $this->name, 'type' => 'parent', 'subtype' => $parent, 'sheet' => $sheet)); } } foreach ($css['theme'] as $sheet => $unused) { $urls[] = new moodle_url($baseurl, array('sheet' => $sheet, 'theme' => $this->name, 'type' => 'theme')); // sheet first in order to make long urls easier to read } } } return $urls; }
/** * Modifies $_SERVER['HTTP_USER_AGENT'] manually to check if check_browser_version * works as expected. */ public function test_check_browser_version() { core_useragent::instance(true, $this->user_agents['Safari']['412']['Mac OS X']); $this->assertTrue(core_useragent::is_safari()); $this->assertTrue(core_useragent::check_safari_version()); $this->assertTrue(core_useragent::is_webkit()); $this->assertTrue(core_useragent::check_webkit_version()); $this->assertTrue(core_useragent::check_safari_version('312')); $this->assertFalse(core_useragent::check_safari_version('500')); $this->assertFalse(core_useragent::is_chrome()); $this->assertFalse(core_useragent::check_chrome_version()); $this->assertFalse(core_useragent::is_safari_ios()); $this->assertFalse(core_useragent::check_safari_ios_version()); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['Safari iOS']['528']['iPhone']); $this->assertTrue(core_useragent::is_safari_ios()); $this->assertTrue(core_useragent::check_safari_ios_version()); $this->assertTrue(core_useragent::is_webkit()); $this->assertTrue(core_useragent::check_webkit_version()); $this->assertTrue(core_useragent::check_safari_ios_version('527')); $this->assertFalse(core_useragent::check_safari_ios_version(590)); $this->assertFalse(core_useragent::check_safari_version('312')); $this->assertFalse(core_useragent::check_safari_version('500')); $this->assertFalse(core_useragent::is_chrome()); $this->assertFalse(core_useragent::check_chrome_version()); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['WebKit Android']['530']['Nexus']); $this->assertTrue(core_useragent::is_webkit()); $this->assertTrue(core_useragent::check_webkit_version()); $this->assertTrue(core_useragent::check_webkit_android_version('527')); $this->assertFalse(core_useragent::check_webkit_android_version(590)); $this->assertFalse(core_useragent::is_safari()); $this->assertFalse(core_useragent::check_safari_version()); $this->assertFalse(core_useragent::is_chrome()); $this->assertFalse(core_useragent::check_chrome_version()); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['WebKit Android']['537']['Samsung GT-9505']); $this->assertTrue(core_useragent::is_webkit()); $this->assertTrue(core_useragent::check_webkit_version()); $this->assertTrue(core_useragent::check_webkit_android_version('527')); $this->assertTrue(core_useragent::is_chrome()); $this->assertTrue(core_useragent::check_chrome_version()); $this->assertFalse(core_useragent::check_webkit_android_version(590)); $this->assertFalse(core_useragent::is_safari()); $this->assertFalse(core_useragent::check_safari_version()); core_useragent::instance(true, $this->user_agents['WebKit Android']['537']['Nexus 5']); $this->assertTrue(core_useragent::is_webkit()); $this->assertTrue(core_useragent::check_webkit_version()); $this->assertTrue(core_useragent::check_webkit_android_version('527')); $this->assertTrue(core_useragent::is_chrome()); $this->assertTrue(core_useragent::check_chrome_version()); $this->assertFalse(core_useragent::check_webkit_android_version(590)); $this->assertFalse(core_useragent::is_safari()); $this->assertFalse(core_useragent::check_safari_version()); core_useragent::instance(true, $this->user_agents['Chrome']['8']['Mac OS X']); $this->assertTrue(core_useragent::is_chrome()); $this->assertTrue(core_useragent::check_chrome_version()); $this->assertTrue(core_useragent::is_webkit()); $this->assertTrue(core_useragent::check_webkit_version()); $this->assertTrue(core_useragent::check_chrome_version(8)); $this->assertFalse(core_useragent::check_chrome_version(10)); $this->assertFalse(core_useragent::check_safari_version('1')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['Opera']['9.0']['Windows XP']); $this->assertTrue(core_useragent::is_opera()); $this->assertTrue(core_useragent::check_opera_version()); $this->assertTrue(core_useragent::check_opera_version('8.0')); $this->assertFalse(core_useragent::check_opera_version('10.0')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['MSIE']['6.0']['Windows XP SP2']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertFalse(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('7.0')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['MSIE']['5.0']['Windows 98']); $this->assertFalse(core_useragent::is_ie()); $this->assertFalse(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version(0)); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertFalse(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('7.0')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['MSIE']['7.0']['Windows XP SP2']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version('7.0')); $this->assertFalse(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('8.0')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['MSIE']['7.0b']['Windows XP']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version('7.0')); $this->assertFalse(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('8.0')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['MSIE']['9.0']['Windows 7']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version(0)); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertTrue(core_useragent::check_ie_version('9.0')); $this->assertFalse(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('10')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['MSIE']['9.0i']['Windows 7']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version(0)); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertTrue(core_useragent::check_ie_version('9.0')); $this->assertTrue(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('10')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['MSIE']['10.0']['Windows 8']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version(0)); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertTrue(core_useragent::check_ie_version('9.0')); $this->assertTrue(core_useragent::check_ie_version('10')); $this->assertFalse(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('11')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['MSIE']['10.0i']['Windows 8']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version(0)); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertTrue(core_useragent::check_ie_version('9.0')); $this->assertTrue(core_useragent::check_ie_version('10')); $this->assertTrue(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('11')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['MSIE']['11.0']['Windows 8.1']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version(0)); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertTrue(core_useragent::check_ie_version('9.0')); $this->assertTrue(core_useragent::check_ie_version('10')); $this->assertTrue(core_useragent::check_ie_version('11')); $this->assertFalse(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('12')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['MSIE']['11.0i']['Windows 8.1']); $this->assertTrue(core_useragent::is_ie()); $this->assertTrue(core_useragent::check_ie_version()); $this->assertTrue(core_useragent::check_ie_version(0)); $this->assertTrue(core_useragent::check_ie_version('5.0')); $this->assertTrue(core_useragent::check_ie_version('9.0')); $this->assertTrue(core_useragent::check_ie_version('10')); $this->assertTrue(core_useragent::check_ie_version('11')); $this->assertTrue(core_useragent::check_ie_compatibility_view()); $this->assertFalse(core_useragent::check_ie_version('12')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['Firefox']['2.0']['Windows XP']); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_firefox_version('1.5')); $this->assertFalse(core_useragent::check_firefox_version('3.0')); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['Firefox']['1.0.6']['Windows XP']); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_gecko_version('1')); $this->assertFalse(core_useragent::check_gecko_version(20030516)); $this->assertFalse(core_useragent::check_gecko_version(20051106)); $this->assertFalse(core_useragent::check_gecko_version(2006010100)); $this->assertFalse(core_useragent::check_firefox_version('1.5')); $this->assertFalse(core_useragent::check_firefox_version('3.0')); $this->assertFalse(core_useragent::check_gecko_version('2')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['Firefox']['2.0']['Windows XP']); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_firefox_version('1.5')); $this->assertTrue(core_useragent::check_gecko_version('1')); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertFalse(core_useragent::check_firefox_version('3.0')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['Firefox']['3.6']['Linux']); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_firefox_version('1.5')); $this->assertTrue(core_useragent::check_firefox_version('3.0')); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version('3.6')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertFalse(core_useragent::check_firefox_version('4')); $this->assertFalse(core_useragent::check_firefox_version('10')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['Firefox']['3.6']['Linux']); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_firefox_version('1.5')); $this->assertTrue(core_useragent::check_firefox_version('3.0')); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version('3.6')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertFalse(core_useragent::check_firefox_version('4')); $this->assertFalse(core_useragent::check_firefox_version('10')); $this->assertFalse(core_useragent::check_firefox_version('18')); $this->assertFalse(core_useragent::check_gecko_version('4')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['Firefox']['15.0a2']['Windows']); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_firefox_version('1.5')); $this->assertTrue(core_useragent::check_firefox_version('3.0')); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version('3.6')); $this->assertTrue(core_useragent::check_gecko_version('15.0')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertTrue(core_useragent::check_firefox_version('4')); $this->assertTrue(core_useragent::check_firefox_version('10')); $this->assertTrue(core_useragent::check_firefox_version('15')); $this->assertFalse(core_useragent::check_firefox_version('18')); $this->assertFalse(core_useragent::check_gecko_version('18')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['Firefox']['18.0']['Mac OS X']); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_firefox_version('1.5')); $this->assertTrue(core_useragent::check_firefox_version('3.0')); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version('3.6')); $this->assertTrue(core_useragent::check_gecko_version('15.0')); $this->assertTrue(core_useragent::check_gecko_version('18.0')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertTrue(core_useragent::check_firefox_version('4')); $this->assertTrue(core_useragent::check_firefox_version('10')); $this->assertTrue(core_useragent::check_firefox_version('15')); $this->assertTrue(core_useragent::check_firefox_version('18')); $this->assertFalse(core_useragent::check_firefox_version('19')); $this->assertFalse(core_useragent::check_gecko_version('19')); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['SeaMonkey']['2.0']['Windows']); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertFalse(core_useragent::check_gecko_version('3.6')); $this->assertFalse(core_useragent::check_gecko_version('4.0')); $this->assertFalse(core_useragent::is_firefox()); $this->assertFalse(core_useragent::check_firefox_version()); $this->assertFalse(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['SeaMonkey']['2.1']['Linux']); $this->assertTrue(core_useragent::check_gecko_version('2')); $this->assertTrue(core_useragent::check_gecko_version('3.6')); $this->assertTrue(core_useragent::check_gecko_version('4.0')); $this->assertTrue(core_useragent::check_gecko_version(20030516)); $this->assertTrue(core_useragent::check_gecko_version(20051106)); $this->assertTrue(core_useragent::check_gecko_version(2006010100)); $this->assertTrue(core_useragent::is_firefox()); $this->assertTrue(core_useragent::check_firefox_version()); $this->assertTrue(core_useragent::check_firefox_version(4.0)); $this->assertFalse(core_useragent::check_firefox_version(5)); $this->assertFalse(core_useragent::check_gecko_version('18.0')); $this->assertFalse(core_useragent::is_msword()); // We're not really interested in what MS Word gets identified as beyond MS Word itself. core_useragent::instance(true, $this->user_agents['MS Word']['2010']['Windows 7']); $this->assertTrue(core_useragent::is_msword()); core_useragent::instance(true, $this->user_agents['MS Word']['2010']['Mac OS X']); $this->assertTrue(core_useragent::is_msword()); // Outlook should not be considered to be MS Word. core_useragent::instance(true, $this->user_agents['MS Outlook']['2010']['Windows 7']); $this->assertFalse(core_useragent::is_msword()); // Meridio should not be considered to be MS Word. core_useragent::instance(true, $this->user_agents['Meridio']['5.0.251']['Windows XP']); $this->assertFalse(core_useragent::is_msword()); }