本文整理汇总了PHP中html_writer::script方法的典型用法代码示例。如果您正苦于以下问题:PHP html_writer::script方法的具体用法?PHP html_writer::script怎么用?PHP html_writer::script使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类html_writer
的用法示例。
在下文中一共展示了html_writer::script方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formulation_and_controls
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;
}
示例2: render_curdate_controls
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;
}
示例3: cr_add_jsordering
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
}
示例4: toHtml
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;
}
}
示例5: cr_add_jsordering
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
}
示例6: mycommentpopupform
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;
}
示例7: add
/**
* 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);
}
示例8: get_content
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;
}
示例9: toHtml
/**
* 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);
}
示例10: embed
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;
}
示例11: array
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;
示例12: _update
/**
* 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();
}
示例13: get_end_code
/**
* 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;
}
示例14: require_js
/**
* 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));
}
}
}
示例15: preg_replace
</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'));
}