public function formulation_and_controls(question_attempt $qa, question_display_options $options) { $question = $qa->get_question(); $response = $qa->get_last_qt_data(); $o = html_writer::tag('div', $question->format_questiontext($qa), array('class' => 'qtext')); $o .= html_writer::start_tag('div', array('id' => 'ablock_' . $question->id, 'class' => 'ablock')); $o .= $this->construct_ablock_select($qa, $options); $o .= html_writer::end_tag('div'); if ($this->can_use_drag_and_drop()) { $o .= html_writer::tag('div', '', array('class' => 'clearer')); } if ($qa->get_state() == question_state::$invalid) { $o .= html_writer::nonempty_tag('div', $question->get_validation_error($response), array('class' => 'validationerror')); } if ($this->can_use_drag_and_drop()) { $initparams = new stdClass(); $initparams->qid = $question->id; $initparams->stemscount = count($question->get_stem_order()); $initparams->ablockcontent = $this->construct_ablock_dragable($qa, $options); $initparams->readonly = $options->readonly; $initparams = json_encode($initparams); $js = "YAHOO.util.Event.onDOMReady(function(){M.order.Init({$initparams});});"; $o .= html_writer::script($js); } return $o; }
protected function render_curdate_controls(attforblock_filter_controls $fcontrols) { global $CFG; $curdate_controls = ''; if ($fcontrols->curdatetxt) { $this->page->requires->strings_for_js(array('calclose', 'caltoday'), 'attforblock'); $jsvals = array('cal_months' => explode(',', get_string('calmonths', 'attforblock')), 'cal_week_days' => explode(',', get_string('calweekdays', 'attforblock')), 'cal_start_weekday' => $CFG->calendar_startwday, 'cal_cur_date' => $fcontrols->curdate); $curdate_controls = html_writer::script(js_writer::set_variable('M.attforblock', $jsvals)); $this->page->requires->yui2_lib('container'); $this->page->requires->yui2_lib('calendar'); $this->page->requires->js('/mod/attforblock/calendar.js'); $curdate_controls .= html_writer::link($fcontrols->url(array('curdate' => $fcontrols->prevcur)), $this->output->larrow()); $params = array('title' => get_string('calshow', 'attforblock'), 'id' => 'show', 'type' => 'button'); $button_form = html_writer::tag('button', $fcontrols->curdatetxt, $params); foreach ($fcontrols->url_params(array('curdate' => '')) as $name => $value) { $params = array('type' => 'hidden', 'id' => $name, 'name' => $name, 'value' => $value); $button_form .= html_writer::empty_tag('input', $params); } $params = array('id' => 'currentdate', 'action' => $fcontrols->url_path(), 'method' => 'post'); $button_form = html_writer::tag('form', $button_form, $params); $curdate_controls .= $button_form; $curdate_controls .= html_writer::link($fcontrols->url(array('curdate' => $fcontrols->nextcur)), $this->output->rarrow()); } return $curdate_controls; }
function cr_add_jsordering($cssid) { global $DB, $CFG, $OUTPUT; $script = new moodle_url('/blocks/configurable_reports/js/datatables/media/js/jquery.js'); $script = ' if (typeof jQuery == "undefined") { document.write(unescape("%3Cscript type=\\"text/javascript\\" src=\\"' . $script . '\\"%3E%3C/script%3E")); } '; echo html_writer::script($script); echo html_writer::script(false, new moodle_url('/blocks/configurable_reports/js/jquery.tablesorter.min.js')); $script = '$(document).ready(function() { // call the tablesorter plugin $("' . $cssid . '").tablesorter(); });'; echo html_writer::script($script); ?> <style type="text/css"> <?php echo $cssid; ?> th.header{ background-image:url(<?php echo $OUTPUT->pix_url('normal', 'block_configurable_reports'); ?> ); background-position:right center; background-repeat:no-repeat; cursor:pointer; } <?php echo $cssid; ?> th.headerSortUp{ background-image:url(<?php echo $OUTPUT->pix_url('asc', 'block_configurable_reports'); ?> ); } <?php echo $cssid; ?> th.headerSortDown{ background-image:url(<?php echo $OUTPUT->pix_url('desc', 'block_configurable_reports'); ?> ); } </style> <?php }
function toHtml() { global $CFG; if ($this->_flagFrozen) { return $this->getFrozenHtml(); } else { $id = $this->getAttribute('id'); $unmask = get_string('unmaskpassword', 'form'); $unmaskjs = html_writer::script(js_writer::set_variable('punmask', array('id' => $id, 'unmaskstr' => $unmask))); $unmaskjs .= html_writer::script('', $CFG->httpswwwroot . '/lib/form/passwordunmask.js'); return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' /><div class="unmask" id="' . $id . 'unmaskdiv"></div>' . $unmaskjs; } }
function cr_add_jsordering($cssid) { global $DB, $CFG, $OUTPUT; echo html_writer::script(false, new moodle_url('/report/configreports/js/jquery-latest.js')); echo html_writer::script(false, new moodle_url('/report/configreports/js/jquery.tablesorter.min.js')); $script = '$(document).ready(function() { // call the tablesorter plugin $("' . $cssid . '").tablesorter(); });'; echo html_writer::script($script); ?> <style type="text/css"> <?php echo $cssid; ?> th.header{ background-image:url(<?php echo $OUTPUT->pix_url('normal', 'report_configreports'); ?> ); background-position:right center; background-repeat:no-repeat; cursor:pointer; } <?php echo $cssid; ?> th.headerSortUp{ background-image:url(<?php echo $OUTPUT->pix_url('asc', 'report_configreports'); ?> ); } <?php echo $cssid; ?> th.headerSortDown{ background-image:url(<?php echo $OUTPUT->pix_url('desc', 'report_configreports'); ?> ); } </style> <?php }
function mycommentpopupform($adminqueryid = '') { $script = html_writer::script('$(document).ready(function() { $("#showDialog'.$adminqueryid.'").click(function(){ $("#basicModal'.$adminqueryid.'").dialog({ modal: true, height: 320, width: 400 }); }); }); form = $("#basicModal'.$adminqueryid.'").find( "form" ).on( "submit", function( event ) { event.preventDefault(); myformvalidation(); }); '); return $script; }
/** * Add a message to the session notification stack. * * @param string $message The message to add to the stack * @param string $level The type of message to add to the stack */ public static function add($message, $level = null) { global $PAGE, $SESSION; if ($PAGE && $PAGE->state === \moodle_page::STATE_IN_BODY) { // Currently in the page body - just render and exit immediately. // We insert some code to immediately insert this into the user-notifications created by the header. $id = uniqid(); echo \html_writer::span($PAGE->get_renderer('core')->render(new \core\output\notification($message, $level)), '', array('id' => $id)); // Insert this JS here using a script directly rather than waiting for the page footer to load to avoid // ensure that the message is added to the user-notifications section as soon as possible after it is created. echo \html_writer::script("(function() {" . "var notificationHolder = document.getElementById('user-notifications');" . "if (!notificationHolder) { return; }" . "var thisNotification = document.getElementById('{$id}');" . "if (!thisNotification) { return; }" . "notificationHolder.appendChild(thisNotification.firstChild);" . "thisNotification.remove();" . "})();"); return; } // Add the notification directly to the session. // This will either be fetched in the header, or by JS in the footer. if (!isset($SESSION->notifications) || !array($SESSION->notifications)) { $SESSION->notifications = []; } $SESSION->notifications[] = (object) array('message' => $message, 'type' => $level); }
public function get_content() { if ($this->content !== null) { return $this->content; } global $USER, $CFG, $DB, $OUTPUT; require_once $CFG->dirroot . '/local/lib.php'; $this->content = new stdClass(); $this->content->text = ''; /*************************** this can seen by admin,instructor and trainer*************************************/ if (is_siteadmin() || is_instructor() || is_trainers()) { //$startday=date ("d-m-y",$user->startdate); $today = date('Y-m-d'); $today_timestamp = strtotime($today); $users = $DB->get_records_sql("SELECT * FROM {facetoface} WHERE completion_status = 0 AND trainerid = {$USER->id} AND enddate < {$today_timestamp}"); //tab changing code start $this->content->text[] = "<div class='alerts_course_exmas_icons'>"; $clswise = html_writer::tag('p', get_string('upcoming', 'block_batchcompletion'), array("class" => "alerts_course_exmas_icons_classwise")); //$this->content->text[] = html_writer::tag('a', $clswise, array('href'=>'javascript:void(0)','class' => 'link','data-link'=>'first')); $datewise = html_writer::tag('p', get_string('inactive', 'block_batchcompletion'), array("class" => "alerts_course_exmas_icons_datewise")); $this->content->text[] = html_writer::tag('a', $datewise, array('href' => 'javascript:void(0)', 'class' => 'link', 'data-link' => 'second')); $this->content->text[] = "</div>"; $this->content->text[] = "<div class='linkdetails' data-link='second' >"; foreach ($users as $user) { $this->content->text[] = html_writer::start_tag('div'); $this->content->text[] = html_writer::tag('b', get_string('batchname', 'block_batchcompletion'), array()); $this->content->text[] = html_writer::tag('a', $user->name, array('href' => $CFG->wwwroot . '/mod/facetoface/view_sessions.php')); $this->content->text[] = html_writer::empty_tag('br'); //$this->content->text[] ="This batch is inactive ,enable the batch to active"; $this->content->text[] = html_writer::end_tag('div'); } $this->content->text[] = html_writer::tag('a', get_string('viewmore', 'block_batchcompletion'), array('href' => $CFG->wwwroot . '/blocks/batchcompletion/viewmore.php')); $this->content->text[] = "</div>"; } // script used for tab changing $this->content->text[] = html_writer::script("\n\t\t\t\$(document).ready(function(){\n\t\t\t\t\$('#details').hide();\n\t\t\t\t\n\t\t\t\t\$('.link').click(function() {\n\t\t\t\t\t\$('.linkdetails').hide();\n\t\t\t\t\t\$('.linkdetails[data-link=' + \$(this).data('link') + ']').fadeIn({\n\t\t\t\t\t\twidth: '200px'\n\t\t\t\t\t}, 300);\t\n\t\t\t\t});\n\t\t\t});\n\t\t\t"); $this->content->footer = ''; $this->content->text = implode('', $this->content->text); return $this->content; }
/** * Returns the recaptcha element in HTML * * @return string */ function toHtml() { global $CFG, $PAGE; require_once $CFG->libdir . '/recaptchalib.php'; $recaptureoptions = array('theme' => 'custom', 'custom_theme_widget' => 'recaptcha_widget'); $html = html_writer::script(js_writer::set_variable('RecaptchaOptions', $recaptureoptions)); $attributes = $this->getAttributes(); if (empty($attributes['error_message'])) { $attributes['error_message'] = null; $this->setAttributes($attributes); } $error = $attributes['error_message']; unset($attributes['error_message']); $strincorrectpleasetryagain = get_string('incorrectpleasetryagain', 'auth'); $strenterthewordsabove = get_string('enterthewordsabove', 'auth'); $strenterthenumbersyouhear = get_string('enterthenumbersyouhear', 'auth'); $strgetanothercaptcha = get_string('getanothercaptcha', 'auth'); $strgetanaudiocaptcha = get_string('getanaudiocaptcha', 'auth'); $strgetanimagecaptcha = get_string('getanimagecaptcha', 'auth'); $html .= ' <div id="recaptcha_widget" style="display:none"> <div id="recaptcha_image"></div> <div class="recaptcha_only_if_incorrect_sol" style="color:red">' . $strincorrectpleasetryagain . '</div> <span class="recaptcha_only_if_image"><label for="recaptcha_response_field">' . $strenterthewordsabove . '</label></span> <span class="recaptcha_only_if_audio"><label for="recaptcha_response_field">' . $strenterthenumbersyouhear . '</label></span> <input type="text" id="recaptcha_response_field" name="recaptcha_response_field" /> <input type="hidden" name="recaptcha_element" value="dummyvalue" /> <!-- Dummy value to fool formslib --> <div><a href="javascript:Recaptcha.reload()">' . $strgetanothercaptcha . '</a></div> <div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type(\'audio\')">' . $strgetanaudiocaptcha . '</a></div> <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type(\'image\')">' . $strgetanimagecaptcha . '</a></div> </div>'; return $html . recaptcha_get_html($CFG->recaptchapublickey, $error, $this->_https); }
public function embed($urls, $name, $width, $height, $options) { // Use first url (there can actually be only one unless some idiot // enters two mp3 files as alternatives). $url = reset($urls); // Unique id even across different http requests made at the same time // (for AJAX, iframes). $id = 'core_media_flv_' . md5(time() . '_' . rand()); // Compute width and height. $autosize = false; if (!$width && !$height) { $width = CORE_MEDIA_VIDEO_WIDTH; $height = CORE_MEDIA_VIDEO_HEIGHT; $autosize = true; } // Fallback span (will normally contain link). $output = html_writer::tag('span', core_media_player::PLACEHOLDER, array('id' => $id, 'class' => 'mediaplugin mediaplugin_flv')); // We can not use standard JS init because this may be cached. $output .= html_writer::script(js_writer::function_call('M.util.add_video_player', array($id, addslashes_js($url->out(false)), $width, $height, $autosize))); return $output; }
if ($isstudent) { $tiiassignment = $DB->get_record('plagiarism_turnitin_config', array('cm' => $cm->id, 'name' => 'turnitin_assignid')); $user = new turnitintooltwo_user($USER->id, "Learner"); $coursedata = turnitintooltwo_assignment::get_course_data($cm->course, 'PP'); $user->join_user_to_class($coursedata->turnitin_cid); echo html_writer::tag("div", turnitintooltwo_view::output_lti_form_launch('rubric_view', 'Learner', $tiiassignment->value), array("class" => "launch_form", "style" => "display:none;")); echo html_writer::script("<!--\n window.document.forms[0].submit();\n //-->"); } break; case "peermarkreviews": $isstudent = $cm->modname == "forum" ? has_capability('mod/' . $cm->modname . ':replypost', $context) : has_capability('mod/' . $cm->modname . ':submit', $context); if ($userrole == 'Instructor' || $isstudent) { $role = $istutor ? 'Instructor' : 'Learner'; $tiiassignment = $DB->get_record('plagiarism_turnitin_config', array('cm' => $cm->id, 'name' => 'turnitin_assignid')); echo html_writer::tag("div", turnitintooltwo_view::output_lti_form_launch('peermark_reviews', $role, $tiiassignment->value), array("class" => "launch_form", "style" => "display:none;")); echo html_writer::script("<!--\n window.document.forms[0].submit();\n //-->"); } break; case "actionuseragreement": if (!confirm_sesskey()) { throw new moodle_exception('invalidsesskey', 'error'); } $message = optional_param('message', '', PARAM_ALPHAEXT); // Get the id from the turnitintooltwo_users table so we can update $turnitin_user = $DB->get_record('turnitintooltwo_users', array('userid' => $USER->id)); // Build user object for update $eula_user = new object(); $eula_user->id = $turnitin_user->id; $eula_user->user_agreement_accepted = 0; if ($message == 'turnitin_eula_accepted') { $eula_user->user_agreement_accepted = 1;
/** * Update the progress bar * * @param int $percent from 1-100 * @param string $msg * @return void Echo's output */ private function _update($percent, $msg) { if (empty($this->time_start)) { throw new coding_exception('You must call create() (or use the $autostart ' . 'argument to the constructor) before you try updating the progress bar.'); } if (CLI_SCRIPT) { return; // temporary solution for cli scripts } $es = $this->estimate($percent); if ($es === null) { // always do the first and last updates $es = "?"; } else { if ($es == 0) { // always do the last updates } else { if ($this->lastupdate + 20 < time()) { // we must update otherwise browser would time out } else { if (round($this->percent, 2) === round($percent, 2)) { // no significant change, no need to update anything return; } } } } $this->percent = $percent; $this->lastupdate = microtime(true); $w = $this->percent / 100 * $this->width; echo html_writer::script(js_writer::function_call('update_progress_bar', array($this->html_id, $w, $this->percent, $msg, $es))); flush(); }
/** * Generate any HTML that needs to go at the end of the page. * * Normally, this method is called automatically by the code that prints the * page footer. You should not normally need to call it in your own code. * * @return string the HTML code to to at the end of the page. */ public function get_end_code() { global $CFG; // Add other requested modules. $output = $this->get_extra_modules_code(); // All the other linked scripts - there should be as few as possible. if ($this->jsincludes['footer']) { foreach ($this->jsincludes['footer'] as $url) { $output .= html_writer::script('', $url); } } // Add all needed strings. if (!empty($this->stringsforjs)) { $strings = array(); foreach ($this->stringsforjs as $component => $v) { foreach ($v as $indentifier => $langstring) { $strings[$component][$indentifier] = $langstring->out(); } } $output .= html_writer::script(js_writer::set_variable('M.str', $strings)); } // Add variables. if ($this->jsinitvariables['footer']) { $js = ''; foreach ($this->jsinitvariables['footer'] as $data) { list($var, $value) = $data; $js .= js_writer::set_variable($var, $value, true); } $output .= html_writer::script($js); } $inyuijs = $this->get_javascript_code(false); $ondomreadyjs = $this->get_javascript_code(true); $jsinit = $this->get_javascript_init_code(); $handlersjs = $this->get_event_handler_code(); // There is no global Y, make sure it is available in your scope. $js = "YUI().use('node', function(Y) {\n{$inyuijs}{$ondomreadyjs}{$jsinit}{$handlersjs}\n});"; $output .= html_writer::script($js); return $output; }
/** * The old method that was used to include JavaScript libraries. * Please use $PAGE->requires->js_module() instead. * * @param mixed $lib The library or libraries to load (a string or array of strings) * There are three way to specify the library: * 1. a shorname like 'yui_yahoo'. This translates into a call to $PAGE->requires->yui2_lib('yahoo'); * 2. the path to the library relative to wwwroot, for example 'lib/javascript-static.js' * 3. (legacy) a full URL like $CFG->wwwroot . '/lib/javascript-static.js'. * 2. and 3. lead to a call $PAGE->requires->js('/lib/javascript-static.js'). */ function require_js($lib) { global $CFG, $PAGE; // Add the lib to the list of libs to be loaded, if it isn't already // in the list. if (is_array($lib)) { foreach($lib as $singlelib) { require_js($singlelib); } return; } debugging('Call to deprecated function require_js. Please use $PAGE->requires->js_module() instead.', DEBUG_DEVELOPER); if (strpos($lib, 'yui_') === 0) { $PAGE->requires->yui2_lib(substr($lib, 4)); } else { if ($PAGE->requires->is_head_done()) { echo html_writer::script('', $lib); } else { $PAGE->requires->js(new moodle_url($lib)); } } }
</div> </noscript> <?php if ($result->prerequisites) { if ($scorm->popup != 0 && $displaymode !=='popup') { // Clean the name for the window as IE is fussy $name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name); if (!$name) { $name = 'DefaultPlayerWindow'; } $name = 'scorm_'.$name; echo html_writer::script('', $CFG->wwwroot.'/mod/scorm/player.js'); $url = new moodle_url($PAGE->url, array('scoid' => $sco->id, 'display' => 'popup')); echo html_writer::script( js_writer::function_call('scorm_openpopup', Array($url->out(false), $name, $scorm->options, $scorm->width, $scorm->height))); ?> <noscript> <!--[if IE]> <iframe id="main" class="scoframe" name="main" src="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr; ?>"></iframe> <![endif]--> <!--[if !IE]> <object id="main" class="scoframe" type="text/html" data="loadSCO.php?id=<?php echo $cm->id.$scoidstr.$modestr; ?>"></object> <![endif]--> </noscript> <?php } } else { echo $OUTPUT->box(get_string('noprerequisites', 'scorm')); }
function displaydir($wdir, $files) { // $wdir == / or /a or /a/b/c/d etc @ini_set('memory_limit', '1024M'); global $courseid, $DB, $OUTPUT; global $USER, $CFG, $COURSE; global $choose; global $deptstr, $userstr; require_once $CFG->dirroot . '/blocks/morsle/constants.php'; $course = $COURSE; $user = $USER; // Get the sort parameter if there is one $sort = optional_param('sort', 1, PARAM_INT); $dirlist = array(); $filelist = array(); $dirhref = array(); $filehref = array(); $courseid = $course->id; $coursecontext = context_course::instance($COURSE->id); // separate all the files list into directories and files foreach ($files as $name => $file) { if (is_folder($file)) { $dirlist[$name] = $file; } else { $filelist[$name] = $file; } } // setup variables and strings $strname = get_string("name", 'block_morsle'); $strsize = get_string("size"); $strmodified = get_string("modified"); $straction = get_string("action"); $strmakeafolder = get_string("morslemakecollection", 'block_morsle'); $struploadafile = get_string("uploadafile"); $strselectall = get_string("selectall"); $strselectnone = get_string("deselectall"); $strwithchosenfiles = get_string("withchosenfiles"); $strmovetoanotherfolder = get_string("movetoanotherfolder"); $strlinktocourse = get_string("linktocourse", 'block_morsle'); $strmovefilestohere = get_string("movefilestohere"); $strdeletefromcollection = get_string("deletefromcollection", 'block_morsle'); $strcreateziparchive = get_string("createziparchive"); $strrename = get_string("rename"); $stredit = get_string("edit"); $strunzip = get_string("unzip"); $strlist = get_string("list"); $strrestore = get_string("restore"); $strchoose = get_string("choose"); $strfolder = get_string("folder"); $strfile = get_string("file"); $strdownload = get_string("strdownload", 'block_morsle'); $struploadthisfile = get_string("uploadthisfile"); $struploadandlinkthisfile = get_string("uploadandlinkthisfile", 'block_morsle'); $filesize = 'Varies as to type of document'; $strmaxsize = get_string("maxsize", "", $filesize); $strcancel = get_string("cancel"); $strmodified = get_string("strmodified", 'block_morsle'); //CLAMP #289 set color and background-color to transparent //Kevin Wiliarty 2011-03-08 $padrename = get_string("rename"); $padedit = $padunzip = $padlist = $padrestore = $padchoose = $padfolder = $padfile = $padlink = ''; $attsArr = array($padedit => $stredit, $padunzip => $strunzip, $padlist => $strlist, $padrestore => $strrestore, $padchoose => $strchoose, $padfolder => $strfolder, $padfile => $strfile, $padlink => $strlinktocourse); foreach ($attsArr as $key => $value) { $key = html_writer::div($value . ' ', '', array('style' => 'color:transparent; background-color:transparent; display:inline;')); } /* $padedit = html_writer::div($stredit . ' ','', array('style'=>'color:transparent; background-color:transparent; display:inline')); $padunzip = html_writer::div($strunzip . ' ','', array('style'=>'color:transparent; background-color:transparent; display:inline')); $padlist = html_writer::div($strlist . ' ','', array('style'=>'color:transparent; background-color:transparent; display:inline')); $padrestore = html_writer::div($strrestore . ' ','', array('style'=>'color:transparent; background-color:transparent; display:inline')); $padchoose = html_writer::div($strchoose . ' ','', array('style'=>'color: transparent; background-color:transparent; display:inline')); $padfolder = html_writer::div($strfolder . ' ','', array('style'=>'color:transparent; background-color:transparent; display:inline;')); $padfile = html_writer::div($strfile . ' ','', array('style'=>'color:transparent; background-color; transparent; display:inline;')); $padlink = html_writer::div($strlinktocourse . ' ','', array('style'=>'color:transparent; background-color:transparent; display:inline;')); */ $gdocsstr = 'Google-Docs-Storage-for-'; // Set sort arguments so that clicking on a column that is already sorted reverses the sort order $sortvalues = array(1, 2, 3); foreach ($sortvalues as &$sortvalue) { if ($sortvalue == $sort) { $sortvalue = -$sortvalue; } } $upload_max_filesize = get_max_upload_file_size($CFG->maxbytes); // beginning of with selected files portion echo html_writer::start_tag('table', array('border' => '0', 'cellspacing' => '2', 'cellpadding' => '2', 'style' => 'min-width: 900px; margin-left:auto; margin-right:auto', 'class' => 'files')); if ($wdir !== '') { echo html_writer::start_tag('tr'); //html_writer::table($table); if (!empty($USER->fileop) and $USER->fileop == "move" and $USER->filesource != $wdir) { echo html_writer::start_tag('td', array('colspan' => '3', 'align' => 'center')); // move files to other folder form echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get')); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'paste')); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'sesskey', 'value' => $USER->sesskey)); echo html_writer::tag('input', '', array('align' => 'center', 'type' => 'submit', 'value' => $strmovefilestohere)); //echo "<span> --> <b>$wdir</b></span><br />"; echo html_writer::start_span() . '-->' . html_writer::tag('b', $wdir) . html_writer::end_span() . html_writer::end_tag('br'); echo html_writer::end_tag('td'); echo html_writer::start_tag('td'); echo html_writer::end_tag('form'); // cancel moving form echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get', 'align' => 'left')); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'cancel')); echo html_writer::tag('input', '', array('type' => 'submit', 'value' => $strcancel, 'style' => 'color:red; margin-left:10px')); echo html_writer::end_tag('form'); echo html_writer::end_tag('td'); } else { if (has_capability('moodle/course:update', $coursecontext) || strpos($wdir, '-write')) { echo html_writer::start_tag('tr', array('style' => 'background-color: #ffddbb;')); echo html_writer::start_tag('td', array('colspan' => '3', 'align' => 'left', 'style' => 'background-color:#ffddbb; padding-left:5px;')); // file upload form // TODO: what if we're in the user or departmental dir? echo html_writer::start_tag('form', array('enctype' => 'multipart/form-data', 'method' => 'post', 'action' => 'morslefiles.php')); echo html_writer::start_span() . ' ' . $struploadafile . ' (' . $strmaxsize . ') ' . html_writer::tag('b', $wdir) . html_writer::end_span() . html_writer::tag('br', ''); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'upload')); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'sesskey', 'value' => $USER->sesskey)); if (!isset($coursebytes)) { $coursebytes = 0; } if (!isset($modbytes)) { $modbytes = 0; } $maxbytes = get_max_upload_file_size($CFG->maxbytes, $coursebytes, $modbytes); $str = html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'MAX_FILE_SIZE', 'value' => $maxbytes)) . "\n"; $name = 'userfile'; $str .= html_writer::tag('input', '', array('type' => 'file', 'size' => '50', 'name' => $name, 'alt' => $name, 'style' => 'margin-left: 5px;')) . html_writer::end_tag('br') . "\n"; echo $str; echo html_writer::tag('input', '', array('type' => 'submit', 'name' => 'save', 'value' => $struploadthisfile, 'style' => 'color:green; padding-left:5px;')); echo html_writer::tag('input', '', array('type' => 'submit', 'name' => 'savelink', 'value' => $struploadandlinkthisfile, 'style' => 'color:blue; padding-left:5px;')); echo html_writer::end_tag('form'); echo html_writer::end_tag('td'); echo html_writer::end_tag('tr'); // cancel button div only if not in root morsle directory echo html_writer::start_tag('tr'); echo html_writer::tag('td', '', array('colspan' => '2', 'style' => 'background-color:#ffddbb;')); echo html_writer::start_tag('td', array('style' => 'background-color:#ffddbb; padding-left:5px;', 'colspan' => '1', 'align' => 'right')); echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get', 'align' => 'left')); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'cancel')); echo html_writer::tag('input', '', array('type' => 'submit', 'value' => $strcancel, 'align' => 'left', 'style' => 'color:red;')); echo html_writer::end_tag('form'); echo html_writer::end_tag('td'); echo html_writer::end_tag('tr'); echo html_writer::end_tag('tr'); echo html_writer::start_tag('tr'); echo html_writer::start_tag('tr') . html_writer::tag('td', '<br>', array('colspace' => '4')) . html_writer::end_tag('tr'); echo html_writer::start_tag('td', array('style' => 'max-width:50px; white-space:nowrap;', 'colspan' => '2', 'align' => 'left')); //dummy form - alignment only echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get')); echo html_writer::start_tag('fieldset', array('class' => 'invisiblefieldset')); echo html_writer::tag('input', '', array('type' => 'button', 'value' => $strselectall, 'onclick' => 'checkall();', 'style' => 'color:green;')); echo html_writer::tag('input', '', array('type' => 'button', 'value' => $strselectnone, 'onclick' => 'checknone();', 'style' => 'color:red;')); echo html_writer::end_tag('fieldset'); echo html_writer::end_tag('form'); echo html_writer::end_tag('td'); echo html_writer::start_tag('td', array('align' => 'center', 'colspan' => '2')); // makedir form // TODO: program to allow this in user and departmental directory if (strpos($wdir, $deptstr) === false && strpos($wdir, $userstr) === false) { // not a user or departmental folder echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'get')); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'action', 'value' => 'makedir')); echo html_writer::tag('input', '', array('type' => 'submit', 'value' => $strmakeafolder)); echo html_writer::end_tag('form'); } echo html_writer::end_tag('td'); echo html_writer::end_tag('tr'); } } } echo html_writer::start_tag('form', array('action' => 'morslefiles.php', 'method' => 'post', 'id' => 'dirform')); echo html_writer::start_div(); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose)); echo html_writer::start_tag('tr'); echo html_writer::start_tag('th', array('class' => 'header', 'scope' => 'col', 'style' => 'max-width:40px;')); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'courseid', 'value' => $courseid)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'choose', 'value' => $choose)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'wdir', 'value' => $wdir)); echo html_writer::tag('input', '', array('type' => 'hidden', 'name' => 'sesskey', 'value' => $USER->sesskey)); // $options = array ("delete" => "$strdeletefromcollection"); // only editing teachers can link items to course page if (has_capability('moodle/course:update', $coursecontext)) { $options['link'] = "{$strlinktocourse}"; } if (!empty($filelist) || !empty($dirlist)) { // echo html_writer::tag('label', "$strwithchosenfiles...", array('for'=>'formactionid')); // echo html_writer::select($options, "$strwithchosenfiles...", '', array(1 => "$strwithchosenfiles...")); echo html_writer::start_div('', array('id' => 'noscriptgo', 'style' => 'display:inline;')); echo html_writer::tag('input', '', array('type' => 'submit', 'value' => get_string('go'))); echo html_writer::script('document.getElementById("noscriptgo").style.display="none"'); echo html_writer::end_div(); } echo html_writer::end_tag('th'); echo html_writer::start_tag('th', array('style' => 'padding-right:120px;', 'class' => 'header name', 'scope' => 'col')) . html_writer::link(qualified_me(), $strname, array('&sort' => '{' . $sortvalues[0] . '}')) . html_writer::end_tag('th'); echo html_writer::start_tag('th', array('class' => 'header date', 'scope' => 'col')) . html_writer::link(qualified_me(), $strmodified, array('&sort' => '{' . $sortvalues[2] . '}')) . html_writer::end_tag('th'); echo html_writer::tag('th', $straction, array('class' => 'header commands', 'scope' => 'col')); echo html_writer::end_tag('tr') . "\n"; // Sort parameter indicates column to sort by, and parity gives the direction switch ($sort) { case 1: $sortcmp = 'return strcasecmp($a[0],$b[0]);'; break; case -1: $sortcmp = 'return strcasecmp($b[0],$a[0]);'; break; case 2: $sortcmp = 'return ($a[1] - $b[1]);'; break; case -2: $sortcmp = 'return ($b[1] - $a[1]);'; break; case 3: $sortcmp = 'return ($a[2] - $b[2]);'; break; case -3: $sortcmp = 'return ($b[2] - $a[2]);'; break; } // Create a 2D array of directories and sort $dirdetails = array(); foreach ($dirlist as $name => $dir) { $dirdetails[$name] = new stdClass(); $dirdetails[$name]->updated = docdate($dir); $dirdetails[$name]->link = $dir->alternateLink; // usort($dirdetails, create_function('$a,$b', $sortcmp)); } // TODO: change to handle cross-listed courses // TODO: this needs to change if we eliminate morsle table if ($wdir === '') { $shortname = is_number(substr($course->shortname, 0, 5)) ? substr($course->shortname, 6) : $course->shortname; // SPLIT INTO DEPARTMENTAL CODES $dept = explode("-", $shortname); $deptpart = defined($dept[0]) ? CONSTANT($dept[0]) : null; $deptstr = $deptpart . $deptstr; $deptaccount = strtolower($deptstr); // only show the user collection if we're in the base folder $dirdetails[$userstr] = new stdClass(); $dirdetails[$userstr]->updated = date('Y-m-d'); $dirdetails[$userstr]->link = 'https://drive.google.com'; // always include departmental directory if exists // check to see if we even have a departmental account for this department but don't show the departmental collection if we're already in it indicated by $wdir if ($is_morsle_dept = $DB->get_record('morsle_active', array('shortname' => $deptaccount)) && has_capability('moodle/course:update', $coursecontext)) { $dirdetails[$deptstr] = new stdClass(); $dirdetails[$deptstr]->updated = date('Y-m-d'); } } // Create a 2D array of files and sort $filedetails = array(); $filetitles = array(); foreach ($filelist as $name => $file) { $filedetails[$name] = new stdClass(); $filedetails[$name]->updated = docdate($file); $filedetails[$name]->link = $file->alternateLink; // $row = array($filename, $filedate); // array_push($filedetails, $row); // usort($filedetails, create_function('$a,$b', $sortcmp)); } // TODO: fix this hack so we're back to being able to sort // ksort($filedetails); // sets the locked in sorting to name // need this in order to look up the link for the file based on doc title (key) /* if (sizeof($filelist) > 0) { $filevalues = array_values($filelist); $filelist = array_combine($filetitles, $filevalues); } */ // $count = 0; // $countdir = 0; $edittext = $padchoose . $padedit . $padunzip . $padlist . $padrestore; if ($wdir !== '') { $pathparts = explode('/', $wdir); array_pop($pathparts); $wdir = implode('/', $pathparts); echo "<tr class=\"folder\">"; print_cell(); print_cell('left', '<a href="morslefiles.php?courseid=' . $courseid . '&wdir=' . $wdir . '&choose=' . $choose . '&name=' . $name . '"><img src="' . $OUTPUT->pix_url('f/folder') . '" class="icon" alt="" /> ' . get_string('parentfolder') . '</a>', 'name'); // print_cell('left', '<a style="padding-left:0px" href="morslefiles.php?courseid='.$courseid.'&wdir='.$wdir.'/&choose='.$choose.'"> '.get_string('parentfolder').'</a>', 'parent'); echo "</tr>"; } if (!empty($dirdetails)) { foreach ($dirdetails as $name => $dir) { echo html_writer::start_tag('tr', array('class' => 'folder')); $filedate = $dir->updated; $filesafe = rawurlencode($name); $filename = $name; $fileurl = $dir->link; // $countdir++; // TODO: fix the parent directory if ($name == '..') { // $fileurl = rawurlencode(dirname($wdir)); print_cell(); // alt attribute intentionally empty to prevent repetition in screen reader //CLAMP #289 change padding-left from 10 to 0px //Kevin Wiliarty 2011-03-08 print_cell('left', '<a style="padding-left:0px" href="morslefiles.php?courseid=' . $courseid . '&wdir=' . $wdir . '/' . $fileurl . '&choose=' . $choose . '"><img src="' . $OUTPUT->pix_url('f/parent.gif') . '" class="icon" alt="" /> ' . get_string('parentfolder') . '</a>', 'name'); print_cell(); print_cell(); print_cell(); /* } else if ($name === $userstr) { // if departmental account or user collection // TODO: need to determine what $wdir is if we're coming in from one of the course subcollections // don't know where this fits in $branchdir = strpos($wdir,'read') !== false || strpos($wdir,'write') !== false || $wdir === '' ? $filesafe : "$wdir/$filesafe"; print_cell(); // alt attribute intentionally empty to prevent repetition in screen reader //CLAMP #289 change padding-left from 10 to 0px //Kevin Wiliarty 2011-03-08 print_cell('left', '<a style="padding-left:0px" href="morslefiles.php?courseid=' . $courseid . '&wdir=' . $wdir . '&choose=' . $choose .'&name=' . $name . '"><img src="'.$OUTPUT->pix_url('f/folder').'" class="icon" alt="" /> '. $name .'</a>', 'name'); // print_cell('left', '<a style="padding-left:0px" href="' . $fileurl . '" target="_blank"><img src="'. $OUTPUT->pix_url("f/folder") .'" class="icon" alt="" /> '. $filename .'</a>'); print_cell("right", $filedate, 'date'); // print_cell(); print_cell(); // print_cell(); } else if ($name === $deptstr){ // TODO: need to determine what $wdir is if we're coming in from one of the course subcollections $branchdir = strpos($wdir,'read') !== false || strpos($wdir,'write') !== false || $wdir === '' ? $filesafe : "$wdir/$filesafe"; print_cell("center", "<input type=\"checkbox\" name=\"dir$countdir\" value=\"$filename\" />", 'checkbox'); // alt attribute intentionally empty to prevent repetition in screen reader //CLAMP #289 change padding-left from 10 to 0px //Kevin Wiliarty 2011-03-08 print_cell('left', '<a style="padding-left:0px" href="morslefiles.php?courseid=' . $courseid . '&wdir=' . $branchdir . '&choose=' . $choose . '&name=' . $name . '"><img src="'.$OUTPUT->pix_url('f/folder').'" class="icon" alt="" /> '. $name .'</a>', 'name'); print_cell("right", $filedate, 'date'); // print_cell(); if (has_capability('moodle/course:update', $coursecontext)) { print_cell("left", "$edittext<a href=\"morslefiles.php?courseid=$courseid&wdir=$branchdir&file=$filename&action=link&type=dir&choose=$choose\">$strlinktocourse</a>", 'commands'); } // print_cell(); */ } else { // not a user or departmental folder print_cell(); // print_cell("center", "<input type=\"checkbox\" name=\"$name\" value=\"$filename\" />", 'checkbox'); // print_cell("left", "<a href=\"morslefiles.php?courseid=$courseid&wdir=$wdir/$filesafe&choose=$choose\"><img src=\"$OUTPUT->pix_url('f/folder')\" class=\"icon\" alt=\"$strfolder\" /> ".$filename."</a>", 'name'); $branchdir = "{$wdir}/{$filesafe}"; // $branchdir = strpos($wdir,'read') !== false || strpos($wdir,'write') !== false || $wdir === '' ? $filesafe : "$wdir/$filesafe"; print_cell('left', '<a href="morslefiles.php?courseid=' . $courseid . '&wdir=' . $branchdir . '&choose=' . $choose . '&name=' . $name . '"><img src="' . $OUTPUT->pix_url('f/folder') . '" class="icon" alt="" /> ' . $filename . '</a>', 'name'); print_cell("right", $filedate, 'date'); // print_cell(); if (has_capability('moodle/course:update', $coursecontext)) { print_cell("left", "{$edittext}<a href=\"morslefiles.php?courseid={$courseid}&wdir={$branchdir}&file={$filename}&action=link&type=dir&choose={$choose}\">{$strlinktocourse}</a>", 'commands'); // print_cell("left", "$edittext<a href=\"morslefiles.php?courseid=$courseid&wdir=$wdir&file=$filename&action=link&type=dir&choose=$choose\">$strlinktocourse</a>", 'commands'); } } echo html_writer::end_tag('tr'); } } $iconchoices = array('excel' => 'download/spreadsheets', 'powerpoint' => 'download/presentations', 'word' => 'download/documents', 'pdf' => 'application/pdf'); if (!empty($filedetails)) { foreach ($filedetails as $name => $file) { if (isset($filelist[$name]->exportLinks)) { $links = array(); $links = array_values($filelist[$name]->exportLinks); $exportlink = $links[0]; } else { $exportlink = $filelist[$name]->alternateLink; } // positively identify the correct icon regardless of filename extension $icon = $filelist[$name]->iconLink; $filename = $name; $fileurl = $file->link; $embedlink = $filelist[$name]->embedLink; $embedsafe = rawurlencode($embedlink); $fileurlsafe = rawurlencode($fileurl); $filedate = $file->updated; $fileid = $filelist[$name]->id; $selectfile = trim($fileurl, "/"); // echo html_writer::start_tag('td', array('class'=>'file')); // echo html_writer::end_tag('td'); print_cell("center", "<input type=\"checkbox\" name=\"file\" value=\"{$filename}\" />", 'checkbox'); //CLAMP #289 change padding-left from 10 to 0px //Kevin Wiliarty 2011-03-08 // echo html_writer::start_tag('td', array('align'=>'left','style'=>'white-space:nowrap; padding-left:0px;','class'=>'name')); print_cell('left', '<a href="' . $fileurl . '" class="morslefile" target="_blank"> <img src="' . $icon . '" class="icon" alt="' . $strfile . '" /> ' . $filename . '</a>', 'name'); // $echovar = '<a href="' . $fileurl . '" target="_blank"> // <img src="' . $OUTPUT->pix_url("f/$icon") . '" class="icon" alt="' . $strfile . '" /> ' . htmlspecialchars($filename) . '</a>'; // echo $echovar; //html_writer::link(qualified_me(), $strname, array('&sort'=>'{'.$sortvalues[0].'}')) //$echovar = html_writer::tag('a', $fileurl, array('target'=>'_blank')) . html_writer::img($OUTPUT->pix_url("f/$icon"), $strfile, array('class'=>'icon')) . ' '.htmlspecialchars($filename) . html_writer::end_tag('a'); //echo $echovar; // echo html_writer::end_tag('td'); print_cell("right", $filedate, 'date'); if (has_capability('moodle/course:update', $coursecontext)) { if (strpos($wdir, $gdocsstr) === 1) { print_cell("left", "{$edittext} <a href=\"morslefiles.php?courseid={$courseid}&wdir={$wdir}/{$fileid}&file={$filename}&name={$filename}&filelink={$fileurl}&action=link&type=file&choose={$choose}\">{$strlinktocourse}</a>", 'commands'); } else { print_cell("left", "{$edittext} <a href=\"morslefiles.php?courseid={$courseid}&wdir={$wdir}&file={$filename}&action=link&type=file&choose={$choose}\">{$strlinktocourse}</a>", 'commands'); } // print_cell('left', '  <a title="' . $name . '" href="embeddoc.php?courseid=$courseid&embedlink=' . $embedsafe . '&name=' . $filename . '"> Embed </a>','embed'); } // print_cell('left', '  <a title="' . strip_tags($strdownload) . ': ' . $name . '" href="' .$CFG->wwwroot // . '/blocks/morsle/docs_export.php?exportlink=' . s($exportlink) . '&shortname=' . $course->shortname . '&title=' . $filename . '" target="_blank"> Download </a>','commands'); print_cell(); print_cell('left', '  <a title="' . $name . '" href="' . s($exportlink) . '" target="_blank"> Download </a>', 'commands'); //print_cell('left', '  <a title="' . $name . '" href="embeddoc.php?"' . s($embedlink) . '" target="_blank"> Embed in a Page resource </a>','commands'); echo html_writer::end_tag('tr'); } } echo html_writer::end_div(); echo html_writer::end_tag('form'); echo html_writer::end_tag('table'); }
$PAGE->set_title($title); $PAGE->set_heading($course->fullname); $PAGE->requires->js('/mod/reader/js/jquery-1.4.2.min.js', true); if (empty($quizid)) { echo $OUTPUT->header(); echo $OUTPUT->box_start('generalbox'); $o = ""; $o .= 'var quizzes = new Array();'; $lastkey = 0; while (list($key, $value) = each($quiz)) { $o .= ' quizzes[' . $key . '] = [' . $value . '];'; $lastkey = $key; } $o .= 'lastkey = ' . $lastkey . ';'; $o .= '$(document).ready(function() {loadquiz(0);});function loadquiz(key) {if (key == window.lastkey) var end = 1; else var end = 0;$.post(\'' . $CFG->wwwroot . '/mod/reader/dlquizzes_proccess.php?id=' . $id . '&quizid=\'+window.quizzes[key]+\'&courseid=' . $courseid . '§ionchoosing=' . $sectionchoosing . '§ion=' . $section . '&end=\'+end, function(data) {$("#installationlog").append(data);if (key != window.lastkey) loadquiz(key + 1); });}'; echo html_writer::script($o); echo html_writer::tag('div', 'Installation in process...', array('id' => 'installationlog')); } else { $OUTPUT->header(); $xmlquizzesfile = reader_file($readercfg->reader_serverlink . "/?a=quizzes&login={$readercfg->reader_serverlogin}&password={$readercfg->reader_serverpassword}", array('password' => $password, 'quiz' => array($quizid), 'upload' => 'true')); $listofquizzes = xmlize($xmlquizzesfile); foreach ($listofquizzes['myxml']['#']['item'] as $number => $listofquizze) { foreach ($listofquizze['@'] as $key => $value) { $quizzestoadd[$number][$key] = $value; $sections[$listofquizze['@']['publisher'] . " - " . $listofquizze['@']['level']] = $listofquizze['@']['publisher'] . " - " . $listofquizze['@']['level']; if (empty($currentsection)) { $currentsection = $listofquizze['@']['publisher'] . " - " . $listofquizze['@']['level']; } } } if ($courseid == 0) {
}, success: function(data){ $("#result").html("Cost is Updated"); } }); }; '); echo html_writer::script("$( document ).ready(function() { $('.batch_cost').attr('disabled', 'disabled'); $('#checkboxcost').click(function() { if($(this).prop('checked') == true){ $('.batch_cost').removeAttr('disabled'); $('.session_cost').attr('disabled', 'disabled'); } else if($(this).prop('checked') == false){ $('.batch_cost').attr('disabled', 'disabled'); $('.session_cost').removeAttr('disabled'); } }); }); "); } else{ echo $output->cost_lists($id); } break;
/** * Update the progress bar * * @param int $percent from 1-100 * @param string $msg * @return void Echo's output * @throws coding_exception */ private function _update($percent, $msg) { if (empty($this->time_start)) { throw new coding_exception('You must call create() (or use the $autostart ' . 'argument to the constructor) before you try updating the progress bar.'); } if (CLI_SCRIPT) { return; // Temporary solution for cli scripts. } $estimate = $this->estimate($percent); if ($estimate === null) { // Always do the first and last updates. } else { if ($estimate == 0) { // Always do the last updates. } else { if ($this->lastupdate + 20 < time()) { // We must update otherwise browser would time out. } else { if (round($this->percent, 2) === round($percent, 2)) { // No significant change, no need to update anything. return; } } } } if (is_numeric($estimate)) { $estimate = get_string('secondsleft', 'moodle', round($estimate, 2)); } $this->percent = round($percent, 2); $this->lastupdate = microtime(true); echo html_writer::script(js_writer::function_call('updateProgressBar', array($this->html_id, $this->percent, $msg, $estimate))); flush(); }
window.close(); }, {$timeout}); EOF; if ($data = $form->get_data()) { $type = new stdClass(); if (!empty($typeid)) { $type->id = $typeid; lti_load_type_if_cartridge($data); lti_update_type($type, $data); $fromdb = lti_get_type($typeid); $json = json_encode($fromdb); // Output script to update the calling window. $script = <<<EOF window.opener.M.mod_lti.editor.updateToolType({$json}); EOF; } else { $type->state = LTI_TOOL_STATE_CONFIGURED; $type->course = $COURSE->id; lti_load_type_if_cartridge($data); $id = lti_add_type($type, $data); $fromdb = lti_get_type($id); $json = json_encode($fromdb); // Output script to update the calling window. $script = <<<EOF window.opener.M.mod_lti.editor.addToolType({$json}); EOF; } } echo html_writer::script($script . $closewindow); } echo $OUTPUT->footer();
/** * Replace flv links with flow player. * * @param $link * @return string */ function filter_mediaplugin_flv_callback($link) { static $count = 0; if (filter_mediaplugin_ignore($link[0])) { return $link[0]; } $count++; $id = 'filter_flv_' . time() . '_' . $count; //we need something unique because it might be stored in text cache list($urls, $width, $height) = filter_mediaplugin_parse_alternatives($link[1], 0, 0); $autosize = false; if (!$width and !$height) { $width = FILTER_MEDIAPLUGIN_VIDEO_WIDTH; $height = FILTER_MEDIAPLUGIN_VIDEO_HEIGHT; $autosize = true; } $flashurl = null; $sources = array(); foreach ($urls as $url) { $mimetype = filter_mediaplugin_get_mimetype($url); if (strpos($mimetype, 'video/') !== 0) { continue; } $source = html_writer::tag('source', '', array('src' => $url, 'type' => $mimetype)); if ($mimetype === 'video/mp4') { // better add m4v as first source, it might be a bit more compatible with problematic browsers array_unshift($sources, $source); } else { $sources[] = $source; } if ($flashurl === null) { $flashurl = $url; } } if (!$sources) { return $link[0]; } $info = trim($link[4]); if (empty($info) or strpos($info, 'http') === 0) { $info = get_string('fallbackvideo', 'filter_mediaplugin'); } $printlink = html_writer::link($flashurl . '#', $info, array('class' => 'mediafallbacklink')); // the '#' prevents the QT filter $title = s($info); if (count($sources) > 1) { $sources = implode("\n", $sources); // html 5 fallback $printlink = <<<OET <video controls="true" width="{$width}" height="{$height}" preload="metadata" title="{$title}"> {$sources} {$printlink} </video> <noscript><br /> {$printlink} </noscript> OET; } // note: no need to print "this is flv link" because it is printed automatically if JS or Flash not available $output = html_writer::tag('span', $printlink, array('id' => $id, 'class' => 'mediaplugin mediaplugin_flv')); $output .= html_writer::script(js_writer::function_call('M.util.add_video_player', array($id, addslashes_js($flashurl), $width, $height, $autosize))); // we can not use standard JS init because this may be cached return $output; }
public function timetable_school_classtypes_view() { global $DB, $CFG, $OUTPUT, $USER, $PAGE; $PAGE->requires->js('/local/timetable/js/tmember_toggle.js'); $systemcontext = context_system::instance(); $j = 0; foreach ($this->classtype_schools as $list) { // echo $list->teammanagerid; $line = array(); $schoolinfo = $DB->get_record('local_school', array('id' => $list->schoolid, 'visible' => 1)); if ($j > 0) $displaynone = "display:none"; else $displaynone = ""; $firstrow = "<ul id='settiming_firstrow'><li>" . get_string('school_time', 'local_timetable') . '<b>' . $schoolinfo->fullname . html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('t/switch'), 'class' => 'iconsmall', 'onclick' => 'teammember_list(' . $list->id . ')', 'id' => 'tm_switchbutton'), array('style' => 'cursor:pointer')) . "</b></li></ul>"; $toggle = "<div id = 'dialog$list->id' class = 'tmem_toggle dialog1' style = '$displaynone;clear:both; '>"; $toggle .= $this->toggle_classtypeview($list->schoolid); $toggle .="</div>"; $cell1 = new html_table_cell(); $cell1->attributes['class'] = 'tmcell'; $cell1->text = $firstrow . $toggle; $line[] = $cell1; $data[] = $line; $j++; } $table = new html_table(); //if (has_capability('local/costcenter:manage', $systemcontext)) $table->head = array(get_string('schoolclasstypes', 'local_timetable')); $table->id = "cltype_view"; $table->size = array('100%'); $table->align = array('left', 'left', 'left'); $table->width = '99%'; $table->data = $data; $output = html_writer::table($table); echo html_writer::script(" $(document).ready(function() { $('#timetable_view').dataTable({ 'iDisplayLength': 5, 'fnDrawCallback': function(oSettings) { if(oSettings._iDisplayLength > oSettings.fnRecordsDisplay()) { $('#cltype_view'+'_paginate').hide(); $('#cltype_view'+'_length').hide(); } }, 'aLengthMenu': [ [5, 10, 25, 50, -1], [5, 10, 25, 50, 'All']], 'searching': false, 'aaSorting': [], } ); } ); "); return $output; }
/** * Generate any HTML that needs to go at the end of the page. * * Normally, this method is called automatically by the code that prints the * page footer. You should not normally need to call it in your own code. * * @return string the HTML code to to at the end of the page. */ public function get_end_code() { global $CFG; // add other requested modules $output = $this->get_extra_modules_code(); // add missing YUI2 YUI - to be removed once we convert everything to YUI3! $output .= $this->get_yui2lib_code(); // all the other linked scripts - there should be as few as possible if ($this->jsincludes['footer']) { foreach ($this->jsincludes['footer'] as $url) { $output .= html_writer::script('', $url); } } // add all needed strings if (!empty($this->stringsforjs)) { $output .= html_writer::script(js_writer::set_variable('M.str', $this->stringsforjs)); } // add variables if ($this->jsinitvariables['footer']) { $js = ''; foreach ($this->jsinitvariables['footer'] as $data) { list($var, $value) = $data; $js .= js_writer::set_variable($var, $value, true); } $output .= html_writer::script($js); } $inyuijs = $this->get_javascript_code(false); $ondomreadyjs = $this->get_javascript_code(true); $jsinit = $this->get_javascript_init_code(); $handlersjs = $this->get_event_handler_code(); // there is no global Y, make sure it is available in your scope $js = "YUI(M.yui.loader).use('node', function(Y) {\n{$inyuijs}{$ondomreadyjs}{$jsinit}{$handlersjs}\n});"; $output .= html_writer::script($js); return $output; }
/** * @todo Document this function */ function forum_print_big_search_form($course) { global $CFG, $DB, $words, $subject, $phrase, $user, $userid, $fullwords, $notwords, $datefrom, $dateto, $PAGE, $OUTPUT; echo $OUTPUT->box(get_string('searchforumintro', 'forum'), 'searchbox boxaligncenter', 'intro'); echo $OUTPUT->box_start('generalbox boxaligncenter'); echo html_writer::script('', $CFG->wwwroot . '/mod/forum/forum.js'); echo '<form id="searchform" action="search.php" method="get">'; echo '<table cellpadding="10" class="searchbox" id="form">'; echo '<tr>'; echo '<td class="c0"><label for="words">' . get_string('searchwords', 'forum') . '</label>'; echo '<input type="hidden" value="' . $course->id . '" name="id" alt="" /></td>'; echo '<td class="c1"><input type="text" size="35" name="words" id="words"value="' . s($words, true) . '" alt="" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td class="c0"><label for="phrase">' . get_string('searchphrase', 'forum') . '</label></td>'; echo '<td class="c1"><input type="text" size="35" name="phrase" id="phrase" value="' . s($phrase, true) . '" alt="" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td class="c0"><label for="notwords">' . get_string('searchnotwords', 'forum') . '</label></td>'; echo '<td class="c1"><input type="text" size="35" name="notwords" id="notwords" value="' . s($notwords, true) . '" alt="" /></td>'; echo '</tr>'; if ($DB->get_dbfamily() == 'mysql' || $DB->get_dbfamily() == 'postgres') { echo '<tr>'; echo '<td class="c0"><label for="fullwords">' . get_string('searchfullwords', 'forum') . '</label></td>'; echo '<td class="c1"><input type="text" size="35" name="fullwords" id="fullwords" value="' . s($fullwords, true) . '" alt="" /></td>'; echo '</tr>'; } echo '<tr>'; echo '<td class="c0">' . get_string('searchdatefrom', 'forum') . '</td>'; echo '<td class="c1">'; if (empty($datefrom)) { $datefromchecked = ''; $datefrom = make_timestamp(2000, 1, 1, 0, 0, 0); } else { $datefromchecked = 'checked="checked"'; } echo '<input name="timefromrestrict" type="checkbox" value="1" alt="' . get_string('searchdatefrom', 'forum') . '" onclick="return lockoptions(\'searchform\', \'timefromrestrict\', timefromitems)" ' . $datefromchecked . ' /> '; $selectors = html_writer::select_time('days', 'fromday', $datefrom) . html_writer::select_time('months', 'frommonth', $datefrom) . html_writer::select_time('years', 'fromyear', $datefrom) . html_writer::select_time('hours', 'fromhour', $datefrom) . html_writer::select_time('minutes', 'fromminute', $datefrom); echo $selectors; echo '<input type="hidden" name="hfromday" value="0" />'; echo '<input type="hidden" name="hfrommonth" value="0" />'; echo '<input type="hidden" name="hfromyear" value="0" />'; echo '<input type="hidden" name="hfromhour" value="0" />'; echo '<input type="hidden" name="hfromminute" value="0" />'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td class="c0">' . get_string('searchdateto', 'forum') . '</td>'; echo '<td class="c1">'; if (empty($dateto)) { $datetochecked = ''; $dateto = time() + 3600; } else { $datetochecked = 'checked="checked"'; } echo '<input name="timetorestrict" type="checkbox" value="1" alt="' . get_string('searchdateto', 'forum') . '" onclick="return lockoptions(\'searchform\', \'timetorestrict\', timetoitems)" ' . $datetochecked . ' /> '; $selectors = html_writer::select_time('days', 'today', $dateto) . html_writer::select_time('months', 'tomonth', $dateto) . html_writer::select_time('years', 'toyear', $dateto) . html_writer::select_time('hours', 'tohour', $dateto) . html_writer::select_time('minutes', 'tominute', $dateto); echo $selectors; echo '<input type="hidden" name="htoday" value="0" />'; echo '<input type="hidden" name="htomonth" value="0" />'; echo '<input type="hidden" name="htoyear" value="0" />'; echo '<input type="hidden" name="htohour" value="0" />'; echo '<input type="hidden" name="htominute" value="0" />'; echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td class="c0"><label for="menuforumid">' . get_string('searchwhichforums', 'forum') . '</label></td>'; echo '<td class="c1">'; echo html_writer::select(forum_menu_list($course), 'forumid', '', array('' => get_string('allforums', 'forum'))); echo '</td>'; echo '</tr>'; echo '<tr>'; echo '<td class="c0"><label for="subject">' . get_string('searchsubject', 'forum') . '</label></td>'; echo '<td class="c1"><input type="text" size="35" name="subject" id="subject" value="' . s($subject, true) . '" alt="" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td class="c0"><label for="user">' . get_string('searchuser', 'forum') . '</label></td>'; echo '<td class="c1"><input type="text" size="35" name="user" id="user" value="' . s($user, true) . '" alt="" /></td>'; echo '</tr>'; echo '<tr>'; echo '<td class="submit" colspan="2" align="center">'; echo '<input type="submit" value="' . get_string('searchforums', 'forum') . '" alt="" /></td>'; echo '</tr>'; echo '</table>'; echo '</form>'; echo html_writer::script(js_writer::function_call('lockoptions_timetoitems')); echo html_writer::script(js_writer::function_call('lockoptions_timefromitems')); echo $OUTPUT->box_end(); }
// No Martin(i), No Party ;-) ?> </div> </noscript> <?php if ($result->prerequisites) { if ($scorm->popup != 0) { // Clean the name for the window as IE is fussy $name = preg_replace("/[^A-Za-z0-9]/", "", $scorm->name); if (!$name) { $name = 'DefaultPlayerWindow'; } $name = 'scorm_' . $name; echo html_writer::script('', $CFG->wwwroot . '/mod/scorm/player.js'); echo html_writer::script(js_writer::function_call('scorm_openpopup', array("loadSCO.php?id=" . $cm->id . $scoidpop, $name, $scorm->options, $scorm->width, $scorm->height))); ?> <noscript> <!--[if IE]> <iframe id="main" class="scoframe" name="main" src="loadSCO.php?id=<?php echo $cm->id . $scoidstr . $modestr; ?> "></iframe> <![endif]--> <!--[if !IE]> <object id="main" class="scoframe" type="text/html" data="loadSCO.php?id=<?php echo $cm->id . $scoidstr . $modestr; ?> "></object> <![endif]--> </noscript>
echo "<h2 class='tmhead2'>".get_string('pluginname', 'local_positions')."</h2>"; //$positions->print_positionstabs('view', $id = NULL); $editoroptions = array('maxfiles' => EDITOR_UNLIMITED_FILES, 'maxbytes' => $CFG->maxbytes, 'trusttext' => false, 'noclean' => true); $editform = new positions_form($CFG->wwwroot.'/local/positions/positions.php?id='.$id.'', array('id' => $id, 'tool' => $positions_instance, 'editoroptions' => $editoroptions)); $editform->set_data($positions_instance); $positionslist = $DB->get_records('local_positions'); if (empty($positionslist)and has_capability('local/positions:manage', $systemcontext)) { $collapse = false; // print_error('positionsnotcreated', 'local_positions', $CFG->wwwroot . '/local/positions/positions.php'); } //if (isset($CFG->allowframembedding) and ! $CFG->allowframembedding and has_capability('local/positions:manage', $systemcontext)) { // echo $output->box(get_string('allowframembedding', 'local_positions')); //} print_collapsible_region_start('', 'positions-form', $form_header,false,$collapse); $editform->display(); print_collapsible_region_end(); echo $output->departments_view(); echo html_writer::script(' $(document).ready(function() { $("#department-index").dataTable({ searching: true, "aaSorting": [], "lengthMenu": [[5, 10, 25,50,100, -1], [5,10,25, 50,100, "All"]], "aoColumnDefs": [{ \'bSortable\': false, \'aTargets\': [ 0 ] }] }); });'); echo $output->footer();
} echo '</table></td></tr>'; } else { echo '<tr><td>'.get_string('noresults').'</td></tr>'; } } else { echo html_writer::label(get_string('search_course', 'feedback') . ': ', 'searchcourse'); echo '<input id="searchcourse" type="text" name="searchcourse" value="'.s($searchcourse).'"/> '; echo '<input type="submit" value="'.get_string('search').'"/>'; echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />'; echo '<input type="hidden" name="id" value="'.$id.'" />'; echo '<input type="hidden" name="courseitemfilter" value="'.$courseitemfilter.'" />'; echo '<input type="hidden" name="courseitemfiltertyp" value="'.$courseitemfiltertyp.'" />'; echo '<input type="hidden" name="courseid" value="'.$courseid.'" />'; echo html_writer::script('', $CFG->wwwroot.'/mod/feedback/feedback.js'); $sql = 'select DISTINCT c.id, c.shortname from {course} c, '. '{feedback_value} fv, {feedback_item} fi '. 'where c.id = fv.course_id and fv.item = fi.id '. 'and fi.feedback = ? '. 'and ('.$DB->sql_like('c.shortname', '?', false).' OR '.$DB->sql_like('c.fullname', '?', false).')'; $params = array($feedback->id, "%$searchcourse%", "%$searchcourse%"); if ($courses = $DB->get_records_sql_menu($sql, $params)) { echo ' '. html_writer::label(get_string('filter_by_course', 'feedback'), 'coursefilterid'). ': '; echo html_writer::select($courses, 'coursefilter', $coursefilter, null, array('id'=>'coursefilterid'));
/** * Generate any HTML that needs to go at the end of the page. * * Normally, this method is called automatically by the code that prints the * page footer. You should not normally need to call it in your own code. * * @return string the HTML code to to at the end of the page. */ public function get_end_code() { global $CFG; $output = ''; // Set the log level for the JS logging. $logconfig = new stdClass(); $logconfig->level = 'warn'; if ($CFG->debugdeveloper) { $logconfig->level = 'trace'; } $this->js_call_amd('core/log', 'setConfig', array($logconfig)); // Call amd init functions. $output .= $this->get_amd_footercode(); // Add other requested modules. $output .= $this->get_extra_modules_code(); $this->js_init_code('M.util.js_complete("init");', true); // All the other linked scripts - there should be as few as possible. if ($this->jsincludes['footer']) { foreach ($this->jsincludes['footer'] as $url) { $output .= html_writer::script('', $url); } } // Add all needed strings. // First add core strings required for some dialogues. $this->strings_for_js(array('confirm', 'yes', 'no', 'areyousure', 'closebuttontitle', 'unknownerror'), 'moodle'); if (!empty($this->stringsforjs)) { $strings = array(); foreach ($this->stringsforjs as $component => $v) { foreach ($v as $indentifier => $langstring) { $strings[$component][$indentifier] = $langstring->out(); } } $output .= html_writer::script(js_writer::set_variable('M.str', $strings)); } // Add variables. if ($this->jsinitvariables['footer']) { $js = ''; foreach ($this->jsinitvariables['footer'] as $data) { list($var, $value) = $data; $js .= js_writer::set_variable($var, $value, true); } $output .= html_writer::script($js); } $inyuijs = $this->get_javascript_code(false); $ondomreadyjs = $this->get_javascript_code(true); $jsinit = $this->get_javascript_init_code(); $handlersjs = $this->get_event_handler_code(); // There is a global Y, make sure it is available in your scope. $js = "(function() {{$inyuijs}{$ondomreadyjs}{$jsinit}{$handlersjs}})();"; $output .= html_writer::script($js); return $output; }
/** * print the item at the complete-page of feedback * * @global object * @param object $item * @param string $value * @param bool $highlightrequire * @return void */ function print_item_complete($item, $value = '', $highlightrequire = false) { global $SESSION, $CFG, $DB, $USER; require_once $CFG->libdir . '/recaptchalib.php'; $align = right_to_left() ? 'right' : 'left'; $cmid = 0; $feedbackid = $item->feedback; if ($feedbackid > 0) { $feedback = $DB->get_record('feedback', array('id' => $feedbackid)); if ($cm = get_coursemodule_from_instance("feedback", $feedback->id, $feedback->course)) { $cmid = $cm->id; } } //check if an false value even the value is not required if ($highlightrequire and !$this->check_value($value, $item)) { $falsevalue = true; } else { $falsevalue = false; } if ($falsevalue) { $highlight = 'missingrequire'; } else { $highlight = ''; } $requiredmark = '<span class="feedback_required_mark">*</span>'; if (isset($SESSION->feedback->captchacheck) and $SESSION->feedback->captchacheck == $USER->sesskey and $value == $USER->sesskey) { //print the question and label echo '<div class="feedback_item_label_' . $align . '">'; echo '(' . $item->label . ') '; echo format_text($item->name . $requiredmark, true, false, false); echo '<input type="hidden" value="' . $USER->sesskey . '" name="' . $item->typ . '_' . $item->id . '" />'; echo '</div>'; return; } $strincorrectpleasetryagain = get_string('incorrectpleasetryagain', 'auth'); $strenterthewordsabove = get_string('enterthewordsabove', 'auth'); $strenterthenumbersyouhear = get_string('enterthenumbersyouhear', 'auth'); $strgetanothercaptcha = get_string('getanothercaptcha', 'auth'); $strgetanaudiocaptcha = get_string('getanaudiocaptcha', 'auth'); $strgetanimagecaptcha = get_string('getanimagecaptcha', 'auth'); $recaptureoptions = array('theme' => 'custom', 'custom_theme_widget' => 'recaptcha_widget'); $html = html_writer::script(js_writer::set_variable('RecaptchaOptions', $recaptureoptions)); $html .= ' <div class="' . $highlight . '" id="recaptcha_widget" style="display:none"> <div id="recaptcha_image"></div> <div class="recaptcha_only_if_incorrect_sol" style="color:red">' . $strincorrectpleasetryagain . '</div> <span class="recaptcha_only_if_image"><label for="recaptcha_response_field">' . $strenterthewordsabove . $requiredmark . '</label></span> <span class="recaptcha_only_if_audio"><label for="recaptcha_response_field">' . $strenterthenumbersyouhear . '</label></span> <input type="text" id="recaptcha_response_field" name="' . $item->typ . '_' . $item->id . '" /> <div><a href="javascript:Recaptcha.reload()">' . $strgetanothercaptcha . '</a></div> <div class="recaptcha_only_if_image"><a href="javascript:Recaptcha.switch_type(\'audio\')">' . $strgetanaudiocaptcha . '</a></div> <div class="recaptcha_only_if_audio"><a href="javascript:Recaptcha.switch_type(\'image\')">' . $strgetanimagecaptcha . '</a></div> </div>'; //we have to rename the challengefield $captchahtml = recaptcha_get_html($CFG->recaptchapublickey, NULL); echo $html . $captchahtml; }
function my_batches_table_dispaly($frecord,$location,$tab,$userid,$sessiontype,$f2f_renderer,$my_session=1){ global $DB, $OUTPUT,$USER,$CFG,$PAGE; $row = array(); $cm = get_coursemodule_from_instance('facetoface', $frecord->id, 0, false, MUST_EXIST); $course_name = $DB->get_field('course','fullname',array('id'=>$cm->course)); $courseid = $DB->get_field('local_batch_courses','courseid',array('batchid'=>$frecord->id)); if($courseid!=''){ $coursename_id = $DB->get_field('course','fullname',array('id'=>$courseid)); } else{ $coursename_id = get_string('not_assigned', 'facetoface'); } $modcontext = context_module::instance($cm->id); $cm->course==1 ? $cname ='System' : $cname = $course_name; $session_active=""; $cofirmation=$DB->record_exists('local_batch_users', array('f2fid'=>$frecord->id,'userid'=>$userid,'confirmation'=>0)); if($userid==$USER->id && $cofirmation){//This condition for employee one time confirmation button*// //$session_active.='<span class="knowmore" style="cursor: pointer;" onclick="confirmation('.$frecord->id.');">'.get_string('confirm', 'facetoface').'</span>'; $confirmation = html_writer::tag('a','<span class="knowmore cpointer" >'.get_string('confirm', 'facetoface').'</span>', array('href' => "$CFG->wwwroot/mod/facetoface/batchstatus.php?type=confirmation&id=$frecord->id", 'id' => 'confirmation'.$frecord->id.'')); $session_active.=$confirmation.html_writer::script("Y.on('click', M.util.tmahendra_show_confirm_dialog, '#confirmation$frecord->id', null, {'message':'" . get_string('confirmation_info', 'mod_facetoface',$frecord->name) . "','callbackargs':{'id':$frecord->id,'extraparams':'&type=confirmation'}});"); } $content = $f2f_renderer->print_session_list($frecord->course, $frecord, $location,$tab);//*This function returns Sessions list of face2fcae*// $actions = '<span id="lp_actions">'.$session_active.'</span>'; $extrainfo = $f2f_renderer->my_session_tabs($frecord,$userid);//*This function returns Sessions list of Tabs based on there capabilities*// $batch_info_dispaly_content=$f2f_renderer->batch_info_dispaly_content($frecord,$userid,$coursename_id,'',$my_session=1);//*This function returns batch_info_dispaly_content on each face2face top*// $row[] = ''. $batch_info_dispaly_content .$actions.$extrainfo.'<div id="f2fview'.$frecord->id.'" style="display:none;" class="dialog">'. $content.'</div>'; return $row; }