本文整理汇总了PHP中js_writer::set_variable方法的典型用法代码示例。如果您正苦于以下问题:PHP js_writer::set_variable方法的具体用法?PHP js_writer::set_variable怎么用?PHP js_writer::set_variable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类js_writer
的用法示例。
在下文中一共展示了js_writer::set_variable方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
}
示例3: 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);
}
示例4: print_item_complete
/**
* 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;
}
示例5: 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;
}
示例6: 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();
// 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;
}
示例7: 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;
$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;
}
示例8: get_end_code
/**
* Generate any HTML that needs to go at the end of the page.
*
* @return string the HTML code to to at the end of the page.
*/
public function get_end_code()
{
global $CFG;
$output = '';
// Call amd init functions.
$output .= $this->get_amd_footercode();
// 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);
}
}
if (!empty($this->stringsforjs)) {
// Add all needed strings.
$strings = array();
foreach ($this->stringsforjs as $component => $v) {
foreach ($v as $indentifier => $langstring) {
$strings[$component][$indentifier] = $langstring->out();
}
}
// Append don't overwrite.
$output .= html_writer::script('require(["jquery"], function($) {
M.str = $.extend(true, M.str, ' . json_encode($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);
// See if this is still needed when we get to the ajax page.
$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;
}
示例9: scorm_get_toc
//.........这里部分代码省略.........
}
}
if ($usertrack->score_raw != '') {
$score = '(' . get_string('score', 'scorm') . ': ' . $usertrack->score_raw . ')';
}
$strsuspended = get_string('suspended', 'scorm');
if ($incomplete && isset($usertrack->{'cmi.core.exit'}) && $usertrack->{'cmi.core.exit'} == 'suspend') {
$statusicon = '<img src="' . $OUTPUT->pix_url('suspend', 'scorm') . '" alt="' . $strstatus . ' - ' . $strsuspended . '" title="' . $strstatus . ' - ' . $strsuspended . '" />';
}
} else {
if ($play && empty($scoid)) {
$scoid = $sco->id;
}
$incomplete = true;
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="' . $OUTPUT->pix_url('notattempted', 'scorm') . '" alt="' . get_string('notattempted', 'scorm') . '" title="' . get_string('notattempted', 'scorm') . '" />';
} else {
$statusicon = '<img src="' . $OUTPUT->pix_url('asset', 'scorm') . '" alt="' . get_string('asset', 'scorm') . '" title="' . get_string('asset', 'scorm') . '" />';
}
}
if ($sco->id == $scoid) {
$startbold = '<b>';
$endbold = '</b>';
$findnext = true;
$shownext = isset($sco->next) ? $sco->next : 0;
$showprev = isset($sco->previous) ? $sco->previous : 0;
}
if ($nextid == 0 && scorm_count_launchable($scorm->id, $currentorg) > 1 && $nextsco !== false && !$findnext) {
if (!empty($sco->launch)) {
$previd = $sco->id;
}
}
if (empty($sco->prerequisites) || scorm_eval_prerequisites($sco->prerequisites, $usertracks)) {
if ($sco->id == $scoid) {
$result->prerequisites = true;
}
$url = $CFG->wwwroot . '/mod/scorm/player.php?a=' . $scorm->id . '&currentorg=' . $currentorg . $modestr . '&scoid=' . $sco->id;
$thisscoidstr = '&scoid=' . $sco->id;
//$link = $CFG->wwwroot.'/mod/scorm/loadSCO.php?a='.$scorm->id.$thisscoidstr.$modestr;
$link = 'a=' . $scorm->id . $thisscoidstr . '¤torg=' . $currentorg . $modestr . '&attempt=' . $attempt;
//$result->toc .= $statusicon.' '.$startbold.'<a href="'.$url.'">'.format_string($sco->title).'</a>'.$score.$endbold."</li>\n";
//$result->toc .= '<a title="'.$link.'">'.$statusicon.' '.format_string($sco->title).' '.$score.'</a>';
if ($sco->launch) {
$result->toc .= '<a title="' . $link . '">' . $statusicon . ' ' . format_string($sco->title) . ' ' . $score . '</a>';
} else {
$result->toc .= '<span>' . $statusicon . ' ' . format_string($sco->title) . '</span>';
}
$tocmenus[$sco->id] = scorm_repeater('−', $level) . '>' . format_string($sco->title);
} else {
if ($sco->id == $scoid) {
$result->prerequisites = false;
}
if ($play) {
// should be disabled
$result->toc .= '<span>' . $statusicon . ' ' . format_string($sco->title) . '</span>';
} else {
$result->toc .= $statusicon . ' ' . format_string($sco->title) . "\n";
}
}
if ($nextsco === false || $nextsco->parent == $sco->parent) {
$result->toc .= '</li>';
}
}
} else {
$result->toc .= ' ' . format_string($sco->title) . "</li>\n";
}
if ($nextsco !== false && $nextid == 0 && $findnext) {
if (!empty($nextsco->launch)) {
$nextid = $nextsco->id;
}
}
}
for ($i = 0; $i < $level; $i++) {
$result->toc .= "\t\t</ul></li>\n";
}
if ($play) {
$sco = scorm_get_sco($scoid);
$sco->previd = $previd;
$sco->nextid = $nextid;
$result->sco = $sco;
$result->incomplete = $incomplete;
} else {
$result->incomplete = $incomplete;
}
}
$result->toc .= '</ul>';
// NEW IMS TOC
if ($tocheader) {
$result->toc .= '</div></div></div>';
$result->toc .= '<div id="scorm_navpanel"></div>';
}
if ($scorm->hidetoc == 0) {
$result->toc .= html_writer::script(js_writer::set_variable('scormdata', array('plusicon' => $OUTPUT->pix_url('plus', 'scorm'), 'minusicon' => $OUTPUT->pix_url('minus', 'scorm'))));
$result->toc .= html_writer::script('', $CFG->wwwroot . '/lib/cookies.js');
$result->toc .= html_writer::script('', $CFG->wwwroot . '/mod/scorm/datamodels/scorm_datamodels.js');
}
$url = new moodle_url('/mod/scorm/player.php?a=' . $scorm->id . '¤torg=' . $currentorg . $modestr);
$result->tocmenu = $OUTPUT->single_select($url, 'scoid', $tocmenus, $sco->id, null, "tocmenu");
return $result;
}
示例10: scorm_get_toc
//.........这里部分代码省略.........
}
} else {
if ($play && empty($scoid)) {
$scoid = $sco->id;
}
$incomplete = true;
if ($sco->scormtype == 'sco') {
$statusicon = '<img src="'.$OUTPUT->pix_url('notattempted', 'scorm').'" alt="'.get_string('notattempted','scorm').'" title="'.get_string('notattempted','scorm').'" />';
} else {
$statusicon = '<img src="'.$OUTPUT->pix_url('asset', 'scorm').'" alt="'.get_string('asset','scorm').'" title="'.get_string('asset','scorm').'" />';
}
}
if ($sco->id == $scoid) {
$findnext = true;
}
if (($nextid == 0) && (scorm_count_launchable($scorm->id,$currentorg) > 1) && ($nextsco!==false) && (!$findnext)) {
if (!empty($sco->launch)) {
$previd = $sco->id;
}
}
if (empty($sco->prerequisites) || scorm_eval_prerequisites($sco->prerequisites,$usertracks)) {
if ($sco->id == $scoid) {
$result->prerequisites = true;
}
$thisscoidstr = '&scoid='.$sco->id;
$link = 'a='.$scorm->id.$thisscoidstr.'¤torg='.$currentorg.$modestr.'&attempt='.$attempt;
if ($toclink == TOCFULLURL) { //display toc with urls for structure page
$url = $CFG->wwwroot.'/mod/scorm/player.php?a='.$scorm->id.'&currentorg='.$currentorg.$modestr.'&scoid='.$sco->id;
$result->toc .= $statusicon.' <a href="'.$url.'">'.format_string($sco->title).'</a>'.$score."\n";
} else {
if ($sco->launch) {
$result->toc .= '<a title="'.$link.'">'.$statusicon.' '.format_string($sco->title).' '.$score.'</a>';
} else {
$result->toc .= '<span>'.$statusicon.' '.format_string($sco->title).'</span>';
}
}
$tocmenus[$sco->id] = scorm_repeater('−',$level) . '>' . format_string($sco->title);
} else {
if ($sco->id == $scoid) {
$result->prerequisites = false;
}
if ($play) {
// should be disabled
$result->toc .= '<span>'.$statusicon.' '.format_string($sco->title).'</span>';
} else {
$result->toc .= $statusicon.' '.format_string($sco->title)."\n";
}
}
if (($nextsco === false) || $nextsco->parent == $sco->parent) {
$result->toc .= '</li>';
}
}
} else {
$result->toc .= ' '.format_string($sco->title)."</li>\n";
}
if (($nextsco !== false) && ($nextid == 0) && ($findnext)) {
if (!empty($nextsco->launch)) {
$nextid = $nextsco->id;
}
}
}
for ($i=0;$i<$level;$i++) {
$result->toc .= "\t\t</ul></li>\n";
}
if ($play) {
$sco = scorm_get_sco($scoid);
$sco->previd = $previd;
$sco->nextid = $nextid;
$result->sco = $sco;
$result->incomplete = $incomplete;
} else {
$result->incomplete = $incomplete;
}
}
$result->toc .= '</ul>';
// NEW IMS TOC
if ($tocheader) {
$result->toc .= '</div></div></div>';
$result->toc .= '<div id="scorm_navpanel"></div>';
}
if ($scorm->hidetoc == 0) {
$result->toc .= html_writer::script(js_writer::set_variable('scormdata', array(
'plusicon' => $OUTPUT->pix_url('plus', 'scorm'),
'minusicon' => $OUTPUT->pix_url('minus', 'scorm'))));
$result->toc .= html_writer::script('', $CFG->wwwroot.'/lib/cookies.js');
$result->toc .= html_writer::script('', $CFG->wwwroot.'/mod/scorm/datamodels/scorm_datamodels.js');
}
$url = new moodle_url('/mod/scorm/player.php?a='.$scorm->id.'¤torg='.$currentorg.$modestr);
$result->tocmenu = $OUTPUT->single_select($url, 'scoid', $tocmenus, $sco->id, null, "tocmenu");
return $result;
}