function form_init_date_js() { global $CFG; static $done = false; if (!$done) { echo '<style type="text/css">'; echo '@import "' . $CFG->httpswwwroot . '/lib/yui/calendar/assets/skins/sam/calendar.css";'; echo '@import "' . $CFG->httpswwwroot . '/lib/yui/calendar/assets/skins/sam/container.css";'; echo '</style>'; require_js(array('yui_yahoo', 'yui_dom', 'yui_event', 'yui_calendar', 'yui_container')); print_delayed_js_call(1, 'init_date_selectors', array(get_string('firstdayofweek'))); $done = true; } }
/** * Redirects the user to another page, after printing a notice * * @param string $url The url to take the user to * @param string $message The text message to display to the user about the redirect, if any * @param string $delay How long before refreshing to the new page at $url? * @todo '&' needs to be encoded into '&' for XHTML compliance, * however, this is not true for javascript. Therefore we * first decode all entities in $url (since we cannot rely on) * the correct input) and then encode for where it's needed * echo "<script type='text/javascript'>alert('Redirect $url');</script>"; */ function redirect($url, $message = '', $delay = -1) { global $CFG, $THEME, $SESSION, $PAGE; if (!empty($CFG->usesid) && !isset($_COOKIE[session_name()])) { $url = $SESSION->sid_process_url($url); } $message = clean_text($message); $encodedurl = preg_replace("/\\&(?![a-zA-Z0-9#]{1,8};)/", "&", $url); $encodedurl = preg_replace('/^.*href="([^"]*)".*$/', "\\1", clean_text('<a href="' . $encodedurl . '" />')); $url = str_replace('&', '&', $encodedurl); /// At developer debug level. Don't redirect if errors have been printed on screen. /// Currenly only works in PHP 5.2+; we do not want strict PHP5 errors $lasterror = error_get_last(); $error = defined('DEBUGGING_PRINTED') or !empty($lasterror) && $lasterror['type'] & DEBUG_DEVELOPER; $errorprinted = debugging('', DEBUG_ALL) && $CFG->debugdisplay && $error; if ($errorprinted) { $message = "<strong>Error output, so disabling automatic redirect.</strong></p><p>" . $message; } $performanceinfo = ''; if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) { if (defined('MDL_PERFTOLOG') && !function_exists('register_shutdown_function')) { $perf = get_performance_info(); error_log("PERF: " . $perf['txt']); } } /// when no message and header printed yet, try to redirect if (empty($message) and !$PAGE->headerprinted) { // Technically, HTTP/1.1 requires Location: header to contain // the absolute path. (In practice browsers accept relative // paths - but still, might as well do it properly.) // This code turns relative into absolute. if (!preg_match('|^[a-z]+:|', $url)) { // Get host name http://www.wherever.com $hostpart = preg_replace('|^(.*?[^:/])/.*$|', '$1', $CFG->wwwroot); if (preg_match('|^/|', $url)) { // URLs beginning with / are relative to web server root so we just add them in $url = $hostpart . $url; } else { // URLs not beginning with / are relative to path of current script, so add that on. $url = $hostpart . preg_replace('|\\?.*$|', '', me()) . '/../' . $url; } // Replace all ..s while (true) { $newurl = preg_replace('|/(?!\\.\\.)[^/]*/\\.\\./|', '/', $url); if ($newurl == $url) { break; } $url = $newurl; } } $delay = 0; //try header redirection first @header($_SERVER['SERVER_PROTOCOL'] . ' 303 See Other'); //302 might not work for POST requests, 303 is ignored by obsolete clients @header('Location: ' . $url); //another way for older browsers and already sent headers (eg trailing whitespace in config.php) echo '<meta http-equiv="refresh" content="' . $delay . '; url=' . $encodedurl . '" />'; print_js_call('document.location.replace', array($url)); die; } if ($delay == -1) { $delay = 3; // if no delay specified wait 3 seconds } if (!$PAGE->headerprinted) { // this type of redirect might not be working in some browsers - such as lynx :-( print_header('', '', '', '', $errorprinted ? '' : '<meta http-equiv="refresh" content="' . $delay . '; url=' . $encodedurl . '" />'); $delay += 3; // double redirect prevention, it was sometimes breaking upgrades before 1.7 } else { print_container_end_all(false, $THEME->open_header_containers); } echo '<div id="redirect">'; echo '<div id="message">' . $message . '</div>'; echo '<div id="continue">( <a href="' . $encodedurl . '">' . get_string('continue') . '</a> )</div>'; echo '</div>'; if (!$errorprinted) { print_delayed_js_call($delay, 'document.location.replace', array($url)); } $CFG->docroot = false; // to prevent the link to moodle docs from being displayed on redirect page. print_footer('none'); die; }
$DB->delete_records('message', array('id'=>$messageid)); } } if (get_user_preferences('message_beepnewmessage', 0)) { $playbeep = true; } echo 'parent.messages.scroll(1,5000000);'."\n"; echo 'parent.send.focus();'."\n"; $wait = MESSAGE_DEFAULT_REFRESH; } else { if ($wait < 300) { // Until the wait is five minutes $wait = ceil(1.2 * (float)$wait); // Exponential growth } } */ echo '-->' . "\n"; echo '</script>' . "\n"; echo '</head>' . "\n"; echo '<body>' . "\n"; if (!empty($playbeep)) { echo '<embed src="bell.wav" autostart="true" hidden="true" name="bell" />'; echo '<script type="text/javascript">' . "\n"; echo '<!--' . "\n"; echo 'parent.send.focus();' . "\n"; echo '-->' . "\n"; echo '</script>' . "\n"; } // Javascript for Mozilla to cope with the redirect bug from editor being on in this page print_delayed_js_call($wait, 'document.location.replace', array("refresh.php?id={$userid}&name=" . urlencode($userfullname) . "&wait={$wait}")); echo '</body>' . "\n"; echo '</html>' . "\n";
print_error('exporterror', 'question', $thispageurl->out()); } if (!$qformat->exportprocess()) { // Process the export data print_error('exporterror', 'question', $thispageurl->out()); } if (!$qformat->exportpostprocess()) { // In case anything needs to be done after print_error('exporterror', 'question', $thispageurl->out()); } echo "<hr />"; // link to download the finished file $file_ext = $qformat->export_file_extension(); $filename = $from_form->exportfilename . $file_ext; if ($canaccessbackupdata) { $efile = get_file_url($qformat->question_get_export_dir() . '/' . $filename, array('forcedownload' => 1)); echo '<p><div class="boxaligncenter"><a href="' . $efile . '">' . get_string('download', 'quiz') . '</a></div></p>'; echo '<p><div class="boxaligncenter"><font size="-1">' . get_string('downloadextra', 'quiz') . '</font></div></p>'; } else { $efile = get_file_url($filename, null, 'questionfile'); echo '<p><div class="boxaligncenter">' . get_string('yourfileshoulddownload', 'question', $efile) . '</div></p>'; print_delayed_js_call(1, 'document.location.replace', array($efile)); } print_continue('edit.php?' . $thispageurl->get_query_string()); print_footer($COURSE); exit; } /// Display export form print_heading_with_help($strexportquestions, 'export', 'quiz'); $export_form->display(); print_footer($COURSE);