id int32 0 241k | repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 |
|---|---|---|---|---|---|---|---|---|---|---|---|
212,800 | moodle/moodle | lib/weblib.php | moodle_url.out_omit_querystring | public function out_omit_querystring($includeanchor = false) {
$uri = $this->scheme ? $this->scheme.':'.((strtolower($this->scheme) == 'mailto') ? '':'//'): '';
$uri .= $this->user ? $this->user.($this->pass? ':'.$this->pass:'').'@':'';
$uri .= $this->host ? $this->host : '';
$uri .= $this->port ? ':'.$this->port : '';
$uri .= $this->path ? $this->path : '';
if ($includeanchor and !is_null($this->anchor)) {
$uri .= '#' . $this->anchor;
}
return $uri;
} | php | public function out_omit_querystring($includeanchor = false) {
$uri = $this->scheme ? $this->scheme.':'.((strtolower($this->scheme) == 'mailto') ? '':'//'): '';
$uri .= $this->user ? $this->user.($this->pass? ':'.$this->pass:'').'@':'';
$uri .= $this->host ? $this->host : '';
$uri .= $this->port ? ':'.$this->port : '';
$uri .= $this->path ? $this->path : '';
if ($includeanchor and !is_null($this->anchor)) {
$uri .= '#' . $this->anchor;
}
return $uri;
} | [
"public",
"function",
"out_omit_querystring",
"(",
"$",
"includeanchor",
"=",
"false",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"scheme",
"?",
"$",
"this",
"->",
"scheme",
".",
"':'",
".",
"(",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"scheme",
")",
"==",
"'mailto'",
")",
"?",
"''",
":",
"'//'",
")",
":",
"''",
";",
"$",
"uri",
".=",
"$",
"this",
"->",
"user",
"?",
"$",
"this",
"->",
"user",
".",
"(",
"$",
"this",
"->",
"pass",
"?",
"':'",
".",
"$",
"this",
"->",
"pass",
":",
"''",
")",
".",
"'@'",
":",
"''",
";",
"$",
"uri",
".=",
"$",
"this",
"->",
"host",
"?",
"$",
"this",
"->",
"host",
":",
"''",
";",
"$",
"uri",
".=",
"$",
"this",
"->",
"port",
"?",
"':'",
".",
"$",
"this",
"->",
"port",
":",
"''",
";",
"$",
"uri",
".=",
"$",
"this",
"->",
"path",
"?",
"$",
"this",
"->",
"path",
":",
"''",
";",
"if",
"(",
"$",
"includeanchor",
"and",
"!",
"is_null",
"(",
"$",
"this",
"->",
"anchor",
")",
")",
"{",
"$",
"uri",
".=",
"'#'",
".",
"$",
"this",
"->",
"anchor",
";",
"}",
"return",
"$",
"uri",
";",
"}"
] | Returns url without parameters, everything before '?'.
@param bool $includeanchor if {@link self::anchor} is defined, should it be returned?
@return string | [
"Returns",
"url",
"without",
"parameters",
"everything",
"before",
"?",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/weblib.php#L606-L618 |
212,801 | moodle/moodle | lib/weblib.php | moodle_url.compare | public function compare(moodle_url $url, $matchtype = URL_MATCH_EXACT) {
$baseself = $this->out_omit_querystring();
$baseother = $url->out_omit_querystring();
// Append index.php if there is no specific file.
if (substr($baseself, -1) == '/') {
$baseself .= 'index.php';
}
if (substr($baseother, -1) == '/') {
$baseother .= 'index.php';
}
// Compare the two base URLs.
if ($baseself != $baseother) {
return false;
}
if ($matchtype == URL_MATCH_BASE) {
return true;
}
$urlparams = $url->params();
foreach ($this->params() as $param => $value) {
if ($param == 'sesskey') {
continue;
}
if (!array_key_exists($param, $urlparams) || $urlparams[$param] != $value) {
return false;
}
}
if ($matchtype == URL_MATCH_PARAMS) {
return true;
}
foreach ($urlparams as $param => $value) {
if ($param == 'sesskey') {
continue;
}
if (!array_key_exists($param, $this->params()) || $this->param($param) != $value) {
return false;
}
}
if ($url->anchor !== $this->anchor) {
return false;
}
return true;
} | php | public function compare(moodle_url $url, $matchtype = URL_MATCH_EXACT) {
$baseself = $this->out_omit_querystring();
$baseother = $url->out_omit_querystring();
// Append index.php if there is no specific file.
if (substr($baseself, -1) == '/') {
$baseself .= 'index.php';
}
if (substr($baseother, -1) == '/') {
$baseother .= 'index.php';
}
// Compare the two base URLs.
if ($baseself != $baseother) {
return false;
}
if ($matchtype == URL_MATCH_BASE) {
return true;
}
$urlparams = $url->params();
foreach ($this->params() as $param => $value) {
if ($param == 'sesskey') {
continue;
}
if (!array_key_exists($param, $urlparams) || $urlparams[$param] != $value) {
return false;
}
}
if ($matchtype == URL_MATCH_PARAMS) {
return true;
}
foreach ($urlparams as $param => $value) {
if ($param == 'sesskey') {
continue;
}
if (!array_key_exists($param, $this->params()) || $this->param($param) != $value) {
return false;
}
}
if ($url->anchor !== $this->anchor) {
return false;
}
return true;
} | [
"public",
"function",
"compare",
"(",
"moodle_url",
"$",
"url",
",",
"$",
"matchtype",
"=",
"URL_MATCH_EXACT",
")",
"{",
"$",
"baseself",
"=",
"$",
"this",
"->",
"out_omit_querystring",
"(",
")",
";",
"$",
"baseother",
"=",
"$",
"url",
"->",
"out_omit_querystring",
"(",
")",
";",
"// Append index.php if there is no specific file.",
"if",
"(",
"substr",
"(",
"$",
"baseself",
",",
"-",
"1",
")",
"==",
"'/'",
")",
"{",
"$",
"baseself",
".=",
"'index.php'",
";",
"}",
"if",
"(",
"substr",
"(",
"$",
"baseother",
",",
"-",
"1",
")",
"==",
"'/'",
")",
"{",
"$",
"baseother",
".=",
"'index.php'",
";",
"}",
"// Compare the two base URLs.",
"if",
"(",
"$",
"baseself",
"!=",
"$",
"baseother",
")",
"{",
"return",
"false",
";",
"}",
"if",
"(",
"$",
"matchtype",
"==",
"URL_MATCH_BASE",
")",
"{",
"return",
"true",
";",
"}",
"$",
"urlparams",
"=",
"$",
"url",
"->",
"params",
"(",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"params",
"(",
")",
"as",
"$",
"param",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"param",
"==",
"'sesskey'",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"param",
",",
"$",
"urlparams",
")",
"||",
"$",
"urlparams",
"[",
"$",
"param",
"]",
"!=",
"$",
"value",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"matchtype",
"==",
"URL_MATCH_PARAMS",
")",
"{",
"return",
"true",
";",
"}",
"foreach",
"(",
"$",
"urlparams",
"as",
"$",
"param",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"param",
"==",
"'sesskey'",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"param",
",",
"$",
"this",
"->",
"params",
"(",
")",
")",
"||",
"$",
"this",
"->",
"param",
"(",
"$",
"param",
")",
"!=",
"$",
"value",
")",
"{",
"return",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"url",
"->",
"anchor",
"!==",
"$",
"this",
"->",
"anchor",
")",
"{",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] | Compares this moodle_url with another.
See documentation of constants for an explanation of the comparison flags.
@param moodle_url $url The moodle_url object to compare
@param int $matchtype The type of comparison (URL_MATCH_BASE, URL_MATCH_PARAMS, URL_MATCH_EXACT)
@return bool | [
"Compares",
"this",
"moodle_url",
"with",
"another",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/weblib.php#L629-L679 |
212,802 | moodle/moodle | lib/weblib.php | moodle_url.set_slashargument | public function set_slashargument($path, $parameter = 'file', $supported = null) {
global $CFG;
if (is_null($supported)) {
$supported = !empty($CFG->slasharguments);
}
if ($supported) {
$parts = explode('/', $path);
$parts = array_map('rawurlencode', $parts);
$path = implode('/', $parts);
$this->slashargument = $path;
unset($this->params[$parameter]);
} else {
$this->slashargument = '';
$this->params[$parameter] = $path;
}
} | php | public function set_slashargument($path, $parameter = 'file', $supported = null) {
global $CFG;
if (is_null($supported)) {
$supported = !empty($CFG->slasharguments);
}
if ($supported) {
$parts = explode('/', $path);
$parts = array_map('rawurlencode', $parts);
$path = implode('/', $parts);
$this->slashargument = $path;
unset($this->params[$parameter]);
} else {
$this->slashargument = '';
$this->params[$parameter] = $path;
}
} | [
"public",
"function",
"set_slashargument",
"(",
"$",
"path",
",",
"$",
"parameter",
"=",
"'file'",
",",
"$",
"supported",
"=",
"null",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"is_null",
"(",
"$",
"supported",
")",
")",
"{",
"$",
"supported",
"=",
"!",
"empty",
"(",
"$",
"CFG",
"->",
"slasharguments",
")",
";",
"}",
"if",
"(",
"$",
"supported",
")",
"{",
"$",
"parts",
"=",
"explode",
"(",
"'/'",
",",
"$",
"path",
")",
";",
"$",
"parts",
"=",
"array_map",
"(",
"'rawurlencode'",
",",
"$",
"parts",
")",
";",
"$",
"path",
"=",
"implode",
"(",
"'/'",
",",
"$",
"parts",
")",
";",
"$",
"this",
"->",
"slashargument",
"=",
"$",
"path",
";",
"unset",
"(",
"$",
"this",
"->",
"params",
"[",
"$",
"parameter",
"]",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"slashargument",
"=",
"''",
";",
"$",
"this",
"->",
"params",
"[",
"$",
"parameter",
"]",
"=",
"$",
"path",
";",
"}",
"}"
] | Sets the url slashargument value.
@param string $path usually file path
@param string $parameter name of page parameter if slasharguments not supported
@param bool $supported usually null, then it depends on $CFG->slasharguments, use true or false for other servers
@return void | [
"Sets",
"the",
"url",
"slashargument",
"value",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/weblib.php#L724-L741 |
212,803 | moodle/moodle | lib/weblib.php | moodle_url.make_file_url | public static function make_file_url($urlbase, $path, $forcedownload = false) {
$params = array();
if ($forcedownload) {
$params['forcedownload'] = 1;
}
$url = new moodle_url($urlbase, $params);
$url->set_slashargument($path);
return $url;
} | php | public static function make_file_url($urlbase, $path, $forcedownload = false) {
$params = array();
if ($forcedownload) {
$params['forcedownload'] = 1;
}
$url = new moodle_url($urlbase, $params);
$url->set_slashargument($path);
return $url;
} | [
"public",
"static",
"function",
"make_file_url",
"(",
"$",
"urlbase",
",",
"$",
"path",
",",
"$",
"forcedownload",
"=",
"false",
")",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"forcedownload",
")",
"{",
"$",
"params",
"[",
"'forcedownload'",
"]",
"=",
"1",
";",
"}",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"$",
"urlbase",
",",
"$",
"params",
")",
";",
"$",
"url",
"->",
"set_slashargument",
"(",
"$",
"path",
")",
";",
"return",
"$",
"url",
";",
"}"
] | General moodle file url.
@param string $urlbase the script serving the file
@param string $path
@param bool $forcedownload
@return moodle_url | [
"General",
"moodle",
"file",
"url",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/weblib.php#L753-L761 |
212,804 | moodle/moodle | lib/weblib.php | moodle_url.make_pluginfile_url | public static function make_pluginfile_url($contextid, $component, $area, $itemid, $pathname, $filename,
$forcedownload = false, $includetoken = false) {
global $CFG, $USER;
$path = [];
if ($includetoken) {
$urlbase = "$CFG->wwwroot/tokenpluginfile.php";
$userid = $includetoken === true ? $USER->id : $includetoken;
$token = get_user_key('core_files', $userid);
if ($CFG->slasharguments) {
$path[] = $token;
}
} else {
$urlbase = "$CFG->wwwroot/pluginfile.php";
}
$path[] = $contextid;
$path[] = $component;
$path[] = $area;
if ($itemid !== null) {
$path[] = $itemid;
}
$path = "/" . implode('/', $path) . "{$pathname}{$filename}";
$url = self::make_file_url($urlbase, $path, $forcedownload, $includetoken);
if ($includetoken && empty($CFG->slasharguments)) {
$url->param('token', $token);
}
return $url;
} | php | public static function make_pluginfile_url($contextid, $component, $area, $itemid, $pathname, $filename,
$forcedownload = false, $includetoken = false) {
global $CFG, $USER;
$path = [];
if ($includetoken) {
$urlbase = "$CFG->wwwroot/tokenpluginfile.php";
$userid = $includetoken === true ? $USER->id : $includetoken;
$token = get_user_key('core_files', $userid);
if ($CFG->slasharguments) {
$path[] = $token;
}
} else {
$urlbase = "$CFG->wwwroot/pluginfile.php";
}
$path[] = $contextid;
$path[] = $component;
$path[] = $area;
if ($itemid !== null) {
$path[] = $itemid;
}
$path = "/" . implode('/', $path) . "{$pathname}{$filename}";
$url = self::make_file_url($urlbase, $path, $forcedownload, $includetoken);
if ($includetoken && empty($CFG->slasharguments)) {
$url->param('token', $token);
}
return $url;
} | [
"public",
"static",
"function",
"make_pluginfile_url",
"(",
"$",
"contextid",
",",
"$",
"component",
",",
"$",
"area",
",",
"$",
"itemid",
",",
"$",
"pathname",
",",
"$",
"filename",
",",
"$",
"forcedownload",
"=",
"false",
",",
"$",
"includetoken",
"=",
"false",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"USER",
";",
"$",
"path",
"=",
"[",
"]",
";",
"if",
"(",
"$",
"includetoken",
")",
"{",
"$",
"urlbase",
"=",
"\"$CFG->wwwroot/tokenpluginfile.php\"",
";",
"$",
"userid",
"=",
"$",
"includetoken",
"===",
"true",
"?",
"$",
"USER",
"->",
"id",
":",
"$",
"includetoken",
";",
"$",
"token",
"=",
"get_user_key",
"(",
"'core_files'",
",",
"$",
"userid",
")",
";",
"if",
"(",
"$",
"CFG",
"->",
"slasharguments",
")",
"{",
"$",
"path",
"[",
"]",
"=",
"$",
"token",
";",
"}",
"}",
"else",
"{",
"$",
"urlbase",
"=",
"\"$CFG->wwwroot/pluginfile.php\"",
";",
"}",
"$",
"path",
"[",
"]",
"=",
"$",
"contextid",
";",
"$",
"path",
"[",
"]",
"=",
"$",
"component",
";",
"$",
"path",
"[",
"]",
"=",
"$",
"area",
";",
"if",
"(",
"$",
"itemid",
"!==",
"null",
")",
"{",
"$",
"path",
"[",
"]",
"=",
"$",
"itemid",
";",
"}",
"$",
"path",
"=",
"\"/\"",
".",
"implode",
"(",
"'/'",
",",
"$",
"path",
")",
".",
"\"{$pathname}{$filename}\"",
";",
"$",
"url",
"=",
"self",
"::",
"make_file_url",
"(",
"$",
"urlbase",
",",
"$",
"path",
",",
"$",
"forcedownload",
",",
"$",
"includetoken",
")",
";",
"if",
"(",
"$",
"includetoken",
"&&",
"empty",
"(",
"$",
"CFG",
"->",
"slasharguments",
")",
")",
"{",
"$",
"url",
"->",
"param",
"(",
"'token'",
",",
"$",
"token",
")",
";",
"}",
"return",
"$",
"url",
";",
"}"
] | Factory method for creation of url pointing to plugin file.
Please note this method can be used only from the plugins to
create urls of own files, it must not be used outside of plugins!
@param int $contextid
@param string $component
@param string $area
@param int $itemid
@param string $pathname
@param string $filename
@param bool $forcedownload
@param mixed $includetoken Whether to use a user token when displaying this group image.
True indicates to generate a token for current user, and integer value indicates to generate a token for the
user whose id is the value indicated.
If the group picture is included in an e-mail or some other location where the audience is a specific
user who will not be logged in when viewing, then we use a token to authenticate the user.
@return moodle_url | [
"Factory",
"method",
"for",
"creation",
"of",
"url",
"pointing",
"to",
"plugin",
"file",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/weblib.php#L783-L814 |
212,805 | moodle/moodle | lib/weblib.php | moodle_url.make_webservice_pluginfile_url | public static function make_webservice_pluginfile_url($contextid, $component, $area, $itemid, $pathname, $filename,
$forcedownload = false) {
global $CFG;
$urlbase = "$CFG->wwwroot/webservice/pluginfile.php";
if ($itemid === null) {
return self::make_file_url($urlbase, "/$contextid/$component/$area".$pathname.$filename, $forcedownload);
} else {
return self::make_file_url($urlbase, "/$contextid/$component/$area/$itemid".$pathname.$filename, $forcedownload);
}
} | php | public static function make_webservice_pluginfile_url($contextid, $component, $area, $itemid, $pathname, $filename,
$forcedownload = false) {
global $CFG;
$urlbase = "$CFG->wwwroot/webservice/pluginfile.php";
if ($itemid === null) {
return self::make_file_url($urlbase, "/$contextid/$component/$area".$pathname.$filename, $forcedownload);
} else {
return self::make_file_url($urlbase, "/$contextid/$component/$area/$itemid".$pathname.$filename, $forcedownload);
}
} | [
"public",
"static",
"function",
"make_webservice_pluginfile_url",
"(",
"$",
"contextid",
",",
"$",
"component",
",",
"$",
"area",
",",
"$",
"itemid",
",",
"$",
"pathname",
",",
"$",
"filename",
",",
"$",
"forcedownload",
"=",
"false",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"urlbase",
"=",
"\"$CFG->wwwroot/webservice/pluginfile.php\"",
";",
"if",
"(",
"$",
"itemid",
"===",
"null",
")",
"{",
"return",
"self",
"::",
"make_file_url",
"(",
"$",
"urlbase",
",",
"\"/$contextid/$component/$area\"",
".",
"$",
"pathname",
".",
"$",
"filename",
",",
"$",
"forcedownload",
")",
";",
"}",
"else",
"{",
"return",
"self",
"::",
"make_file_url",
"(",
"$",
"urlbase",
",",
"\"/$contextid/$component/$area/$itemid\"",
".",
"$",
"pathname",
".",
"$",
"filename",
",",
"$",
"forcedownload",
")",
";",
"}",
"}"
] | Factory method for creation of url pointing to plugin file.
This method is the same that make_pluginfile_url but pointing to the webservice pluginfile.php script.
It should be used only in external functions.
@since 2.8
@param int $contextid
@param string $component
@param string $area
@param int $itemid
@param string $pathname
@param string $filename
@param bool $forcedownload
@return moodle_url | [
"Factory",
"method",
"for",
"creation",
"of",
"url",
"pointing",
"to",
"plugin",
"file",
".",
"This",
"method",
"is",
"the",
"same",
"that",
"make_pluginfile_url",
"but",
"pointing",
"to",
"the",
"webservice",
"pluginfile",
".",
"php",
"script",
".",
"It",
"should",
"be",
"used",
"only",
"in",
"external",
"functions",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/weblib.php#L831-L840 |
212,806 | moodle/moodle | lib/weblib.php | moodle_url.make_draftfile_url | public static function make_draftfile_url($draftid, $pathname, $filename, $forcedownload = false) {
global $CFG, $USER;
$urlbase = "$CFG->wwwroot/draftfile.php";
$context = context_user::instance($USER->id);
return self::make_file_url($urlbase, "/$context->id/user/draft/$draftid".$pathname.$filename, $forcedownload);
} | php | public static function make_draftfile_url($draftid, $pathname, $filename, $forcedownload = false) {
global $CFG, $USER;
$urlbase = "$CFG->wwwroot/draftfile.php";
$context = context_user::instance($USER->id);
return self::make_file_url($urlbase, "/$context->id/user/draft/$draftid".$pathname.$filename, $forcedownload);
} | [
"public",
"static",
"function",
"make_draftfile_url",
"(",
"$",
"draftid",
",",
"$",
"pathname",
",",
"$",
"filename",
",",
"$",
"forcedownload",
"=",
"false",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"USER",
";",
"$",
"urlbase",
"=",
"\"$CFG->wwwroot/draftfile.php\"",
";",
"$",
"context",
"=",
"context_user",
"::",
"instance",
"(",
"$",
"USER",
"->",
"id",
")",
";",
"return",
"self",
"::",
"make_file_url",
"(",
"$",
"urlbase",
",",
"\"/$context->id/user/draft/$draftid\"",
".",
"$",
"pathname",
".",
"$",
"filename",
",",
"$",
"forcedownload",
")",
";",
"}"
] | Factory method for creation of url pointing to draft file of current user.
@param int $draftid draft item id
@param string $pathname
@param string $filename
@param bool $forcedownload
@return moodle_url | [
"Factory",
"method",
"for",
"creation",
"of",
"url",
"pointing",
"to",
"draft",
"file",
"of",
"current",
"user",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/weblib.php#L851-L857 |
212,807 | moodle/moodle | lib/weblib.php | moodle_url.make_legacyfile_url | public static function make_legacyfile_url($courseid, $filepath, $forcedownload = false) {
global $CFG;
$urlbase = "$CFG->wwwroot/file.php";
return self::make_file_url($urlbase, '/'.$courseid.'/'.$filepath, $forcedownload);
} | php | public static function make_legacyfile_url($courseid, $filepath, $forcedownload = false) {
global $CFG;
$urlbase = "$CFG->wwwroot/file.php";
return self::make_file_url($urlbase, '/'.$courseid.'/'.$filepath, $forcedownload);
} | [
"public",
"static",
"function",
"make_legacyfile_url",
"(",
"$",
"courseid",
",",
"$",
"filepath",
",",
"$",
"forcedownload",
"=",
"false",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"urlbase",
"=",
"\"$CFG->wwwroot/file.php\"",
";",
"return",
"self",
"::",
"make_file_url",
"(",
"$",
"urlbase",
",",
"'/'",
".",
"$",
"courseid",
".",
"'/'",
".",
"$",
"filepath",
",",
"$",
"forcedownload",
")",
";",
"}"
] | Factory method for creating of links to legacy course files.
@param int $courseid
@param string $filepath
@param bool $forcedownload
@return moodle_url | [
"Factory",
"method",
"for",
"creating",
"of",
"links",
"to",
"legacy",
"course",
"files",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/weblib.php#L867-L872 |
212,808 | moodle/moodle | lib/weblib.php | moodle_url.get_param | public function get_param($name) {
if (array_key_exists($name, $this->params)) {
return $this->params[$name];
} else {
return null;
}
} | php | public function get_param($name) {
if (array_key_exists($name, $this->params)) {
return $this->params[$name];
} else {
return null;
}
} | [
"public",
"function",
"get_param",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"params",
")",
")",
"{",
"return",
"$",
"this",
"->",
"params",
"[",
"$",
"name",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Returns a given parameter value from the URL.
@param string $name Name of parameter
@return string Value of parameter or null if not set | [
"Returns",
"a",
"given",
"parameter",
"value",
"from",
"the",
"URL",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/weblib.php#L923-L929 |
212,809 | moodle/moodle | lib/weblib.php | html_list_progress_trace.output | public function output($message, $depth = 0) {
$samedepth = true;
while ($this->currentdepth > $depth) {
echo "</li>\n</ul>\n";
$this->currentdepth -= 1;
if ($this->currentdepth == $depth) {
echo '<li>';
}
$samedepth = false;
}
while ($this->currentdepth < $depth) {
echo "<ul>\n<li>";
$this->currentdepth += 1;
$samedepth = false;
}
if ($samedepth) {
echo "</li>\n<li>";
}
echo htmlspecialchars($message);
flush();
} | php | public function output($message, $depth = 0) {
$samedepth = true;
while ($this->currentdepth > $depth) {
echo "</li>\n</ul>\n";
$this->currentdepth -= 1;
if ($this->currentdepth == $depth) {
echo '<li>';
}
$samedepth = false;
}
while ($this->currentdepth < $depth) {
echo "<ul>\n<li>";
$this->currentdepth += 1;
$samedepth = false;
}
if ($samedepth) {
echo "</li>\n<li>";
}
echo htmlspecialchars($message);
flush();
} | [
"public",
"function",
"output",
"(",
"$",
"message",
",",
"$",
"depth",
"=",
"0",
")",
"{",
"$",
"samedepth",
"=",
"true",
";",
"while",
"(",
"$",
"this",
"->",
"currentdepth",
">",
"$",
"depth",
")",
"{",
"echo",
"\"</li>\\n</ul>\\n\"",
";",
"$",
"this",
"->",
"currentdepth",
"-=",
"1",
";",
"if",
"(",
"$",
"this",
"->",
"currentdepth",
"==",
"$",
"depth",
")",
"{",
"echo",
"'<li>'",
";",
"}",
"$",
"samedepth",
"=",
"false",
";",
"}",
"while",
"(",
"$",
"this",
"->",
"currentdepth",
"<",
"$",
"depth",
")",
"{",
"echo",
"\"<ul>\\n<li>\"",
";",
"$",
"this",
"->",
"currentdepth",
"+=",
"1",
";",
"$",
"samedepth",
"=",
"false",
";",
"}",
"if",
"(",
"$",
"samedepth",
")",
"{",
"echo",
"\"</li>\\n<li>\"",
";",
"}",
"echo",
"htmlspecialchars",
"(",
"$",
"message",
")",
";",
"flush",
"(",
")",
";",
"}"
] | Echo out the list
@param string $message The message to display
@param int $depth
@return void Output is echoed | [
"Echo",
"out",
"the",
"list"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/weblib.php#L3420-L3440 |
212,810 | moodle/moodle | lib/weblib.php | progress_trace_buffer.output | public function output($message, $depth = 0) {
ob_start();
$this->trace->output($message, $depth);
$this->buffer .= ob_get_contents();
if ($this->passthrough) {
ob_end_flush();
} else {
ob_end_clean();
}
} | php | public function output($message, $depth = 0) {
ob_start();
$this->trace->output($message, $depth);
$this->buffer .= ob_get_contents();
if ($this->passthrough) {
ob_end_flush();
} else {
ob_end_clean();
}
} | [
"public",
"function",
"output",
"(",
"$",
"message",
",",
"$",
"depth",
"=",
"0",
")",
"{",
"ob_start",
"(",
")",
";",
"$",
"this",
"->",
"trace",
"->",
"output",
"(",
"$",
"message",
",",
"$",
"depth",
")",
";",
"$",
"this",
"->",
"buffer",
".=",
"ob_get_contents",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"passthrough",
")",
"{",
"ob_end_flush",
"(",
")",
";",
"}",
"else",
"{",
"ob_end_clean",
"(",
")",
";",
"}",
"}"
] | Output the trace message.
@param string $message the message to output.
@param int $depth indent depth for this message.
@return void output stored in buffer | [
"Output",
"the",
"trace",
"message",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/weblib.php#L3518-L3527 |
212,811 | moodle/moodle | lib/weblib.php | progress_trace_buffer.finished | public function finished() {
ob_start();
$this->trace->finished();
$this->buffer .= ob_get_contents();
if ($this->passthrough) {
ob_end_flush();
} else {
ob_end_clean();
}
} | php | public function finished() {
ob_start();
$this->trace->finished();
$this->buffer .= ob_get_contents();
if ($this->passthrough) {
ob_end_flush();
} else {
ob_end_clean();
}
} | [
"public",
"function",
"finished",
"(",
")",
"{",
"ob_start",
"(",
")",
";",
"$",
"this",
"->",
"trace",
"->",
"finished",
"(",
")",
";",
"$",
"this",
"->",
"buffer",
".=",
"ob_get_contents",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"passthrough",
")",
"{",
"ob_end_flush",
"(",
")",
";",
"}",
"else",
"{",
"ob_end_clean",
"(",
")",
";",
"}",
"}"
] | Called when the processing is finished. | [
"Called",
"when",
"the",
"processing",
"is",
"finished",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/weblib.php#L3532-L3541 |
212,812 | moodle/moodle | lib/weblib.php | combined_progress_trace.output | public function output($message, $depth = 0) {
foreach ($this->traces as $trace) {
$trace->output($message, $depth);
}
} | php | public function output($message, $depth = 0) {
foreach ($this->traces as $trace) {
$trace->output($message, $depth);
}
} | [
"public",
"function",
"output",
"(",
"$",
"message",
",",
"$",
"depth",
"=",
"0",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"traces",
"as",
"$",
"trace",
")",
"{",
"$",
"trace",
"->",
"output",
"(",
"$",
"message",
",",
"$",
"depth",
")",
";",
"}",
"}"
] | Output an progress message in whatever format.
@param string $message the message to output.
@param integer $depth indent depth for this message. | [
"Output",
"an",
"progress",
"message",
"in",
"whatever",
"format",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/weblib.php#L3589-L3593 |
212,813 | moodle/moodle | lib/simplepie/library/SimplePie.php | SimplePie.set_input_encoding | public function set_input_encoding($encoding = false)
{
if ($encoding)
{
$this->input_encoding = (string) $encoding;
}
else
{
$this->input_encoding = false;
}
} | php | public function set_input_encoding($encoding = false)
{
if ($encoding)
{
$this->input_encoding = (string) $encoding;
}
else
{
$this->input_encoding = false;
}
} | [
"public",
"function",
"set_input_encoding",
"(",
"$",
"encoding",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"encoding",
")",
"{",
"$",
"this",
"->",
"input_encoding",
"=",
"(",
"string",
")",
"$",
"encoding",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"input_encoding",
"=",
"false",
";",
"}",
"}"
] | Set the character encoding used to parse the feed
This overrides the encoding reported by the feed, however it will fall
back to the normal encoding detection if the override fails
@param string $encoding Character encoding | [
"Set",
"the",
"character",
"encoding",
"used",
"to",
"parse",
"the",
"feed"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie.php#L929-L939 |
212,814 | moodle/moodle | lib/simplepie/library/SimplePie.php | SimplePie.set_image_handler | public function set_image_handler($page = false, $qs = 'i')
{
if ($page !== false)
{
$this->sanitize->set_image_handler($page . '?' . $qs . '=');
}
else
{
$this->image_handler = '';
}
} | php | public function set_image_handler($page = false, $qs = 'i')
{
if ($page !== false)
{
$this->sanitize->set_image_handler($page . '?' . $qs . '=');
}
else
{
$this->image_handler = '';
}
} | [
"public",
"function",
"set_image_handler",
"(",
"$",
"page",
"=",
"false",
",",
"$",
"qs",
"=",
"'i'",
")",
"{",
"if",
"(",
"$",
"page",
"!==",
"false",
")",
"{",
"$",
"this",
"->",
"sanitize",
"->",
"set_image_handler",
"(",
"$",
"page",
".",
"'?'",
".",
"$",
"qs",
".",
"'='",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"image_handler",
"=",
"''",
";",
"}",
"}"
] | Set the handler to enable the display of cached images.
@param str $page Web-accessible path to the handler_image.php file.
@param str $qs The query string that the value should be passed to. | [
"Set",
"the",
"handler",
"to",
"enable",
"the",
"display",
"of",
"cached",
"images",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie.php#L1257-L1267 |
212,815 | moodle/moodle | lib/simplepie/library/SimplePie.php | SimplePie.handle_content_type | public function handle_content_type($mime = 'text/html')
{
if (!headers_sent())
{
$header = "Content-type: $mime;";
if ($this->get_encoding())
{
$header .= ' charset=' . $this->get_encoding();
}
else
{
$header .= ' charset=UTF-8';
}
header($header);
}
} | php | public function handle_content_type($mime = 'text/html')
{
if (!headers_sent())
{
$header = "Content-type: $mime;";
if ($this->get_encoding())
{
$header .= ' charset=' . $this->get_encoding();
}
else
{
$header .= ' charset=UTF-8';
}
header($header);
}
} | [
"public",
"function",
"handle_content_type",
"(",
"$",
"mime",
"=",
"'text/html'",
")",
"{",
"if",
"(",
"!",
"headers_sent",
"(",
")",
")",
"{",
"$",
"header",
"=",
"\"Content-type: $mime;\"",
";",
"if",
"(",
"$",
"this",
"->",
"get_encoding",
"(",
")",
")",
"{",
"$",
"header",
".=",
"' charset='",
".",
"$",
"this",
"->",
"get_encoding",
"(",
")",
";",
"}",
"else",
"{",
"$",
"header",
".=",
"' charset=UTF-8'",
";",
"}",
"header",
"(",
"$",
"header",
")",
";",
"}",
"}"
] | Send the content-type header with correct encoding
This method ensures that the SimplePie-enabled page is being served with
the correct {@link http://www.iana.org/assignments/media-types/ mime-type}
and character encoding HTTP headers (character encoding determined by the
{@see set_output_encoding} config option).
This won't work properly if any content or whitespace has already been
sent to the browser, because it relies on PHP's
{@link http://php.net/header header()} function, and these are the
circumstances under which the function works.
Because it's setting these settings for the entire page (as is the nature
of HTTP headers), this should only be used once per page (again, at the
top).
@param string $mime MIME type to serve the page as | [
"Send",
"the",
"content",
"-",
"type",
"header",
"with",
"correct",
"encoding"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie.php#L1792-L1807 |
212,816 | moodle/moodle | lib/simplepie/library/SimplePie.php | SimplePie.get_feed_tags | public function get_feed_tags($namespace, $tag)
{
$type = $this->get_type();
if ($type & SIMPLEPIE_TYPE_ATOM_10)
{
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]))
{
return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag];
}
}
if ($type & SIMPLEPIE_TYPE_ATOM_03)
{
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]))
{
return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag];
}
}
if ($type & SIMPLEPIE_TYPE_RSS_RDF)
{
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]))
{
return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag];
}
}
if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
{
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]))
{
return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag];
}
}
return null;
} | php | public function get_feed_tags($namespace, $tag)
{
$type = $this->get_type();
if ($type & SIMPLEPIE_TYPE_ATOM_10)
{
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag]))
{
return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_10]['feed'][0]['child'][$namespace][$tag];
}
}
if ($type & SIMPLEPIE_TYPE_ATOM_03)
{
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag]))
{
return $this->data['child'][SIMPLEPIE_NAMESPACE_ATOM_03]['feed'][0]['child'][$namespace][$tag];
}
}
if ($type & SIMPLEPIE_TYPE_RSS_RDF)
{
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag]))
{
return $this->data['child'][SIMPLEPIE_NAMESPACE_RDF]['RDF'][0]['child'][$namespace][$tag];
}
}
if ($type & SIMPLEPIE_TYPE_RSS_SYNDICATION)
{
if (isset($this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag]))
{
return $this->data['child'][SIMPLEPIE_NAMESPACE_RSS_20]['rss'][0]['child'][$namespace][$tag];
}
}
return null;
} | [
"public",
"function",
"get_feed_tags",
"(",
"$",
"namespace",
",",
"$",
"tag",
")",
"{",
"$",
"type",
"=",
"$",
"this",
"->",
"get_type",
"(",
")",
";",
"if",
"(",
"$",
"type",
"&",
"SIMPLEPIE_TYPE_ATOM_10",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'child'",
"]",
"[",
"SIMPLEPIE_NAMESPACE_ATOM_10",
"]",
"[",
"'feed'",
"]",
"[",
"0",
"]",
"[",
"'child'",
"]",
"[",
"$",
"namespace",
"]",
"[",
"$",
"tag",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"data",
"[",
"'child'",
"]",
"[",
"SIMPLEPIE_NAMESPACE_ATOM_10",
"]",
"[",
"'feed'",
"]",
"[",
"0",
"]",
"[",
"'child'",
"]",
"[",
"$",
"namespace",
"]",
"[",
"$",
"tag",
"]",
";",
"}",
"}",
"if",
"(",
"$",
"type",
"&",
"SIMPLEPIE_TYPE_ATOM_03",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'child'",
"]",
"[",
"SIMPLEPIE_NAMESPACE_ATOM_03",
"]",
"[",
"'feed'",
"]",
"[",
"0",
"]",
"[",
"'child'",
"]",
"[",
"$",
"namespace",
"]",
"[",
"$",
"tag",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"data",
"[",
"'child'",
"]",
"[",
"SIMPLEPIE_NAMESPACE_ATOM_03",
"]",
"[",
"'feed'",
"]",
"[",
"0",
"]",
"[",
"'child'",
"]",
"[",
"$",
"namespace",
"]",
"[",
"$",
"tag",
"]",
";",
"}",
"}",
"if",
"(",
"$",
"type",
"&",
"SIMPLEPIE_TYPE_RSS_RDF",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'child'",
"]",
"[",
"SIMPLEPIE_NAMESPACE_RDF",
"]",
"[",
"'RDF'",
"]",
"[",
"0",
"]",
"[",
"'child'",
"]",
"[",
"$",
"namespace",
"]",
"[",
"$",
"tag",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"data",
"[",
"'child'",
"]",
"[",
"SIMPLEPIE_NAMESPACE_RDF",
"]",
"[",
"'RDF'",
"]",
"[",
"0",
"]",
"[",
"'child'",
"]",
"[",
"$",
"namespace",
"]",
"[",
"$",
"tag",
"]",
";",
"}",
"}",
"if",
"(",
"$",
"type",
"&",
"SIMPLEPIE_TYPE_RSS_SYNDICATION",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"'child'",
"]",
"[",
"SIMPLEPIE_NAMESPACE_RSS_20",
"]",
"[",
"'rss'",
"]",
"[",
"0",
"]",
"[",
"'child'",
"]",
"[",
"$",
"namespace",
"]",
"[",
"$",
"tag",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"data",
"[",
"'child'",
"]",
"[",
"SIMPLEPIE_NAMESPACE_RSS_20",
"]",
"[",
"'rss'",
"]",
"[",
"0",
"]",
"[",
"'child'",
"]",
"[",
"$",
"namespace",
"]",
"[",
"$",
"tag",
"]",
";",
"}",
"}",
"return",
"null",
";",
"}"
] | Get data for an feed-level element
This method allows you to get access to ANY element/attribute that is a
sub-element of the opening feed tag.
The return value is an indexed array of elements matching the given
namespace and tag name. Each element has `attribs`, `data` and `child`
subkeys. For `attribs` and `child`, these contain namespace subkeys.
`attribs` then has one level of associative name => value data (where
`value` is a string) after the namespace. `child` has tag-indexed keys
after the namespace, each member of which is an indexed array matching
this same format.
For example:
<pre>
// This is probably a bad example because we already support
// <media:content> natively, but it shows you how to parse through
// the nodes.
$group = $item->get_item_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'group');
$content = $group[0]['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['content'];
$file = $content[0]['attribs']['']['url'];
echo $file;
</pre>
@since 1.0
@see http://simplepie.org/wiki/faq/supported_xml_namespaces
@param string $namespace The URL of the XML namespace of the elements you're trying to access
@param string $tag Tag name
@return array | [
"Get",
"data",
"for",
"an",
"feed",
"-",
"level",
"element"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie.php#L1988-L2020 |
212,817 | moodle/moodle | lib/simplepie/library/SimplePie.php | SimplePie.get_base | public function get_base($element = array())
{
if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base']))
{
return $element['xml_base'];
}
elseif ($this->get_link() !== null)
{
return $this->get_link();
}
else
{
return $this->subscribe_url();
}
} | php | public function get_base($element = array())
{
if (!($this->get_type() & SIMPLEPIE_TYPE_RSS_SYNDICATION) && !empty($element['xml_base_explicit']) && isset($element['xml_base']))
{
return $element['xml_base'];
}
elseif ($this->get_link() !== null)
{
return $this->get_link();
}
else
{
return $this->subscribe_url();
}
} | [
"public",
"function",
"get_base",
"(",
"$",
"element",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"this",
"->",
"get_type",
"(",
")",
"&",
"SIMPLEPIE_TYPE_RSS_SYNDICATION",
")",
"&&",
"!",
"empty",
"(",
"$",
"element",
"[",
"'xml_base_explicit'",
"]",
")",
"&&",
"isset",
"(",
"$",
"element",
"[",
"'xml_base'",
"]",
")",
")",
"{",
"return",
"$",
"element",
"[",
"'xml_base'",
"]",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"get_link",
"(",
")",
"!==",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"get_link",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"subscribe_url",
"(",
")",
";",
"}",
"}"
] | Get the base URL value from the feed
Uses `<xml:base>` if available, otherwise uses the first link in the
feed, or failing that, the URL of the feed itself.
@see get_link
@see subscribe_url
@param array $element
@return string | [
"Get",
"the",
"base",
"URL",
"value",
"from",
"the",
"feed"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie.php#L2141-L2155 |
212,818 | moodle/moodle | lib/simplepie/library/SimplePie.php | SimplePie.sanitize | public function sanitize($data, $type, $base = '')
{
try
{
return $this->sanitize->sanitize($data, $type, $base);
}
catch (SimplePie_Exception $e)
{
if (!$this->enable_exceptions)
{
$this->error = $e->getMessage();
$this->registry->call('Misc', 'error', array($this->error, E_USER_WARNING, $e->getFile(), $e->getLine()));
return '';
}
throw $e;
}
} | php | public function sanitize($data, $type, $base = '')
{
try
{
return $this->sanitize->sanitize($data, $type, $base);
}
catch (SimplePie_Exception $e)
{
if (!$this->enable_exceptions)
{
$this->error = $e->getMessage();
$this->registry->call('Misc', 'error', array($this->error, E_USER_WARNING, $e->getFile(), $e->getLine()));
return '';
}
throw $e;
}
} | [
"public",
"function",
"sanitize",
"(",
"$",
"data",
",",
"$",
"type",
",",
"$",
"base",
"=",
"''",
")",
"{",
"try",
"{",
"return",
"$",
"this",
"->",
"sanitize",
"->",
"sanitize",
"(",
"$",
"data",
",",
"$",
"type",
",",
"$",
"base",
")",
";",
"}",
"catch",
"(",
"SimplePie_Exception",
"$",
"e",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"enable_exceptions",
")",
"{",
"$",
"this",
"->",
"error",
"=",
"$",
"e",
"->",
"getMessage",
"(",
")",
";",
"$",
"this",
"->",
"registry",
"->",
"call",
"(",
"'Misc'",
",",
"'error'",
",",
"array",
"(",
"$",
"this",
"->",
"error",
",",
"E_USER_WARNING",
",",
"$",
"e",
"->",
"getFile",
"(",
")",
",",
"$",
"e",
"->",
"getLine",
"(",
")",
")",
")",
";",
"return",
"''",
";",
"}",
"throw",
"$",
"e",
";",
"}",
"}"
] | Sanitize feed data
@access private
@see SimplePie_Sanitize::sanitize()
@param string $data Data to sanitize
@param int $type One of the SIMPLEPIE_CONSTRUCT_* constants
@param string $base Base URL to resolve URLs against
@return string Sanitized data | [
"Sanitize",
"feed",
"data"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie.php#L2167-L2184 |
212,819 | moodle/moodle | lib/simplepie/library/SimplePie.php | SimplePie.get_category | public function get_category($key = 0)
{
$categories = $this->get_categories();
if (isset($categories[$key]))
{
return $categories[$key];
}
else
{
return null;
}
} | php | public function get_category($key = 0)
{
$categories = $this->get_categories();
if (isset($categories[$key]))
{
return $categories[$key];
}
else
{
return null;
}
} | [
"public",
"function",
"get_category",
"(",
"$",
"key",
"=",
"0",
")",
"{",
"$",
"categories",
"=",
"$",
"this",
"->",
"get_categories",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"categories",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"categories",
"[",
"$",
"key",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Get a category for the feed
@since Unknown
@param int $key The category that you want to return. Remember that arrays begin with 0, not 1
@return SimplePie_Category|null | [
"Get",
"a",
"category",
"for",
"the",
"feed"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie.php#L2237-L2248 |
212,820 | moodle/moodle | lib/simplepie/library/SimplePie.php | SimplePie.get_author | public function get_author($key = 0)
{
$authors = $this->get_authors();
if (isset($authors[$key]))
{
return $authors[$key];
}
else
{
return null;
}
} | php | public function get_author($key = 0)
{
$authors = $this->get_authors();
if (isset($authors[$key]))
{
return $authors[$key];
}
else
{
return null;
}
} | [
"public",
"function",
"get_author",
"(",
"$",
"key",
"=",
"0",
")",
"{",
"$",
"authors",
"=",
"$",
"this",
"->",
"get_authors",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"authors",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"authors",
"[",
"$",
"key",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Get an author for the feed
@since 1.1
@param int $key The author that you want to return. Remember that arrays begin with 0, not 1
@return SimplePie_Author|null | [
"Get",
"an",
"author",
"for",
"the",
"feed"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie.php#L2322-L2333 |
212,821 | moodle/moodle | lib/simplepie/library/SimplePie.php | SimplePie.get_contributor | public function get_contributor($key = 0)
{
$contributors = $this->get_contributors();
if (isset($contributors[$key]))
{
return $contributors[$key];
}
else
{
return null;
}
} | php | public function get_contributor($key = 0)
{
$contributors = $this->get_contributors();
if (isset($contributors[$key]))
{
return $contributors[$key];
}
else
{
return null;
}
} | [
"public",
"function",
"get_contributor",
"(",
"$",
"key",
"=",
"0",
")",
"{",
"$",
"contributors",
"=",
"$",
"this",
"->",
"get_contributors",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"contributors",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"$",
"contributors",
"[",
"$",
"key",
"]",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Get a contributor for the feed
@since 1.1
@param int $key The contrbutor that you want to return. Remember that arrays begin with 0, not 1
@return SimplePie_Author|null | [
"Get",
"a",
"contributor",
"for",
"the",
"feed"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie.php#L2420-L2431 |
212,822 | moodle/moodle | lib/simplepie/library/SimplePie.php | SimplePie.get_image_url | public function get_image_url()
{
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image'))
{
return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI);
}
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
else
{
return null;
}
} | php | public function get_image_url()
{
if ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'image'))
{
return $this->sanitize($return[0]['attribs']['']['href'], SIMPLEPIE_CONSTRUCT_IRI);
}
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'logo'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
elseif ($return = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_10, 'icon'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'url'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'url'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
elseif ($return = $this->get_image_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'url'))
{
return $this->sanitize($return[0]['data'], SIMPLEPIE_CONSTRUCT_IRI, $this->get_base($return[0]));
}
else
{
return null;
}
} | [
"public",
"function",
"get_image_url",
"(",
")",
"{",
"if",
"(",
"$",
"return",
"=",
"$",
"this",
"->",
"get_channel_tags",
"(",
"SIMPLEPIE_NAMESPACE_ITUNES",
",",
"'image'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"sanitize",
"(",
"$",
"return",
"[",
"0",
"]",
"[",
"'attribs'",
"]",
"[",
"''",
"]",
"[",
"'href'",
"]",
",",
"SIMPLEPIE_CONSTRUCT_IRI",
")",
";",
"}",
"elseif",
"(",
"$",
"return",
"=",
"$",
"this",
"->",
"get_channel_tags",
"(",
"SIMPLEPIE_NAMESPACE_ATOM_10",
",",
"'logo'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"sanitize",
"(",
"$",
"return",
"[",
"0",
"]",
"[",
"'data'",
"]",
",",
"SIMPLEPIE_CONSTRUCT_IRI",
",",
"$",
"this",
"->",
"get_base",
"(",
"$",
"return",
"[",
"0",
"]",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"return",
"=",
"$",
"this",
"->",
"get_channel_tags",
"(",
"SIMPLEPIE_NAMESPACE_ATOM_10",
",",
"'icon'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"sanitize",
"(",
"$",
"return",
"[",
"0",
"]",
"[",
"'data'",
"]",
",",
"SIMPLEPIE_CONSTRUCT_IRI",
",",
"$",
"this",
"->",
"get_base",
"(",
"$",
"return",
"[",
"0",
"]",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"return",
"=",
"$",
"this",
"->",
"get_image_tags",
"(",
"SIMPLEPIE_NAMESPACE_RSS_10",
",",
"'url'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"sanitize",
"(",
"$",
"return",
"[",
"0",
"]",
"[",
"'data'",
"]",
",",
"SIMPLEPIE_CONSTRUCT_IRI",
",",
"$",
"this",
"->",
"get_base",
"(",
"$",
"return",
"[",
"0",
"]",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"return",
"=",
"$",
"this",
"->",
"get_image_tags",
"(",
"SIMPLEPIE_NAMESPACE_RSS_090",
",",
"'url'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"sanitize",
"(",
"$",
"return",
"[",
"0",
"]",
"[",
"'data'",
"]",
",",
"SIMPLEPIE_CONSTRUCT_IRI",
",",
"$",
"this",
"->",
"get_base",
"(",
"$",
"return",
"[",
"0",
"]",
")",
")",
";",
"}",
"elseif",
"(",
"$",
"return",
"=",
"$",
"this",
"->",
"get_image_tags",
"(",
"SIMPLEPIE_NAMESPACE_RSS_20",
",",
"'url'",
")",
")",
"{",
"return",
"$",
"this",
"->",
"sanitize",
"(",
"$",
"return",
"[",
"0",
"]",
"[",
"'data'",
"]",
",",
"SIMPLEPIE_CONSTRUCT_IRI",
",",
"$",
"this",
"->",
"get_base",
"(",
"$",
"return",
"[",
"0",
"]",
")",
")",
";",
"}",
"else",
"{",
"return",
"null",
";",
"}",
"}"
] | Get the feed logo's URL
RSS 0.9.0, 2.0, Atom 1.0, and feeds with iTunes RSS tags are allowed to
have a "feed logo" URL. This points directly to the image itself.
Uses `<itunes:image>`, `<atom:logo>`, `<atom:icon>`,
`<image><title>` or `<image><dc:title>`
@return string|null | [
"Get",
"the",
"feed",
"logo",
"s",
"URL"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie.php#L2872-L2902 |
212,823 | moodle/moodle | lib/simplepie/library/SimplePie.php | SimplePie.set_favicon_handler | public function set_favicon_handler($page = false, $qs = 'i')
{
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
trigger_error('Favicon handling has been removed, please use your own handling', $level);
return false;
} | php | public function set_favicon_handler($page = false, $qs = 'i')
{
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
trigger_error('Favicon handling has been removed, please use your own handling', $level);
return false;
} | [
"public",
"function",
"set_favicon_handler",
"(",
"$",
"page",
"=",
"false",
",",
"$",
"qs",
"=",
"'i'",
")",
"{",
"$",
"level",
"=",
"defined",
"(",
"'E_USER_DEPRECATED'",
")",
"?",
"E_USER_DEPRECATED",
":",
"E_USER_WARNING",
";",
"trigger_error",
"(",
"'Favicon handling has been removed, please use your own handling'",
",",
"$",
"level",
")",
";",
"return",
"false",
";",
"}"
] | Set the favicon handler
@deprecated Use your own favicon handling instead | [
"Set",
"the",
"favicon",
"handler"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie.php#L3139-L3144 |
212,824 | moodle/moodle | lib/simplepie/library/SimplePie.php | SimplePie.get_favicon | public function get_favicon()
{
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
trigger_error('Favicon handling has been removed, please use your own handling', $level);
if (($url = $this->get_link()) !== null)
{
return 'http://g.etfv.co/' . urlencode($url);
}
return false;
} | php | public function get_favicon()
{
$level = defined('E_USER_DEPRECATED') ? E_USER_DEPRECATED : E_USER_WARNING;
trigger_error('Favicon handling has been removed, please use your own handling', $level);
if (($url = $this->get_link()) !== null)
{
return 'http://g.etfv.co/' . urlencode($url);
}
return false;
} | [
"public",
"function",
"get_favicon",
"(",
")",
"{",
"$",
"level",
"=",
"defined",
"(",
"'E_USER_DEPRECATED'",
")",
"?",
"E_USER_DEPRECATED",
":",
"E_USER_WARNING",
";",
"trigger_error",
"(",
"'Favicon handling has been removed, please use your own handling'",
",",
"$",
"level",
")",
";",
"if",
"(",
"(",
"$",
"url",
"=",
"$",
"this",
"->",
"get_link",
"(",
")",
")",
"!==",
"null",
")",
"{",
"return",
"'http://g.etfv.co/'",
".",
"urlencode",
"(",
"$",
"url",
")",
";",
"}",
"return",
"false",
";",
"}"
] | Get the favicon for the current feed
@deprecated Use your own favicon handling instead | [
"Get",
"the",
"favicon",
"for",
"the",
"current",
"feed"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie.php#L3151-L3162 |
212,825 | moodle/moodle | lib/simplepie/library/SimplePie.php | SimplePie.sort_items | public static function sort_items($a, $b)
{
$a_date = $a->get_date('U');
$b_date = $b->get_date('U');
if ($a_date && $b_date) {
return $a_date > $b_date ? -1 : 1;
}
// Sort items without dates to the top.
if ($a_date) {
return 1;
}
if ($b_date) {
return -1;
}
return 0;
} | php | public static function sort_items($a, $b)
{
$a_date = $a->get_date('U');
$b_date = $b->get_date('U');
if ($a_date && $b_date) {
return $a_date > $b_date ? -1 : 1;
}
// Sort items without dates to the top.
if ($a_date) {
return 1;
}
if ($b_date) {
return -1;
}
return 0;
} | [
"public",
"static",
"function",
"sort_items",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"$",
"a_date",
"=",
"$",
"a",
"->",
"get_date",
"(",
"'U'",
")",
";",
"$",
"b_date",
"=",
"$",
"b",
"->",
"get_date",
"(",
"'U'",
")",
";",
"if",
"(",
"$",
"a_date",
"&&",
"$",
"b_date",
")",
"{",
"return",
"$",
"a_date",
">",
"$",
"b_date",
"?",
"-",
"1",
":",
"1",
";",
"}",
"// Sort items without dates to the top.",
"if",
"(",
"$",
"a_date",
")",
"{",
"return",
"1",
";",
"}",
"if",
"(",
"$",
"b_date",
")",
"{",
"return",
"-",
"1",
";",
"}",
"return",
"0",
";",
"}"
] | Sorting callback for items
@access private
@param SimplePie $a
@param SimplePie $b
@return boolean | [
"Sorting",
"callback",
"for",
"items"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie.php#L3201-L3216 |
212,826 | moodle/moodle | lib/simplepie/library/SimplePie.php | SimplePie.store_links | private function store_links(&$file, $hub, $self) {
if (isset($file->headers['link']['hub']) ||
(isset($file->headers['link']) &&
preg_match('/rel=hub/', $file->headers['link'])))
{
return;
}
if ($hub)
{
if (isset($file->headers['link']))
{
if ($file->headers['link'] !== '')
{
$file->headers['link'] = ', ';
}
}
else
{
$file->headers['link'] = '';
}
$file->headers['link'] .= '<'.$hub.'>; rel=hub';
if ($self)
{
$file->headers['link'] .= ', <'.$self.'>; rel=self';
}
}
} | php | private function store_links(&$file, $hub, $self) {
if (isset($file->headers['link']['hub']) ||
(isset($file->headers['link']) &&
preg_match('/rel=hub/', $file->headers['link'])))
{
return;
}
if ($hub)
{
if (isset($file->headers['link']))
{
if ($file->headers['link'] !== '')
{
$file->headers['link'] = ', ';
}
}
else
{
$file->headers['link'] = '';
}
$file->headers['link'] .= '<'.$hub.'>; rel=hub';
if ($self)
{
$file->headers['link'] .= ', <'.$self.'>; rel=self';
}
}
} | [
"private",
"function",
"store_links",
"(",
"&",
"$",
"file",
",",
"$",
"hub",
",",
"$",
"self",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"file",
"->",
"headers",
"[",
"'link'",
"]",
"[",
"'hub'",
"]",
")",
"||",
"(",
"isset",
"(",
"$",
"file",
"->",
"headers",
"[",
"'link'",
"]",
")",
"&&",
"preg_match",
"(",
"'/rel=hub/'",
",",
"$",
"file",
"->",
"headers",
"[",
"'link'",
"]",
")",
")",
")",
"{",
"return",
";",
"}",
"if",
"(",
"$",
"hub",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"file",
"->",
"headers",
"[",
"'link'",
"]",
")",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"headers",
"[",
"'link'",
"]",
"!==",
"''",
")",
"{",
"$",
"file",
"->",
"headers",
"[",
"'link'",
"]",
"=",
"', '",
";",
"}",
"}",
"else",
"{",
"$",
"file",
"->",
"headers",
"[",
"'link'",
"]",
"=",
"''",
";",
"}",
"$",
"file",
"->",
"headers",
"[",
"'link'",
"]",
".=",
"'<'",
".",
"$",
"hub",
".",
"'>; rel=hub'",
";",
"if",
"(",
"$",
"self",
")",
"{",
"$",
"file",
"->",
"headers",
"[",
"'link'",
"]",
".=",
"', <'",
".",
"$",
"self",
".",
"'>; rel=self'",
";",
"}",
"}",
"}"
] | Store PubSubHubbub links as headers
There is no way to find PuSH links in the body of a microformats feed,
so they are added to the headers when found, to be used later by get_links.
@param SimplePie_File $file
@param string $hub
@param string $self | [
"Store",
"PubSubHubbub",
"links",
"as",
"headers"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/simplepie/library/SimplePie.php#L3275-L3302 |
212,827 | moodle/moodle | mod/lti/service/profile/classes/local/resources/profile.php | profile.get_path | public function get_path() {
$path = $this->template;
$toolproxy = $this->get_service()->get_tool_proxy();
if (!empty($toolproxy)) {
$path = str_replace('{tool_proxy_id}', $toolproxy->guid, $path);
}
return $path;
} | php | public function get_path() {
$path = $this->template;
$toolproxy = $this->get_service()->get_tool_proxy();
if (!empty($toolproxy)) {
$path = str_replace('{tool_proxy_id}', $toolproxy->guid, $path);
}
return $path;
} | [
"public",
"function",
"get_path",
"(",
")",
"{",
"$",
"path",
"=",
"$",
"this",
"->",
"template",
";",
"$",
"toolproxy",
"=",
"$",
"this",
"->",
"get_service",
"(",
")",
"->",
"get_tool_proxy",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"toolproxy",
")",
")",
"{",
"$",
"path",
"=",
"str_replace",
"(",
"'{tool_proxy_id}'",
",",
"$",
"toolproxy",
"->",
"guid",
",",
"$",
"path",
")",
";",
"}",
"return",
"$",
"path",
";",
"}"
] | Get the path for this resource.
@return string | [
"Get",
"the",
"path",
"for",
"this",
"resource",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/service/profile/classes/local/resources/profile.php#L64-L74 |
212,828 | moodle/moodle | lib/horde/framework/Horde/Imap/Client/Data/AclCommon.php | Horde_Imap_Client_Data_AclCommon.getString | public function getString($type = self::RFC_4314)
{
$acl = strval($this);
if ($type == self::RFC_2086) {
foreach ($this->_virtual as $key => $val) {
$acl = str_replace($val, '', $acl, $count);
if ($count) {
$acl .= $key;
}
}
}
return $acl;
} | php | public function getString($type = self::RFC_4314)
{
$acl = strval($this);
if ($type == self::RFC_2086) {
foreach ($this->_virtual as $key => $val) {
$acl = str_replace($val, '', $acl, $count);
if ($count) {
$acl .= $key;
}
}
}
return $acl;
} | [
"public",
"function",
"getString",
"(",
"$",
"type",
"=",
"self",
"::",
"RFC_4314",
")",
"{",
"$",
"acl",
"=",
"strval",
"(",
"$",
"this",
")",
";",
"if",
"(",
"$",
"type",
"==",
"self",
"::",
"RFC_2086",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"_virtual",
"as",
"$",
"key",
"=>",
"$",
"val",
")",
"{",
"$",
"acl",
"=",
"str_replace",
"(",
"$",
"val",
",",
"''",
",",
"$",
"acl",
",",
"$",
"count",
")",
";",
"if",
"(",
"$",
"count",
")",
"{",
"$",
"acl",
".=",
"$",
"key",
";",
"}",
"}",
"}",
"return",
"$",
"acl",
";",
"}"
] | Returns the raw string to use in IMAP server calls.
@param integer $type The RFC type to use (RFC_* constant).
@return string The string representation of the ACL. | [
"Returns",
"the",
"raw",
"string",
"to",
"use",
"in",
"IMAP",
"server",
"calls",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Data/AclCommon.php#L56-L70 |
212,829 | moodle/moodle | availability/condition/grouping/classes/condition.php | condition.get_grouping_id | protected function get_grouping_id(\core_availability\info $info) {
if ($this->activitygrouping) {
$groupingid = $info->get_course_module()->groupingid;
if (!$groupingid) {
throw new \coding_exception(
'Not supposed to be able to turn on activitygrouping when no grouping');
}
return $groupingid;
} else {
return $this->groupingid;
}
} | php | protected function get_grouping_id(\core_availability\info $info) {
if ($this->activitygrouping) {
$groupingid = $info->get_course_module()->groupingid;
if (!$groupingid) {
throw new \coding_exception(
'Not supposed to be able to turn on activitygrouping when no grouping');
}
return $groupingid;
} else {
return $this->groupingid;
}
} | [
"protected",
"function",
"get_grouping_id",
"(",
"\\",
"core_availability",
"\\",
"info",
"$",
"info",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"activitygrouping",
")",
"{",
"$",
"groupingid",
"=",
"$",
"info",
"->",
"get_course_module",
"(",
")",
"->",
"groupingid",
";",
"if",
"(",
"!",
"$",
"groupingid",
")",
"{",
"throw",
"new",
"\\",
"coding_exception",
"(",
"'Not supposed to be able to turn on activitygrouping when no grouping'",
")",
";",
"}",
"return",
"$",
"groupingid",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"groupingid",
";",
"}",
"}"
] | Gets the actual grouping id for the condition. This is either a specified
id, or a special flag indicating that we use the one for the current cm.
@param \core_availability\info $info Info about context cm
@return int Grouping id
@throws \coding_exception If it's set to use a cm but there isn't grouping | [
"Gets",
"the",
"actual",
"grouping",
"id",
"for",
"the",
"condition",
".",
"This",
"is",
"either",
"a",
"specified",
"id",
"or",
"a",
"special",
"flag",
"indicating",
"that",
"we",
"use",
"the",
"one",
"for",
"the",
"current",
"cm",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/availability/condition/grouping/classes/condition.php#L111-L122 |
212,830 | moodle/moodle | lib/form/filetypes.php | MoodleQuickForm_filetypes._createElements | public function _createElements() {
$this->_generateId();
$this->setElements([
$this->createFormElement('text', 'filetypes', $this->getLabel(), [
'id' => $this->getAttribute('id'),
]),
$this->createFormElement('static', 'browser', null,
'<span data-filetypesbrowser="'.$this->getAttribute('id').'"></span>'),
$this->createFormElement('static', 'descriptions', null,
'<div data-filetypesdescriptions="'.$this->getAttribute('id').'"></div>')
]);
} | php | public function _createElements() {
$this->_generateId();
$this->setElements([
$this->createFormElement('text', 'filetypes', $this->getLabel(), [
'id' => $this->getAttribute('id'),
]),
$this->createFormElement('static', 'browser', null,
'<span data-filetypesbrowser="'.$this->getAttribute('id').'"></span>'),
$this->createFormElement('static', 'descriptions', null,
'<div data-filetypesdescriptions="'.$this->getAttribute('id').'"></div>')
]);
} | [
"public",
"function",
"_createElements",
"(",
")",
"{",
"$",
"this",
"->",
"_generateId",
"(",
")",
";",
"$",
"this",
"->",
"setElements",
"(",
"[",
"$",
"this",
"->",
"createFormElement",
"(",
"'text'",
",",
"'filetypes'",
",",
"$",
"this",
"->",
"getLabel",
"(",
")",
",",
"[",
"'id'",
"=>",
"$",
"this",
"->",
"getAttribute",
"(",
"'id'",
")",
",",
"]",
")",
",",
"$",
"this",
"->",
"createFormElement",
"(",
"'static'",
",",
"'browser'",
",",
"null",
",",
"'<span data-filetypesbrowser=\"'",
".",
"$",
"this",
"->",
"getAttribute",
"(",
"'id'",
")",
".",
"'\"></span>'",
")",
",",
"$",
"this",
"->",
"createFormElement",
"(",
"'static'",
",",
"'descriptions'",
",",
"null",
",",
"'<div data-filetypesdescriptions=\"'",
".",
"$",
"this",
"->",
"getAttribute",
"(",
"'id'",
")",
".",
"'\"></div>'",
")",
"]",
")",
";",
"}"
] | Assemble the elements of the form control. | [
"Assemble",
"the",
"elements",
"of",
"the",
"form",
"control",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/form/filetypes.php#L93-L108 |
212,831 | moodle/moodle | lib/form/filetypes.php | MoodleQuickForm_filetypes.exportValue | public function exportValue(&$submitted, $assoc = false) {
$value = '';
$filetypeselement = null;
foreach ($this->_elements as $key => $element) {
if ($element->_attributes['name'] === 'filetypes') {
$filetypeselement = $this->_elements[$key];
}
}
if ($filetypeselement) {
$formval = $filetypeselement->exportValue($submitted[$this->getName()], false);
if ($formval) {
$value = $this->util->normalize_file_types($formval);
if ($value === ['*'] && !$this->allowall) {
$value = [];
}
$value = implode(',', $value);
}
}
return $this->_prepareValue($value, $assoc);
} | php | public function exportValue(&$submitted, $assoc = false) {
$value = '';
$filetypeselement = null;
foreach ($this->_elements as $key => $element) {
if ($element->_attributes['name'] === 'filetypes') {
$filetypeselement = $this->_elements[$key];
}
}
if ($filetypeselement) {
$formval = $filetypeselement->exportValue($submitted[$this->getName()], false);
if ($formval) {
$value = $this->util->normalize_file_types($formval);
if ($value === ['*'] && !$this->allowall) {
$value = [];
}
$value = implode(',', $value);
}
}
return $this->_prepareValue($value, $assoc);
} | [
"public",
"function",
"exportValue",
"(",
"&",
"$",
"submitted",
",",
"$",
"assoc",
"=",
"false",
")",
"{",
"$",
"value",
"=",
"''",
";",
"$",
"filetypeselement",
"=",
"null",
";",
"foreach",
"(",
"$",
"this",
"->",
"_elements",
"as",
"$",
"key",
"=>",
"$",
"element",
")",
"{",
"if",
"(",
"$",
"element",
"->",
"_attributes",
"[",
"'name'",
"]",
"===",
"'filetypes'",
")",
"{",
"$",
"filetypeselement",
"=",
"$",
"this",
"->",
"_elements",
"[",
"$",
"key",
"]",
";",
"}",
"}",
"if",
"(",
"$",
"filetypeselement",
")",
"{",
"$",
"formval",
"=",
"$",
"filetypeselement",
"->",
"exportValue",
"(",
"$",
"submitted",
"[",
"$",
"this",
"->",
"getName",
"(",
")",
"]",
",",
"false",
")",
";",
"if",
"(",
"$",
"formval",
")",
"{",
"$",
"value",
"=",
"$",
"this",
"->",
"util",
"->",
"normalize_file_types",
"(",
"$",
"formval",
")",
";",
"if",
"(",
"$",
"value",
"===",
"[",
"'*'",
"]",
"&&",
"!",
"$",
"this",
"->",
"allowall",
")",
"{",
"$",
"value",
"=",
"[",
"]",
";",
"}",
"$",
"value",
"=",
"implode",
"(",
"','",
",",
"$",
"value",
")",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"_prepareValue",
"(",
"$",
"value",
",",
"$",
"assoc",
")",
";",
"}"
] | Return the selected file types.
@param array $submitted submitted values
@param bool $assoc if true the retured value is associated array
@return array | [
"Return",
"the",
"selected",
"file",
"types",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/form/filetypes.php#L117-L140 |
212,832 | moodle/moodle | lib/form/filetypes.php | MoodleQuickForm_filetypes.validateSubmitValue | public function validateSubmitValue($value) {
if (!$this->allowall) {
// Assert that there is an actual list provided.
$normalized = $this->util->normalize_file_types($value['filetypes']);
if (empty($normalized) || $normalized == ['*']) {
return get_string('filetypesnotall', 'core_form');
}
}
if (!$this->allowunknown) {
// Assert that all file types are known.
$unknown = $this->util->get_unknown_file_types($value['filetypes']);
if ($unknown) {
return get_string('filetypesunknown', 'core_form', implode(', ', $unknown));
}
}
if ($this->onlytypes) {
// Assert that all file types are allowed here.
$notwhitelisted = $this->util->get_not_whitelisted($value['filetypes'], $this->onlytypes);
if ($notwhitelisted) {
return get_string('filetypesnotwhitelisted', 'core_form', implode(', ', $notwhitelisted));
}
}
return;
} | php | public function validateSubmitValue($value) {
if (!$this->allowall) {
// Assert that there is an actual list provided.
$normalized = $this->util->normalize_file_types($value['filetypes']);
if (empty($normalized) || $normalized == ['*']) {
return get_string('filetypesnotall', 'core_form');
}
}
if (!$this->allowunknown) {
// Assert that all file types are known.
$unknown = $this->util->get_unknown_file_types($value['filetypes']);
if ($unknown) {
return get_string('filetypesunknown', 'core_form', implode(', ', $unknown));
}
}
if ($this->onlytypes) {
// Assert that all file types are allowed here.
$notwhitelisted = $this->util->get_not_whitelisted($value['filetypes'], $this->onlytypes);
if ($notwhitelisted) {
return get_string('filetypesnotwhitelisted', 'core_form', implode(', ', $notwhitelisted));
}
}
return;
} | [
"public",
"function",
"validateSubmitValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"allowall",
")",
"{",
"// Assert that there is an actual list provided.",
"$",
"normalized",
"=",
"$",
"this",
"->",
"util",
"->",
"normalize_file_types",
"(",
"$",
"value",
"[",
"'filetypes'",
"]",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"normalized",
")",
"||",
"$",
"normalized",
"==",
"[",
"'*'",
"]",
")",
"{",
"return",
"get_string",
"(",
"'filetypesnotall'",
",",
"'core_form'",
")",
";",
"}",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"allowunknown",
")",
"{",
"// Assert that all file types are known.",
"$",
"unknown",
"=",
"$",
"this",
"->",
"util",
"->",
"get_unknown_file_types",
"(",
"$",
"value",
"[",
"'filetypes'",
"]",
")",
";",
"if",
"(",
"$",
"unknown",
")",
"{",
"return",
"get_string",
"(",
"'filetypesunknown'",
",",
"'core_form'",
",",
"implode",
"(",
"', '",
",",
"$",
"unknown",
")",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"onlytypes",
")",
"{",
"// Assert that all file types are allowed here.",
"$",
"notwhitelisted",
"=",
"$",
"this",
"->",
"util",
"->",
"get_not_whitelisted",
"(",
"$",
"value",
"[",
"'filetypes'",
"]",
",",
"$",
"this",
"->",
"onlytypes",
")",
";",
"if",
"(",
"$",
"notwhitelisted",
")",
"{",
"return",
"get_string",
"(",
"'filetypesnotwhitelisted'",
",",
"'core_form'",
",",
"implode",
"(",
"', '",
",",
"$",
"notwhitelisted",
")",
")",
";",
"}",
"}",
"return",
";",
"}"
] | Check that the submitted list contains only known and allowed file types.
The validation obeys the element options 'allowall', 'allowunknown' and
'onlytypes' passed when creating the element.
@param array $value Submitted value.
@return string|null Validation error message or null. | [
"Check",
"that",
"the",
"submitted",
"list",
"contains",
"only",
"known",
"and",
"allowed",
"file",
"types",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/form/filetypes.php#L222-L251 |
212,833 | moodle/moodle | lib/outputrenderers.php | renderer_base.get_mustache | protected function get_mustache() {
global $CFG;
if ($this->mustache === null) {
require_once("{$CFG->libdir}/filelib.php");
$themename = $this->page->theme->name;
$themerev = theme_get_revision();
// Create new localcache directory.
$cachedir = make_localcache_directory("mustache/$themerev/$themename");
// Remove old localcache directories.
$mustachecachedirs = glob("{$CFG->localcachedir}/mustache/*", GLOB_ONLYDIR);
foreach ($mustachecachedirs as $localcachedir) {
$cachedrev = [];
preg_match("/\/mustache\/([0-9]+)$/", $localcachedir, $cachedrev);
$cachedrev = isset($cachedrev[1]) ? intval($cachedrev[1]) : 0;
if ($cachedrev > 0 && $cachedrev < $themerev) {
fulldelete($localcachedir);
}
}
$loader = new \core\output\mustache_filesystem_loader();
$stringhelper = new \core\output\mustache_string_helper();
$quotehelper = new \core\output\mustache_quote_helper();
$jshelper = new \core\output\mustache_javascript_helper($this->page);
$pixhelper = new \core\output\mustache_pix_helper($this);
$shortentexthelper = new \core\output\mustache_shorten_text_helper();
$userdatehelper = new \core\output\mustache_user_date_helper();
// We only expose the variables that are exposed to JS templates.
$safeconfig = $this->page->requires->get_config_for_javascript($this->page, $this);
$helpers = array('config' => $safeconfig,
'str' => array($stringhelper, 'str'),
'quote' => array($quotehelper, 'quote'),
'js' => array($jshelper, 'help'),
'pix' => array($pixhelper, 'pix'),
'shortentext' => array($shortentexthelper, 'shorten'),
'userdate' => array($userdatehelper, 'transform'),
);
$this->mustache = new Mustache_Engine(array(
'cache' => $cachedir,
'escape' => 's',
'loader' => $loader,
'helpers' => $helpers,
'pragmas' => [Mustache_Engine::PRAGMA_BLOCKS]));
}
return $this->mustache;
} | php | protected function get_mustache() {
global $CFG;
if ($this->mustache === null) {
require_once("{$CFG->libdir}/filelib.php");
$themename = $this->page->theme->name;
$themerev = theme_get_revision();
// Create new localcache directory.
$cachedir = make_localcache_directory("mustache/$themerev/$themename");
// Remove old localcache directories.
$mustachecachedirs = glob("{$CFG->localcachedir}/mustache/*", GLOB_ONLYDIR);
foreach ($mustachecachedirs as $localcachedir) {
$cachedrev = [];
preg_match("/\/mustache\/([0-9]+)$/", $localcachedir, $cachedrev);
$cachedrev = isset($cachedrev[1]) ? intval($cachedrev[1]) : 0;
if ($cachedrev > 0 && $cachedrev < $themerev) {
fulldelete($localcachedir);
}
}
$loader = new \core\output\mustache_filesystem_loader();
$stringhelper = new \core\output\mustache_string_helper();
$quotehelper = new \core\output\mustache_quote_helper();
$jshelper = new \core\output\mustache_javascript_helper($this->page);
$pixhelper = new \core\output\mustache_pix_helper($this);
$shortentexthelper = new \core\output\mustache_shorten_text_helper();
$userdatehelper = new \core\output\mustache_user_date_helper();
// We only expose the variables that are exposed to JS templates.
$safeconfig = $this->page->requires->get_config_for_javascript($this->page, $this);
$helpers = array('config' => $safeconfig,
'str' => array($stringhelper, 'str'),
'quote' => array($quotehelper, 'quote'),
'js' => array($jshelper, 'help'),
'pix' => array($pixhelper, 'pix'),
'shortentext' => array($shortentexthelper, 'shorten'),
'userdate' => array($userdatehelper, 'transform'),
);
$this->mustache = new Mustache_Engine(array(
'cache' => $cachedir,
'escape' => 's',
'loader' => $loader,
'helpers' => $helpers,
'pragmas' => [Mustache_Engine::PRAGMA_BLOCKS]));
}
return $this->mustache;
} | [
"protected",
"function",
"get_mustache",
"(",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"$",
"this",
"->",
"mustache",
"===",
"null",
")",
"{",
"require_once",
"(",
"\"{$CFG->libdir}/filelib.php\"",
")",
";",
"$",
"themename",
"=",
"$",
"this",
"->",
"page",
"->",
"theme",
"->",
"name",
";",
"$",
"themerev",
"=",
"theme_get_revision",
"(",
")",
";",
"// Create new localcache directory.",
"$",
"cachedir",
"=",
"make_localcache_directory",
"(",
"\"mustache/$themerev/$themename\"",
")",
";",
"// Remove old localcache directories.",
"$",
"mustachecachedirs",
"=",
"glob",
"(",
"\"{$CFG->localcachedir}/mustache/*\"",
",",
"GLOB_ONLYDIR",
")",
";",
"foreach",
"(",
"$",
"mustachecachedirs",
"as",
"$",
"localcachedir",
")",
"{",
"$",
"cachedrev",
"=",
"[",
"]",
";",
"preg_match",
"(",
"\"/\\/mustache\\/([0-9]+)$/\"",
",",
"$",
"localcachedir",
",",
"$",
"cachedrev",
")",
";",
"$",
"cachedrev",
"=",
"isset",
"(",
"$",
"cachedrev",
"[",
"1",
"]",
")",
"?",
"intval",
"(",
"$",
"cachedrev",
"[",
"1",
"]",
")",
":",
"0",
";",
"if",
"(",
"$",
"cachedrev",
">",
"0",
"&&",
"$",
"cachedrev",
"<",
"$",
"themerev",
")",
"{",
"fulldelete",
"(",
"$",
"localcachedir",
")",
";",
"}",
"}",
"$",
"loader",
"=",
"new",
"\\",
"core",
"\\",
"output",
"\\",
"mustache_filesystem_loader",
"(",
")",
";",
"$",
"stringhelper",
"=",
"new",
"\\",
"core",
"\\",
"output",
"\\",
"mustache_string_helper",
"(",
")",
";",
"$",
"quotehelper",
"=",
"new",
"\\",
"core",
"\\",
"output",
"\\",
"mustache_quote_helper",
"(",
")",
";",
"$",
"jshelper",
"=",
"new",
"\\",
"core",
"\\",
"output",
"\\",
"mustache_javascript_helper",
"(",
"$",
"this",
"->",
"page",
")",
";",
"$",
"pixhelper",
"=",
"new",
"\\",
"core",
"\\",
"output",
"\\",
"mustache_pix_helper",
"(",
"$",
"this",
")",
";",
"$",
"shortentexthelper",
"=",
"new",
"\\",
"core",
"\\",
"output",
"\\",
"mustache_shorten_text_helper",
"(",
")",
";",
"$",
"userdatehelper",
"=",
"new",
"\\",
"core",
"\\",
"output",
"\\",
"mustache_user_date_helper",
"(",
")",
";",
"// We only expose the variables that are exposed to JS templates.",
"$",
"safeconfig",
"=",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"get_config_for_javascript",
"(",
"$",
"this",
"->",
"page",
",",
"$",
"this",
")",
";",
"$",
"helpers",
"=",
"array",
"(",
"'config'",
"=>",
"$",
"safeconfig",
",",
"'str'",
"=>",
"array",
"(",
"$",
"stringhelper",
",",
"'str'",
")",
",",
"'quote'",
"=>",
"array",
"(",
"$",
"quotehelper",
",",
"'quote'",
")",
",",
"'js'",
"=>",
"array",
"(",
"$",
"jshelper",
",",
"'help'",
")",
",",
"'pix'",
"=>",
"array",
"(",
"$",
"pixhelper",
",",
"'pix'",
")",
",",
"'shortentext'",
"=>",
"array",
"(",
"$",
"shortentexthelper",
",",
"'shorten'",
")",
",",
"'userdate'",
"=>",
"array",
"(",
"$",
"userdatehelper",
",",
"'transform'",
")",
",",
")",
";",
"$",
"this",
"->",
"mustache",
"=",
"new",
"Mustache_Engine",
"(",
"array",
"(",
"'cache'",
"=>",
"$",
"cachedir",
",",
"'escape'",
"=>",
"'s'",
",",
"'loader'",
"=>",
"$",
"loader",
",",
"'helpers'",
"=>",
"$",
"helpers",
",",
"'pragmas'",
"=>",
"[",
"Mustache_Engine",
"::",
"PRAGMA_BLOCKS",
"]",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"mustache",
";",
"}"
] | Return an instance of the mustache class.
@since 2.9
@return Mustache_Engine | [
"Return",
"an",
"instance",
"of",
"the",
"mustache",
"class",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L80-L133 |
212,834 | moodle/moodle | lib/outputrenderers.php | renderer_base.render_from_template | public function render_from_template($templatename, $context) {
static $templatecache = array();
$mustache = $this->get_mustache();
try {
// Grab a copy of the existing helper to be restored later.
$uniqidhelper = $mustache->getHelper('uniqid');
} catch (Mustache_Exception_UnknownHelperException $e) {
// Helper doesn't exist.
$uniqidhelper = null;
}
// Provide 1 random value that will not change within a template
// but will be different from template to template. This is useful for
// e.g. aria attributes that only work with id attributes and must be
// unique in a page.
$mustache->addHelper('uniqid', new \core\output\mustache_uniqid_helper());
if (isset($templatecache[$templatename])) {
$template = $templatecache[$templatename];
} else {
try {
$template = $mustache->loadTemplate($templatename);
$templatecache[$templatename] = $template;
} catch (Mustache_Exception_UnknownTemplateException $e) {
throw new moodle_exception('Unknown template: ' . $templatename);
}
}
$renderedtemplate = trim($template->render($context));
// If we had an existing uniqid helper then we need to restore it to allow
// handle nested calls of render_from_template.
if ($uniqidhelper) {
$mustache->addHelper('uniqid', $uniqidhelper);
}
return $renderedtemplate;
} | php | public function render_from_template($templatename, $context) {
static $templatecache = array();
$mustache = $this->get_mustache();
try {
// Grab a copy of the existing helper to be restored later.
$uniqidhelper = $mustache->getHelper('uniqid');
} catch (Mustache_Exception_UnknownHelperException $e) {
// Helper doesn't exist.
$uniqidhelper = null;
}
// Provide 1 random value that will not change within a template
// but will be different from template to template. This is useful for
// e.g. aria attributes that only work with id attributes and must be
// unique in a page.
$mustache->addHelper('uniqid', new \core\output\mustache_uniqid_helper());
if (isset($templatecache[$templatename])) {
$template = $templatecache[$templatename];
} else {
try {
$template = $mustache->loadTemplate($templatename);
$templatecache[$templatename] = $template;
} catch (Mustache_Exception_UnknownTemplateException $e) {
throw new moodle_exception('Unknown template: ' . $templatename);
}
}
$renderedtemplate = trim($template->render($context));
// If we had an existing uniqid helper then we need to restore it to allow
// handle nested calls of render_from_template.
if ($uniqidhelper) {
$mustache->addHelper('uniqid', $uniqidhelper);
}
return $renderedtemplate;
} | [
"public",
"function",
"render_from_template",
"(",
"$",
"templatename",
",",
"$",
"context",
")",
"{",
"static",
"$",
"templatecache",
"=",
"array",
"(",
")",
";",
"$",
"mustache",
"=",
"$",
"this",
"->",
"get_mustache",
"(",
")",
";",
"try",
"{",
"// Grab a copy of the existing helper to be restored later.",
"$",
"uniqidhelper",
"=",
"$",
"mustache",
"->",
"getHelper",
"(",
"'uniqid'",
")",
";",
"}",
"catch",
"(",
"Mustache_Exception_UnknownHelperException",
"$",
"e",
")",
"{",
"// Helper doesn't exist.",
"$",
"uniqidhelper",
"=",
"null",
";",
"}",
"// Provide 1 random value that will not change within a template",
"// but will be different from template to template. This is useful for",
"// e.g. aria attributes that only work with id attributes and must be",
"// unique in a page.",
"$",
"mustache",
"->",
"addHelper",
"(",
"'uniqid'",
",",
"new",
"\\",
"core",
"\\",
"output",
"\\",
"mustache_uniqid_helper",
"(",
")",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"templatecache",
"[",
"$",
"templatename",
"]",
")",
")",
"{",
"$",
"template",
"=",
"$",
"templatecache",
"[",
"$",
"templatename",
"]",
";",
"}",
"else",
"{",
"try",
"{",
"$",
"template",
"=",
"$",
"mustache",
"->",
"loadTemplate",
"(",
"$",
"templatename",
")",
";",
"$",
"templatecache",
"[",
"$",
"templatename",
"]",
"=",
"$",
"template",
";",
"}",
"catch",
"(",
"Mustache_Exception_UnknownTemplateException",
"$",
"e",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'Unknown template: '",
".",
"$",
"templatename",
")",
";",
"}",
"}",
"$",
"renderedtemplate",
"=",
"trim",
"(",
"$",
"template",
"->",
"render",
"(",
"$",
"context",
")",
")",
";",
"// If we had an existing uniqid helper then we need to restore it to allow",
"// handle nested calls of render_from_template.",
"if",
"(",
"$",
"uniqidhelper",
")",
"{",
"$",
"mustache",
"->",
"addHelper",
"(",
"'uniqid'",
",",
"$",
"uniqidhelper",
")",
";",
"}",
"return",
"$",
"renderedtemplate",
";",
"}"
] | Renders a template by name with the given context.
The provided data needs to be array/stdClass made up of only simple types.
Simple types are array,stdClass,bool,int,float,string
@since 2.9
@param array|stdClass $context Context containing data for the template.
@return string|boolean | [
"Renders",
"a",
"template",
"by",
"name",
"with",
"the",
"given",
"context",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L163-L200 |
212,835 | moodle/moodle | lib/outputrenderers.php | renderer_base.render | public function render(renderable $widget) {
$classparts = explode('\\', get_class($widget));
// Strip namespaces.
$classname = array_pop($classparts);
// Remove _renderable suffixes
$classname = preg_replace('/_renderable$/', '', $classname);
$rendermethod = 'render_'.$classname;
if (method_exists($this, $rendermethod)) {
return $this->$rendermethod($widget);
}
if ($widget instanceof templatable) {
$component = array_shift($classparts);
if (!$component) {
$component = 'core';
}
$template = $component . '/' . $classname;
$context = $widget->export_for_template($this);
return $this->render_from_template($template, $context);
}
throw new coding_exception('Can not render widget, renderer method ('.$rendermethod.') not found.');
} | php | public function render(renderable $widget) {
$classparts = explode('\\', get_class($widget));
// Strip namespaces.
$classname = array_pop($classparts);
// Remove _renderable suffixes
$classname = preg_replace('/_renderable$/', '', $classname);
$rendermethod = 'render_'.$classname;
if (method_exists($this, $rendermethod)) {
return $this->$rendermethod($widget);
}
if ($widget instanceof templatable) {
$component = array_shift($classparts);
if (!$component) {
$component = 'core';
}
$template = $component . '/' . $classname;
$context = $widget->export_for_template($this);
return $this->render_from_template($template, $context);
}
throw new coding_exception('Can not render widget, renderer method ('.$rendermethod.') not found.');
} | [
"public",
"function",
"render",
"(",
"renderable",
"$",
"widget",
")",
"{",
"$",
"classparts",
"=",
"explode",
"(",
"'\\\\'",
",",
"get_class",
"(",
"$",
"widget",
")",
")",
";",
"// Strip namespaces.",
"$",
"classname",
"=",
"array_pop",
"(",
"$",
"classparts",
")",
";",
"// Remove _renderable suffixes",
"$",
"classname",
"=",
"preg_replace",
"(",
"'/_renderable$/'",
",",
"''",
",",
"$",
"classname",
")",
";",
"$",
"rendermethod",
"=",
"'render_'",
".",
"$",
"classname",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"rendermethod",
")",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"rendermethod",
"(",
"$",
"widget",
")",
";",
"}",
"if",
"(",
"$",
"widget",
"instanceof",
"templatable",
")",
"{",
"$",
"component",
"=",
"array_shift",
"(",
"$",
"classparts",
")",
";",
"if",
"(",
"!",
"$",
"component",
")",
"{",
"$",
"component",
"=",
"'core'",
";",
"}",
"$",
"template",
"=",
"$",
"component",
".",
"'/'",
".",
"$",
"classname",
";",
"$",
"context",
"=",
"$",
"widget",
"->",
"export_for_template",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
"->",
"render_from_template",
"(",
"$",
"template",
",",
"$",
"context",
")",
";",
"}",
"throw",
"new",
"coding_exception",
"(",
"'Can not render widget, renderer method ('",
".",
"$",
"rendermethod",
".",
"') not found.'",
")",
";",
"}"
] | Returns rendered widget.
The provided widget needs to be an object that extends the renderable
interface.
If will then be rendered by a method based upon the classname for the widget.
For instance a widget of class `crazywidget` will be rendered by a protected
render_crazywidget method of this renderer.
If no render_crazywidget method exists and crazywidget implements templatable,
look for the 'crazywidget' template in the same component and render that.
@param renderable $widget instance with renderable interface
@return string | [
"Returns",
"rendered",
"widget",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L217-L238 |
212,836 | moodle/moodle | lib/outputrenderers.php | renderer_base.add_action_handler | public function add_action_handler(component_action $action, $id = null) {
if (!$id) {
$id = html_writer::random_id($action->event);
}
$this->page->requires->event_handler("#$id", $action->event, $action->jsfunction, $action->jsfunctionargs);
return $id;
} | php | public function add_action_handler(component_action $action, $id = null) {
if (!$id) {
$id = html_writer::random_id($action->event);
}
$this->page->requires->event_handler("#$id", $action->event, $action->jsfunction, $action->jsfunctionargs);
return $id;
} | [
"public",
"function",
"add_action_handler",
"(",
"component_action",
"$",
"action",
",",
"$",
"id",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"id",
")",
"{",
"$",
"id",
"=",
"html_writer",
"::",
"random_id",
"(",
"$",
"action",
"->",
"event",
")",
";",
"}",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"event_handler",
"(",
"\"#$id\"",
",",
"$",
"action",
"->",
"event",
",",
"$",
"action",
"->",
"jsfunction",
",",
"$",
"action",
"->",
"jsfunctionargs",
")",
";",
"return",
"$",
"id",
";",
"}"
] | Adds a JS action for the element with the provided id.
This method adds a JS event for the provided component action to the page
and then returns the id that the event has been attached to.
If no id has been provided then a new ID is generated by {@link html_writer::random_id()}
@param component_action $action
@param string $id
@return string id of element, either original submitted or random new if not supplied | [
"Adds",
"a",
"JS",
"action",
"for",
"the",
"element",
"with",
"the",
"provided",
"id",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L251-L257 |
212,837 | moodle/moodle | lib/outputrenderers.php | renderer_base.get_logo_url | public function get_logo_url($maxwidth = null, $maxheight = 200) {
global $CFG;
$logo = get_config('core_admin', 'logo');
if (empty($logo)) {
return false;
}
// 200px high is the default image size which should be displayed at 100px in the page to account for retina displays.
// It's not worth the overhead of detecting and serving 2 different images based on the device.
// Hide the requested size in the file path.
$filepath = ((int) $maxwidth . 'x' . (int) $maxheight) . '/';
// Use $CFG->themerev to prevent browser caching when the file changes.
return moodle_url::make_pluginfile_url(context_system::instance()->id, 'core_admin', 'logo', $filepath,
theme_get_revision(), $logo);
} | php | public function get_logo_url($maxwidth = null, $maxheight = 200) {
global $CFG;
$logo = get_config('core_admin', 'logo');
if (empty($logo)) {
return false;
}
// 200px high is the default image size which should be displayed at 100px in the page to account for retina displays.
// It's not worth the overhead of detecting and serving 2 different images based on the device.
// Hide the requested size in the file path.
$filepath = ((int) $maxwidth . 'x' . (int) $maxheight) . '/';
// Use $CFG->themerev to prevent browser caching when the file changes.
return moodle_url::make_pluginfile_url(context_system::instance()->id, 'core_admin', 'logo', $filepath,
theme_get_revision(), $logo);
} | [
"public",
"function",
"get_logo_url",
"(",
"$",
"maxwidth",
"=",
"null",
",",
"$",
"maxheight",
"=",
"200",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"logo",
"=",
"get_config",
"(",
"'core_admin'",
",",
"'logo'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"logo",
")",
")",
"{",
"return",
"false",
";",
"}",
"// 200px high is the default image size which should be displayed at 100px in the page to account for retina displays.",
"// It's not worth the overhead of detecting and serving 2 different images based on the device.",
"// Hide the requested size in the file path.",
"$",
"filepath",
"=",
"(",
"(",
"int",
")",
"$",
"maxwidth",
".",
"'x'",
".",
"(",
"int",
")",
"$",
"maxheight",
")",
".",
"'/'",
";",
"// Use $CFG->themerev to prevent browser caching when the file changes.",
"return",
"moodle_url",
"::",
"make_pluginfile_url",
"(",
"context_system",
"::",
"instance",
"(",
")",
"->",
"id",
",",
"'core_admin'",
",",
"'logo'",
",",
"$",
"filepath",
",",
"theme_get_revision",
"(",
")",
",",
"$",
"logo",
")",
";",
"}"
] | Return the site's logo URL, if any.
@param int $maxwidth The maximum width, or null when the maximum width does not matter.
@param int $maxheight The maximum height, or null when the maximum height does not matter.
@return moodle_url|false | [
"Return",
"the",
"site",
"s",
"logo",
"URL",
"if",
"any",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L331-L347 |
212,838 | moodle/moodle | lib/outputrenderers.php | renderer_base.should_display_main_logo | public function should_display_main_logo($headinglevel = 1) {
global $PAGE;
// Only render the logo if we're on the front page or login page and the we have a logo.
$logo = $this->get_logo_url();
if ($headinglevel == 1 && !empty($logo)) {
if ($PAGE->pagelayout == 'frontpage' || $PAGE->pagelayout == 'login') {
return true;
}
}
return false;
} | php | public function should_display_main_logo($headinglevel = 1) {
global $PAGE;
// Only render the logo if we're on the front page or login page and the we have a logo.
$logo = $this->get_logo_url();
if ($headinglevel == 1 && !empty($logo)) {
if ($PAGE->pagelayout == 'frontpage' || $PAGE->pagelayout == 'login') {
return true;
}
}
return false;
} | [
"public",
"function",
"should_display_main_logo",
"(",
"$",
"headinglevel",
"=",
"1",
")",
"{",
"global",
"$",
"PAGE",
";",
"// Only render the logo if we're on the front page or login page and the we have a logo.",
"$",
"logo",
"=",
"$",
"this",
"->",
"get_logo_url",
"(",
")",
";",
"if",
"(",
"$",
"headinglevel",
"==",
"1",
"&&",
"!",
"empty",
"(",
"$",
"logo",
")",
")",
"{",
"if",
"(",
"$",
"PAGE",
"->",
"pagelayout",
"==",
"'frontpage'",
"||",
"$",
"PAGE",
"->",
"pagelayout",
"==",
"'login'",
")",
"{",
"return",
"true",
";",
"}",
"}",
"return",
"false",
";",
"}"
] | Whether we should display the main logo.
@param int $headinglevel
@return bool | [
"Whether",
"we",
"should",
"display",
"the",
"main",
"logo",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L389-L401 |
212,839 | moodle/moodle | lib/outputrenderers.php | plugin_renderer_base.render | public function render(renderable $widget) {
$classname = get_class($widget);
// Strip namespaces.
$classname = preg_replace('/^.*\\\/', '', $classname);
// Keep a copy at this point, we may need to look for a deprecated method.
$deprecatedmethod = 'render_'.$classname;
// Remove _renderable suffixes
$classname = preg_replace('/_renderable$/', '', $classname);
$rendermethod = 'render_'.$classname;
if (method_exists($this, $rendermethod)) {
return $this->$rendermethod($widget);
}
if ($rendermethod !== $deprecatedmethod && method_exists($this, $deprecatedmethod)) {
// This is exactly where we don't want to be.
// If you have arrived here you have a renderable component within your plugin that has the name
// blah_renderable, and you have a render method render_blah_renderable on your plugin.
// In 2.8 we revamped output, as part of this change we changed slightly how renderables got rendered
// and the _renderable suffix now gets removed when looking for a render method.
// You need to change your renderers render_blah_renderable to render_blah.
// Until you do this it will not be possible for a theme to override the renderer to override your method.
// Please do it ASAP.
static $debugged = array();
if (!isset($debugged[$deprecatedmethod])) {
debugging(sprintf('Deprecated call. Please rename your renderables render method from %s to %s.',
$deprecatedmethod, $rendermethod), DEBUG_DEVELOPER);
$debugged[$deprecatedmethod] = true;
}
return $this->$deprecatedmethod($widget);
}
// pass to core renderer if method not found here
return $this->output->render($widget);
} | php | public function render(renderable $widget) {
$classname = get_class($widget);
// Strip namespaces.
$classname = preg_replace('/^.*\\\/', '', $classname);
// Keep a copy at this point, we may need to look for a deprecated method.
$deprecatedmethod = 'render_'.$classname;
// Remove _renderable suffixes
$classname = preg_replace('/_renderable$/', '', $classname);
$rendermethod = 'render_'.$classname;
if (method_exists($this, $rendermethod)) {
return $this->$rendermethod($widget);
}
if ($rendermethod !== $deprecatedmethod && method_exists($this, $deprecatedmethod)) {
// This is exactly where we don't want to be.
// If you have arrived here you have a renderable component within your plugin that has the name
// blah_renderable, and you have a render method render_blah_renderable on your plugin.
// In 2.8 we revamped output, as part of this change we changed slightly how renderables got rendered
// and the _renderable suffix now gets removed when looking for a render method.
// You need to change your renderers render_blah_renderable to render_blah.
// Until you do this it will not be possible for a theme to override the renderer to override your method.
// Please do it ASAP.
static $debugged = array();
if (!isset($debugged[$deprecatedmethod])) {
debugging(sprintf('Deprecated call. Please rename your renderables render method from %s to %s.',
$deprecatedmethod, $rendermethod), DEBUG_DEVELOPER);
$debugged[$deprecatedmethod] = true;
}
return $this->$deprecatedmethod($widget);
}
// pass to core renderer if method not found here
return $this->output->render($widget);
} | [
"public",
"function",
"render",
"(",
"renderable",
"$",
"widget",
")",
"{",
"$",
"classname",
"=",
"get_class",
"(",
"$",
"widget",
")",
";",
"// Strip namespaces.",
"$",
"classname",
"=",
"preg_replace",
"(",
"'/^.*\\\\\\/'",
",",
"''",
",",
"$",
"classname",
")",
";",
"// Keep a copy at this point, we may need to look for a deprecated method.",
"$",
"deprecatedmethod",
"=",
"'render_'",
".",
"$",
"classname",
";",
"// Remove _renderable suffixes",
"$",
"classname",
"=",
"preg_replace",
"(",
"'/_renderable$/'",
",",
"''",
",",
"$",
"classname",
")",
";",
"$",
"rendermethod",
"=",
"'render_'",
".",
"$",
"classname",
";",
"if",
"(",
"method_exists",
"(",
"$",
"this",
",",
"$",
"rendermethod",
")",
")",
"{",
"return",
"$",
"this",
"->",
"$",
"rendermethod",
"(",
"$",
"widget",
")",
";",
"}",
"if",
"(",
"$",
"rendermethod",
"!==",
"$",
"deprecatedmethod",
"&&",
"method_exists",
"(",
"$",
"this",
",",
"$",
"deprecatedmethod",
")",
")",
"{",
"// This is exactly where we don't want to be.",
"// If you have arrived here you have a renderable component within your plugin that has the name",
"// blah_renderable, and you have a render method render_blah_renderable on your plugin.",
"// In 2.8 we revamped output, as part of this change we changed slightly how renderables got rendered",
"// and the _renderable suffix now gets removed when looking for a render method.",
"// You need to change your renderers render_blah_renderable to render_blah.",
"// Until you do this it will not be possible for a theme to override the renderer to override your method.",
"// Please do it ASAP.",
"static",
"$",
"debugged",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"debugged",
"[",
"$",
"deprecatedmethod",
"]",
")",
")",
"{",
"debugging",
"(",
"sprintf",
"(",
"'Deprecated call. Please rename your renderables render method from %s to %s.'",
",",
"$",
"deprecatedmethod",
",",
"$",
"rendermethod",
")",
",",
"DEBUG_DEVELOPER",
")",
";",
"$",
"debugged",
"[",
"$",
"deprecatedmethod",
"]",
"=",
"true",
";",
"}",
"return",
"$",
"this",
"->",
"$",
"deprecatedmethod",
"(",
"$",
"widget",
")",
";",
"}",
"// pass to core renderer if method not found here",
"return",
"$",
"this",
"->",
"output",
"->",
"render",
"(",
"$",
"widget",
")",
";",
"}"
] | Renders the provided widget and returns the HTML to display it.
@param renderable $widget instance with renderable interface
@return string | [
"Renders",
"the",
"provided",
"widget",
"and",
"returns",
"the",
"HTML",
"to",
"display",
"it",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L447-L479 |
212,840 | moodle/moodle | lib/outputrenderers.php | core_renderer.doctype | public function doctype() {
if ($this->page->theme->doctype === 'html5') {
$this->contenttype = 'text/html; charset=utf-8';
return "<!DOCTYPE html>\n";
} else if ($this->page->theme->doctype === 'xhtml5') {
$this->contenttype = 'application/xhtml+xml; charset=utf-8';
return "<!DOCTYPE html>\n";
} else {
// legacy xhtml 1.0
$this->contenttype = 'text/html; charset=utf-8';
return ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n");
}
} | php | public function doctype() {
if ($this->page->theme->doctype === 'html5') {
$this->contenttype = 'text/html; charset=utf-8';
return "<!DOCTYPE html>\n";
} else if ($this->page->theme->doctype === 'xhtml5') {
$this->contenttype = 'application/xhtml+xml; charset=utf-8';
return "<!DOCTYPE html>\n";
} else {
// legacy xhtml 1.0
$this->contenttype = 'text/html; charset=utf-8';
return ('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">' . "\n");
}
} | [
"public",
"function",
"doctype",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"theme",
"->",
"doctype",
"===",
"'html5'",
")",
"{",
"$",
"this",
"->",
"contenttype",
"=",
"'text/html; charset=utf-8'",
";",
"return",
"\"<!DOCTYPE html>\\n\"",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"theme",
"->",
"doctype",
"===",
"'xhtml5'",
")",
"{",
"$",
"this",
"->",
"contenttype",
"=",
"'application/xhtml+xml; charset=utf-8'",
";",
"return",
"\"<!DOCTYPE html>\\n\"",
";",
"}",
"else",
"{",
"// legacy xhtml 1.0",
"$",
"this",
"->",
"contenttype",
"=",
"'text/html; charset=utf-8'",
";",
"return",
"(",
"'<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">'",
".",
"\"\\n\"",
")",
";",
"}",
"}"
] | Get the DOCTYPE declaration that should be used with this page. Designed to
be called in theme layout.php files.
@return string the DOCTYPE declaration that should be used. | [
"Get",
"the",
"DOCTYPE",
"declaration",
"that",
"should",
"be",
"used",
"with",
"this",
"page",
".",
"Designed",
"to",
"be",
"called",
"in",
"theme",
"layout",
".",
"php",
"files",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L572-L586 |
212,841 | moodle/moodle | lib/outputrenderers.php | core_renderer.maintenance_warning | public function maintenance_warning() {
global $CFG;
$output = '';
if (isset($CFG->maintenance_later) and $CFG->maintenance_later > time()) {
$timeleft = $CFG->maintenance_later - time();
// If timeleft less than 30 sec, set the class on block to error to highlight.
$errorclass = ($timeleft < 30) ? 'alert-error alert-danger' : 'alert-warning';
$output .= $this->box_start($errorclass . ' moodle-has-zindex maintenancewarning m-a-1 alert');
$a = new stdClass();
$a->hour = (int)($timeleft / 3600);
$a->min = (int)(($timeleft / 60) % 60);
$a->sec = (int)($timeleft % 60);
if ($a->hour > 0) {
$output .= get_string('maintenancemodeisscheduledlong', 'admin', $a);
} else {
$output .= get_string('maintenancemodeisscheduled', 'admin', $a);
}
$output .= $this->box_end();
$this->page->requires->yui_module('moodle-core-maintenancemodetimer', 'M.core.maintenancemodetimer',
array(array('timeleftinsec' => $timeleft)));
$this->page->requires->strings_for_js(
array('maintenancemodeisscheduled', 'maintenancemodeisscheduledlong', 'sitemaintenance'),
'admin');
}
return $output;
} | php | public function maintenance_warning() {
global $CFG;
$output = '';
if (isset($CFG->maintenance_later) and $CFG->maintenance_later > time()) {
$timeleft = $CFG->maintenance_later - time();
// If timeleft less than 30 sec, set the class on block to error to highlight.
$errorclass = ($timeleft < 30) ? 'alert-error alert-danger' : 'alert-warning';
$output .= $this->box_start($errorclass . ' moodle-has-zindex maintenancewarning m-a-1 alert');
$a = new stdClass();
$a->hour = (int)($timeleft / 3600);
$a->min = (int)(($timeleft / 60) % 60);
$a->sec = (int)($timeleft % 60);
if ($a->hour > 0) {
$output .= get_string('maintenancemodeisscheduledlong', 'admin', $a);
} else {
$output .= get_string('maintenancemodeisscheduled', 'admin', $a);
}
$output .= $this->box_end();
$this->page->requires->yui_module('moodle-core-maintenancemodetimer', 'M.core.maintenancemodetimer',
array(array('timeleftinsec' => $timeleft)));
$this->page->requires->strings_for_js(
array('maintenancemodeisscheduled', 'maintenancemodeisscheduledlong', 'sitemaintenance'),
'admin');
}
return $output;
} | [
"public",
"function",
"maintenance_warning",
"(",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"isset",
"(",
"$",
"CFG",
"->",
"maintenance_later",
")",
"and",
"$",
"CFG",
"->",
"maintenance_later",
">",
"time",
"(",
")",
")",
"{",
"$",
"timeleft",
"=",
"$",
"CFG",
"->",
"maintenance_later",
"-",
"time",
"(",
")",
";",
"// If timeleft less than 30 sec, set the class on block to error to highlight.",
"$",
"errorclass",
"=",
"(",
"$",
"timeleft",
"<",
"30",
")",
"?",
"'alert-error alert-danger'",
":",
"'alert-warning'",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"box_start",
"(",
"$",
"errorclass",
".",
"' moodle-has-zindex maintenancewarning m-a-1 alert'",
")",
";",
"$",
"a",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"a",
"->",
"hour",
"=",
"(",
"int",
")",
"(",
"$",
"timeleft",
"/",
"3600",
")",
";",
"$",
"a",
"->",
"min",
"=",
"(",
"int",
")",
"(",
"(",
"$",
"timeleft",
"/",
"60",
")",
"%",
"60",
")",
";",
"$",
"a",
"->",
"sec",
"=",
"(",
"int",
")",
"(",
"$",
"timeleft",
"%",
"60",
")",
";",
"if",
"(",
"$",
"a",
"->",
"hour",
">",
"0",
")",
"{",
"$",
"output",
".=",
"get_string",
"(",
"'maintenancemodeisscheduledlong'",
",",
"'admin'",
",",
"$",
"a",
")",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"get_string",
"(",
"'maintenancemodeisscheduled'",
",",
"'admin'",
",",
"$",
"a",
")",
";",
"}",
"$",
"output",
".=",
"$",
"this",
"->",
"box_end",
"(",
")",
";",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"yui_module",
"(",
"'moodle-core-maintenancemodetimer'",
",",
"'M.core.maintenancemodetimer'",
",",
"array",
"(",
"array",
"(",
"'timeleftinsec'",
"=>",
"$",
"timeleft",
")",
")",
")",
";",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"strings_for_js",
"(",
"array",
"(",
"'maintenancemodeisscheduled'",
",",
"'maintenancemodeisscheduledlong'",
",",
"'sitemaintenance'",
")",
",",
"'admin'",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Scheduled maintenance warning message.
Note: This is a nasty hack to display maintenance notice, this should be moved
to some general notification area once we have it.
@return string | [
"Scheduled",
"maintenance",
"warning",
"message",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L780-L807 |
212,842 | moodle/moodle | lib/outputrenderers.php | core_renderer.activity_navigation | public function activity_navigation() {
// First we should check if we want to add navigation.
$context = $this->page->context;
if (($this->page->pagelayout !== 'incourse' && $this->page->pagelayout !== 'frametop')
|| $context->contextlevel != CONTEXT_MODULE) {
return '';
}
// If the activity is in stealth mode, show no links.
if ($this->page->cm->is_stealth()) {
return '';
}
// Get a list of all the activities in the course.
$course = $this->page->cm->get_course();
$modules = get_fast_modinfo($course->id)->get_cms();
// Put the modules into an array in order by the position they are shown in the course.
$mods = [];
$activitylist = [];
foreach ($modules as $module) {
// Only add activities the user can access, aren't in stealth mode and have a url (eg. mod_label does not).
if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
continue;
}
$mods[$module->id] = $module;
// No need to add the current module to the list for the activity dropdown menu.
if ($module->id == $this->page->cm->id) {
continue;
}
// Module name.
$modname = $module->get_formatted_name();
// Display the hidden text if necessary.
if (!$module->visible) {
$modname .= ' ' . get_string('hiddenwithbrackets');
}
// Module URL.
$linkurl = new moodle_url($module->url, array('forceview' => 1));
// Add module URL (as key) and name (as value) to the activity list array.
$activitylist[$linkurl->out(false)] = $modname;
}
$nummods = count($mods);
// If there is only one mod then do nothing.
if ($nummods == 1) {
return '';
}
// Get an array of just the course module ids used to get the cmid value based on their position in the course.
$modids = array_keys($mods);
// Get the position in the array of the course module we are viewing.
$position = array_search($this->page->cm->id, $modids);
$prevmod = null;
$nextmod = null;
// Check if we have a previous mod to show.
if ($position > 0) {
$prevmod = $mods[$modids[$position - 1]];
}
// Check if we have a next mod to show.
if ($position < ($nummods - 1)) {
$nextmod = $mods[$modids[$position + 1]];
}
$activitynav = new \core_course\output\activity_navigation($prevmod, $nextmod, $activitylist);
$renderer = $this->page->get_renderer('core', 'course');
return $renderer->render($activitynav);
} | php | public function activity_navigation() {
// First we should check if we want to add navigation.
$context = $this->page->context;
if (($this->page->pagelayout !== 'incourse' && $this->page->pagelayout !== 'frametop')
|| $context->contextlevel != CONTEXT_MODULE) {
return '';
}
// If the activity is in stealth mode, show no links.
if ($this->page->cm->is_stealth()) {
return '';
}
// Get a list of all the activities in the course.
$course = $this->page->cm->get_course();
$modules = get_fast_modinfo($course->id)->get_cms();
// Put the modules into an array in order by the position they are shown in the course.
$mods = [];
$activitylist = [];
foreach ($modules as $module) {
// Only add activities the user can access, aren't in stealth mode and have a url (eg. mod_label does not).
if (!$module->uservisible || $module->is_stealth() || empty($module->url)) {
continue;
}
$mods[$module->id] = $module;
// No need to add the current module to the list for the activity dropdown menu.
if ($module->id == $this->page->cm->id) {
continue;
}
// Module name.
$modname = $module->get_formatted_name();
// Display the hidden text if necessary.
if (!$module->visible) {
$modname .= ' ' . get_string('hiddenwithbrackets');
}
// Module URL.
$linkurl = new moodle_url($module->url, array('forceview' => 1));
// Add module URL (as key) and name (as value) to the activity list array.
$activitylist[$linkurl->out(false)] = $modname;
}
$nummods = count($mods);
// If there is only one mod then do nothing.
if ($nummods == 1) {
return '';
}
// Get an array of just the course module ids used to get the cmid value based on their position in the course.
$modids = array_keys($mods);
// Get the position in the array of the course module we are viewing.
$position = array_search($this->page->cm->id, $modids);
$prevmod = null;
$nextmod = null;
// Check if we have a previous mod to show.
if ($position > 0) {
$prevmod = $mods[$modids[$position - 1]];
}
// Check if we have a next mod to show.
if ($position < ($nummods - 1)) {
$nextmod = $mods[$modids[$position + 1]];
}
$activitynav = new \core_course\output\activity_navigation($prevmod, $nextmod, $activitylist);
$renderer = $this->page->get_renderer('core', 'course');
return $renderer->render($activitynav);
} | [
"public",
"function",
"activity_navigation",
"(",
")",
"{",
"// First we should check if we want to add navigation.",
"$",
"context",
"=",
"$",
"this",
"->",
"page",
"->",
"context",
";",
"if",
"(",
"(",
"$",
"this",
"->",
"page",
"->",
"pagelayout",
"!==",
"'incourse'",
"&&",
"$",
"this",
"->",
"page",
"->",
"pagelayout",
"!==",
"'frametop'",
")",
"||",
"$",
"context",
"->",
"contextlevel",
"!=",
"CONTEXT_MODULE",
")",
"{",
"return",
"''",
";",
"}",
"// If the activity is in stealth mode, show no links.",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"cm",
"->",
"is_stealth",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"// Get a list of all the activities in the course.",
"$",
"course",
"=",
"$",
"this",
"->",
"page",
"->",
"cm",
"->",
"get_course",
"(",
")",
";",
"$",
"modules",
"=",
"get_fast_modinfo",
"(",
"$",
"course",
"->",
"id",
")",
"->",
"get_cms",
"(",
")",
";",
"// Put the modules into an array in order by the position they are shown in the course.",
"$",
"mods",
"=",
"[",
"]",
";",
"$",
"activitylist",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"modules",
"as",
"$",
"module",
")",
"{",
"// Only add activities the user can access, aren't in stealth mode and have a url (eg. mod_label does not).",
"if",
"(",
"!",
"$",
"module",
"->",
"uservisible",
"||",
"$",
"module",
"->",
"is_stealth",
"(",
")",
"||",
"empty",
"(",
"$",
"module",
"->",
"url",
")",
")",
"{",
"continue",
";",
"}",
"$",
"mods",
"[",
"$",
"module",
"->",
"id",
"]",
"=",
"$",
"module",
";",
"// No need to add the current module to the list for the activity dropdown menu.",
"if",
"(",
"$",
"module",
"->",
"id",
"==",
"$",
"this",
"->",
"page",
"->",
"cm",
"->",
"id",
")",
"{",
"continue",
";",
"}",
"// Module name.",
"$",
"modname",
"=",
"$",
"module",
"->",
"get_formatted_name",
"(",
")",
";",
"// Display the hidden text if necessary.",
"if",
"(",
"!",
"$",
"module",
"->",
"visible",
")",
"{",
"$",
"modname",
".=",
"' '",
".",
"get_string",
"(",
"'hiddenwithbrackets'",
")",
";",
"}",
"// Module URL.",
"$",
"linkurl",
"=",
"new",
"moodle_url",
"(",
"$",
"module",
"->",
"url",
",",
"array",
"(",
"'forceview'",
"=>",
"1",
")",
")",
";",
"// Add module URL (as key) and name (as value) to the activity list array.",
"$",
"activitylist",
"[",
"$",
"linkurl",
"->",
"out",
"(",
"false",
")",
"]",
"=",
"$",
"modname",
";",
"}",
"$",
"nummods",
"=",
"count",
"(",
"$",
"mods",
")",
";",
"// If there is only one mod then do nothing.",
"if",
"(",
"$",
"nummods",
"==",
"1",
")",
"{",
"return",
"''",
";",
"}",
"// Get an array of just the course module ids used to get the cmid value based on their position in the course.",
"$",
"modids",
"=",
"array_keys",
"(",
"$",
"mods",
")",
";",
"// Get the position in the array of the course module we are viewing.",
"$",
"position",
"=",
"array_search",
"(",
"$",
"this",
"->",
"page",
"->",
"cm",
"->",
"id",
",",
"$",
"modids",
")",
";",
"$",
"prevmod",
"=",
"null",
";",
"$",
"nextmod",
"=",
"null",
";",
"// Check if we have a previous mod to show.",
"if",
"(",
"$",
"position",
">",
"0",
")",
"{",
"$",
"prevmod",
"=",
"$",
"mods",
"[",
"$",
"modids",
"[",
"$",
"position",
"-",
"1",
"]",
"]",
";",
"}",
"// Check if we have a next mod to show.",
"if",
"(",
"$",
"position",
"<",
"(",
"$",
"nummods",
"-",
"1",
")",
")",
"{",
"$",
"nextmod",
"=",
"$",
"mods",
"[",
"$",
"modids",
"[",
"$",
"position",
"+",
"1",
"]",
"]",
";",
"}",
"$",
"activitynav",
"=",
"new",
"\\",
"core_course",
"\\",
"output",
"\\",
"activity_navigation",
"(",
"$",
"prevmod",
",",
"$",
"nextmod",
",",
"$",
"activitylist",
")",
";",
"$",
"renderer",
"=",
"$",
"this",
"->",
"page",
"->",
"get_renderer",
"(",
"'core'",
",",
"'course'",
")",
";",
"return",
"$",
"renderer",
"->",
"render",
"(",
"$",
"activitynav",
")",
";",
"}"
] | Returns standard navigation between activities in a course.
@return string the navigation HTML. | [
"Returns",
"standard",
"navigation",
"between",
"activities",
"in",
"a",
"course",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L897-L969 |
212,843 | moodle/moodle | lib/outputrenderers.php | core_renderer.home_link | public function home_link() {
global $CFG, $SITE;
if ($this->page->pagetype == 'site-index') {
// Special case for site home page - please do not remove
return '<div class="sitelink">' .
'<a title="Moodle" href="http://moodle.org/">' .
'<img src="' . $this->image_url('moodlelogo') . '" alt="'.get_string('moodlelogo').'" /></a></div>';
} else if (!empty($CFG->target_release) && $CFG->target_release != $CFG->release) {
// Special case for during install/upgrade.
return '<div class="sitelink">'.
'<a title="Moodle" href="http://docs.moodle.org/en/Administrator_documentation" onclick="this.target=\'_blank\'">' .
'<img src="' . $this->image_url('moodlelogo') . '" alt="'.get_string('moodlelogo').'" /></a></div>';
} else if ($this->page->course->id == $SITE->id || strpos($this->page->pagetype, 'course-view') === 0) {
return '<div class="homelink"><a href="' . $CFG->wwwroot . '/">' .
get_string('home') . '</a></div>';
} else {
return '<div class="homelink"><a href="' . $CFG->wwwroot . '/course/view.php?id=' . $this->page->course->id . '">' .
format_string($this->page->course->shortname, true, array('context' => $this->page->context)) . '</a></div>';
}
} | php | public function home_link() {
global $CFG, $SITE;
if ($this->page->pagetype == 'site-index') {
// Special case for site home page - please do not remove
return '<div class="sitelink">' .
'<a title="Moodle" href="http://moodle.org/">' .
'<img src="' . $this->image_url('moodlelogo') . '" alt="'.get_string('moodlelogo').'" /></a></div>';
} else if (!empty($CFG->target_release) && $CFG->target_release != $CFG->release) {
// Special case for during install/upgrade.
return '<div class="sitelink">'.
'<a title="Moodle" href="http://docs.moodle.org/en/Administrator_documentation" onclick="this.target=\'_blank\'">' .
'<img src="' . $this->image_url('moodlelogo') . '" alt="'.get_string('moodlelogo').'" /></a></div>';
} else if ($this->page->course->id == $SITE->id || strpos($this->page->pagetype, 'course-view') === 0) {
return '<div class="homelink"><a href="' . $CFG->wwwroot . '/">' .
get_string('home') . '</a></div>';
} else {
return '<div class="homelink"><a href="' . $CFG->wwwroot . '/course/view.php?id=' . $this->page->course->id . '">' .
format_string($this->page->course->shortname, true, array('context' => $this->page->context)) . '</a></div>';
}
} | [
"public",
"function",
"home_link",
"(",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"SITE",
";",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"pagetype",
"==",
"'site-index'",
")",
"{",
"// Special case for site home page - please do not remove",
"return",
"'<div class=\"sitelink\">'",
".",
"'<a title=\"Moodle\" href=\"http://moodle.org/\">'",
".",
"'<img src=\"'",
".",
"$",
"this",
"->",
"image_url",
"(",
"'moodlelogo'",
")",
".",
"'\" alt=\"'",
".",
"get_string",
"(",
"'moodlelogo'",
")",
".",
"'\" /></a></div>'",
";",
"}",
"else",
"if",
"(",
"!",
"empty",
"(",
"$",
"CFG",
"->",
"target_release",
")",
"&&",
"$",
"CFG",
"->",
"target_release",
"!=",
"$",
"CFG",
"->",
"release",
")",
"{",
"// Special case for during install/upgrade.",
"return",
"'<div class=\"sitelink\">'",
".",
"'<a title=\"Moodle\" href=\"http://docs.moodle.org/en/Administrator_documentation\" onclick=\"this.target=\\'_blank\\'\">'",
".",
"'<img src=\"'",
".",
"$",
"this",
"->",
"image_url",
"(",
"'moodlelogo'",
")",
".",
"'\" alt=\"'",
".",
"get_string",
"(",
"'moodlelogo'",
")",
".",
"'\" /></a></div>'",
";",
"}",
"else",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"course",
"->",
"id",
"==",
"$",
"SITE",
"->",
"id",
"||",
"strpos",
"(",
"$",
"this",
"->",
"page",
"->",
"pagetype",
",",
"'course-view'",
")",
"===",
"0",
")",
"{",
"return",
"'<div class=\"homelink\"><a href=\"'",
".",
"$",
"CFG",
"->",
"wwwroot",
".",
"'/\">'",
".",
"get_string",
"(",
"'home'",
")",
".",
"'</a></div>'",
";",
"}",
"else",
"{",
"return",
"'<div class=\"homelink\"><a href=\"'",
".",
"$",
"CFG",
"->",
"wwwroot",
".",
"'/course/view.php?id='",
".",
"$",
"this",
"->",
"page",
"->",
"course",
"->",
"id",
".",
"'\">'",
".",
"format_string",
"(",
"$",
"this",
"->",
"page",
"->",
"course",
"->",
"shortname",
",",
"true",
",",
"array",
"(",
"'context'",
"=>",
"$",
"this",
"->",
"page",
"->",
"context",
")",
")",
".",
"'</a></div>'",
";",
"}",
"}"
] | Return the 'back' link that normally appears in the footer.
@return string HTML fragment. | [
"Return",
"the",
"back",
"link",
"that",
"normally",
"appears",
"in",
"the",
"footer",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1160-L1183 |
212,844 | moodle/moodle | lib/outputrenderers.php | core_renderer.redirect_message | public function redirect_message($encodedurl, $message, $delay, $debugdisableredirect,
$messagetype = \core\output\notification::NOTIFY_INFO) {
global $CFG;
$url = str_replace('&', '&', $encodedurl);
switch ($this->page->state) {
case moodle_page::STATE_BEFORE_HEADER :
// No output yet it is safe to delivery the full arsenal of redirect methods
if (!$debugdisableredirect) {
// Don't use exactly the same time here, it can cause problems when both redirects fire at the same time.
$this->metarefreshtag = '<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />'."\n";
$this->page->requires->js_function_call('document.location.replace', array($url), false, ($delay + 3));
}
$output = $this->header();
break;
case moodle_page::STATE_PRINTING_HEADER :
// We should hopefully never get here
throw new coding_exception('You cannot redirect while printing the page header');
break;
case moodle_page::STATE_IN_BODY :
// We really shouldn't be here but we can deal with this
debugging("You should really redirect before you start page output");
if (!$debugdisableredirect) {
$this->page->requires->js_function_call('document.location.replace', array($url), false, $delay);
}
$output = $this->opencontainers->pop_all_but_last();
break;
case moodle_page::STATE_DONE :
// Too late to be calling redirect now
throw new coding_exception('You cannot redirect after the entire page has been generated');
break;
}
$output .= $this->notification($message, $messagetype);
$output .= '<div class="continuebutton">(<a href="'. $encodedurl .'">'. get_string('continue') .'</a>)</div>';
if ($debugdisableredirect) {
$output .= '<p><strong>'.get_string('erroroutput', 'error').'</strong></p>';
}
$output .= $this->footer();
return $output;
} | php | public function redirect_message($encodedurl, $message, $delay, $debugdisableredirect,
$messagetype = \core\output\notification::NOTIFY_INFO) {
global $CFG;
$url = str_replace('&', '&', $encodedurl);
switch ($this->page->state) {
case moodle_page::STATE_BEFORE_HEADER :
// No output yet it is safe to delivery the full arsenal of redirect methods
if (!$debugdisableredirect) {
// Don't use exactly the same time here, it can cause problems when both redirects fire at the same time.
$this->metarefreshtag = '<meta http-equiv="refresh" content="'. $delay .'; url='. $encodedurl .'" />'."\n";
$this->page->requires->js_function_call('document.location.replace', array($url), false, ($delay + 3));
}
$output = $this->header();
break;
case moodle_page::STATE_PRINTING_HEADER :
// We should hopefully never get here
throw new coding_exception('You cannot redirect while printing the page header');
break;
case moodle_page::STATE_IN_BODY :
// We really shouldn't be here but we can deal with this
debugging("You should really redirect before you start page output");
if (!$debugdisableredirect) {
$this->page->requires->js_function_call('document.location.replace', array($url), false, $delay);
}
$output = $this->opencontainers->pop_all_but_last();
break;
case moodle_page::STATE_DONE :
// Too late to be calling redirect now
throw new coding_exception('You cannot redirect after the entire page has been generated');
break;
}
$output .= $this->notification($message, $messagetype);
$output .= '<div class="continuebutton">(<a href="'. $encodedurl .'">'. get_string('continue') .'</a>)</div>';
if ($debugdisableredirect) {
$output .= '<p><strong>'.get_string('erroroutput', 'error').'</strong></p>';
}
$output .= $this->footer();
return $output;
} | [
"public",
"function",
"redirect_message",
"(",
"$",
"encodedurl",
",",
"$",
"message",
",",
"$",
"delay",
",",
"$",
"debugdisableredirect",
",",
"$",
"messagetype",
"=",
"\\",
"core",
"\\",
"output",
"\\",
"notification",
"::",
"NOTIFY_INFO",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"url",
"=",
"str_replace",
"(",
"'&'",
",",
"'&'",
",",
"$",
"encodedurl",
")",
";",
"switch",
"(",
"$",
"this",
"->",
"page",
"->",
"state",
")",
"{",
"case",
"moodle_page",
"::",
"STATE_BEFORE_HEADER",
":",
"// No output yet it is safe to delivery the full arsenal of redirect methods",
"if",
"(",
"!",
"$",
"debugdisableredirect",
")",
"{",
"// Don't use exactly the same time here, it can cause problems when both redirects fire at the same time.",
"$",
"this",
"->",
"metarefreshtag",
"=",
"'<meta http-equiv=\"refresh\" content=\"'",
".",
"$",
"delay",
".",
"'; url='",
".",
"$",
"encodedurl",
".",
"'\" />'",
".",
"\"\\n\"",
";",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"js_function_call",
"(",
"'document.location.replace'",
",",
"array",
"(",
"$",
"url",
")",
",",
"false",
",",
"(",
"$",
"delay",
"+",
"3",
")",
")",
";",
"}",
"$",
"output",
"=",
"$",
"this",
"->",
"header",
"(",
")",
";",
"break",
";",
"case",
"moodle_page",
"::",
"STATE_PRINTING_HEADER",
":",
"// We should hopefully never get here",
"throw",
"new",
"coding_exception",
"(",
"'You cannot redirect while printing the page header'",
")",
";",
"break",
";",
"case",
"moodle_page",
"::",
"STATE_IN_BODY",
":",
"// We really shouldn't be here but we can deal with this",
"debugging",
"(",
"\"You should really redirect before you start page output\"",
")",
";",
"if",
"(",
"!",
"$",
"debugdisableredirect",
")",
"{",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"js_function_call",
"(",
"'document.location.replace'",
",",
"array",
"(",
"$",
"url",
")",
",",
"false",
",",
"$",
"delay",
")",
";",
"}",
"$",
"output",
"=",
"$",
"this",
"->",
"opencontainers",
"->",
"pop_all_but_last",
"(",
")",
";",
"break",
";",
"case",
"moodle_page",
"::",
"STATE_DONE",
":",
"// Too late to be calling redirect now",
"throw",
"new",
"coding_exception",
"(",
"'You cannot redirect after the entire page has been generated'",
")",
";",
"break",
";",
"}",
"$",
"output",
".=",
"$",
"this",
"->",
"notification",
"(",
"$",
"message",
",",
"$",
"messagetype",
")",
";",
"$",
"output",
".=",
"'<div class=\"continuebutton\">(<a href=\"'",
".",
"$",
"encodedurl",
".",
"'\">'",
".",
"get_string",
"(",
"'continue'",
")",
".",
"'</a>)</div>'",
";",
"if",
"(",
"$",
"debugdisableredirect",
")",
"{",
"$",
"output",
".=",
"'<p><strong>'",
".",
"get_string",
"(",
"'erroroutput'",
",",
"'error'",
")",
".",
"'</strong></p>'",
";",
"}",
"$",
"output",
".=",
"$",
"this",
"->",
"footer",
"(",
")",
";",
"return",
"$",
"output",
";",
"}"
] | Redirects the user by any means possible given the current state
This function should not be called directly, it should always be called using
the redirect function in lib/weblib.php
The redirect function should really only be called before page output has started
however it will allow itself to be called during the state STATE_IN_BODY
@param string $encodedurl The URL to send to encoded if required
@param string $message The message to display to the user if any
@param int $delay The delay before redirecting a user, if $message has been
set this is a requirement and defaults to 3, set to 0 no delay
@param boolean $debugdisableredirect this redirect has been disabled for
debugging purposes. Display a message that explains, and don't
trigger the redirect.
@param string $messagetype The type of notification to show the message in.
See constants on \core\output\notification.
@return string The HTML to display to the user before dying, may contain
meta refresh, javascript refresh, and may have set header redirects | [
"Redirects",
"the",
"user",
"by",
"any",
"means",
"possible",
"given",
"the",
"current",
"state"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1206-L1245 |
212,845 | moodle/moodle | lib/outputrenderers.php | core_renderer.render_page_layout | protected function render_page_layout($layoutfile) {
global $CFG, $SITE, $USER;
// The next lines are a bit tricky. The point is, here we are in a method
// of a renderer class, and this object may, or may not, be the same as
// the global $OUTPUT object. When rendering the page layout file, we want to use
// this object. However, people writing Moodle code expect the current
// renderer to be called $OUTPUT, not $this, so define a variable called
// $OUTPUT pointing at $this. The same comment applies to $PAGE and $COURSE.
$OUTPUT = $this;
$PAGE = $this->page;
$COURSE = $this->page->course;
ob_start();
include($layoutfile);
$rendered = ob_get_contents();
ob_end_clean();
return $rendered;
} | php | protected function render_page_layout($layoutfile) {
global $CFG, $SITE, $USER;
// The next lines are a bit tricky. The point is, here we are in a method
// of a renderer class, and this object may, or may not, be the same as
// the global $OUTPUT object. When rendering the page layout file, we want to use
// this object. However, people writing Moodle code expect the current
// renderer to be called $OUTPUT, not $this, so define a variable called
// $OUTPUT pointing at $this. The same comment applies to $PAGE and $COURSE.
$OUTPUT = $this;
$PAGE = $this->page;
$COURSE = $this->page->course;
ob_start();
include($layoutfile);
$rendered = ob_get_contents();
ob_end_clean();
return $rendered;
} | [
"protected",
"function",
"render_page_layout",
"(",
"$",
"layoutfile",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"SITE",
",",
"$",
"USER",
";",
"// The next lines are a bit tricky. The point is, here we are in a method",
"// of a renderer class, and this object may, or may not, be the same as",
"// the global $OUTPUT object. When rendering the page layout file, we want to use",
"// this object. However, people writing Moodle code expect the current",
"// renderer to be called $OUTPUT, not $this, so define a variable called",
"// $OUTPUT pointing at $this. The same comment applies to $PAGE and $COURSE.",
"$",
"OUTPUT",
"=",
"$",
"this",
";",
"$",
"PAGE",
"=",
"$",
"this",
"->",
"page",
";",
"$",
"COURSE",
"=",
"$",
"this",
"->",
"page",
"->",
"course",
";",
"ob_start",
"(",
")",
";",
"include",
"(",
"$",
"layoutfile",
")",
";",
"$",
"rendered",
"=",
"ob_get_contents",
"(",
")",
";",
"ob_end_clean",
"(",
")",
";",
"return",
"$",
"rendered",
";",
"}"
] | Renders and outputs the page layout file.
This is done by preparing the normal globals available to a script, and
then including the layout file provided by the current theme for the
requested layout.
@param string $layoutfile The name of the layout file
@return string HTML code | [
"Renders",
"and",
"outputs",
"the",
"page",
"layout",
"file",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1357-L1374 |
212,846 | moodle/moodle | lib/outputrenderers.php | core_renderer.footer | public function footer() {
global $CFG, $DB, $PAGE;
// Give plugins an opportunity to touch the page before JS is finalized.
$pluginswithfunction = get_plugins_with_function('before_footer', 'lib.php');
foreach ($pluginswithfunction as $plugins) {
foreach ($plugins as $function) {
$function();
}
}
$output = $this->container_end_all(true);
$footer = $this->opencontainers->pop('header/footer');
if (debugging() and $DB and $DB->is_transaction_started()) {
// TODO: MDL-20625 print warning - transaction will be rolled back
}
// Provide some performance info if required
$performanceinfo = '';
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
$perf = get_performance_info();
if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) {
$performanceinfo = $perf['html'];
}
}
// We always want performance data when running a performance test, even if the user is redirected to another page.
if (MDL_PERF_TEST && strpos($footer, $this->unique_performance_info_token) === false) {
$footer = $this->unique_performance_info_token . $footer;
}
$footer = str_replace($this->unique_performance_info_token, $performanceinfo, $footer);
// Only show notifications when we have a $PAGE context id.
if (!empty($PAGE->context->id)) {
$this->page->requires->js_call_amd('core/notification', 'init', array(
$PAGE->context->id,
\core\notification::fetch_as_array($this)
));
}
$footer = str_replace($this->unique_end_html_token, $this->page->requires->get_end_code(), $footer);
$this->page->set_state(moodle_page::STATE_DONE);
return $output . $footer;
} | php | public function footer() {
global $CFG, $DB, $PAGE;
// Give plugins an opportunity to touch the page before JS is finalized.
$pluginswithfunction = get_plugins_with_function('before_footer', 'lib.php');
foreach ($pluginswithfunction as $plugins) {
foreach ($plugins as $function) {
$function();
}
}
$output = $this->container_end_all(true);
$footer = $this->opencontainers->pop('header/footer');
if (debugging() and $DB and $DB->is_transaction_started()) {
// TODO: MDL-20625 print warning - transaction will be rolled back
}
// Provide some performance info if required
$performanceinfo = '';
if (defined('MDL_PERF') || (!empty($CFG->perfdebug) and $CFG->perfdebug > 7)) {
$perf = get_performance_info();
if (defined('MDL_PERFTOFOOT') || debugging() || $CFG->perfdebug > 7) {
$performanceinfo = $perf['html'];
}
}
// We always want performance data when running a performance test, even if the user is redirected to another page.
if (MDL_PERF_TEST && strpos($footer, $this->unique_performance_info_token) === false) {
$footer = $this->unique_performance_info_token . $footer;
}
$footer = str_replace($this->unique_performance_info_token, $performanceinfo, $footer);
// Only show notifications when we have a $PAGE context id.
if (!empty($PAGE->context->id)) {
$this->page->requires->js_call_amd('core/notification', 'init', array(
$PAGE->context->id,
\core\notification::fetch_as_array($this)
));
}
$footer = str_replace($this->unique_end_html_token, $this->page->requires->get_end_code(), $footer);
$this->page->set_state(moodle_page::STATE_DONE);
return $output . $footer;
} | [
"public",
"function",
"footer",
"(",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"DB",
",",
"$",
"PAGE",
";",
"// Give plugins an opportunity to touch the page before JS is finalized.",
"$",
"pluginswithfunction",
"=",
"get_plugins_with_function",
"(",
"'before_footer'",
",",
"'lib.php'",
")",
";",
"foreach",
"(",
"$",
"pluginswithfunction",
"as",
"$",
"plugins",
")",
"{",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"function",
")",
"{",
"$",
"function",
"(",
")",
";",
"}",
"}",
"$",
"output",
"=",
"$",
"this",
"->",
"container_end_all",
"(",
"true",
")",
";",
"$",
"footer",
"=",
"$",
"this",
"->",
"opencontainers",
"->",
"pop",
"(",
"'header/footer'",
")",
";",
"if",
"(",
"debugging",
"(",
")",
"and",
"$",
"DB",
"and",
"$",
"DB",
"->",
"is_transaction_started",
"(",
")",
")",
"{",
"// TODO: MDL-20625 print warning - transaction will be rolled back",
"}",
"// Provide some performance info if required",
"$",
"performanceinfo",
"=",
"''",
";",
"if",
"(",
"defined",
"(",
"'MDL_PERF'",
")",
"||",
"(",
"!",
"empty",
"(",
"$",
"CFG",
"->",
"perfdebug",
")",
"and",
"$",
"CFG",
"->",
"perfdebug",
">",
"7",
")",
")",
"{",
"$",
"perf",
"=",
"get_performance_info",
"(",
")",
";",
"if",
"(",
"defined",
"(",
"'MDL_PERFTOFOOT'",
")",
"||",
"debugging",
"(",
")",
"||",
"$",
"CFG",
"->",
"perfdebug",
">",
"7",
")",
"{",
"$",
"performanceinfo",
"=",
"$",
"perf",
"[",
"'html'",
"]",
";",
"}",
"}",
"// We always want performance data when running a performance test, even if the user is redirected to another page.",
"if",
"(",
"MDL_PERF_TEST",
"&&",
"strpos",
"(",
"$",
"footer",
",",
"$",
"this",
"->",
"unique_performance_info_token",
")",
"===",
"false",
")",
"{",
"$",
"footer",
"=",
"$",
"this",
"->",
"unique_performance_info_token",
".",
"$",
"footer",
";",
"}",
"$",
"footer",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"unique_performance_info_token",
",",
"$",
"performanceinfo",
",",
"$",
"footer",
")",
";",
"// Only show notifications when we have a $PAGE context id.",
"if",
"(",
"!",
"empty",
"(",
"$",
"PAGE",
"->",
"context",
"->",
"id",
")",
")",
"{",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"js_call_amd",
"(",
"'core/notification'",
",",
"'init'",
",",
"array",
"(",
"$",
"PAGE",
"->",
"context",
"->",
"id",
",",
"\\",
"core",
"\\",
"notification",
"::",
"fetch_as_array",
"(",
"$",
"this",
")",
")",
")",
";",
"}",
"$",
"footer",
"=",
"str_replace",
"(",
"$",
"this",
"->",
"unique_end_html_token",
",",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"get_end_code",
"(",
")",
",",
"$",
"footer",
")",
";",
"$",
"this",
"->",
"page",
"->",
"set_state",
"(",
"moodle_page",
"::",
"STATE_DONE",
")",
";",
"return",
"$",
"output",
".",
"$",
"footer",
";",
"}"
] | Outputs the page's footer
@return string HTML fragment | [
"Outputs",
"the",
"page",
"s",
"footer"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1381-L1427 |
212,847 | moodle/moodle | lib/outputrenderers.php | core_renderer.lang_menu | public function lang_menu() {
global $CFG;
if (empty($CFG->langmenu)) {
return '';
}
if ($this->page->course != SITEID and !empty($this->page->course->lang)) {
// do not show lang menu if language forced
return '';
}
$currlang = current_language();
$langs = get_string_manager()->get_list_of_translations();
if (count($langs) < 2) {
return '';
}
$s = new single_select($this->page->url, 'lang', $langs, $currlang, null);
$s->label = get_accesshide(get_string('language'));
$s->class = 'langmenu';
return $this->render($s);
} | php | public function lang_menu() {
global $CFG;
if (empty($CFG->langmenu)) {
return '';
}
if ($this->page->course != SITEID and !empty($this->page->course->lang)) {
// do not show lang menu if language forced
return '';
}
$currlang = current_language();
$langs = get_string_manager()->get_list_of_translations();
if (count($langs) < 2) {
return '';
}
$s = new single_select($this->page->url, 'lang', $langs, $currlang, null);
$s->label = get_accesshide(get_string('language'));
$s->class = 'langmenu';
return $this->render($s);
} | [
"public",
"function",
"lang_menu",
"(",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"empty",
"(",
"$",
"CFG",
"->",
"langmenu",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"course",
"!=",
"SITEID",
"and",
"!",
"empty",
"(",
"$",
"this",
"->",
"page",
"->",
"course",
"->",
"lang",
")",
")",
"{",
"// do not show lang menu if language forced",
"return",
"''",
";",
"}",
"$",
"currlang",
"=",
"current_language",
"(",
")",
";",
"$",
"langs",
"=",
"get_string_manager",
"(",
")",
"->",
"get_list_of_translations",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"langs",
")",
"<",
"2",
")",
"{",
"return",
"''",
";",
"}",
"$",
"s",
"=",
"new",
"single_select",
"(",
"$",
"this",
"->",
"page",
"->",
"url",
",",
"'lang'",
",",
"$",
"langs",
",",
"$",
"currlang",
",",
"null",
")",
";",
"$",
"s",
"->",
"label",
"=",
"get_accesshide",
"(",
"get_string",
"(",
"'language'",
")",
")",
";",
"$",
"s",
"->",
"class",
"=",
"'langmenu'",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"s",
")",
";",
"}"
] | Returns lang menu or '', this method also checks forcing of languages in courses.
This function calls {@link core_renderer::render_single_select()} to actually display the language menu.
@return string The lang menu HTML or empty string | [
"Returns",
"lang",
"menu",
"or",
"this",
"method",
"also",
"checks",
"forcing",
"of",
"languages",
"in",
"courses",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1558-L1581 |
212,848 | moodle/moodle | lib/outputrenderers.php | core_renderer.block_controls | public function block_controls($actions, $blockid = null) {
global $CFG;
if (empty($actions)) {
return '';
}
$menu = new action_menu($actions);
if ($blockid !== null) {
$menu->set_owner_selector('#'.$blockid);
}
$menu->set_constraint('.block-region');
$menu->attributes['class'] .= ' block-control-actions commands';
return $this->render($menu);
} | php | public function block_controls($actions, $blockid = null) {
global $CFG;
if (empty($actions)) {
return '';
}
$menu = new action_menu($actions);
if ($blockid !== null) {
$menu->set_owner_selector('#'.$blockid);
}
$menu->set_constraint('.block-region');
$menu->attributes['class'] .= ' block-control-actions commands';
return $this->render($menu);
} | [
"public",
"function",
"block_controls",
"(",
"$",
"actions",
",",
"$",
"blockid",
"=",
"null",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"empty",
"(",
"$",
"actions",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"menu",
"=",
"new",
"action_menu",
"(",
"$",
"actions",
")",
";",
"if",
"(",
"$",
"blockid",
"!==",
"null",
")",
"{",
"$",
"menu",
"->",
"set_owner_selector",
"(",
"'#'",
".",
"$",
"blockid",
")",
";",
"}",
"$",
"menu",
"->",
"set_constraint",
"(",
"'.block-region'",
")",
";",
"$",
"menu",
"->",
"attributes",
"[",
"'class'",
"]",
".=",
"' block-control-actions commands'",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"menu",
")",
";",
"}"
] | Output the row of editing icons for a block, as defined by the controls array.
@param array $controls an array like {@link block_contents::$controls}.
@param string $blockid The ID given to the block.
@return string HTML fragment. | [
"Output",
"the",
"row",
"of",
"editing",
"icons",
"for",
"a",
"block",
"as",
"defined",
"by",
"the",
"controls",
"array",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1590-L1602 |
212,849 | moodle/moodle | lib/outputrenderers.php | core_renderer.print_textarea | public function print_textarea($name, $id, $value, $rows, $cols) {
global $OUTPUT;
editors_head_setup();
$editor = editors_get_preferred_editor(FORMAT_HTML);
$editor->set_text($value);
$editor->use_editor($id, []);
$context = [
'id' => $id,
'name' => $name,
'value' => $value,
'rows' => $rows,
'cols' => $cols
];
return $OUTPUT->render_from_template('core_form/editor_textarea', $context);
} | php | public function print_textarea($name, $id, $value, $rows, $cols) {
global $OUTPUT;
editors_head_setup();
$editor = editors_get_preferred_editor(FORMAT_HTML);
$editor->set_text($value);
$editor->use_editor($id, []);
$context = [
'id' => $id,
'name' => $name,
'value' => $value,
'rows' => $rows,
'cols' => $cols
];
return $OUTPUT->render_from_template('core_form/editor_textarea', $context);
} | [
"public",
"function",
"print_textarea",
"(",
"$",
"name",
",",
"$",
"id",
",",
"$",
"value",
",",
"$",
"rows",
",",
"$",
"cols",
")",
"{",
"global",
"$",
"OUTPUT",
";",
"editors_head_setup",
"(",
")",
";",
"$",
"editor",
"=",
"editors_get_preferred_editor",
"(",
"FORMAT_HTML",
")",
";",
"$",
"editor",
"->",
"set_text",
"(",
"$",
"value",
")",
";",
"$",
"editor",
"->",
"use_editor",
"(",
"$",
"id",
",",
"[",
"]",
")",
";",
"$",
"context",
"=",
"[",
"'id'",
"=>",
"$",
"id",
",",
"'name'",
"=>",
"$",
"name",
",",
"'value'",
"=>",
"$",
"value",
",",
"'rows'",
"=>",
"$",
"rows",
",",
"'cols'",
"=>",
"$",
"cols",
"]",
";",
"return",
"$",
"OUTPUT",
"->",
"render_from_template",
"(",
"'core_form/editor_textarea'",
",",
"$",
"context",
")",
";",
"}"
] | Returns the HTML for a basic textarea field.
@param string $name Name to use for the textarea element
@param string $id The id to use fort he textarea element
@param string $value Initial content to display in the textarea
@param int $rows Number of rows to display
@param int $cols Number of columns to display
@return string the HTML to display | [
"Returns",
"the",
"HTML",
"for",
"a",
"basic",
"textarea",
"field",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1614-L1631 |
212,850 | moodle/moodle | lib/outputrenderers.php | core_renderer.render_action_menu | public function render_action_menu(action_menu $menu) {
// We don't want the class icon there!
foreach ($menu->get_secondary_actions() as $action) {
if ($action instanceof \action_menu_link && $action->has_class('icon')) {
$action->attributes['class'] = preg_replace('/(^|\s+)icon(\s+|$)/i', '', $action->attributes['class']);
}
}
if ($menu->is_empty()) {
return '';
}
$context = $menu->export_for_template($this);
return $this->render_from_template('core/action_menu', $context);
} | php | public function render_action_menu(action_menu $menu) {
// We don't want the class icon there!
foreach ($menu->get_secondary_actions() as $action) {
if ($action instanceof \action_menu_link && $action->has_class('icon')) {
$action->attributes['class'] = preg_replace('/(^|\s+)icon(\s+|$)/i', '', $action->attributes['class']);
}
}
if ($menu->is_empty()) {
return '';
}
$context = $menu->export_for_template($this);
return $this->render_from_template('core/action_menu', $context);
} | [
"public",
"function",
"render_action_menu",
"(",
"action_menu",
"$",
"menu",
")",
"{",
"// We don't want the class icon there!",
"foreach",
"(",
"$",
"menu",
"->",
"get_secondary_actions",
"(",
")",
"as",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"action",
"instanceof",
"\\",
"action_menu_link",
"&&",
"$",
"action",
"->",
"has_class",
"(",
"'icon'",
")",
")",
"{",
"$",
"action",
"->",
"attributes",
"[",
"'class'",
"]",
"=",
"preg_replace",
"(",
"'/(^|\\s+)icon(\\s+|$)/i'",
",",
"''",
",",
"$",
"action",
"->",
"attributes",
"[",
"'class'",
"]",
")",
";",
"}",
"}",
"if",
"(",
"$",
"menu",
"->",
"is_empty",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"context",
"=",
"$",
"menu",
"->",
"export_for_template",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
"->",
"render_from_template",
"(",
"'core/action_menu'",
",",
"$",
"context",
")",
";",
"}"
] | Renders an action menu component.
@param action_menu $menu
@return string HTML | [
"Renders",
"an",
"action",
"menu",
"component",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1639-L1654 |
212,851 | moodle/moodle | lib/outputrenderers.php | core_renderer.block | public function block(block_contents $bc, $region) {
$bc = clone($bc); // Avoid messing up the object passed in.
if (empty($bc->blockinstanceid) || !strip_tags($bc->title)) {
$bc->collapsible = block_contents::NOT_HIDEABLE;
}
$id = !empty($bc->attributes['id']) ? $bc->attributes['id'] : uniqid('block-');
$context = new stdClass();
$context->skipid = $bc->skipid;
$context->blockinstanceid = $bc->blockinstanceid;
$context->dockable = $bc->dockable;
$context->id = $id;
$context->hidden = $bc->collapsible == block_contents::HIDDEN;
$context->skiptitle = strip_tags($bc->title);
$context->showskiplink = !empty($context->skiptitle);
$context->arialabel = $bc->arialabel;
$context->ariarole = !empty($bc->attributes['role']) ? $bc->attributes['role'] : 'complementary';
$context->type = $bc->attributes['data-block'];
$context->title = $bc->title;
$context->content = $bc->content;
$context->annotation = $bc->annotation;
$context->footer = $bc->footer;
$context->hascontrols = !empty($bc->controls);
if ($context->hascontrols) {
$context->controls = $this->block_controls($bc->controls, $id);
}
return $this->render_from_template('core/block', $context);
} | php | public function block(block_contents $bc, $region) {
$bc = clone($bc); // Avoid messing up the object passed in.
if (empty($bc->blockinstanceid) || !strip_tags($bc->title)) {
$bc->collapsible = block_contents::NOT_HIDEABLE;
}
$id = !empty($bc->attributes['id']) ? $bc->attributes['id'] : uniqid('block-');
$context = new stdClass();
$context->skipid = $bc->skipid;
$context->blockinstanceid = $bc->blockinstanceid;
$context->dockable = $bc->dockable;
$context->id = $id;
$context->hidden = $bc->collapsible == block_contents::HIDDEN;
$context->skiptitle = strip_tags($bc->title);
$context->showskiplink = !empty($context->skiptitle);
$context->arialabel = $bc->arialabel;
$context->ariarole = !empty($bc->attributes['role']) ? $bc->attributes['role'] : 'complementary';
$context->type = $bc->attributes['data-block'];
$context->title = $bc->title;
$context->content = $bc->content;
$context->annotation = $bc->annotation;
$context->footer = $bc->footer;
$context->hascontrols = !empty($bc->controls);
if ($context->hascontrols) {
$context->controls = $this->block_controls($bc->controls, $id);
}
return $this->render_from_template('core/block', $context);
} | [
"public",
"function",
"block",
"(",
"block_contents",
"$",
"bc",
",",
"$",
"region",
")",
"{",
"$",
"bc",
"=",
"clone",
"(",
"$",
"bc",
")",
";",
"// Avoid messing up the object passed in.",
"if",
"(",
"empty",
"(",
"$",
"bc",
"->",
"blockinstanceid",
")",
"||",
"!",
"strip_tags",
"(",
"$",
"bc",
"->",
"title",
")",
")",
"{",
"$",
"bc",
"->",
"collapsible",
"=",
"block_contents",
"::",
"NOT_HIDEABLE",
";",
"}",
"$",
"id",
"=",
"!",
"empty",
"(",
"$",
"bc",
"->",
"attributes",
"[",
"'id'",
"]",
")",
"?",
"$",
"bc",
"->",
"attributes",
"[",
"'id'",
"]",
":",
"uniqid",
"(",
"'block-'",
")",
";",
"$",
"context",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"context",
"->",
"skipid",
"=",
"$",
"bc",
"->",
"skipid",
";",
"$",
"context",
"->",
"blockinstanceid",
"=",
"$",
"bc",
"->",
"blockinstanceid",
";",
"$",
"context",
"->",
"dockable",
"=",
"$",
"bc",
"->",
"dockable",
";",
"$",
"context",
"->",
"id",
"=",
"$",
"id",
";",
"$",
"context",
"->",
"hidden",
"=",
"$",
"bc",
"->",
"collapsible",
"==",
"block_contents",
"::",
"HIDDEN",
";",
"$",
"context",
"->",
"skiptitle",
"=",
"strip_tags",
"(",
"$",
"bc",
"->",
"title",
")",
";",
"$",
"context",
"->",
"showskiplink",
"=",
"!",
"empty",
"(",
"$",
"context",
"->",
"skiptitle",
")",
";",
"$",
"context",
"->",
"arialabel",
"=",
"$",
"bc",
"->",
"arialabel",
";",
"$",
"context",
"->",
"ariarole",
"=",
"!",
"empty",
"(",
"$",
"bc",
"->",
"attributes",
"[",
"'role'",
"]",
")",
"?",
"$",
"bc",
"->",
"attributes",
"[",
"'role'",
"]",
":",
"'complementary'",
";",
"$",
"context",
"->",
"type",
"=",
"$",
"bc",
"->",
"attributes",
"[",
"'data-block'",
"]",
";",
"$",
"context",
"->",
"title",
"=",
"$",
"bc",
"->",
"title",
";",
"$",
"context",
"->",
"content",
"=",
"$",
"bc",
"->",
"content",
";",
"$",
"context",
"->",
"annotation",
"=",
"$",
"bc",
"->",
"annotation",
";",
"$",
"context",
"->",
"footer",
"=",
"$",
"bc",
"->",
"footer",
";",
"$",
"context",
"->",
"hascontrols",
"=",
"!",
"empty",
"(",
"$",
"bc",
"->",
"controls",
")",
";",
"if",
"(",
"$",
"context",
"->",
"hascontrols",
")",
"{",
"$",
"context",
"->",
"controls",
"=",
"$",
"this",
"->",
"block_controls",
"(",
"$",
"bc",
"->",
"controls",
",",
"$",
"id",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render_from_template",
"(",
"'core/block'",
",",
"$",
"context",
")",
";",
"}"
] | Prints a nice side block with an optional header.
@param block_contents $bc HTML for the content
@param string $region the region the block is appearing in.
@return string the HTML to be output. | [
"Prints",
"a",
"nice",
"side",
"block",
"with",
"an",
"optional",
"header",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1703-L1731 |
212,852 | moodle/moodle | lib/outputrenderers.php | core_renderer.list_block_contents | public function list_block_contents($icons, $items) {
$row = 0;
$lis = array();
foreach ($items as $key => $string) {
$item = html_writer::start_tag('li', array('class' => 'r' . $row));
if (!empty($icons[$key])) { //test if the content has an assigned icon
$item .= html_writer::tag('div', $icons[$key], array('class' => 'icon column c0'));
}
$item .= html_writer::tag('div', $string, array('class' => 'column c1'));
$item .= html_writer::end_tag('li');
$lis[] = $item;
$row = 1 - $row; // Flip even/odd.
}
return html_writer::tag('ul', implode("\n", $lis), array('class' => 'unlist'));
} | php | public function list_block_contents($icons, $items) {
$row = 0;
$lis = array();
foreach ($items as $key => $string) {
$item = html_writer::start_tag('li', array('class' => 'r' . $row));
if (!empty($icons[$key])) { //test if the content has an assigned icon
$item .= html_writer::tag('div', $icons[$key], array('class' => 'icon column c0'));
}
$item .= html_writer::tag('div', $string, array('class' => 'column c1'));
$item .= html_writer::end_tag('li');
$lis[] = $item;
$row = 1 - $row; // Flip even/odd.
}
return html_writer::tag('ul', implode("\n", $lis), array('class' => 'unlist'));
} | [
"public",
"function",
"list_block_contents",
"(",
"$",
"icons",
",",
"$",
"items",
")",
"{",
"$",
"row",
"=",
"0",
";",
"$",
"lis",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"key",
"=>",
"$",
"string",
")",
"{",
"$",
"item",
"=",
"html_writer",
"::",
"start_tag",
"(",
"'li'",
",",
"array",
"(",
"'class'",
"=>",
"'r'",
".",
"$",
"row",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"icons",
"[",
"$",
"key",
"]",
")",
")",
"{",
"//test if the content has an assigned icon",
"$",
"item",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"icons",
"[",
"$",
"key",
"]",
",",
"array",
"(",
"'class'",
"=>",
"'icon column c0'",
")",
")",
";",
"}",
"$",
"item",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"string",
",",
"array",
"(",
"'class'",
"=>",
"'column c1'",
")",
")",
";",
"$",
"item",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'li'",
")",
";",
"$",
"lis",
"[",
"]",
"=",
"$",
"item",
";",
"$",
"row",
"=",
"1",
"-",
"$",
"row",
";",
"// Flip even/odd.",
"}",
"return",
"html_writer",
"::",
"tag",
"(",
"'ul'",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"lis",
")",
",",
"array",
"(",
"'class'",
"=>",
"'unlist'",
")",
")",
";",
"}"
] | Render the contents of a block_list.
@param array $icons the icon for each item.
@param array $items the content of each item.
@return string HTML | [
"Render",
"the",
"contents",
"of",
"a",
"block_list",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1740-L1754 |
212,853 | moodle/moodle | lib/outputrenderers.php | core_renderer.blocks_for_region | public function blocks_for_region($region) {
$blockcontents = $this->page->blocks->get_content_for_region($region, $this);
$blocks = $this->page->blocks->get_blocks_for_region($region);
$lastblock = null;
$zones = array();
foreach ($blocks as $block) {
$zones[] = $block->title;
}
$output = '';
foreach ($blockcontents as $bc) {
if ($bc instanceof block_contents) {
$output .= $this->block($bc, $region);
$lastblock = $bc->title;
} else if ($bc instanceof block_move_target) {
$output .= $this->block_move_target($bc, $zones, $lastblock, $region);
} else {
throw new coding_exception('Unexpected type of thing (' . get_class($bc) . ') found in list of block contents.');
}
}
return $output;
} | php | public function blocks_for_region($region) {
$blockcontents = $this->page->blocks->get_content_for_region($region, $this);
$blocks = $this->page->blocks->get_blocks_for_region($region);
$lastblock = null;
$zones = array();
foreach ($blocks as $block) {
$zones[] = $block->title;
}
$output = '';
foreach ($blockcontents as $bc) {
if ($bc instanceof block_contents) {
$output .= $this->block($bc, $region);
$lastblock = $bc->title;
} else if ($bc instanceof block_move_target) {
$output .= $this->block_move_target($bc, $zones, $lastblock, $region);
} else {
throw new coding_exception('Unexpected type of thing (' . get_class($bc) . ') found in list of block contents.');
}
}
return $output;
} | [
"public",
"function",
"blocks_for_region",
"(",
"$",
"region",
")",
"{",
"$",
"blockcontents",
"=",
"$",
"this",
"->",
"page",
"->",
"blocks",
"->",
"get_content_for_region",
"(",
"$",
"region",
",",
"$",
"this",
")",
";",
"$",
"blocks",
"=",
"$",
"this",
"->",
"page",
"->",
"blocks",
"->",
"get_blocks_for_region",
"(",
"$",
"region",
")",
";",
"$",
"lastblock",
"=",
"null",
";",
"$",
"zones",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"blocks",
"as",
"$",
"block",
")",
"{",
"$",
"zones",
"[",
"]",
"=",
"$",
"block",
"->",
"title",
";",
"}",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"blockcontents",
"as",
"$",
"bc",
")",
"{",
"if",
"(",
"$",
"bc",
"instanceof",
"block_contents",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"block",
"(",
"$",
"bc",
",",
"$",
"region",
")",
";",
"$",
"lastblock",
"=",
"$",
"bc",
"->",
"title",
";",
"}",
"else",
"if",
"(",
"$",
"bc",
"instanceof",
"block_move_target",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"block_move_target",
"(",
"$",
"bc",
",",
"$",
"zones",
",",
"$",
"lastblock",
",",
"$",
"region",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Unexpected type of thing ('",
".",
"get_class",
"(",
"$",
"bc",
")",
".",
"') found in list of block contents.'",
")",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] | Output all the blocks in a particular region.
@param string $region the name of a region on this page.
@return string the HTML to be output. | [
"Output",
"all",
"the",
"blocks",
"in",
"a",
"particular",
"region",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1762-L1783 |
212,854 | moodle/moodle | lib/outputrenderers.php | core_renderer.block_move_target | public function block_move_target($target, $zones, $previous, $region) {
if ($previous == null) {
if (empty($zones)) {
// There are no zones, probably because there are no blocks.
$regions = $this->page->theme->get_all_block_regions();
$position = get_string('moveblockinregion', 'block', $regions[$region]);
} else {
$position = get_string('moveblockbefore', 'block', $zones[0]);
}
} else {
$position = get_string('moveblockafter', 'block', $previous);
}
return html_writer::tag('a', html_writer::tag('span', $position, array('class' => 'accesshide')), array('href' => $target->url, 'class' => 'blockmovetarget'));
} | php | public function block_move_target($target, $zones, $previous, $region) {
if ($previous == null) {
if (empty($zones)) {
// There are no zones, probably because there are no blocks.
$regions = $this->page->theme->get_all_block_regions();
$position = get_string('moveblockinregion', 'block', $regions[$region]);
} else {
$position = get_string('moveblockbefore', 'block', $zones[0]);
}
} else {
$position = get_string('moveblockafter', 'block', $previous);
}
return html_writer::tag('a', html_writer::tag('span', $position, array('class' => 'accesshide')), array('href' => $target->url, 'class' => 'blockmovetarget'));
} | [
"public",
"function",
"block_move_target",
"(",
"$",
"target",
",",
"$",
"zones",
",",
"$",
"previous",
",",
"$",
"region",
")",
"{",
"if",
"(",
"$",
"previous",
"==",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"zones",
")",
")",
"{",
"// There are no zones, probably because there are no blocks.",
"$",
"regions",
"=",
"$",
"this",
"->",
"page",
"->",
"theme",
"->",
"get_all_block_regions",
"(",
")",
";",
"$",
"position",
"=",
"get_string",
"(",
"'moveblockinregion'",
",",
"'block'",
",",
"$",
"regions",
"[",
"$",
"region",
"]",
")",
";",
"}",
"else",
"{",
"$",
"position",
"=",
"get_string",
"(",
"'moveblockbefore'",
",",
"'block'",
",",
"$",
"zones",
"[",
"0",
"]",
")",
";",
"}",
"}",
"else",
"{",
"$",
"position",
"=",
"get_string",
"(",
"'moveblockafter'",
",",
"'block'",
",",
"$",
"previous",
")",
";",
"}",
"return",
"html_writer",
"::",
"tag",
"(",
"'a'",
",",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"$",
"position",
",",
"array",
"(",
"'class'",
"=>",
"'accesshide'",
")",
")",
",",
"array",
"(",
"'href'",
"=>",
"$",
"target",
"->",
"url",
",",
"'class'",
"=>",
"'blockmovetarget'",
")",
")",
";",
"}"
] | Output a place where the block that is currently being moved can be dropped.
@param block_move_target $target with the necessary details.
@param array $zones array of areas where the block can be moved to
@param string $previous the block located before the area currently being rendered.
@param string $region the name of the region
@return string the HTML to be output. | [
"Output",
"a",
"place",
"where",
"the",
"block",
"that",
"is",
"currently",
"being",
"moved",
"can",
"be",
"dropped",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1794-L1807 |
212,855 | moodle/moodle | lib/outputrenderers.php | core_renderer.action_link | public function action_link($url, $text, component_action $action = null, array $attributes = null, $icon = null) {
if (!($url instanceof moodle_url)) {
$url = new moodle_url($url);
}
$link = new action_link($url, $text, $action, $attributes, $icon);
return $this->render($link);
} | php | public function action_link($url, $text, component_action $action = null, array $attributes = null, $icon = null) {
if (!($url instanceof moodle_url)) {
$url = new moodle_url($url);
}
$link = new action_link($url, $text, $action, $attributes, $icon);
return $this->render($link);
} | [
"public",
"function",
"action_link",
"(",
"$",
"url",
",",
"$",
"text",
",",
"component_action",
"$",
"action",
"=",
"null",
",",
"array",
"$",
"attributes",
"=",
"null",
",",
"$",
"icon",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"url",
"instanceof",
"moodle_url",
")",
")",
"{",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"$",
"url",
")",
";",
"}",
"$",
"link",
"=",
"new",
"action_link",
"(",
"$",
"url",
",",
"$",
"text",
",",
"$",
"action",
",",
"$",
"attributes",
",",
"$",
"icon",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"link",
")",
";",
"}"
] | Renders a special html link with attached action
Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_action_link()} instead.
@param string|moodle_url $url
@param string $text HTML fragment
@param component_action $action
@param array $attributes associative array of html link attributes + disabled
@param pix_icon optional pix icon to render with the link
@return string HTML fragment | [
"Renders",
"a",
"special",
"html",
"link",
"with",
"attached",
"action"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1822-L1829 |
212,856 | moodle/moodle | lib/outputrenderers.php | core_renderer.single_button | public function single_button($url, $label, $method='post', array $options=null) {
if (!($url instanceof moodle_url)) {
$url = new moodle_url($url);
}
$button = new single_button($url, $label, $method);
foreach ((array)$options as $key=>$value) {
if (array_key_exists($key, $button)) {
$button->$key = $value;
}
}
return $this->render($button);
} | php | public function single_button($url, $label, $method='post', array $options=null) {
if (!($url instanceof moodle_url)) {
$url = new moodle_url($url);
}
$button = new single_button($url, $label, $method);
foreach ((array)$options as $key=>$value) {
if (array_key_exists($key, $button)) {
$button->$key = $value;
}
}
return $this->render($button);
} | [
"public",
"function",
"single_button",
"(",
"$",
"url",
",",
"$",
"label",
",",
"$",
"method",
"=",
"'post'",
",",
"array",
"$",
"options",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"url",
"instanceof",
"moodle_url",
")",
")",
"{",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"$",
"url",
")",
";",
"}",
"$",
"button",
"=",
"new",
"single_button",
"(",
"$",
"url",
",",
"$",
"label",
",",
"$",
"method",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"button",
")",
")",
"{",
"$",
"button",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"button",
")",
";",
"}"
] | Returns a form with a single button.
Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_single_button()} instead.
@param string|moodle_url $url
@param string $label button text
@param string $method get or post submit method
@param array $options associative array {disabled, title, etc.}
@return string HTML fragment | [
"Returns",
"a",
"form",
"with",
"a",
"single",
"button",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1955-L1968 |
212,857 | moodle/moodle | lib/outputrenderers.php | core_renderer.single_select | public function single_select($url, $name, array $options, $selected = '',
$nothing = array('' => 'choosedots'), $formid = null, $attributes = array()) {
if (!($url instanceof moodle_url)) {
$url = new moodle_url($url);
}
$select = new single_select($url, $name, $options, $selected, $nothing, $formid);
if (array_key_exists('label', $attributes)) {
$select->set_label($attributes['label']);
unset($attributes['label']);
}
$select->attributes = $attributes;
return $this->render($select);
} | php | public function single_select($url, $name, array $options, $selected = '',
$nothing = array('' => 'choosedots'), $formid = null, $attributes = array()) {
if (!($url instanceof moodle_url)) {
$url = new moodle_url($url);
}
$select = new single_select($url, $name, $options, $selected, $nothing, $formid);
if (array_key_exists('label', $attributes)) {
$select->set_label($attributes['label']);
unset($attributes['label']);
}
$select->attributes = $attributes;
return $this->render($select);
} | [
"public",
"function",
"single_select",
"(",
"$",
"url",
",",
"$",
"name",
",",
"array",
"$",
"options",
",",
"$",
"selected",
"=",
"''",
",",
"$",
"nothing",
"=",
"array",
"(",
"''",
"=>",
"'choosedots'",
")",
",",
"$",
"formid",
"=",
"null",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"url",
"instanceof",
"moodle_url",
")",
")",
"{",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"$",
"url",
")",
";",
"}",
"$",
"select",
"=",
"new",
"single_select",
"(",
"$",
"url",
",",
"$",
"name",
",",
"$",
"options",
",",
"$",
"selected",
",",
"$",
"nothing",
",",
"$",
"formid",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"'label'",
",",
"$",
"attributes",
")",
")",
"{",
"$",
"select",
"->",
"set_label",
"(",
"$",
"attributes",
"[",
"'label'",
"]",
")",
";",
"unset",
"(",
"$",
"attributes",
"[",
"'label'",
"]",
")",
";",
"}",
"$",
"select",
"->",
"attributes",
"=",
"$",
"attributes",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"select",
")",
";",
"}"
] | Returns a form with a single select widget.
Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_single_select()} instead.
@param moodle_url $url form action target, includes hidden fields
@param string $name name of selection field - the changing parameter in url
@param array $options list of options
@param string $selected selected element
@param array $nothing
@param string $formid
@param array $attributes other attributes for the single select
@return string HTML fragment | [
"Returns",
"a",
"form",
"with",
"a",
"single",
"select",
"widget",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L1997-L2011 |
212,858 | moodle/moodle | lib/outputrenderers.php | core_renderer.download_dataformat_selector | public function download_dataformat_selector($label, $base, $name = 'dataformat', $params = array()) {
$formats = core_plugin_manager::instance()->get_plugins_of_type('dataformat');
$options = array();
foreach ($formats as $format) {
if ($format->is_enabled()) {
$options[] = array(
'value' => $format->name,
'label' => get_string('dataformat', $format->component),
);
}
}
$hiddenparams = array();
foreach ($params as $key => $value) {
$hiddenparams[] = array(
'name' => $key,
'value' => $value,
);
}
$data = array(
'label' => $label,
'base' => $base,
'name' => $name,
'params' => $hiddenparams,
'options' => $options,
'sesskey' => sesskey(),
'submit' => get_string('download'),
);
return $this->render_from_template('core/dataformat_selector', $data);
} | php | public function download_dataformat_selector($label, $base, $name = 'dataformat', $params = array()) {
$formats = core_plugin_manager::instance()->get_plugins_of_type('dataformat');
$options = array();
foreach ($formats as $format) {
if ($format->is_enabled()) {
$options[] = array(
'value' => $format->name,
'label' => get_string('dataformat', $format->component),
);
}
}
$hiddenparams = array();
foreach ($params as $key => $value) {
$hiddenparams[] = array(
'name' => $key,
'value' => $value,
);
}
$data = array(
'label' => $label,
'base' => $base,
'name' => $name,
'params' => $hiddenparams,
'options' => $options,
'sesskey' => sesskey(),
'submit' => get_string('download'),
);
return $this->render_from_template('core/dataformat_selector', $data);
} | [
"public",
"function",
"download_dataformat_selector",
"(",
"$",
"label",
",",
"$",
"base",
",",
"$",
"name",
"=",
"'dataformat'",
",",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"formats",
"=",
"core_plugin_manager",
"::",
"instance",
"(",
")",
"->",
"get_plugins_of_type",
"(",
"'dataformat'",
")",
";",
"$",
"options",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"formats",
"as",
"$",
"format",
")",
"{",
"if",
"(",
"$",
"format",
"->",
"is_enabled",
"(",
")",
")",
"{",
"$",
"options",
"[",
"]",
"=",
"array",
"(",
"'value'",
"=>",
"$",
"format",
"->",
"name",
",",
"'label'",
"=>",
"get_string",
"(",
"'dataformat'",
",",
"$",
"format",
"->",
"component",
")",
",",
")",
";",
"}",
"}",
"$",
"hiddenparams",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"params",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"hiddenparams",
"[",
"]",
"=",
"array",
"(",
"'name'",
"=>",
"$",
"key",
",",
"'value'",
"=>",
"$",
"value",
",",
")",
";",
"}",
"$",
"data",
"=",
"array",
"(",
"'label'",
"=>",
"$",
"label",
",",
"'base'",
"=>",
"$",
"base",
",",
"'name'",
"=>",
"$",
"name",
",",
"'params'",
"=>",
"$",
"hiddenparams",
",",
"'options'",
"=>",
"$",
"options",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
",",
"'submit'",
"=>",
"get_string",
"(",
"'download'",
")",
",",
")",
";",
"return",
"$",
"this",
"->",
"render_from_template",
"(",
"'core/dataformat_selector'",
",",
"$",
"data",
")",
";",
"}"
] | Returns a dataformat selection and download form
@param string $label A text label
@param moodle_url|string $base The download page url
@param string $name The query param which will hold the type of the download
@param array $params Extra params sent to the download page
@return string HTML fragment | [
"Returns",
"a",
"dataformat",
"selection",
"and",
"download",
"form"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2022-L2052 |
212,859 | moodle/moodle | lib/outputrenderers.php | core_renderer.url_select | public function url_select(array $urls, $selected, $nothing = array('' => 'choosedots'), $formid = null) {
$select = new url_select($urls, $selected, $nothing, $formid);
return $this->render($select);
} | php | public function url_select(array $urls, $selected, $nothing = array('' => 'choosedots'), $formid = null) {
$select = new url_select($urls, $selected, $nothing, $formid);
return $this->render($select);
} | [
"public",
"function",
"url_select",
"(",
"array",
"$",
"urls",
",",
"$",
"selected",
",",
"$",
"nothing",
"=",
"array",
"(",
"''",
"=>",
"'choosedots'",
")",
",",
"$",
"formid",
"=",
"null",
")",
"{",
"$",
"select",
"=",
"new",
"url_select",
"(",
"$",
"urls",
",",
"$",
"selected",
",",
"$",
"nothing",
",",
"$",
"formid",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"select",
")",
";",
"}"
] | Returns a form with a url select widget.
Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_url_select()} instead.
@param array $urls list of urls - array('/course/view.php?id=1'=>'Frontpage', ....)
@param string $selected selected element
@param array $nothing
@param string $formid
@return string HTML fragment | [
"Returns",
"a",
"form",
"with",
"a",
"url",
"select",
"widget",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2077-L2080 |
212,860 | moodle/moodle | lib/outputrenderers.php | core_renderer.doc_link | public function doc_link($path, $text = '', $forcepopup = false) {
global $CFG;
$icon = $this->pix_icon('docs', '', 'moodle', array('class'=>'iconhelp icon-pre', 'role'=>'presentation'));
$url = new moodle_url(get_docs_url($path));
$attributes = array('href'=>$url);
if (!empty($CFG->doctonewwindow) || $forcepopup) {
$attributes['class'] = 'helplinkpopup';
}
return html_writer::tag('a', $icon.$text, $attributes);
} | php | public function doc_link($path, $text = '', $forcepopup = false) {
global $CFG;
$icon = $this->pix_icon('docs', '', 'moodle', array('class'=>'iconhelp icon-pre', 'role'=>'presentation'));
$url = new moodle_url(get_docs_url($path));
$attributes = array('href'=>$url);
if (!empty($CFG->doctonewwindow) || $forcepopup) {
$attributes['class'] = 'helplinkpopup';
}
return html_writer::tag('a', $icon.$text, $attributes);
} | [
"public",
"function",
"doc_link",
"(",
"$",
"path",
",",
"$",
"text",
"=",
"''",
",",
"$",
"forcepopup",
"=",
"false",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"icon",
"=",
"$",
"this",
"->",
"pix_icon",
"(",
"'docs'",
",",
"''",
",",
"'moodle'",
",",
"array",
"(",
"'class'",
"=>",
"'iconhelp icon-pre'",
",",
"'role'",
"=>",
"'presentation'",
")",
")",
";",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"get_docs_url",
"(",
"$",
"path",
")",
")",
";",
"$",
"attributes",
"=",
"array",
"(",
"'href'",
"=>",
"$",
"url",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"CFG",
"->",
"doctonewwindow",
")",
"||",
"$",
"forcepopup",
")",
"{",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"'helplinkpopup'",
";",
"}",
"return",
"html_writer",
"::",
"tag",
"(",
"'a'",
",",
"$",
"icon",
".",
"$",
"text",
",",
"$",
"attributes",
")",
";",
"}"
] | Returns a string containing a link to the user documentation.
Also contains an icon by default. Shown to teachers and admin only.
@param string $path The page link after doc root and language, no leading slash.
@param string $text The text to be displayed for the link
@param boolean $forcepopup Whether to force a popup regardless of the value of $CFG->doctonewwindow
@return string | [
"Returns",
"a",
"string",
"containing",
"a",
"link",
"to",
"the",
"user",
"documentation",
".",
"Also",
"contains",
"an",
"icon",
"by",
"default",
".",
"Shown",
"to",
"teachers",
"and",
"admin",
"only",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2101-L2114 |
212,861 | moodle/moodle | lib/outputrenderers.php | core_renderer.image_icon | public function image_icon($pix, $alt, $component='moodle', array $attributes = null) {
$icon = new image_icon($pix, $alt, $component, $attributes);
return $this->render($icon);
} | php | public function image_icon($pix, $alt, $component='moodle', array $attributes = null) {
$icon = new image_icon($pix, $alt, $component, $attributes);
return $this->render($icon);
} | [
"public",
"function",
"image_icon",
"(",
"$",
"pix",
",",
"$",
"alt",
",",
"$",
"component",
"=",
"'moodle'",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"icon",
"=",
"new",
"image_icon",
"(",
"$",
"pix",
",",
"$",
"alt",
",",
"$",
"component",
",",
"$",
"attributes",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"icon",
")",
";",
"}"
] | Return HTML for an image_icon.
Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_image_icon()} instead.
@param string $pix short pix name
@param string $alt mandatory alt attribute
@param string $component standard compoennt name like 'moodle', 'mod_forum', etc.
@param array $attributes htm lattributes
@return string HTML fragment | [
"Return",
"HTML",
"for",
"an",
"image_icon",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2128-L2131 |
212,862 | moodle/moodle | lib/outputrenderers.php | core_renderer.render_pix_emoticon | protected function render_pix_emoticon(pix_emoticon $emoticon) {
$system = \core\output\icon_system::instance(\core\output\icon_system::STANDARD);
return $system->render_pix_icon($this, $emoticon);
} | php | protected function render_pix_emoticon(pix_emoticon $emoticon) {
$system = \core\output\icon_system::instance(\core\output\icon_system::STANDARD);
return $system->render_pix_icon($this, $emoticon);
} | [
"protected",
"function",
"render_pix_emoticon",
"(",
"pix_emoticon",
"$",
"emoticon",
")",
"{",
"$",
"system",
"=",
"\\",
"core",
"\\",
"output",
"\\",
"icon_system",
"::",
"instance",
"(",
"\\",
"core",
"\\",
"output",
"\\",
"icon_system",
"::",
"STANDARD",
")",
";",
"return",
"$",
"system",
"->",
"render_pix_icon",
"(",
"$",
"this",
",",
"$",
"emoticon",
")",
";",
"}"
] | Return HTML to display an emoticon icon.
@param pix_emoticon $emoticon
@return string HTML fragment | [
"Return",
"HTML",
"to",
"display",
"an",
"emoticon",
"icon",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2178-L2181 |
212,863 | moodle/moodle | lib/outputrenderers.php | core_renderer.help_icon | public function help_icon($identifier, $component = 'moodle', $linktext = '') {
$icon = new help_icon($identifier, $component);
$icon->diag_strings();
if ($linktext === true) {
$icon->linktext = get_string($icon->identifier, $icon->component);
} else if (!empty($linktext)) {
$icon->linktext = $linktext;
}
return $this->render($icon);
} | php | public function help_icon($identifier, $component = 'moodle', $linktext = '') {
$icon = new help_icon($identifier, $component);
$icon->diag_strings();
if ($linktext === true) {
$icon->linktext = get_string($icon->identifier, $icon->component);
} else if (!empty($linktext)) {
$icon->linktext = $linktext;
}
return $this->render($icon);
} | [
"public",
"function",
"help_icon",
"(",
"$",
"identifier",
",",
"$",
"component",
"=",
"'moodle'",
",",
"$",
"linktext",
"=",
"''",
")",
"{",
"$",
"icon",
"=",
"new",
"help_icon",
"(",
"$",
"identifier",
",",
"$",
"component",
")",
";",
"$",
"icon",
"->",
"diag_strings",
"(",
")",
";",
"if",
"(",
"$",
"linktext",
"===",
"true",
")",
"{",
"$",
"icon",
"->",
"linktext",
"=",
"get_string",
"(",
"$",
"icon",
"->",
"identifier",
",",
"$",
"icon",
"->",
"component",
")",
";",
"}",
"else",
"if",
"(",
"!",
"empty",
"(",
"$",
"linktext",
")",
")",
"{",
"$",
"icon",
"->",
"linktext",
"=",
"$",
"linktext",
";",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"icon",
")",
";",
"}"
] | Returns HTML to display a help icon.
Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_help_icon()} instead.
@param string $identifier The keyword that defines a help page
@param string $component component name
@param string|bool $linktext true means use $title as link text, string means link text value
@return string HTML fragment | [
"Returns",
"HTML",
"to",
"display",
"a",
"help",
"icon",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2334-L2343 |
212,864 | moodle/moodle | lib/outputrenderers.php | core_renderer.render_help_icon | protected function render_help_icon(help_icon $helpicon) {
$context = $helpicon->export_for_template($this);
return $this->render_from_template('core/help_icon', $context);
} | php | protected function render_help_icon(help_icon $helpicon) {
$context = $helpicon->export_for_template($this);
return $this->render_from_template('core/help_icon', $context);
} | [
"protected",
"function",
"render_help_icon",
"(",
"help_icon",
"$",
"helpicon",
")",
"{",
"$",
"context",
"=",
"$",
"helpicon",
"->",
"export_for_template",
"(",
"$",
"this",
")",
";",
"return",
"$",
"this",
"->",
"render_from_template",
"(",
"'core/help_icon'",
",",
"$",
"context",
")",
";",
"}"
] | Implementation of user image rendering.
@param help_icon $helpicon A help icon instance
@return string HTML fragment | [
"Implementation",
"of",
"user",
"image",
"rendering",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2351-L2354 |
212,865 | moodle/moodle | lib/outputrenderers.php | core_renderer.help_icon_scale | public function help_icon_scale($courseid, stdClass $scale) {
global $CFG;
$title = get_string('helpprefix2', '', $scale->name) .' ('.get_string('newwindow').')';
$icon = $this->pix_icon('help', get_string('scales'), 'moodle', array('class'=>'iconhelp'));
$scaleid = abs($scale->id);
$link = new moodle_url('/course/scales.php', array('id' => $courseid, 'list' => true, 'scaleid' => $scaleid));
$action = new popup_action('click', $link, 'ratingscale');
return html_writer::tag('span', $this->action_link($link, $icon, $action), array('class' => 'helplink'));
} | php | public function help_icon_scale($courseid, stdClass $scale) {
global $CFG;
$title = get_string('helpprefix2', '', $scale->name) .' ('.get_string('newwindow').')';
$icon = $this->pix_icon('help', get_string('scales'), 'moodle', array('class'=>'iconhelp'));
$scaleid = abs($scale->id);
$link = new moodle_url('/course/scales.php', array('id' => $courseid, 'list' => true, 'scaleid' => $scaleid));
$action = new popup_action('click', $link, 'ratingscale');
return html_writer::tag('span', $this->action_link($link, $icon, $action), array('class' => 'helplink'));
} | [
"public",
"function",
"help_icon_scale",
"(",
"$",
"courseid",
",",
"stdClass",
"$",
"scale",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"title",
"=",
"get_string",
"(",
"'helpprefix2'",
",",
"''",
",",
"$",
"scale",
"->",
"name",
")",
".",
"' ('",
".",
"get_string",
"(",
"'newwindow'",
")",
".",
"')'",
";",
"$",
"icon",
"=",
"$",
"this",
"->",
"pix_icon",
"(",
"'help'",
",",
"get_string",
"(",
"'scales'",
")",
",",
"'moodle'",
",",
"array",
"(",
"'class'",
"=>",
"'iconhelp'",
")",
")",
";",
"$",
"scaleid",
"=",
"abs",
"(",
"$",
"scale",
"->",
"id",
")",
";",
"$",
"link",
"=",
"new",
"moodle_url",
"(",
"'/course/scales.php'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"courseid",
",",
"'list'",
"=>",
"true",
",",
"'scaleid'",
"=>",
"$",
"scaleid",
")",
")",
";",
"$",
"action",
"=",
"new",
"popup_action",
"(",
"'click'",
",",
"$",
"link",
",",
"'ratingscale'",
")",
";",
"return",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"$",
"this",
"->",
"action_link",
"(",
"$",
"link",
",",
"$",
"icon",
",",
"$",
"action",
")",
",",
"array",
"(",
"'class'",
"=>",
"'helplink'",
")",
")",
";",
"}"
] | Returns HTML to display a scale help icon.
@param int $courseid
@param stdClass $scale instance
@return string HTML fragment | [
"Returns",
"HTML",
"to",
"display",
"a",
"scale",
"help",
"icon",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2363-L2376 |
212,866 | moodle/moodle | lib/outputrenderers.php | core_renderer.spacer | public function spacer(array $attributes = null, $br = false) {
$attributes = (array)$attributes;
if (empty($attributes['width'])) {
$attributes['width'] = 1;
}
if (empty($attributes['height'])) {
$attributes['height'] = 1;
}
$attributes['class'] = 'spacer';
$output = $this->pix_icon('spacer', '', 'moodle', $attributes);
if (!empty($br)) {
$output .= '<br />';
}
return $output;
} | php | public function spacer(array $attributes = null, $br = false) {
$attributes = (array)$attributes;
if (empty($attributes['width'])) {
$attributes['width'] = 1;
}
if (empty($attributes['height'])) {
$attributes['height'] = 1;
}
$attributes['class'] = 'spacer';
$output = $this->pix_icon('spacer', '', 'moodle', $attributes);
if (!empty($br)) {
$output .= '<br />';
}
return $output;
} | [
"public",
"function",
"spacer",
"(",
"array",
"$",
"attributes",
"=",
"null",
",",
"$",
"br",
"=",
"false",
")",
"{",
"$",
"attributes",
"=",
"(",
"array",
")",
"$",
"attributes",
";",
"if",
"(",
"empty",
"(",
"$",
"attributes",
"[",
"'width'",
"]",
")",
")",
"{",
"$",
"attributes",
"[",
"'width'",
"]",
"=",
"1",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"attributes",
"[",
"'height'",
"]",
")",
")",
"{",
"$",
"attributes",
"[",
"'height'",
"]",
"=",
"1",
";",
"}",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"'spacer'",
";",
"$",
"output",
"=",
"$",
"this",
"->",
"pix_icon",
"(",
"'spacer'",
",",
"''",
",",
"'moodle'",
",",
"$",
"attributes",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"br",
")",
")",
"{",
"$",
"output",
".=",
"'<br />'",
";",
"}",
"return",
"$",
"output",
";",
"}"
] | Creates and returns a spacer image with optional line break.
@param array $attributes Any HTML attributes to add to the spaced.
@param bool $br Include a BR after the spacer.... DON'T USE THIS. Don't be
laxy do it with CSS which is a much better solution.
@return string HTML fragment | [
"Creates",
"and",
"returns",
"a",
"spacer",
"image",
"with",
"optional",
"line",
"break",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2386-L2403 |
212,867 | moodle/moodle | lib/outputrenderers.php | core_renderer.user_picture | public function user_picture(stdClass $user, array $options = null) {
$userpicture = new user_picture($user);
foreach ((array)$options as $key=>$value) {
if (array_key_exists($key, $userpicture)) {
$userpicture->$key = $value;
}
}
return $this->render($userpicture);
} | php | public function user_picture(stdClass $user, array $options = null) {
$userpicture = new user_picture($user);
foreach ((array)$options as $key=>$value) {
if (array_key_exists($key, $userpicture)) {
$userpicture->$key = $value;
}
}
return $this->render($userpicture);
} | [
"public",
"function",
"user_picture",
"(",
"stdClass",
"$",
"user",
",",
"array",
"$",
"options",
"=",
"null",
")",
"{",
"$",
"userpicture",
"=",
"new",
"user_picture",
"(",
"$",
"user",
")",
";",
"foreach",
"(",
"(",
"array",
")",
"$",
"options",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"userpicture",
")",
")",
"{",
"$",
"userpicture",
"->",
"$",
"key",
"=",
"$",
"value",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"userpicture",
")",
";",
"}"
] | Returns HTML to display the specified user's avatar.
User avatar may be obtained in two ways:
<pre>
// Option 1: (shortcut for simple cases, preferred way)
// $user has come from the DB and has fields id, picture, imagealt, firstname and lastname
$OUTPUT->user_picture($user, array('popup'=>true));
// Option 2:
$userpic = new user_picture($user);
// Set properties of $userpic
$userpic->popup = true;
$OUTPUT->render($userpic);
</pre>
Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_user_picture()} instead.
@param stdClass $user Object with at least fields id, picture, imagealt, firstname, lastname
If any of these are missing, the database is queried. Avoid this
if at all possible, particularly for reports. It is very bad for performance.
@param array $options associative array with user picture options, used only if not a user_picture object,
options are:
- courseid=$this->page->course->id (course id of user profile in link)
- size=35 (size of image)
- link=true (make image clickable - the link leads to user profile)
- popup=false (open in popup)
- alttext=true (add image alt attribute)
- class = image class attribute (default 'userpicture')
- visibletoscreenreaders=true (whether to be visible to screen readers)
- includefullname=false (whether to include the user's full name together with the user picture)
- includetoken = false (whether to use a token for authentication. True for current user, int value for other user id)
@return string HTML fragment | [
"Returns",
"HTML",
"to",
"display",
"the",
"specified",
"user",
"s",
"avatar",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2440-L2448 |
212,868 | moodle/moodle | lib/outputrenderers.php | core_renderer.htmllize_file_tree | public function htmllize_file_tree($dir) {
if (empty($dir['subdirs']) and empty($dir['files'])) {
return '';
}
$result = '<ul>';
foreach ($dir['subdirs'] as $subdir) {
$result .= '<li>'.s($subdir['dirname']).' '.$this->htmllize_file_tree($subdir).'</li>';
}
foreach ($dir['files'] as $file) {
$filename = $file->get_filename();
$result .= '<li><span>'.html_writer::link($file->fileurl, $filename).'</span></li>';
}
$result .= '</ul>';
return $result;
} | php | public function htmllize_file_tree($dir) {
if (empty($dir['subdirs']) and empty($dir['files'])) {
return '';
}
$result = '<ul>';
foreach ($dir['subdirs'] as $subdir) {
$result .= '<li>'.s($subdir['dirname']).' '.$this->htmllize_file_tree($subdir).'</li>';
}
foreach ($dir['files'] as $file) {
$filename = $file->get_filename();
$result .= '<li><span>'.html_writer::link($file->fileurl, $filename).'</span></li>';
}
$result .= '</ul>';
return $result;
} | [
"public",
"function",
"htmllize_file_tree",
"(",
"$",
"dir",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"dir",
"[",
"'subdirs'",
"]",
")",
"and",
"empty",
"(",
"$",
"dir",
"[",
"'files'",
"]",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"result",
"=",
"'<ul>'",
";",
"foreach",
"(",
"$",
"dir",
"[",
"'subdirs'",
"]",
"as",
"$",
"subdir",
")",
"{",
"$",
"result",
".=",
"'<li>'",
".",
"s",
"(",
"$",
"subdir",
"[",
"'dirname'",
"]",
")",
".",
"' '",
".",
"$",
"this",
"->",
"htmllize_file_tree",
"(",
"$",
"subdir",
")",
".",
"'</li>'",
";",
"}",
"foreach",
"(",
"$",
"dir",
"[",
"'files'",
"]",
"as",
"$",
"file",
")",
"{",
"$",
"filename",
"=",
"$",
"file",
"->",
"get_filename",
"(",
")",
";",
"$",
"result",
".=",
"'<li><span>'",
".",
"html_writer",
"::",
"link",
"(",
"$",
"file",
"->",
"fileurl",
",",
"$",
"filename",
")",
".",
"'</span></li>'",
";",
"}",
"$",
"result",
".=",
"'</ul>'",
";",
"return",
"$",
"result",
";",
"}"
] | Internal implementation of file tree viewer items rendering.
@param array $dir
@return string | [
"Internal",
"implementation",
"of",
"file",
"tree",
"viewer",
"items",
"rendering",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2546-L2561 |
212,869 | moodle/moodle | lib/outputrenderers.php | core_renderer.render_file_picker | public function render_file_picker(file_picker $fp) {
global $CFG, $OUTPUT, $USER;
$options = $fp->options;
$client_id = $options->client_id;
$strsaved = get_string('filesaved', 'repository');
$straddfile = get_string('openpicker', 'repository');
$strloading = get_string('loading', 'repository');
$strdndenabled = get_string('dndenabled_inbox', 'moodle');
$strdroptoupload = get_string('droptoupload', 'moodle');
$icon_progress = $OUTPUT->pix_icon('i/loading_small', $strloading).'';
$currentfile = $options->currentfile;
if (empty($currentfile)) {
$currentfile = '';
} else {
$currentfile .= ' - ';
}
if ($options->maxbytes) {
$size = $options->maxbytes;
} else {
$size = get_max_upload_file_size();
}
if ($size == -1) {
$maxsize = '';
} else {
$maxsize = get_string('maxfilesize', 'moodle', display_size($size));
}
if ($options->buttonname) {
$buttonname = ' name="' . $options->buttonname . '"';
} else {
$buttonname = '';
}
$html = <<<EOD
<div class="filemanager-loading mdl-align" id='filepicker-loading-{$client_id}'>
$icon_progress
</div>
<div id="filepicker-wrapper-{$client_id}" class="mdl-left w-100" style="display:none">
<div>
<input type="button" class="btn btn-secondary fp-btn-choose" id="filepicker-button-{$client_id}" value="{$straddfile}"{$buttonname}/>
<span> $maxsize </span>
</div>
EOD;
if ($options->env != 'url') {
$html .= <<<EOD
<div id="file_info_{$client_id}" class="mdl-left filepicker-filelist" style="position: relative">
<div class="filepicker-filename">
<div class="filepicker-container">$currentfile<div class="dndupload-message">$strdndenabled <br/><div class="dndupload-arrow"></div></div></div>
<div class="dndupload-progressbars"></div>
</div>
<div><div class="dndupload-target">{$strdroptoupload}<br/><div class="dndupload-arrow"></div></div></div>
</div>
EOD;
}
$html .= '</div>';
return $html;
} | php | public function render_file_picker(file_picker $fp) {
global $CFG, $OUTPUT, $USER;
$options = $fp->options;
$client_id = $options->client_id;
$strsaved = get_string('filesaved', 'repository');
$straddfile = get_string('openpicker', 'repository');
$strloading = get_string('loading', 'repository');
$strdndenabled = get_string('dndenabled_inbox', 'moodle');
$strdroptoupload = get_string('droptoupload', 'moodle');
$icon_progress = $OUTPUT->pix_icon('i/loading_small', $strloading).'';
$currentfile = $options->currentfile;
if (empty($currentfile)) {
$currentfile = '';
} else {
$currentfile .= ' - ';
}
if ($options->maxbytes) {
$size = $options->maxbytes;
} else {
$size = get_max_upload_file_size();
}
if ($size == -1) {
$maxsize = '';
} else {
$maxsize = get_string('maxfilesize', 'moodle', display_size($size));
}
if ($options->buttonname) {
$buttonname = ' name="' . $options->buttonname . '"';
} else {
$buttonname = '';
}
$html = <<<EOD
<div class="filemanager-loading mdl-align" id='filepicker-loading-{$client_id}'>
$icon_progress
</div>
<div id="filepicker-wrapper-{$client_id}" class="mdl-left w-100" style="display:none">
<div>
<input type="button" class="btn btn-secondary fp-btn-choose" id="filepicker-button-{$client_id}" value="{$straddfile}"{$buttonname}/>
<span> $maxsize </span>
</div>
EOD;
if ($options->env != 'url') {
$html .= <<<EOD
<div id="file_info_{$client_id}" class="mdl-left filepicker-filelist" style="position: relative">
<div class="filepicker-filename">
<div class="filepicker-container">$currentfile<div class="dndupload-message">$strdndenabled <br/><div class="dndupload-arrow"></div></div></div>
<div class="dndupload-progressbars"></div>
</div>
<div><div class="dndupload-target">{$strdroptoupload}<br/><div class="dndupload-arrow"></div></div></div>
</div>
EOD;
}
$html .= '</div>';
return $html;
} | [
"public",
"function",
"render_file_picker",
"(",
"file_picker",
"$",
"fp",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"OUTPUT",
",",
"$",
"USER",
";",
"$",
"options",
"=",
"$",
"fp",
"->",
"options",
";",
"$",
"client_id",
"=",
"$",
"options",
"->",
"client_id",
";",
"$",
"strsaved",
"=",
"get_string",
"(",
"'filesaved'",
",",
"'repository'",
")",
";",
"$",
"straddfile",
"=",
"get_string",
"(",
"'openpicker'",
",",
"'repository'",
")",
";",
"$",
"strloading",
"=",
"get_string",
"(",
"'loading'",
",",
"'repository'",
")",
";",
"$",
"strdndenabled",
"=",
"get_string",
"(",
"'dndenabled_inbox'",
",",
"'moodle'",
")",
";",
"$",
"strdroptoupload",
"=",
"get_string",
"(",
"'droptoupload'",
",",
"'moodle'",
")",
";",
"$",
"icon_progress",
"=",
"$",
"OUTPUT",
"->",
"pix_icon",
"(",
"'i/loading_small'",
",",
"$",
"strloading",
")",
".",
"''",
";",
"$",
"currentfile",
"=",
"$",
"options",
"->",
"currentfile",
";",
"if",
"(",
"empty",
"(",
"$",
"currentfile",
")",
")",
"{",
"$",
"currentfile",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"currentfile",
".=",
"' - '",
";",
"}",
"if",
"(",
"$",
"options",
"->",
"maxbytes",
")",
"{",
"$",
"size",
"=",
"$",
"options",
"->",
"maxbytes",
";",
"}",
"else",
"{",
"$",
"size",
"=",
"get_max_upload_file_size",
"(",
")",
";",
"}",
"if",
"(",
"$",
"size",
"==",
"-",
"1",
")",
"{",
"$",
"maxsize",
"=",
"''",
";",
"}",
"else",
"{",
"$",
"maxsize",
"=",
"get_string",
"(",
"'maxfilesize'",
",",
"'moodle'",
",",
"display_size",
"(",
"$",
"size",
")",
")",
";",
"}",
"if",
"(",
"$",
"options",
"->",
"buttonname",
")",
"{",
"$",
"buttonname",
"=",
"' name=\"'",
".",
"$",
"options",
"->",
"buttonname",
".",
"'\"'",
";",
"}",
"else",
"{",
"$",
"buttonname",
"=",
"''",
";",
"}",
"$",
"html",
"=",
" <<<EOD\n<div class=\"filemanager-loading mdl-align\" id='filepicker-loading-{$client_id}'>\n$icon_progress\n</div>\n<div id=\"filepicker-wrapper-{$client_id}\" class=\"mdl-left w-100\" style=\"display:none\">\n <div>\n <input type=\"button\" class=\"btn btn-secondary fp-btn-choose\" id=\"filepicker-button-{$client_id}\" value=\"{$straddfile}\"{$buttonname}/>\n <span> $maxsize </span>\n </div>\nEOD",
";",
"if",
"(",
"$",
"options",
"->",
"env",
"!=",
"'url'",
")",
"{",
"$",
"html",
".=",
" <<<EOD\n <div id=\"file_info_{$client_id}\" class=\"mdl-left filepicker-filelist\" style=\"position: relative\">\n <div class=\"filepicker-filename\">\n <div class=\"filepicker-container\">$currentfile<div class=\"dndupload-message\">$strdndenabled <br/><div class=\"dndupload-arrow\"></div></div></div>\n <div class=\"dndupload-progressbars\"></div>\n </div>\n <div><div class=\"dndupload-target\">{$strdroptoupload}<br/><div class=\"dndupload-arrow\"></div></div></div>\n </div>\nEOD",
";",
"}",
"$",
"html",
".=",
"'</div>'",
";",
"return",
"$",
"html",
";",
"}"
] | Internal implementation of file picker rendering.
@param file_picker $fp
@return string | [
"Internal",
"implementation",
"of",
"file",
"picker",
"rendering",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2594-L2649 |
212,870 | moodle/moodle | lib/outputrenderers.php | core_renderer.close_window_button | public function close_window_button($text='') {
if (empty($text)) {
$text = get_string('closewindow');
}
$button = new single_button(new moodle_url('#'), $text, 'get');
$button->add_action(new component_action('click', 'close_window'));
return $this->container($this->render($button), 'closewindow');
} | php | public function close_window_button($text='') {
if (empty($text)) {
$text = get_string('closewindow');
}
$button = new single_button(new moodle_url('#'), $text, 'get');
$button->add_action(new component_action('click', 'close_window'));
return $this->container($this->render($button), 'closewindow');
} | [
"public",
"function",
"close_window_button",
"(",
"$",
"text",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"text",
")",
")",
"{",
"$",
"text",
"=",
"get_string",
"(",
"'closewindow'",
")",
";",
"}",
"$",
"button",
"=",
"new",
"single_button",
"(",
"new",
"moodle_url",
"(",
"'#'",
")",
",",
"$",
"text",
",",
"'get'",
")",
";",
"$",
"button",
"->",
"add_action",
"(",
"new",
"component_action",
"(",
"'click'",
",",
"'close_window'",
")",
")",
";",
"return",
"$",
"this",
"->",
"container",
"(",
"$",
"this",
"->",
"render",
"(",
"$",
"button",
")",
",",
"'closewindow'",
")",
";",
"}"
] | Returns HTML to display a simple button to close a window
@param string $text The lang string for the button's label (already output from get_string())
@return string html fragment | [
"Returns",
"HTML",
"to",
"display",
"a",
"simple",
"button",
"to",
"close",
"a",
"window"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2686-L2694 |
212,871 | moodle/moodle | lib/outputrenderers.php | core_renderer.continue_button | public function continue_button($url) {
if (!($url instanceof moodle_url)) {
$url = new moodle_url($url);
}
$button = new single_button($url, get_string('continue'), 'get', true);
$button->class = 'continuebutton';
return $this->render($button);
} | php | public function continue_button($url) {
if (!($url instanceof moodle_url)) {
$url = new moodle_url($url);
}
$button = new single_button($url, get_string('continue'), 'get', true);
$button->class = 'continuebutton';
return $this->render($button);
} | [
"public",
"function",
"continue_button",
"(",
"$",
"url",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"url",
"instanceof",
"moodle_url",
")",
")",
"{",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"$",
"url",
")",
";",
"}",
"$",
"button",
"=",
"new",
"single_button",
"(",
"$",
"url",
",",
"get_string",
"(",
"'continue'",
")",
",",
"'get'",
",",
"true",
")",
";",
"$",
"button",
"->",
"class",
"=",
"'continuebutton'",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"button",
")",
";",
"}"
] | Returns HTML to display a continue button that goes to a particular URL.
@param string|moodle_url $url The url the button goes to.
@return string the HTML to output. | [
"Returns",
"HTML",
"to",
"display",
"a",
"continue",
"button",
"that",
"goes",
"to",
"a",
"particular",
"URL",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2919-L2927 |
212,872 | moodle/moodle | lib/outputrenderers.php | core_renderer.render_paging_bar | protected function render_paging_bar(paging_bar $pagingbar) {
// Any more than 10 is not usable and causes weird wrapping of the pagination.
$pagingbar->maxdisplay = 10;
return $this->render_from_template('core/paging_bar', $pagingbar->export_for_template($this));
} | php | protected function render_paging_bar(paging_bar $pagingbar) {
// Any more than 10 is not usable and causes weird wrapping of the pagination.
$pagingbar->maxdisplay = 10;
return $this->render_from_template('core/paging_bar', $pagingbar->export_for_template($this));
} | [
"protected",
"function",
"render_paging_bar",
"(",
"paging_bar",
"$",
"pagingbar",
")",
"{",
"// Any more than 10 is not usable and causes weird wrapping of the pagination.",
"$",
"pagingbar",
"->",
"maxdisplay",
"=",
"10",
";",
"return",
"$",
"this",
"->",
"render_from_template",
"(",
"'core/paging_bar'",
",",
"$",
"pagingbar",
"->",
"export_for_template",
"(",
"$",
"this",
")",
")",
";",
"}"
] | Returns HTML to display the paging bar.
@param paging_bar $pagingbar
@return string the HTML to output. | [
"Returns",
"HTML",
"to",
"display",
"the",
"paging",
"bar",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L2953-L2957 |
212,873 | moodle/moodle | lib/outputrenderers.php | core_renderer.heading | public function heading($text, $level = 2, $classes = null, $id = null) {
$level = (integer) $level;
if ($level < 1 or $level > 6) {
throw new coding_exception('Heading level must be an integer between 1 and 6.');
}
return html_writer::tag('h' . $level, $text, array('id' => $id, 'class' => renderer_base::prepare_classes($classes)));
} | php | public function heading($text, $level = 2, $classes = null, $id = null) {
$level = (integer) $level;
if ($level < 1 or $level > 6) {
throw new coding_exception('Heading level must be an integer between 1 and 6.');
}
return html_writer::tag('h' . $level, $text, array('id' => $id, 'class' => renderer_base::prepare_classes($classes)));
} | [
"public",
"function",
"heading",
"(",
"$",
"text",
",",
"$",
"level",
"=",
"2",
",",
"$",
"classes",
"=",
"null",
",",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"level",
"=",
"(",
"integer",
")",
"$",
"level",
";",
"if",
"(",
"$",
"level",
"<",
"1",
"or",
"$",
"level",
">",
"6",
")",
"{",
"throw",
"new",
"coding_exception",
"(",
"'Heading level must be an integer between 1 and 6.'",
")",
";",
"}",
"return",
"html_writer",
"::",
"tag",
"(",
"'h'",
".",
"$",
"level",
",",
"$",
"text",
",",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
"'class'",
"=>",
"renderer_base",
"::",
"prepare_classes",
"(",
"$",
"classes",
")",
")",
")",
";",
"}"
] | Outputs a heading
@param string $text The text of the heading
@param int $level The level of importance of the heading. Defaulting to 2
@param string $classes A space-separated list of CSS classes. Defaulting to null
@param string $id An optional ID
@return string the HTML to output. | [
"Outputs",
"a",
"heading"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3004-L3010 |
212,874 | moodle/moodle | lib/outputrenderers.php | core_renderer.box | public function box($contents, $classes = 'generalbox', $id = null, $attributes = array()) {
return $this->box_start($classes, $id, $attributes) . $contents . $this->box_end();
} | php | public function box($contents, $classes = 'generalbox', $id = null, $attributes = array()) {
return $this->box_start($classes, $id, $attributes) . $contents . $this->box_end();
} | [
"public",
"function",
"box",
"(",
"$",
"contents",
",",
"$",
"classes",
"=",
"'generalbox'",
",",
"$",
"id",
"=",
"null",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"return",
"$",
"this",
"->",
"box_start",
"(",
"$",
"classes",
",",
"$",
"id",
",",
"$",
"attributes",
")",
".",
"$",
"contents",
".",
"$",
"this",
"->",
"box_end",
"(",
")",
";",
"}"
] | Outputs a box.
@param string $contents The contents of the box
@param string $classes A space-separated list of CSS classes
@param string $id An optional ID
@param array $attributes An array of other attributes to give the box.
@return string the HTML to output. | [
"Outputs",
"a",
"box",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3021-L3023 |
212,875 | moodle/moodle | lib/outputrenderers.php | core_renderer.box_start | public function box_start($classes = 'generalbox', $id = null, $attributes = array()) {
$this->opencontainers->push('box', html_writer::end_tag('div'));
$attributes['id'] = $id;
$attributes['class'] = 'box py-3 ' . renderer_base::prepare_classes($classes);
return html_writer::start_tag('div', $attributes);
} | php | public function box_start($classes = 'generalbox', $id = null, $attributes = array()) {
$this->opencontainers->push('box', html_writer::end_tag('div'));
$attributes['id'] = $id;
$attributes['class'] = 'box py-3 ' . renderer_base::prepare_classes($classes);
return html_writer::start_tag('div', $attributes);
} | [
"public",
"function",
"box_start",
"(",
"$",
"classes",
"=",
"'generalbox'",
",",
"$",
"id",
"=",
"null",
",",
"$",
"attributes",
"=",
"array",
"(",
")",
")",
"{",
"$",
"this",
"->",
"opencontainers",
"->",
"push",
"(",
"'box'",
",",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
")",
";",
"$",
"attributes",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"'box py-3 '",
".",
"renderer_base",
"::",
"prepare_classes",
"(",
"$",
"classes",
")",
";",
"return",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"$",
"attributes",
")",
";",
"}"
] | Outputs the opening section of a box.
@param string $classes A space-separated list of CSS classes
@param string $id An optional ID
@param array $attributes An array of other attributes to give the box.
@return string the HTML to output. | [
"Outputs",
"the",
"opening",
"section",
"of",
"a",
"box",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3033-L3038 |
212,876 | moodle/moodle | lib/outputrenderers.php | core_renderer.container | public function container($contents, $classes = null, $id = null) {
return $this->container_start($classes, $id) . $contents . $this->container_end();
} | php | public function container($contents, $classes = null, $id = null) {
return $this->container_start($classes, $id) . $contents . $this->container_end();
} | [
"public",
"function",
"container",
"(",
"$",
"contents",
",",
"$",
"classes",
"=",
"null",
",",
"$",
"id",
"=",
"null",
")",
"{",
"return",
"$",
"this",
"->",
"container_start",
"(",
"$",
"classes",
",",
"$",
"id",
")",
".",
"$",
"contents",
".",
"$",
"this",
"->",
"container_end",
"(",
")",
";",
"}"
] | Outputs a container.
@param string $contents The contents of the box
@param string $classes A space-separated list of CSS classes
@param string $id An optional ID
@return string the HTML to output. | [
"Outputs",
"a",
"container",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3057-L3059 |
212,877 | moodle/moodle | lib/outputrenderers.php | core_renderer.container_start | public function container_start($classes = null, $id = null) {
$this->opencontainers->push('container', html_writer::end_tag('div'));
return html_writer::start_tag('div', array('id' => $id,
'class' => renderer_base::prepare_classes($classes)));
} | php | public function container_start($classes = null, $id = null) {
$this->opencontainers->push('container', html_writer::end_tag('div'));
return html_writer::start_tag('div', array('id' => $id,
'class' => renderer_base::prepare_classes($classes)));
} | [
"public",
"function",
"container_start",
"(",
"$",
"classes",
"=",
"null",
",",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"opencontainers",
"->",
"push",
"(",
"'container'",
",",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
")",
";",
"return",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"id",
",",
"'class'",
"=>",
"renderer_base",
"::",
"prepare_classes",
"(",
"$",
"classes",
")",
")",
")",
";",
"}"
] | Outputs the opening section of a container.
@param string $classes A space-separated list of CSS classes
@param string $id An optional ID
@return string the HTML to output. | [
"Outputs",
"the",
"opening",
"section",
"of",
"a",
"container",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3068-L3072 |
212,878 | moodle/moodle | lib/outputrenderers.php | core_renderer.tree_block_contents | public function tree_block_contents($items, $attrs = array()) {
// exit if empty, we don't want an empty ul element
if (empty($items)) {
return '';
}
// array of nested li elements
$lis = array();
foreach ($items as $item) {
// this applies to the li item which contains all child lists too
$content = $item->content($this);
$liclasses = array($item->get_css_type());
if (!$item->forceopen || (!$item->forceopen && $item->collapse) || ($item->children->count()==0 && $item->nodetype==navigation_node::NODETYPE_BRANCH)) {
$liclasses[] = 'collapsed';
}
if ($item->isactive === true) {
$liclasses[] = 'current_branch';
}
$liattr = array('class'=>join(' ',$liclasses));
// class attribute on the div item which only contains the item content
$divclasses = array('tree_item');
if ($item->children->count()>0 || $item->nodetype==navigation_node::NODETYPE_BRANCH) {
$divclasses[] = 'branch';
} else {
$divclasses[] = 'leaf';
}
if (!empty($item->classes) && count($item->classes)>0) {
$divclasses[] = join(' ', $item->classes);
}
$divattr = array('class'=>join(' ', $divclasses));
if (!empty($item->id)) {
$divattr['id'] = $item->id;
}
$content = html_writer::tag('p', $content, $divattr) . $this->tree_block_contents($item->children);
if (!empty($item->preceedwithhr) && $item->preceedwithhr===true) {
$content = html_writer::empty_tag('hr') . $content;
}
$content = html_writer::tag('li', $content, $liattr);
$lis[] = $content;
}
return html_writer::tag('ul', implode("\n", $lis), $attrs);
} | php | public function tree_block_contents($items, $attrs = array()) {
// exit if empty, we don't want an empty ul element
if (empty($items)) {
return '';
}
// array of nested li elements
$lis = array();
foreach ($items as $item) {
// this applies to the li item which contains all child lists too
$content = $item->content($this);
$liclasses = array($item->get_css_type());
if (!$item->forceopen || (!$item->forceopen && $item->collapse) || ($item->children->count()==0 && $item->nodetype==navigation_node::NODETYPE_BRANCH)) {
$liclasses[] = 'collapsed';
}
if ($item->isactive === true) {
$liclasses[] = 'current_branch';
}
$liattr = array('class'=>join(' ',$liclasses));
// class attribute on the div item which only contains the item content
$divclasses = array('tree_item');
if ($item->children->count()>0 || $item->nodetype==navigation_node::NODETYPE_BRANCH) {
$divclasses[] = 'branch';
} else {
$divclasses[] = 'leaf';
}
if (!empty($item->classes) && count($item->classes)>0) {
$divclasses[] = join(' ', $item->classes);
}
$divattr = array('class'=>join(' ', $divclasses));
if (!empty($item->id)) {
$divattr['id'] = $item->id;
}
$content = html_writer::tag('p', $content, $divattr) . $this->tree_block_contents($item->children);
if (!empty($item->preceedwithhr) && $item->preceedwithhr===true) {
$content = html_writer::empty_tag('hr') . $content;
}
$content = html_writer::tag('li', $content, $liattr);
$lis[] = $content;
}
return html_writer::tag('ul', implode("\n", $lis), $attrs);
} | [
"public",
"function",
"tree_block_contents",
"(",
"$",
"items",
",",
"$",
"attrs",
"=",
"array",
"(",
")",
")",
"{",
"// exit if empty, we don't want an empty ul element",
"if",
"(",
"empty",
"(",
"$",
"items",
")",
")",
"{",
"return",
"''",
";",
"}",
"// array of nested li elements",
"$",
"lis",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"items",
"as",
"$",
"item",
")",
"{",
"// this applies to the li item which contains all child lists too",
"$",
"content",
"=",
"$",
"item",
"->",
"content",
"(",
"$",
"this",
")",
";",
"$",
"liclasses",
"=",
"array",
"(",
"$",
"item",
"->",
"get_css_type",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"item",
"->",
"forceopen",
"||",
"(",
"!",
"$",
"item",
"->",
"forceopen",
"&&",
"$",
"item",
"->",
"collapse",
")",
"||",
"(",
"$",
"item",
"->",
"children",
"->",
"count",
"(",
")",
"==",
"0",
"&&",
"$",
"item",
"->",
"nodetype",
"==",
"navigation_node",
"::",
"NODETYPE_BRANCH",
")",
")",
"{",
"$",
"liclasses",
"[",
"]",
"=",
"'collapsed'",
";",
"}",
"if",
"(",
"$",
"item",
"->",
"isactive",
"===",
"true",
")",
"{",
"$",
"liclasses",
"[",
"]",
"=",
"'current_branch'",
";",
"}",
"$",
"liattr",
"=",
"array",
"(",
"'class'",
"=>",
"join",
"(",
"' '",
",",
"$",
"liclasses",
")",
")",
";",
"// class attribute on the div item which only contains the item content",
"$",
"divclasses",
"=",
"array",
"(",
"'tree_item'",
")",
";",
"if",
"(",
"$",
"item",
"->",
"children",
"->",
"count",
"(",
")",
">",
"0",
"||",
"$",
"item",
"->",
"nodetype",
"==",
"navigation_node",
"::",
"NODETYPE_BRANCH",
")",
"{",
"$",
"divclasses",
"[",
"]",
"=",
"'branch'",
";",
"}",
"else",
"{",
"$",
"divclasses",
"[",
"]",
"=",
"'leaf'",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"->",
"classes",
")",
"&&",
"count",
"(",
"$",
"item",
"->",
"classes",
")",
">",
"0",
")",
"{",
"$",
"divclasses",
"[",
"]",
"=",
"join",
"(",
"' '",
",",
"$",
"item",
"->",
"classes",
")",
";",
"}",
"$",
"divattr",
"=",
"array",
"(",
"'class'",
"=>",
"join",
"(",
"' '",
",",
"$",
"divclasses",
")",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"->",
"id",
")",
")",
"{",
"$",
"divattr",
"[",
"'id'",
"]",
"=",
"$",
"item",
"->",
"id",
";",
"}",
"$",
"content",
"=",
"html_writer",
"::",
"tag",
"(",
"'p'",
",",
"$",
"content",
",",
"$",
"divattr",
")",
".",
"$",
"this",
"->",
"tree_block_contents",
"(",
"$",
"item",
"->",
"children",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"item",
"->",
"preceedwithhr",
")",
"&&",
"$",
"item",
"->",
"preceedwithhr",
"===",
"true",
")",
"{",
"$",
"content",
"=",
"html_writer",
"::",
"empty_tag",
"(",
"'hr'",
")",
".",
"$",
"content",
";",
"}",
"$",
"content",
"=",
"html_writer",
"::",
"tag",
"(",
"'li'",
",",
"$",
"content",
",",
"$",
"liattr",
")",
";",
"$",
"lis",
"[",
"]",
"=",
"$",
"content",
";",
"}",
"return",
"html_writer",
"::",
"tag",
"(",
"'ul'",
",",
"implode",
"(",
"\"\\n\"",
",",
"$",
"lis",
")",
",",
"$",
"attrs",
")",
";",
"}"
] | Make nested HTML lists out of the items
The resulting list will look something like this:
<pre>
<<ul>>
<<li>><div class='tree_item parent'>(item contents)</div>
<<ul>
<<li>><div class='tree_item'>(item contents)</div><</li>>
<</ul>>
<</li>>
<</ul>>
</pre>
@param array $items
@param array $attrs html attributes passed to the top ofs the list
@return string HTML | [
"Make",
"nested",
"HTML",
"lists",
"out",
"of",
"the",
"items"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3102-L3142 |
212,879 | moodle/moodle | lib/outputrenderers.php | core_renderer.search_box | public function search_box($id = false) {
global $CFG;
// Accessing $CFG directly as using \core_search::is_global_search_enabled would
// result in an extra included file for each site, even the ones where global search
// is disabled.
if (empty($CFG->enableglobalsearch) || !has_capability('moodle/search:query', context_system::instance())) {
return '';
}
if ($id == false) {
$id = uniqid();
} else {
// Needs to be cleaned, we use it for the input id.
$id = clean_param($id, PARAM_ALPHANUMEXT);
}
// JS to animate the form.
$this->page->requires->js_call_amd('core/search-input', 'init', array($id));
$searchicon = html_writer::tag('div', $this->pix_icon('a/search', get_string('search', 'search'), 'moodle'),
array('role' => 'button', 'tabindex' => 0));
$formattrs = array('class' => 'search-input-form', 'action' => $CFG->wwwroot . '/search/index.php');
$inputattrs = array('type' => 'text', 'name' => 'q', 'placeholder' => get_string('search', 'search'),
'size' => 13, 'tabindex' => -1, 'id' => 'id_q_' . $id, 'class' => 'form-control');
$contents = html_writer::tag('label', get_string('enteryoursearchquery', 'search'),
array('for' => 'id_q_' . $id, 'class' => 'accesshide')) . html_writer::tag('input', '', $inputattrs);
if ($this->page->context && $this->page->context->contextlevel !== CONTEXT_SYSTEM) {
$contents .= html_writer::empty_tag('input', ['type' => 'hidden',
'name' => 'context', 'value' => $this->page->context->id]);
}
$searchinput = html_writer::tag('form', $contents, $formattrs);
return html_writer::tag('div', $searchicon . $searchinput, array('class' => 'search-input-wrapper nav-link', 'id' => $id));
} | php | public function search_box($id = false) {
global $CFG;
// Accessing $CFG directly as using \core_search::is_global_search_enabled would
// result in an extra included file for each site, even the ones where global search
// is disabled.
if (empty($CFG->enableglobalsearch) || !has_capability('moodle/search:query', context_system::instance())) {
return '';
}
if ($id == false) {
$id = uniqid();
} else {
// Needs to be cleaned, we use it for the input id.
$id = clean_param($id, PARAM_ALPHANUMEXT);
}
// JS to animate the form.
$this->page->requires->js_call_amd('core/search-input', 'init', array($id));
$searchicon = html_writer::tag('div', $this->pix_icon('a/search', get_string('search', 'search'), 'moodle'),
array('role' => 'button', 'tabindex' => 0));
$formattrs = array('class' => 'search-input-form', 'action' => $CFG->wwwroot . '/search/index.php');
$inputattrs = array('type' => 'text', 'name' => 'q', 'placeholder' => get_string('search', 'search'),
'size' => 13, 'tabindex' => -1, 'id' => 'id_q_' . $id, 'class' => 'form-control');
$contents = html_writer::tag('label', get_string('enteryoursearchquery', 'search'),
array('for' => 'id_q_' . $id, 'class' => 'accesshide')) . html_writer::tag('input', '', $inputattrs);
if ($this->page->context && $this->page->context->contextlevel !== CONTEXT_SYSTEM) {
$contents .= html_writer::empty_tag('input', ['type' => 'hidden',
'name' => 'context', 'value' => $this->page->context->id]);
}
$searchinput = html_writer::tag('form', $contents, $formattrs);
return html_writer::tag('div', $searchicon . $searchinput, array('class' => 'search-input-wrapper nav-link', 'id' => $id));
} | [
"public",
"function",
"search_box",
"(",
"$",
"id",
"=",
"false",
")",
"{",
"global",
"$",
"CFG",
";",
"// Accessing $CFG directly as using \\core_search::is_global_search_enabled would",
"// result in an extra included file for each site, even the ones where global search",
"// is disabled.",
"if",
"(",
"empty",
"(",
"$",
"CFG",
"->",
"enableglobalsearch",
")",
"||",
"!",
"has_capability",
"(",
"'moodle/search:query'",
",",
"context_system",
"::",
"instance",
"(",
")",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"$",
"id",
"==",
"false",
")",
"{",
"$",
"id",
"=",
"uniqid",
"(",
")",
";",
"}",
"else",
"{",
"// Needs to be cleaned, we use it for the input id.",
"$",
"id",
"=",
"clean_param",
"(",
"$",
"id",
",",
"PARAM_ALPHANUMEXT",
")",
";",
"}",
"// JS to animate the form.",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"js_call_amd",
"(",
"'core/search-input'",
",",
"'init'",
",",
"array",
"(",
"$",
"id",
")",
")",
";",
"$",
"searchicon",
"=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"this",
"->",
"pix_icon",
"(",
"'a/search'",
",",
"get_string",
"(",
"'search'",
",",
"'search'",
")",
",",
"'moodle'",
")",
",",
"array",
"(",
"'role'",
"=>",
"'button'",
",",
"'tabindex'",
"=>",
"0",
")",
")",
";",
"$",
"formattrs",
"=",
"array",
"(",
"'class'",
"=>",
"'search-input-form'",
",",
"'action'",
"=>",
"$",
"CFG",
"->",
"wwwroot",
".",
"'/search/index.php'",
")",
";",
"$",
"inputattrs",
"=",
"array",
"(",
"'type'",
"=>",
"'text'",
",",
"'name'",
"=>",
"'q'",
",",
"'placeholder'",
"=>",
"get_string",
"(",
"'search'",
",",
"'search'",
")",
",",
"'size'",
"=>",
"13",
",",
"'tabindex'",
"=>",
"-",
"1",
",",
"'id'",
"=>",
"'id_q_'",
".",
"$",
"id",
",",
"'class'",
"=>",
"'form-control'",
")",
";",
"$",
"contents",
"=",
"html_writer",
"::",
"tag",
"(",
"'label'",
",",
"get_string",
"(",
"'enteryoursearchquery'",
",",
"'search'",
")",
",",
"array",
"(",
"'for'",
"=>",
"'id_q_'",
".",
"$",
"id",
",",
"'class'",
"=>",
"'accesshide'",
")",
")",
".",
"html_writer",
"::",
"tag",
"(",
"'input'",
",",
"''",
",",
"$",
"inputattrs",
")",
";",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"context",
"&&",
"$",
"this",
"->",
"page",
"->",
"context",
"->",
"contextlevel",
"!==",
"CONTEXT_SYSTEM",
")",
"{",
"$",
"contents",
".=",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"[",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"'context'",
",",
"'value'",
"=>",
"$",
"this",
"->",
"page",
"->",
"context",
"->",
"id",
"]",
")",
";",
"}",
"$",
"searchinput",
"=",
"html_writer",
"::",
"tag",
"(",
"'form'",
",",
"$",
"contents",
",",
"$",
"formattrs",
")",
";",
"return",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"searchicon",
".",
"$",
"searchinput",
",",
"array",
"(",
"'class'",
"=>",
"'search-input-wrapper nav-link'",
",",
"'id'",
"=>",
"$",
"id",
")",
")",
";",
"}"
] | Returns a search box.
@param string $id The search box wrapper div id, defaults to an autogenerated one.
@return string HTML with the search form hidden by default. | [
"Returns",
"a",
"search",
"box",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3150-L3185 |
212,880 | moodle/moodle | lib/outputrenderers.php | core_renderer.navbar_plugin_output | public function navbar_plugin_output() {
$output = '';
// Give subsystems an opportunity to inject extra html content. The callback
// must always return a string containing valid html.
foreach (\core_component::get_core_subsystems() as $name => $path) {
if ($path) {
$output .= component_callback($name, 'render_navbar_output', [$this], '');
}
}
if ($pluginsfunction = get_plugins_with_function('render_navbar_output')) {
foreach ($pluginsfunction as $plugintype => $plugins) {
foreach ($plugins as $pluginfunction) {
$output .= $pluginfunction($this);
}
}
}
return $output;
} | php | public function navbar_plugin_output() {
$output = '';
// Give subsystems an opportunity to inject extra html content. The callback
// must always return a string containing valid html.
foreach (\core_component::get_core_subsystems() as $name => $path) {
if ($path) {
$output .= component_callback($name, 'render_navbar_output', [$this], '');
}
}
if ($pluginsfunction = get_plugins_with_function('render_navbar_output')) {
foreach ($pluginsfunction as $plugintype => $plugins) {
foreach ($plugins as $pluginfunction) {
$output .= $pluginfunction($this);
}
}
}
return $output;
} | [
"public",
"function",
"navbar_plugin_output",
"(",
")",
"{",
"$",
"output",
"=",
"''",
";",
"// Give subsystems an opportunity to inject extra html content. The callback",
"// must always return a string containing valid html.",
"foreach",
"(",
"\\",
"core_component",
"::",
"get_core_subsystems",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"path",
")",
"{",
"if",
"(",
"$",
"path",
")",
"{",
"$",
"output",
".=",
"component_callback",
"(",
"$",
"name",
",",
"'render_navbar_output'",
",",
"[",
"$",
"this",
"]",
",",
"''",
")",
";",
"}",
"}",
"if",
"(",
"$",
"pluginsfunction",
"=",
"get_plugins_with_function",
"(",
"'render_navbar_output'",
")",
")",
"{",
"foreach",
"(",
"$",
"pluginsfunction",
"as",
"$",
"plugintype",
"=>",
"$",
"plugins",
")",
"{",
"foreach",
"(",
"$",
"plugins",
"as",
"$",
"pluginfunction",
")",
"{",
"$",
"output",
".=",
"$",
"pluginfunction",
"(",
"$",
"this",
")",
";",
"}",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] | Allow plugins to provide some content to be rendered in the navbar.
The plugin must define a PLUGIN_render_navbar_output function that returns
the HTML they wish to add to the navbar.
@return string HTML for the navbar | [
"Allow",
"plugins",
"to",
"provide",
"some",
"content",
"to",
"be",
"rendered",
"in",
"the",
"navbar",
".",
"The",
"plugin",
"must",
"define",
"a",
"PLUGIN_render_navbar_output",
"function",
"that",
"returns",
"the",
"HTML",
"they",
"wish",
"to",
"add",
"to",
"the",
"navbar",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3194-L3214 |
212,881 | moodle/moodle | lib/outputrenderers.php | core_renderer.render_breadcrumb_navigation_node | protected function render_breadcrumb_navigation_node(breadcrumb_navigation_node $item) {
if ($item->action instanceof moodle_url) {
$content = $item->get_content();
$title = $item->get_title();
$attributes = array();
$attributes['itemprop'] = 'url';
if ($title !== '') {
$attributes['title'] = $title;
}
if ($item->hidden) {
$attributes['class'] = 'dimmed_text';
}
if ($item->is_last()) {
$attributes['aria-current'] = 'page';
}
$content = html_writer::tag('span', $content, array('itemprop' => 'title'));
$content = html_writer::link($item->action, $content, $attributes);
$attributes = array();
$attributes['itemscope'] = '';
$attributes['itemtype'] = 'http://data-vocabulary.org/Breadcrumb';
$content = html_writer::tag('span', $content, $attributes);
} else {
$content = $this->render_navigation_node($item);
}
return $content;
} | php | protected function render_breadcrumb_navigation_node(breadcrumb_navigation_node $item) {
if ($item->action instanceof moodle_url) {
$content = $item->get_content();
$title = $item->get_title();
$attributes = array();
$attributes['itemprop'] = 'url';
if ($title !== '') {
$attributes['title'] = $title;
}
if ($item->hidden) {
$attributes['class'] = 'dimmed_text';
}
if ($item->is_last()) {
$attributes['aria-current'] = 'page';
}
$content = html_writer::tag('span', $content, array('itemprop' => 'title'));
$content = html_writer::link($item->action, $content, $attributes);
$attributes = array();
$attributes['itemscope'] = '';
$attributes['itemtype'] = 'http://data-vocabulary.org/Breadcrumb';
$content = html_writer::tag('span', $content, $attributes);
} else {
$content = $this->render_navigation_node($item);
}
return $content;
} | [
"protected",
"function",
"render_breadcrumb_navigation_node",
"(",
"breadcrumb_navigation_node",
"$",
"item",
")",
"{",
"if",
"(",
"$",
"item",
"->",
"action",
"instanceof",
"moodle_url",
")",
"{",
"$",
"content",
"=",
"$",
"item",
"->",
"get_content",
"(",
")",
";",
"$",
"title",
"=",
"$",
"item",
"->",
"get_title",
"(",
")",
";",
"$",
"attributes",
"=",
"array",
"(",
")",
";",
"$",
"attributes",
"[",
"'itemprop'",
"]",
"=",
"'url'",
";",
"if",
"(",
"$",
"title",
"!==",
"''",
")",
"{",
"$",
"attributes",
"[",
"'title'",
"]",
"=",
"$",
"title",
";",
"}",
"if",
"(",
"$",
"item",
"->",
"hidden",
")",
"{",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"'dimmed_text'",
";",
"}",
"if",
"(",
"$",
"item",
"->",
"is_last",
"(",
")",
")",
"{",
"$",
"attributes",
"[",
"'aria-current'",
"]",
"=",
"'page'",
";",
"}",
"$",
"content",
"=",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"$",
"content",
",",
"array",
"(",
"'itemprop'",
"=>",
"'title'",
")",
")",
";",
"$",
"content",
"=",
"html_writer",
"::",
"link",
"(",
"$",
"item",
"->",
"action",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"$",
"attributes",
"=",
"array",
"(",
")",
";",
"$",
"attributes",
"[",
"'itemscope'",
"]",
"=",
"''",
";",
"$",
"attributes",
"[",
"'itemtype'",
"]",
"=",
"'http://data-vocabulary.org/Breadcrumb'",
";",
"$",
"content",
"=",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"}",
"else",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"render_navigation_node",
"(",
"$",
"item",
")",
";",
"}",
"return",
"$",
"content",
";",
"}"
] | Renders a breadcrumb navigation node object.
@param breadcrumb_navigation_node $item The navigation node to render.
@return string HTML fragment | [
"Renders",
"a",
"breadcrumb",
"navigation",
"node",
"object",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3427-L3455 |
212,882 | moodle/moodle | lib/outputrenderers.php | core_renderer.render_navigation_node | protected function render_navigation_node(navigation_node $item) {
$content = $item->get_content();
$title = $item->get_title();
if ($item->icon instanceof renderable && !$item->hideicon) {
$icon = $this->render($item->icon);
$content = $icon.$content; // use CSS for spacing of icons
}
if ($item->helpbutton !== null) {
$content = trim($item->helpbutton).html_writer::tag('span', $content, array('class'=>'clearhelpbutton', 'tabindex'=>'0'));
}
if ($content === '') {
return '';
}
if ($item->action instanceof action_link) {
$link = $item->action;
if ($item->hidden) {
$link->add_class('dimmed');
}
if (!empty($content)) {
// Providing there is content we will use that for the link content.
$link->text = $content;
}
$content = $this->render($link);
} else if ($item->action instanceof moodle_url) {
$attributes = array();
if ($title !== '') {
$attributes['title'] = $title;
}
if ($item->hidden) {
$attributes['class'] = 'dimmed_text';
}
$content = html_writer::link($item->action, $content, $attributes);
} else if (is_string($item->action) || empty($item->action)) {
$attributes = array('tabindex'=>'0'); //add tab support to span but still maintain character stream sequence.
if ($title !== '') {
$attributes['title'] = $title;
}
if ($item->hidden) {
$attributes['class'] = 'dimmed_text';
}
$content = html_writer::tag('span', $content, $attributes);
}
return $content;
} | php | protected function render_navigation_node(navigation_node $item) {
$content = $item->get_content();
$title = $item->get_title();
if ($item->icon instanceof renderable && !$item->hideicon) {
$icon = $this->render($item->icon);
$content = $icon.$content; // use CSS for spacing of icons
}
if ($item->helpbutton !== null) {
$content = trim($item->helpbutton).html_writer::tag('span', $content, array('class'=>'clearhelpbutton', 'tabindex'=>'0'));
}
if ($content === '') {
return '';
}
if ($item->action instanceof action_link) {
$link = $item->action;
if ($item->hidden) {
$link->add_class('dimmed');
}
if (!empty($content)) {
// Providing there is content we will use that for the link content.
$link->text = $content;
}
$content = $this->render($link);
} else if ($item->action instanceof moodle_url) {
$attributes = array();
if ($title !== '') {
$attributes['title'] = $title;
}
if ($item->hidden) {
$attributes['class'] = 'dimmed_text';
}
$content = html_writer::link($item->action, $content, $attributes);
} else if (is_string($item->action) || empty($item->action)) {
$attributes = array('tabindex'=>'0'); //add tab support to span but still maintain character stream sequence.
if ($title !== '') {
$attributes['title'] = $title;
}
if ($item->hidden) {
$attributes['class'] = 'dimmed_text';
}
$content = html_writer::tag('span', $content, $attributes);
}
return $content;
} | [
"protected",
"function",
"render_navigation_node",
"(",
"navigation_node",
"$",
"item",
")",
"{",
"$",
"content",
"=",
"$",
"item",
"->",
"get_content",
"(",
")",
";",
"$",
"title",
"=",
"$",
"item",
"->",
"get_title",
"(",
")",
";",
"if",
"(",
"$",
"item",
"->",
"icon",
"instanceof",
"renderable",
"&&",
"!",
"$",
"item",
"->",
"hideicon",
")",
"{",
"$",
"icon",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"item",
"->",
"icon",
")",
";",
"$",
"content",
"=",
"$",
"icon",
".",
"$",
"content",
";",
"// use CSS for spacing of icons",
"}",
"if",
"(",
"$",
"item",
"->",
"helpbutton",
"!==",
"null",
")",
"{",
"$",
"content",
"=",
"trim",
"(",
"$",
"item",
"->",
"helpbutton",
")",
".",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"$",
"content",
",",
"array",
"(",
"'class'",
"=>",
"'clearhelpbutton'",
",",
"'tabindex'",
"=>",
"'0'",
")",
")",
";",
"}",
"if",
"(",
"$",
"content",
"===",
"''",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"$",
"item",
"->",
"action",
"instanceof",
"action_link",
")",
"{",
"$",
"link",
"=",
"$",
"item",
"->",
"action",
";",
"if",
"(",
"$",
"item",
"->",
"hidden",
")",
"{",
"$",
"link",
"->",
"add_class",
"(",
"'dimmed'",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"content",
")",
")",
"{",
"// Providing there is content we will use that for the link content.",
"$",
"link",
"->",
"text",
"=",
"$",
"content",
";",
"}",
"$",
"content",
"=",
"$",
"this",
"->",
"render",
"(",
"$",
"link",
")",
";",
"}",
"else",
"if",
"(",
"$",
"item",
"->",
"action",
"instanceof",
"moodle_url",
")",
"{",
"$",
"attributes",
"=",
"array",
"(",
")",
";",
"if",
"(",
"$",
"title",
"!==",
"''",
")",
"{",
"$",
"attributes",
"[",
"'title'",
"]",
"=",
"$",
"title",
";",
"}",
"if",
"(",
"$",
"item",
"->",
"hidden",
")",
"{",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"'dimmed_text'",
";",
"}",
"$",
"content",
"=",
"html_writer",
"::",
"link",
"(",
"$",
"item",
"->",
"action",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"item",
"->",
"action",
")",
"||",
"empty",
"(",
"$",
"item",
"->",
"action",
")",
")",
"{",
"$",
"attributes",
"=",
"array",
"(",
"'tabindex'",
"=>",
"'0'",
")",
";",
"//add tab support to span but still maintain character stream sequence.",
"if",
"(",
"$",
"title",
"!==",
"''",
")",
"{",
"$",
"attributes",
"[",
"'title'",
"]",
"=",
"$",
"title",
";",
"}",
"if",
"(",
"$",
"item",
"->",
"hidden",
")",
"{",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"'dimmed_text'",
";",
"}",
"$",
"content",
"=",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"}",
"return",
"$",
"content",
";",
"}"
] | Renders a navigation node object.
@param navigation_node $item The navigation node to render.
@return string HTML fragment | [
"Renders",
"a",
"navigation",
"node",
"object",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3463-L3507 |
212,883 | moodle/moodle | lib/outputrenderers.php | core_renderer.custom_menu | public function custom_menu($custommenuitems = '') {
global $CFG;
if (empty($custommenuitems) && !empty($CFG->custommenuitems)) {
$custommenuitems = $CFG->custommenuitems;
}
$custommenu = new custom_menu($custommenuitems, current_language());
return $this->render_custom_menu($custommenu);
} | php | public function custom_menu($custommenuitems = '') {
global $CFG;
if (empty($custommenuitems) && !empty($CFG->custommenuitems)) {
$custommenuitems = $CFG->custommenuitems;
}
$custommenu = new custom_menu($custommenuitems, current_language());
return $this->render_custom_menu($custommenu);
} | [
"public",
"function",
"custom_menu",
"(",
"$",
"custommenuitems",
"=",
"''",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"empty",
"(",
"$",
"custommenuitems",
")",
"&&",
"!",
"empty",
"(",
"$",
"CFG",
"->",
"custommenuitems",
")",
")",
"{",
"$",
"custommenuitems",
"=",
"$",
"CFG",
"->",
"custommenuitems",
";",
"}",
"$",
"custommenu",
"=",
"new",
"custom_menu",
"(",
"$",
"custommenuitems",
",",
"current_language",
"(",
")",
")",
";",
"return",
"$",
"this",
"->",
"render_custom_menu",
"(",
"$",
"custommenu",
")",
";",
"}"
] | Returns the custom menu if one has been set
A custom menu can be configured by browsing to
Settings: Administration > Appearance > Themes > Theme settings
and then configuring the custommenu config setting as described.
Theme developers: DO NOT OVERRIDE! Please override function
{@link core_renderer::render_custom_menu()} instead.
@param string $custommenuitems - custom menuitems set by theme instead of global theme settings
@return string | [
"Returns",
"the",
"custom",
"menu",
"if",
"one",
"has",
"been",
"set"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3574-L3582 |
212,884 | moodle/moodle | lib/outputrenderers.php | core_renderer.custom_menu_flat | public function custom_menu_flat() {
global $CFG;
$custommenuitems = '';
if (empty($custommenuitems) && !empty($CFG->custommenuitems)) {
$custommenuitems = $CFG->custommenuitems;
}
$custommenu = new custom_menu($custommenuitems, current_language());
$langs = get_string_manager()->get_list_of_translations();
$haslangmenu = $this->lang_menu() != '';
if ($haslangmenu) {
$strlang = get_string('language');
$currentlang = current_language();
if (isset($langs[$currentlang])) {
$currentlang = $langs[$currentlang];
} else {
$currentlang = $strlang;
}
$this->language = $custommenu->add($currentlang, new moodle_url('#'), $strlang, 10000);
foreach ($langs as $langtype => $langname) {
$this->language->add($langname, new moodle_url($this->page->url, array('lang' => $langtype)), $langname);
}
}
return $custommenu->export_for_template($this);
} | php | public function custom_menu_flat() {
global $CFG;
$custommenuitems = '';
if (empty($custommenuitems) && !empty($CFG->custommenuitems)) {
$custommenuitems = $CFG->custommenuitems;
}
$custommenu = new custom_menu($custommenuitems, current_language());
$langs = get_string_manager()->get_list_of_translations();
$haslangmenu = $this->lang_menu() != '';
if ($haslangmenu) {
$strlang = get_string('language');
$currentlang = current_language();
if (isset($langs[$currentlang])) {
$currentlang = $langs[$currentlang];
} else {
$currentlang = $strlang;
}
$this->language = $custommenu->add($currentlang, new moodle_url('#'), $strlang, 10000);
foreach ($langs as $langtype => $langname) {
$this->language->add($langname, new moodle_url($this->page->url, array('lang' => $langtype)), $langname);
}
}
return $custommenu->export_for_template($this);
} | [
"public",
"function",
"custom_menu_flat",
"(",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"custommenuitems",
"=",
"''",
";",
"if",
"(",
"empty",
"(",
"$",
"custommenuitems",
")",
"&&",
"!",
"empty",
"(",
"$",
"CFG",
"->",
"custommenuitems",
")",
")",
"{",
"$",
"custommenuitems",
"=",
"$",
"CFG",
"->",
"custommenuitems",
";",
"}",
"$",
"custommenu",
"=",
"new",
"custom_menu",
"(",
"$",
"custommenuitems",
",",
"current_language",
"(",
")",
")",
";",
"$",
"langs",
"=",
"get_string_manager",
"(",
")",
"->",
"get_list_of_translations",
"(",
")",
";",
"$",
"haslangmenu",
"=",
"$",
"this",
"->",
"lang_menu",
"(",
")",
"!=",
"''",
";",
"if",
"(",
"$",
"haslangmenu",
")",
"{",
"$",
"strlang",
"=",
"get_string",
"(",
"'language'",
")",
";",
"$",
"currentlang",
"=",
"current_language",
"(",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"langs",
"[",
"$",
"currentlang",
"]",
")",
")",
"{",
"$",
"currentlang",
"=",
"$",
"langs",
"[",
"$",
"currentlang",
"]",
";",
"}",
"else",
"{",
"$",
"currentlang",
"=",
"$",
"strlang",
";",
"}",
"$",
"this",
"->",
"language",
"=",
"$",
"custommenu",
"->",
"add",
"(",
"$",
"currentlang",
",",
"new",
"moodle_url",
"(",
"'#'",
")",
",",
"$",
"strlang",
",",
"10000",
")",
";",
"foreach",
"(",
"$",
"langs",
"as",
"$",
"langtype",
"=>",
"$",
"langname",
")",
"{",
"$",
"this",
"->",
"language",
"->",
"add",
"(",
"$",
"langname",
",",
"new",
"moodle_url",
"(",
"$",
"this",
"->",
"page",
"->",
"url",
",",
"array",
"(",
"'lang'",
"=>",
"$",
"langtype",
")",
")",
",",
"$",
"langname",
")",
";",
"}",
"}",
"return",
"$",
"custommenu",
"->",
"export_for_template",
"(",
"$",
"this",
")",
";",
"}"
] | We want to show the custom menus as a list of links in the footer on small screens.
Just return the menu object exported so we can render it differently. | [
"We",
"want",
"to",
"show",
"the",
"custom",
"menus",
"as",
"a",
"list",
"of",
"links",
"in",
"the",
"footer",
"on",
"small",
"screens",
".",
"Just",
"return",
"the",
"menu",
"object",
"exported",
"so",
"we",
"can",
"render",
"it",
"differently",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3588-L3614 |
212,885 | moodle/moodle | lib/outputrenderers.php | core_renderer.render_custom_menu_item | protected function render_custom_menu_item(custom_menu_item $menunode) {
// Required to ensure we get unique trackable id's
static $submenucount = 0;
if ($menunode->has_children()) {
// If the child has menus render it as a sub menu
$submenucount++;
$content = html_writer::start_tag('li');
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#cm_submenu_'.$submenucount;
}
$content .= html_writer::link($url, $menunode->get_text(), array('class'=>'yui3-menu-label', 'title'=>$menunode->get_title()));
$content .= html_writer::start_tag('div', array('id'=>'cm_submenu_'.$submenucount, 'class'=>'yui3-menu custom_menu_submenu'));
$content .= html_writer::start_tag('div', array('class'=>'yui3-menu-content'));
$content .= html_writer::start_tag('ul');
foreach ($menunode->get_children() as $menunode) {
$content .= $this->render_custom_menu_item($menunode);
}
$content .= html_writer::end_tag('ul');
$content .= html_writer::end_tag('div');
$content .= html_writer::end_tag('div');
$content .= html_writer::end_tag('li');
} else {
// The node doesn't have children so produce a final menuitem.
// Also, if the node's text matches '####', add a class so we can treat it as a divider.
$content = '';
if (preg_match("/^#+$/", $menunode->get_text())) {
// This is a divider.
$content = html_writer::start_tag('li', array('class' => 'yui3-menuitem divider'));
} else {
$content = html_writer::start_tag(
'li',
array(
'class' => 'yui3-menuitem'
)
);
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#';
}
$content .= html_writer::link(
$url,
$menunode->get_text(),
array('class' => 'yui3-menuitem-content', 'title' => $menunode->get_title())
);
}
$content .= html_writer::end_tag('li');
}
// Return the sub menu
return $content;
} | php | protected function render_custom_menu_item(custom_menu_item $menunode) {
// Required to ensure we get unique trackable id's
static $submenucount = 0;
if ($menunode->has_children()) {
// If the child has menus render it as a sub menu
$submenucount++;
$content = html_writer::start_tag('li');
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#cm_submenu_'.$submenucount;
}
$content .= html_writer::link($url, $menunode->get_text(), array('class'=>'yui3-menu-label', 'title'=>$menunode->get_title()));
$content .= html_writer::start_tag('div', array('id'=>'cm_submenu_'.$submenucount, 'class'=>'yui3-menu custom_menu_submenu'));
$content .= html_writer::start_tag('div', array('class'=>'yui3-menu-content'));
$content .= html_writer::start_tag('ul');
foreach ($menunode->get_children() as $menunode) {
$content .= $this->render_custom_menu_item($menunode);
}
$content .= html_writer::end_tag('ul');
$content .= html_writer::end_tag('div');
$content .= html_writer::end_tag('div');
$content .= html_writer::end_tag('li');
} else {
// The node doesn't have children so produce a final menuitem.
// Also, if the node's text matches '####', add a class so we can treat it as a divider.
$content = '';
if (preg_match("/^#+$/", $menunode->get_text())) {
// This is a divider.
$content = html_writer::start_tag('li', array('class' => 'yui3-menuitem divider'));
} else {
$content = html_writer::start_tag(
'li',
array(
'class' => 'yui3-menuitem'
)
);
if ($menunode->get_url() !== null) {
$url = $menunode->get_url();
} else {
$url = '#';
}
$content .= html_writer::link(
$url,
$menunode->get_text(),
array('class' => 'yui3-menuitem-content', 'title' => $menunode->get_title())
);
}
$content .= html_writer::end_tag('li');
}
// Return the sub menu
return $content;
} | [
"protected",
"function",
"render_custom_menu_item",
"(",
"custom_menu_item",
"$",
"menunode",
")",
"{",
"// Required to ensure we get unique trackable id's",
"static",
"$",
"submenucount",
"=",
"0",
";",
"if",
"(",
"$",
"menunode",
"->",
"has_children",
"(",
")",
")",
"{",
"// If the child has menus render it as a sub menu",
"$",
"submenucount",
"++",
";",
"$",
"content",
"=",
"html_writer",
"::",
"start_tag",
"(",
"'li'",
")",
";",
"if",
"(",
"$",
"menunode",
"->",
"get_url",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"url",
"=",
"$",
"menunode",
"->",
"get_url",
"(",
")",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"'#cm_submenu_'",
".",
"$",
"submenucount",
";",
"}",
"$",
"content",
".=",
"html_writer",
"::",
"link",
"(",
"$",
"url",
",",
"$",
"menunode",
"->",
"get_text",
"(",
")",
",",
"array",
"(",
"'class'",
"=>",
"'yui3-menu-label'",
",",
"'title'",
"=>",
"$",
"menunode",
"->",
"get_title",
"(",
")",
")",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'id'",
"=>",
"'cm_submenu_'",
".",
"$",
"submenucount",
",",
"'class'",
"=>",
"'yui3-menu custom_menu_submenu'",
")",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'yui3-menu-content'",
")",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'ul'",
")",
";",
"foreach",
"(",
"$",
"menunode",
"->",
"get_children",
"(",
")",
"as",
"$",
"menunode",
")",
"{",
"$",
"content",
".=",
"$",
"this",
"->",
"render_custom_menu_item",
"(",
"$",
"menunode",
")",
";",
"}",
"$",
"content",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'ul'",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'li'",
")",
";",
"}",
"else",
"{",
"// The node doesn't have children so produce a final menuitem.",
"// Also, if the node's text matches '####', add a class so we can treat it as a divider.",
"$",
"content",
"=",
"''",
";",
"if",
"(",
"preg_match",
"(",
"\"/^#+$/\"",
",",
"$",
"menunode",
"->",
"get_text",
"(",
")",
")",
")",
"{",
"// This is a divider.",
"$",
"content",
"=",
"html_writer",
"::",
"start_tag",
"(",
"'li'",
",",
"array",
"(",
"'class'",
"=>",
"'yui3-menuitem divider'",
")",
")",
";",
"}",
"else",
"{",
"$",
"content",
"=",
"html_writer",
"::",
"start_tag",
"(",
"'li'",
",",
"array",
"(",
"'class'",
"=>",
"'yui3-menuitem'",
")",
")",
";",
"if",
"(",
"$",
"menunode",
"->",
"get_url",
"(",
")",
"!==",
"null",
")",
"{",
"$",
"url",
"=",
"$",
"menunode",
"->",
"get_url",
"(",
")",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"'#'",
";",
"}",
"$",
"content",
".=",
"html_writer",
"::",
"link",
"(",
"$",
"url",
",",
"$",
"menunode",
"->",
"get_text",
"(",
")",
",",
"array",
"(",
"'class'",
"=>",
"'yui3-menuitem-content'",
",",
"'title'",
"=>",
"$",
"menunode",
"->",
"get_title",
"(",
")",
")",
")",
";",
"}",
"$",
"content",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'li'",
")",
";",
"}",
"// Return the sub menu",
"return",
"$",
"content",
";",
"}"
] | Renders a custom menu node as part of a submenu
The custom menu this method produces makes use of the YUI3 menunav widget
and requires very specific html elements and classes.
@see core:renderer::render_custom_menu()
@staticvar int $submenucount
@param custom_menu_item $menunode
@return string | [
"Renders",
"a",
"custom",
"menu",
"node",
"as",
"part",
"of",
"a",
"submenu"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3671-L3724 |
212,886 | moodle/moodle | lib/outputrenderers.php | core_renderer.theme_switch_links | protected function theme_switch_links() {
$actualdevice = core_useragent::get_device_type();
$currentdevice = $this->page->devicetypeinuse;
$switched = ($actualdevice != $currentdevice);
if (!$switched && $currentdevice == 'default' && $actualdevice == 'default') {
// The user is using the a default device and hasn't switched so don't shown the switch
// device links.
return '';
}
if ($switched) {
$linktext = get_string('switchdevicerecommended');
$devicetype = $actualdevice;
} else {
$linktext = get_string('switchdevicedefault');
$devicetype = 'default';
}
$linkurl = new moodle_url('/theme/switchdevice.php', array('url' => $this->page->url, 'device' => $devicetype, 'sesskey' => sesskey()));
$content = html_writer::start_tag('div', array('id' => 'theme_switch_link'));
$content .= html_writer::link($linkurl, $linktext, array('rel' => 'nofollow'));
$content .= html_writer::end_tag('div');
return $content;
} | php | protected function theme_switch_links() {
$actualdevice = core_useragent::get_device_type();
$currentdevice = $this->page->devicetypeinuse;
$switched = ($actualdevice != $currentdevice);
if (!$switched && $currentdevice == 'default' && $actualdevice == 'default') {
// The user is using the a default device and hasn't switched so don't shown the switch
// device links.
return '';
}
if ($switched) {
$linktext = get_string('switchdevicerecommended');
$devicetype = $actualdevice;
} else {
$linktext = get_string('switchdevicedefault');
$devicetype = 'default';
}
$linkurl = new moodle_url('/theme/switchdevice.php', array('url' => $this->page->url, 'device' => $devicetype, 'sesskey' => sesskey()));
$content = html_writer::start_tag('div', array('id' => 'theme_switch_link'));
$content .= html_writer::link($linkurl, $linktext, array('rel' => 'nofollow'));
$content .= html_writer::end_tag('div');
return $content;
} | [
"protected",
"function",
"theme_switch_links",
"(",
")",
"{",
"$",
"actualdevice",
"=",
"core_useragent",
"::",
"get_device_type",
"(",
")",
";",
"$",
"currentdevice",
"=",
"$",
"this",
"->",
"page",
"->",
"devicetypeinuse",
";",
"$",
"switched",
"=",
"(",
"$",
"actualdevice",
"!=",
"$",
"currentdevice",
")",
";",
"if",
"(",
"!",
"$",
"switched",
"&&",
"$",
"currentdevice",
"==",
"'default'",
"&&",
"$",
"actualdevice",
"==",
"'default'",
")",
"{",
"// The user is using the a default device and hasn't switched so don't shown the switch",
"// device links.",
"return",
"''",
";",
"}",
"if",
"(",
"$",
"switched",
")",
"{",
"$",
"linktext",
"=",
"get_string",
"(",
"'switchdevicerecommended'",
")",
";",
"$",
"devicetype",
"=",
"$",
"actualdevice",
";",
"}",
"else",
"{",
"$",
"linktext",
"=",
"get_string",
"(",
"'switchdevicedefault'",
")",
";",
"$",
"devicetype",
"=",
"'default'",
";",
"}",
"$",
"linkurl",
"=",
"new",
"moodle_url",
"(",
"'/theme/switchdevice.php'",
",",
"array",
"(",
"'url'",
"=>",
"$",
"this",
"->",
"page",
"->",
"url",
",",
"'device'",
"=>",
"$",
"devicetype",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"$",
"content",
"=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'id'",
"=>",
"'theme_switch_link'",
")",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"link",
"(",
"$",
"linkurl",
",",
"$",
"linktext",
",",
"array",
"(",
"'rel'",
"=>",
"'nofollow'",
")",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"return",
"$",
"content",
";",
"}"
] | Renders theme links for switching between default and other themes.
@return string | [
"Renders",
"theme",
"links",
"for",
"switching",
"between",
"default",
"and",
"other",
"themes",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3731-L3757 |
212,887 | moodle/moodle | lib/outputrenderers.php | core_renderer.blocks | public function blocks($region, $classes = array(), $tag = 'aside') {
$displayregion = $this->page->apply_theme_region_manipulations($region);
$classes = (array)$classes;
$classes[] = 'block-region';
$attributes = array(
'id' => 'block-region-'.preg_replace('#[^a-zA-Z0-9_\-]+#', '-', $displayregion),
'class' => join(' ', $classes),
'data-blockregion' => $displayregion,
'data-droptarget' => '1'
);
if ($this->page->blocks->region_has_content($displayregion, $this)) {
$content = $this->blocks_for_region($displayregion);
} else {
$content = '';
}
return html_writer::tag($tag, $content, $attributes);
} | php | public function blocks($region, $classes = array(), $tag = 'aside') {
$displayregion = $this->page->apply_theme_region_manipulations($region);
$classes = (array)$classes;
$classes[] = 'block-region';
$attributes = array(
'id' => 'block-region-'.preg_replace('#[^a-zA-Z0-9_\-]+#', '-', $displayregion),
'class' => join(' ', $classes),
'data-blockregion' => $displayregion,
'data-droptarget' => '1'
);
if ($this->page->blocks->region_has_content($displayregion, $this)) {
$content = $this->blocks_for_region($displayregion);
} else {
$content = '';
}
return html_writer::tag($tag, $content, $attributes);
} | [
"public",
"function",
"blocks",
"(",
"$",
"region",
",",
"$",
"classes",
"=",
"array",
"(",
")",
",",
"$",
"tag",
"=",
"'aside'",
")",
"{",
"$",
"displayregion",
"=",
"$",
"this",
"->",
"page",
"->",
"apply_theme_region_manipulations",
"(",
"$",
"region",
")",
";",
"$",
"classes",
"=",
"(",
"array",
")",
"$",
"classes",
";",
"$",
"classes",
"[",
"]",
"=",
"'block-region'",
";",
"$",
"attributes",
"=",
"array",
"(",
"'id'",
"=>",
"'block-region-'",
".",
"preg_replace",
"(",
"'#[^a-zA-Z0-9_\\-]+#'",
",",
"'-'",
",",
"$",
"displayregion",
")",
",",
"'class'",
"=>",
"join",
"(",
"' '",
",",
"$",
"classes",
")",
",",
"'data-blockregion'",
"=>",
"$",
"displayregion",
",",
"'data-droptarget'",
"=>",
"'1'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"blocks",
"->",
"region_has_content",
"(",
"$",
"displayregion",
",",
"$",
"this",
")",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"blocks_for_region",
"(",
"$",
"displayregion",
")",
";",
"}",
"else",
"{",
"$",
"content",
"=",
"''",
";",
"}",
"return",
"html_writer",
"::",
"tag",
"(",
"$",
"tag",
",",
"$",
"content",
",",
"$",
"attributes",
")",
";",
"}"
] | Get the HTML for blocks in the given region.
@since Moodle 2.5.1 2.6
@param string $region The region to get HTML for.
@return string HTML. | [
"Get",
"the",
"HTML",
"for",
"blocks",
"in",
"the",
"given",
"region",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3868-L3884 |
212,888 | moodle/moodle | lib/outputrenderers.php | core_renderer.custom_block_region | public function custom_block_region($regionname) {
if ($this->page->theme->get_block_render_method() === 'blocks') {
return $this->blocks($regionname);
} else {
return $this->blocks_for_region($regionname);
}
} | php | public function custom_block_region($regionname) {
if ($this->page->theme->get_block_render_method() === 'blocks') {
return $this->blocks($regionname);
} else {
return $this->blocks_for_region($regionname);
}
} | [
"public",
"function",
"custom_block_region",
"(",
"$",
"regionname",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"theme",
"->",
"get_block_render_method",
"(",
")",
"===",
"'blocks'",
")",
"{",
"return",
"$",
"this",
"->",
"blocks",
"(",
"$",
"regionname",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"blocks_for_region",
"(",
"$",
"regionname",
")",
";",
"}",
"}"
] | Renders a custom block region.
Use this method if you want to add an additional block region to the content of the page.
Please note this should only be used in special situations.
We want to leave the theme is control where ever possible!
This method must use the same method that the theme uses within its layout file.
As such it asks the theme what method it is using.
It can be one of two values, blocks or blocks_for_region (deprecated).
@param string $regionname The name of the custom region to add.
@return string HTML for the block region. | [
"Renders",
"a",
"custom",
"block",
"region",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3900-L3906 |
212,889 | moodle/moodle | lib/outputrenderers.php | core_renderer.body_attributes | public function body_attributes($additionalclasses = array()) {
if (!is_array($additionalclasses)) {
$additionalclasses = explode(' ', $additionalclasses);
}
return ' id="'. $this->body_id().'" class="'.$this->body_css_classes($additionalclasses).'"';
} | php | public function body_attributes($additionalclasses = array()) {
if (!is_array($additionalclasses)) {
$additionalclasses = explode(' ', $additionalclasses);
}
return ' id="'. $this->body_id().'" class="'.$this->body_css_classes($additionalclasses).'"';
} | [
"public",
"function",
"body_attributes",
"(",
"$",
"additionalclasses",
"=",
"array",
"(",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"additionalclasses",
")",
")",
"{",
"$",
"additionalclasses",
"=",
"explode",
"(",
"' '",
",",
"$",
"additionalclasses",
")",
";",
"}",
"return",
"' id=\"'",
".",
"$",
"this",
"->",
"body_id",
"(",
")",
".",
"'\" class=\"'",
".",
"$",
"this",
"->",
"body_css_classes",
"(",
"$",
"additionalclasses",
")",
".",
"'\"'",
";",
"}"
] | Returns HTML attributes to use within the body tag. This includes an ID and classes.
@since Moodle 2.5.1 2.6
@param string|array $additionalclasses Any additional classes to give the body tag,
@return string | [
"Returns",
"HTML",
"attributes",
"to",
"use",
"within",
"the",
"body",
"tag",
".",
"This",
"includes",
"an",
"ID",
"and",
"classes",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3936-L3941 |
212,890 | moodle/moodle | lib/outputrenderers.php | core_renderer.page_doc_link | public function page_doc_link($text = null) {
if ($text === null) {
$text = get_string('moodledocslink');
}
$path = page_get_doc_link_path($this->page);
if (!$path) {
return '';
}
return $this->doc_link($path, $text);
} | php | public function page_doc_link($text = null) {
if ($text === null) {
$text = get_string('moodledocslink');
}
$path = page_get_doc_link_path($this->page);
if (!$path) {
return '';
}
return $this->doc_link($path, $text);
} | [
"public",
"function",
"page_doc_link",
"(",
"$",
"text",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"text",
"===",
"null",
")",
"{",
"$",
"text",
"=",
"get_string",
"(",
"'moodledocslink'",
")",
";",
"}",
"$",
"path",
"=",
"page_get_doc_link_path",
"(",
"$",
"this",
"->",
"page",
")",
";",
"if",
"(",
"!",
"$",
"path",
")",
"{",
"return",
"''",
";",
"}",
"return",
"$",
"this",
"->",
"doc_link",
"(",
"$",
"path",
",",
"$",
"text",
")",
";",
"}"
] | Returns the Moodle docs link to use for this page.
@since Moodle 2.5.1 2.6
@param string $text
@return string | [
"Returns",
"the",
"Moodle",
"docs",
"link",
"to",
"use",
"for",
"this",
"page",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L3971-L3980 |
212,891 | moodle/moodle | lib/outputrenderers.php | core_renderer.render_preferences_group | public function render_preferences_group(preferences_group $renderable) {
$html = '';
$html .= html_writer::start_tag('div', array('class' => 'col-sm-4 preferences-group'));
$html .= $this->heading($renderable->title, 3);
$html .= html_writer::start_tag('ul');
foreach ($renderable->nodes as $node) {
if ($node->has_children()) {
debugging('Preferences nodes do not support children', DEBUG_DEVELOPER);
}
$html .= html_writer::tag('li', $this->render($node));
}
$html .= html_writer::end_tag('ul');
$html .= html_writer::end_tag('div');
return $html;
} | php | public function render_preferences_group(preferences_group $renderable) {
$html = '';
$html .= html_writer::start_tag('div', array('class' => 'col-sm-4 preferences-group'));
$html .= $this->heading($renderable->title, 3);
$html .= html_writer::start_tag('ul');
foreach ($renderable->nodes as $node) {
if ($node->has_children()) {
debugging('Preferences nodes do not support children', DEBUG_DEVELOPER);
}
$html .= html_writer::tag('li', $this->render($node));
}
$html .= html_writer::end_tag('ul');
$html .= html_writer::end_tag('div');
return $html;
} | [
"public",
"function",
"render_preferences_group",
"(",
"preferences_group",
"$",
"renderable",
")",
"{",
"$",
"html",
"=",
"''",
";",
"$",
"html",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'col-sm-4 preferences-group'",
")",
")",
";",
"$",
"html",
".=",
"$",
"this",
"->",
"heading",
"(",
"$",
"renderable",
"->",
"title",
",",
"3",
")",
";",
"$",
"html",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'ul'",
")",
";",
"foreach",
"(",
"$",
"renderable",
"->",
"nodes",
"as",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"has_children",
"(",
")",
")",
"{",
"debugging",
"(",
"'Preferences nodes do not support children'",
",",
"DEBUG_DEVELOPER",
")",
";",
"}",
"$",
"html",
".=",
"html_writer",
"::",
"tag",
"(",
"'li'",
",",
"$",
"this",
"->",
"render",
"(",
"$",
"node",
")",
")",
";",
"}",
"$",
"html",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'ul'",
")",
";",
"$",
"html",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"return",
"$",
"html",
";",
"}"
] | Renders preferences group.
@param preferences_group $renderable The renderable
@return string The output. | [
"Renders",
"preferences",
"group",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L4028-L4042 |
212,892 | moodle/moodle | lib/outputrenderers.php | core_renderer.render_skip_links | public function render_skip_links($links) {
$context = [ 'links' => []];
foreach ($links as $url => $text) {
$context['links'][] = [ 'url' => $url, 'text' => $text];
}
return $this->render_from_template('core/skip_links', $context);
} | php | public function render_skip_links($links) {
$context = [ 'links' => []];
foreach ($links as $url => $text) {
$context['links'][] = [ 'url' => $url, 'text' => $text];
}
return $this->render_from_template('core/skip_links', $context);
} | [
"public",
"function",
"render_skip_links",
"(",
"$",
"links",
")",
"{",
"$",
"context",
"=",
"[",
"'links'",
"=>",
"[",
"]",
"]",
";",
"foreach",
"(",
"$",
"links",
"as",
"$",
"url",
"=>",
"$",
"text",
")",
"{",
"$",
"context",
"[",
"'links'",
"]",
"[",
"]",
"=",
"[",
"'url'",
"=>",
"$",
"url",
",",
"'text'",
"=>",
"$",
"text",
"]",
";",
"}",
"return",
"$",
"this",
"->",
"render_from_template",
"(",
"'core/skip_links'",
",",
"$",
"context",
")",
";",
"}"
] | Renders the skip links for the page.
@param array $links List of skip links.
@return string HTML for the skip links. | [
"Renders",
"the",
"skip",
"links",
"for",
"the",
"page",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L4142-L4150 |
212,893 | moodle/moodle | lib/outputrenderers.php | core_renderer.render_context_header | protected function render_context_header(context_header $contextheader) {
$showheader = empty($this->page->layout_options['nocontextheader']);
if (!$showheader) {
return '';
}
// All the html stuff goes here.
$html = html_writer::start_div('page-context-header');
// Image data.
if (isset($contextheader->imagedata)) {
// Header specific image.
$html .= html_writer::div($contextheader->imagedata, 'page-header-image');
}
// Headings.
if (!isset($contextheader->heading)) {
$headings = $this->heading($this->page->heading, $contextheader->headinglevel);
} else {
$headings = $this->heading($contextheader->heading, $contextheader->headinglevel);
}
$html .= html_writer::tag('div', $headings, array('class' => 'page-header-headings'));
// Buttons.
if (isset($contextheader->additionalbuttons)) {
$html .= html_writer::start_div('btn-group header-button-group');
foreach ($contextheader->additionalbuttons as $button) {
if (!isset($button->page)) {
// Include js for messaging.
if ($button['buttontype'] === 'togglecontact') {
\core_message\helper::togglecontact_requirejs();
}
if ($button['buttontype'] === 'message') {
\core_message\helper::messageuser_requirejs();
}
$image = $this->pix_icon($button['formattedimage'], $button['title'], 'moodle', array(
'class' => 'iconsmall',
'role' => 'presentation'
));
$image .= html_writer::span($button['title'], 'header-button-title');
} else {
$image = html_writer::empty_tag('img', array(
'src' => $button['formattedimage'],
'role' => 'presentation'
));
}
$html .= html_writer::link($button['url'], html_writer::tag('span', $image), $button['linkattributes']);
}
$html .= html_writer::end_div();
}
$html .= html_writer::end_div();
return $html;
} | php | protected function render_context_header(context_header $contextheader) {
$showheader = empty($this->page->layout_options['nocontextheader']);
if (!$showheader) {
return '';
}
// All the html stuff goes here.
$html = html_writer::start_div('page-context-header');
// Image data.
if (isset($contextheader->imagedata)) {
// Header specific image.
$html .= html_writer::div($contextheader->imagedata, 'page-header-image');
}
// Headings.
if (!isset($contextheader->heading)) {
$headings = $this->heading($this->page->heading, $contextheader->headinglevel);
} else {
$headings = $this->heading($contextheader->heading, $contextheader->headinglevel);
}
$html .= html_writer::tag('div', $headings, array('class' => 'page-header-headings'));
// Buttons.
if (isset($contextheader->additionalbuttons)) {
$html .= html_writer::start_div('btn-group header-button-group');
foreach ($contextheader->additionalbuttons as $button) {
if (!isset($button->page)) {
// Include js for messaging.
if ($button['buttontype'] === 'togglecontact') {
\core_message\helper::togglecontact_requirejs();
}
if ($button['buttontype'] === 'message') {
\core_message\helper::messageuser_requirejs();
}
$image = $this->pix_icon($button['formattedimage'], $button['title'], 'moodle', array(
'class' => 'iconsmall',
'role' => 'presentation'
));
$image .= html_writer::span($button['title'], 'header-button-title');
} else {
$image = html_writer::empty_tag('img', array(
'src' => $button['formattedimage'],
'role' => 'presentation'
));
}
$html .= html_writer::link($button['url'], html_writer::tag('span', $image), $button['linkattributes']);
}
$html .= html_writer::end_div();
}
$html .= html_writer::end_div();
return $html;
} | [
"protected",
"function",
"render_context_header",
"(",
"context_header",
"$",
"contextheader",
")",
"{",
"$",
"showheader",
"=",
"empty",
"(",
"$",
"this",
"->",
"page",
"->",
"layout_options",
"[",
"'nocontextheader'",
"]",
")",
";",
"if",
"(",
"!",
"$",
"showheader",
")",
"{",
"return",
"''",
";",
"}",
"// All the html stuff goes here.",
"$",
"html",
"=",
"html_writer",
"::",
"start_div",
"(",
"'page-context-header'",
")",
";",
"// Image data.",
"if",
"(",
"isset",
"(",
"$",
"contextheader",
"->",
"imagedata",
")",
")",
"{",
"// Header specific image.",
"$",
"html",
".=",
"html_writer",
"::",
"div",
"(",
"$",
"contextheader",
"->",
"imagedata",
",",
"'page-header-image'",
")",
";",
"}",
"// Headings.",
"if",
"(",
"!",
"isset",
"(",
"$",
"contextheader",
"->",
"heading",
")",
")",
"{",
"$",
"headings",
"=",
"$",
"this",
"->",
"heading",
"(",
"$",
"this",
"->",
"page",
"->",
"heading",
",",
"$",
"contextheader",
"->",
"headinglevel",
")",
";",
"}",
"else",
"{",
"$",
"headings",
"=",
"$",
"this",
"->",
"heading",
"(",
"$",
"contextheader",
"->",
"heading",
",",
"$",
"contextheader",
"->",
"headinglevel",
")",
";",
"}",
"$",
"html",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"headings",
",",
"array",
"(",
"'class'",
"=>",
"'page-header-headings'",
")",
")",
";",
"// Buttons.",
"if",
"(",
"isset",
"(",
"$",
"contextheader",
"->",
"additionalbuttons",
")",
")",
"{",
"$",
"html",
".=",
"html_writer",
"::",
"start_div",
"(",
"'btn-group header-button-group'",
")",
";",
"foreach",
"(",
"$",
"contextheader",
"->",
"additionalbuttons",
"as",
"$",
"button",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"button",
"->",
"page",
")",
")",
"{",
"// Include js for messaging.",
"if",
"(",
"$",
"button",
"[",
"'buttontype'",
"]",
"===",
"'togglecontact'",
")",
"{",
"\\",
"core_message",
"\\",
"helper",
"::",
"togglecontact_requirejs",
"(",
")",
";",
"}",
"if",
"(",
"$",
"button",
"[",
"'buttontype'",
"]",
"===",
"'message'",
")",
"{",
"\\",
"core_message",
"\\",
"helper",
"::",
"messageuser_requirejs",
"(",
")",
";",
"}",
"$",
"image",
"=",
"$",
"this",
"->",
"pix_icon",
"(",
"$",
"button",
"[",
"'formattedimage'",
"]",
",",
"$",
"button",
"[",
"'title'",
"]",
",",
"'moodle'",
",",
"array",
"(",
"'class'",
"=>",
"'iconsmall'",
",",
"'role'",
"=>",
"'presentation'",
")",
")",
";",
"$",
"image",
".=",
"html_writer",
"::",
"span",
"(",
"$",
"button",
"[",
"'title'",
"]",
",",
"'header-button-title'",
")",
";",
"}",
"else",
"{",
"$",
"image",
"=",
"html_writer",
"::",
"empty_tag",
"(",
"'img'",
",",
"array",
"(",
"'src'",
"=>",
"$",
"button",
"[",
"'formattedimage'",
"]",
",",
"'role'",
"=>",
"'presentation'",
")",
")",
";",
"}",
"$",
"html",
".=",
"html_writer",
"::",
"link",
"(",
"$",
"button",
"[",
"'url'",
"]",
",",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"$",
"image",
")",
",",
"$",
"button",
"[",
"'linkattributes'",
"]",
")",
";",
"}",
"$",
"html",
".=",
"html_writer",
"::",
"end_div",
"(",
")",
";",
"}",
"$",
"html",
".=",
"html_writer",
"::",
"end_div",
"(",
")",
";",
"return",
"$",
"html",
";",
"}"
] | Renders the header bar.
@param context_header $contextheader Header bar object.
@return string HTML for the header bar. | [
"Renders",
"the",
"header",
"bar",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L4158-L4213 |
212,894 | moodle/moodle | lib/outputrenderers.php | core_renderer.full_header | public function full_header() {
global $PAGE;
$header = new stdClass();
$header->settingsmenu = $this->context_header_settings_menu();
$header->contextheader = $this->context_header();
$header->hasnavbar = empty($PAGE->layout_options['nonavbar']);
$header->navbar = $this->navbar();
$header->pageheadingbutton = $this->page_heading_button();
$header->courseheader = $this->course_header();
return $this->render_from_template('core/full_header', $header);
} | php | public function full_header() {
global $PAGE;
$header = new stdClass();
$header->settingsmenu = $this->context_header_settings_menu();
$header->contextheader = $this->context_header();
$header->hasnavbar = empty($PAGE->layout_options['nonavbar']);
$header->navbar = $this->navbar();
$header->pageheadingbutton = $this->page_heading_button();
$header->courseheader = $this->course_header();
return $this->render_from_template('core/full_header', $header);
} | [
"public",
"function",
"full_header",
"(",
")",
"{",
"global",
"$",
"PAGE",
";",
"$",
"header",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"header",
"->",
"settingsmenu",
"=",
"$",
"this",
"->",
"context_header_settings_menu",
"(",
")",
";",
"$",
"header",
"->",
"contextheader",
"=",
"$",
"this",
"->",
"context_header",
"(",
")",
";",
"$",
"header",
"->",
"hasnavbar",
"=",
"empty",
"(",
"$",
"PAGE",
"->",
"layout_options",
"[",
"'nonavbar'",
"]",
")",
";",
"$",
"header",
"->",
"navbar",
"=",
"$",
"this",
"->",
"navbar",
"(",
")",
";",
"$",
"header",
"->",
"pageheadingbutton",
"=",
"$",
"this",
"->",
"page_heading_button",
"(",
")",
";",
"$",
"header",
"->",
"courseheader",
"=",
"$",
"this",
"->",
"course_header",
"(",
")",
";",
"return",
"$",
"this",
"->",
"render_from_template",
"(",
"'core/full_header'",
",",
"$",
"header",
")",
";",
"}"
] | Wrapper for header elements.
@return string HTML to display the main header. | [
"Wrapper",
"for",
"header",
"elements",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L4220-L4231 |
212,895 | moodle/moodle | lib/outputrenderers.php | core_renderer.build_action_menu_from_navigation | protected function build_action_menu_from_navigation(action_menu $menu,
navigation_node $node,
$indent = false,
$onlytopleafnodes = false) {
$skipped = false;
// Build an action menu based on the visible nodes from this navigation tree.
foreach ($node->children as $menuitem) {
if ($menuitem->display) {
if ($onlytopleafnodes && $menuitem->children->count()) {
$skipped = true;
continue;
}
if ($menuitem->action) {
if ($menuitem->action instanceof action_link) {
$link = $menuitem->action;
// Give preference to setting icon over action icon.
if (!empty($menuitem->icon)) {
$link->icon = $menuitem->icon;
}
} else {
$link = new action_link($menuitem->action, $menuitem->text, null, null, $menuitem->icon);
}
} else {
if ($onlytopleafnodes) {
$skipped = true;
continue;
}
$link = new action_link(new moodle_url('#'), $menuitem->text, null, ['disabled' => true], $menuitem->icon);
}
if ($indent) {
$link->add_class('ml-4');
}
if (!empty($menuitem->classes)) {
$link->add_class(implode(" ", $menuitem->classes));
}
$menu->add_secondary_action($link);
$skipped = $skipped || $this->build_action_menu_from_navigation($menu, $menuitem, true);
}
}
return $skipped;
} | php | protected function build_action_menu_from_navigation(action_menu $menu,
navigation_node $node,
$indent = false,
$onlytopleafnodes = false) {
$skipped = false;
// Build an action menu based on the visible nodes from this navigation tree.
foreach ($node->children as $menuitem) {
if ($menuitem->display) {
if ($onlytopleafnodes && $menuitem->children->count()) {
$skipped = true;
continue;
}
if ($menuitem->action) {
if ($menuitem->action instanceof action_link) {
$link = $menuitem->action;
// Give preference to setting icon over action icon.
if (!empty($menuitem->icon)) {
$link->icon = $menuitem->icon;
}
} else {
$link = new action_link($menuitem->action, $menuitem->text, null, null, $menuitem->icon);
}
} else {
if ($onlytopleafnodes) {
$skipped = true;
continue;
}
$link = new action_link(new moodle_url('#'), $menuitem->text, null, ['disabled' => true], $menuitem->icon);
}
if ($indent) {
$link->add_class('ml-4');
}
if (!empty($menuitem->classes)) {
$link->add_class(implode(" ", $menuitem->classes));
}
$menu->add_secondary_action($link);
$skipped = $skipped || $this->build_action_menu_from_navigation($menu, $menuitem, true);
}
}
return $skipped;
} | [
"protected",
"function",
"build_action_menu_from_navigation",
"(",
"action_menu",
"$",
"menu",
",",
"navigation_node",
"$",
"node",
",",
"$",
"indent",
"=",
"false",
",",
"$",
"onlytopleafnodes",
"=",
"false",
")",
"{",
"$",
"skipped",
"=",
"false",
";",
"// Build an action menu based on the visible nodes from this navigation tree.",
"foreach",
"(",
"$",
"node",
"->",
"children",
"as",
"$",
"menuitem",
")",
"{",
"if",
"(",
"$",
"menuitem",
"->",
"display",
")",
"{",
"if",
"(",
"$",
"onlytopleafnodes",
"&&",
"$",
"menuitem",
"->",
"children",
"->",
"count",
"(",
")",
")",
"{",
"$",
"skipped",
"=",
"true",
";",
"continue",
";",
"}",
"if",
"(",
"$",
"menuitem",
"->",
"action",
")",
"{",
"if",
"(",
"$",
"menuitem",
"->",
"action",
"instanceof",
"action_link",
")",
"{",
"$",
"link",
"=",
"$",
"menuitem",
"->",
"action",
";",
"// Give preference to setting icon over action icon.",
"if",
"(",
"!",
"empty",
"(",
"$",
"menuitem",
"->",
"icon",
")",
")",
"{",
"$",
"link",
"->",
"icon",
"=",
"$",
"menuitem",
"->",
"icon",
";",
"}",
"}",
"else",
"{",
"$",
"link",
"=",
"new",
"action_link",
"(",
"$",
"menuitem",
"->",
"action",
",",
"$",
"menuitem",
"->",
"text",
",",
"null",
",",
"null",
",",
"$",
"menuitem",
"->",
"icon",
")",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"onlytopleafnodes",
")",
"{",
"$",
"skipped",
"=",
"true",
";",
"continue",
";",
"}",
"$",
"link",
"=",
"new",
"action_link",
"(",
"new",
"moodle_url",
"(",
"'#'",
")",
",",
"$",
"menuitem",
"->",
"text",
",",
"null",
",",
"[",
"'disabled'",
"=>",
"true",
"]",
",",
"$",
"menuitem",
"->",
"icon",
")",
";",
"}",
"if",
"(",
"$",
"indent",
")",
"{",
"$",
"link",
"->",
"add_class",
"(",
"'ml-4'",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"menuitem",
"->",
"classes",
")",
")",
"{",
"$",
"link",
"->",
"add_class",
"(",
"implode",
"(",
"\" \"",
",",
"$",
"menuitem",
"->",
"classes",
")",
")",
";",
"}",
"$",
"menu",
"->",
"add_secondary_action",
"(",
"$",
"link",
")",
";",
"$",
"skipped",
"=",
"$",
"skipped",
"||",
"$",
"this",
"->",
"build_action_menu_from_navigation",
"(",
"$",
"menu",
",",
"$",
"menuitem",
",",
"true",
")",
";",
"}",
"}",
"return",
"$",
"skipped",
";",
"}"
] | Take a node in the nav tree and make an action menu out of it.
The links are injected in the action menu.
@param action_menu $menu
@param navigation_node $node
@param boolean $indent
@param boolean $onlytopleafnodes
@return boolean nodesskipped - True if nodes were skipped in building the menu | [
"Take",
"a",
"node",
"in",
"the",
"nav",
"tree",
"and",
"make",
"an",
"action",
"menu",
"out",
"of",
"it",
".",
"The",
"links",
"are",
"injected",
"in",
"the",
"action",
"menu",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L4342-L4383 |
212,896 | moodle/moodle | lib/outputrenderers.php | core_renderer.region_main_settings_menu | public function region_main_settings_menu() {
$context = $this->page->context;
$menu = new action_menu();
if ($context->contextlevel == CONTEXT_MODULE) {
$this->page->navigation->initialise();
$node = $this->page->navigation->find_active_node();
$buildmenu = false;
// If the settings menu has been forced then show the menu.
if ($this->page->is_settings_menu_forced()) {
$buildmenu = true;
} else if (!empty($node) && ($node->type == navigation_node::TYPE_ACTIVITY ||
$node->type == navigation_node::TYPE_RESOURCE)) {
$items = $this->page->navbar->get_items();
$navbarnode = end($items);
// We only want to show the menu on the first page of the activity. This means
// the breadcrumb has no additional nodes.
if ($navbarnode && ($navbarnode->key === $node->key && $navbarnode->type == $node->type)) {
$buildmenu = true;
}
}
if ($buildmenu) {
// Get the course admin node from the settings navigation.
$node = $this->page->settingsnav->find('modulesettings', navigation_node::TYPE_SETTING);
if ($node) {
// Build an action menu based on the visible nodes from this navigation tree.
$this->build_action_menu_from_navigation($menu, $node);
}
}
} else if ($context->contextlevel == CONTEXT_COURSECAT) {
// For course category context, show category settings menu, if we're on the course category page.
if ($this->page->pagetype === 'course-index-category') {
$node = $this->page->settingsnav->find('categorysettings', navigation_node::TYPE_CONTAINER);
if ($node) {
// Build an action menu based on the visible nodes from this navigation tree.
$this->build_action_menu_from_navigation($menu, $node);
}
}
} else {
$items = $this->page->navbar->get_items();
$navbarnode = end($items);
if ($navbarnode && ($navbarnode->key === 'participants')) {
$node = $this->page->settingsnav->find('users', navigation_node::TYPE_CONTAINER);
if ($node) {
// Build an action menu based on the visible nodes from this navigation tree.
$this->build_action_menu_from_navigation($menu, $node);
}
}
}
return $this->render($menu);
} | php | public function region_main_settings_menu() {
$context = $this->page->context;
$menu = new action_menu();
if ($context->contextlevel == CONTEXT_MODULE) {
$this->page->navigation->initialise();
$node = $this->page->navigation->find_active_node();
$buildmenu = false;
// If the settings menu has been forced then show the menu.
if ($this->page->is_settings_menu_forced()) {
$buildmenu = true;
} else if (!empty($node) && ($node->type == navigation_node::TYPE_ACTIVITY ||
$node->type == navigation_node::TYPE_RESOURCE)) {
$items = $this->page->navbar->get_items();
$navbarnode = end($items);
// We only want to show the menu on the first page of the activity. This means
// the breadcrumb has no additional nodes.
if ($navbarnode && ($navbarnode->key === $node->key && $navbarnode->type == $node->type)) {
$buildmenu = true;
}
}
if ($buildmenu) {
// Get the course admin node from the settings navigation.
$node = $this->page->settingsnav->find('modulesettings', navigation_node::TYPE_SETTING);
if ($node) {
// Build an action menu based on the visible nodes from this navigation tree.
$this->build_action_menu_from_navigation($menu, $node);
}
}
} else if ($context->contextlevel == CONTEXT_COURSECAT) {
// For course category context, show category settings menu, if we're on the course category page.
if ($this->page->pagetype === 'course-index-category') {
$node = $this->page->settingsnav->find('categorysettings', navigation_node::TYPE_CONTAINER);
if ($node) {
// Build an action menu based on the visible nodes from this navigation tree.
$this->build_action_menu_from_navigation($menu, $node);
}
}
} else {
$items = $this->page->navbar->get_items();
$navbarnode = end($items);
if ($navbarnode && ($navbarnode->key === 'participants')) {
$node = $this->page->settingsnav->find('users', navigation_node::TYPE_CONTAINER);
if ($node) {
// Build an action menu based on the visible nodes from this navigation tree.
$this->build_action_menu_from_navigation($menu, $node);
}
}
}
return $this->render($menu);
} | [
"public",
"function",
"region_main_settings_menu",
"(",
")",
"{",
"$",
"context",
"=",
"$",
"this",
"->",
"page",
"->",
"context",
";",
"$",
"menu",
"=",
"new",
"action_menu",
"(",
")",
";",
"if",
"(",
"$",
"context",
"->",
"contextlevel",
"==",
"CONTEXT_MODULE",
")",
"{",
"$",
"this",
"->",
"page",
"->",
"navigation",
"->",
"initialise",
"(",
")",
";",
"$",
"node",
"=",
"$",
"this",
"->",
"page",
"->",
"navigation",
"->",
"find_active_node",
"(",
")",
";",
"$",
"buildmenu",
"=",
"false",
";",
"// If the settings menu has been forced then show the menu.",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"is_settings_menu_forced",
"(",
")",
")",
"{",
"$",
"buildmenu",
"=",
"true",
";",
"}",
"else",
"if",
"(",
"!",
"empty",
"(",
"$",
"node",
")",
"&&",
"(",
"$",
"node",
"->",
"type",
"==",
"navigation_node",
"::",
"TYPE_ACTIVITY",
"||",
"$",
"node",
"->",
"type",
"==",
"navigation_node",
"::",
"TYPE_RESOURCE",
")",
")",
"{",
"$",
"items",
"=",
"$",
"this",
"->",
"page",
"->",
"navbar",
"->",
"get_items",
"(",
")",
";",
"$",
"navbarnode",
"=",
"end",
"(",
"$",
"items",
")",
";",
"// We only want to show the menu on the first page of the activity. This means",
"// the breadcrumb has no additional nodes.",
"if",
"(",
"$",
"navbarnode",
"&&",
"(",
"$",
"navbarnode",
"->",
"key",
"===",
"$",
"node",
"->",
"key",
"&&",
"$",
"navbarnode",
"->",
"type",
"==",
"$",
"node",
"->",
"type",
")",
")",
"{",
"$",
"buildmenu",
"=",
"true",
";",
"}",
"}",
"if",
"(",
"$",
"buildmenu",
")",
"{",
"// Get the course admin node from the settings navigation.",
"$",
"node",
"=",
"$",
"this",
"->",
"page",
"->",
"settingsnav",
"->",
"find",
"(",
"'modulesettings'",
",",
"navigation_node",
"::",
"TYPE_SETTING",
")",
";",
"if",
"(",
"$",
"node",
")",
"{",
"// Build an action menu based on the visible nodes from this navigation tree.",
"$",
"this",
"->",
"build_action_menu_from_navigation",
"(",
"$",
"menu",
",",
"$",
"node",
")",
";",
"}",
"}",
"}",
"else",
"if",
"(",
"$",
"context",
"->",
"contextlevel",
"==",
"CONTEXT_COURSECAT",
")",
"{",
"// For course category context, show category settings menu, if we're on the course category page.",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"pagetype",
"===",
"'course-index-category'",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"page",
"->",
"settingsnav",
"->",
"find",
"(",
"'categorysettings'",
",",
"navigation_node",
"::",
"TYPE_CONTAINER",
")",
";",
"if",
"(",
"$",
"node",
")",
"{",
"// Build an action menu based on the visible nodes from this navigation tree.",
"$",
"this",
"->",
"build_action_menu_from_navigation",
"(",
"$",
"menu",
",",
"$",
"node",
")",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"items",
"=",
"$",
"this",
"->",
"page",
"->",
"navbar",
"->",
"get_items",
"(",
")",
";",
"$",
"navbarnode",
"=",
"end",
"(",
"$",
"items",
")",
";",
"if",
"(",
"$",
"navbarnode",
"&&",
"(",
"$",
"navbarnode",
"->",
"key",
"===",
"'participants'",
")",
")",
"{",
"$",
"node",
"=",
"$",
"this",
"->",
"page",
"->",
"settingsnav",
"->",
"find",
"(",
"'users'",
",",
"navigation_node",
"::",
"TYPE_CONTAINER",
")",
";",
"if",
"(",
"$",
"node",
")",
"{",
"// Build an action menu based on the visible nodes from this navigation tree.",
"$",
"this",
"->",
"build_action_menu_from_navigation",
"(",
"$",
"menu",
",",
"$",
"node",
")",
";",
"}",
"}",
"}",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"menu",
")",
";",
"}"
] | This is an optional menu that can be added to a layout by a theme. It contains the
menu for the most specific thing from the settings block. E.g. Module administration.
@return string | [
"This",
"is",
"an",
"optional",
"menu",
"that",
"can",
"be",
"added",
"to",
"a",
"layout",
"by",
"a",
"theme",
".",
"It",
"contains",
"the",
"menu",
"for",
"the",
"most",
"specific",
"thing",
"from",
"the",
"settings",
"block",
".",
"E",
".",
"g",
".",
"Module",
"administration",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L4391-L4447 |
212,897 | moodle/moodle | lib/outputrenderers.php | core_renderer.tag_list | public function tag_list($tags, $label = null, $classes = '', $limit = 10, $pagecontext = null) {
$list = new \core_tag\output\taglist($tags, $label, $classes, $limit, $pagecontext);
return $this->render_from_template('core_tag/taglist', $list->export_for_template($this));
} | php | public function tag_list($tags, $label = null, $classes = '', $limit = 10, $pagecontext = null) {
$list = new \core_tag\output\taglist($tags, $label, $classes, $limit, $pagecontext);
return $this->render_from_template('core_tag/taglist', $list->export_for_template($this));
} | [
"public",
"function",
"tag_list",
"(",
"$",
"tags",
",",
"$",
"label",
"=",
"null",
",",
"$",
"classes",
"=",
"''",
",",
"$",
"limit",
"=",
"10",
",",
"$",
"pagecontext",
"=",
"null",
")",
"{",
"$",
"list",
"=",
"new",
"\\",
"core_tag",
"\\",
"output",
"\\",
"taglist",
"(",
"$",
"tags",
",",
"$",
"label",
",",
"$",
"classes",
",",
"$",
"limit",
",",
"$",
"pagecontext",
")",
";",
"return",
"$",
"this",
"->",
"render_from_template",
"(",
"'core_tag/taglist'",
",",
"$",
"list",
"->",
"export_for_template",
"(",
"$",
"this",
")",
")",
";",
"}"
] | Displays the list of tags associated with an entry
@param array $tags list of instances of core_tag or stdClass
@param string $label label to display in front, by default 'Tags' (get_string('tags')), set to null
to use default, set to '' (empty string) to omit the label completely
@param string $classes additional classes for the enclosing div element
@param int $limit limit the number of tags to display, if size of $tags is more than this limit the "more" link
will be appended to the end, JS will toggle the rest of the tags
@param context $pagecontext specify if needed to overwrite the current page context for the view tag link
@return string | [
"Displays",
"the",
"list",
"of",
"tags",
"associated",
"with",
"an",
"entry"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L4461-L4464 |
212,898 | moodle/moodle | lib/outputrenderers.php | core_renderer.render_inplace_editable | public function render_inplace_editable(\core\output\inplace_editable $element) {
return $this->render_from_template('core/inplace_editable', $element->export_for_template($this));
} | php | public function render_inplace_editable(\core\output\inplace_editable $element) {
return $this->render_from_template('core/inplace_editable', $element->export_for_template($this));
} | [
"public",
"function",
"render_inplace_editable",
"(",
"\\",
"core",
"\\",
"output",
"\\",
"inplace_editable",
"$",
"element",
")",
"{",
"return",
"$",
"this",
"->",
"render_from_template",
"(",
"'core/inplace_editable'",
",",
"$",
"element",
"->",
"export_for_template",
"(",
"$",
"this",
")",
")",
";",
"}"
] | Renders element for inline editing of any value
@param \core\output\inplace_editable $element
@return string | [
"Renders",
"element",
"for",
"inline",
"editing",
"of",
"any",
"value"
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L4472-L4474 |
212,899 | moodle/moodle | lib/outputrenderers.php | core_renderer.mform_element | public function mform_element($element, $required, $advanced, $error, $ingroup) {
$templatename = 'core_form/element-' . $element->getType();
if ($ingroup) {
$templatename .= "-inline";
}
try {
// We call this to generate a file not found exception if there is no template.
// We don't want to call export_for_template if there is no template.
core\output\mustache_template_finder::get_template_filepath($templatename);
if ($element instanceof templatable) {
$elementcontext = $element->export_for_template($this);
$helpbutton = '';
if (method_exists($element, 'getHelpButton')) {
$helpbutton = $element->getHelpButton();
}
$label = $element->getLabel();
$text = '';
if (method_exists($element, 'getText')) {
// There currently exists code that adds a form element with an empty label.
// If this is the case then set the label to the description.
if (empty($label)) {
$label = $element->getText();
} else {
$text = $element->getText();
}
}
// Generate the form element wrapper ids and names to pass to the template.
// This differs between group and non-group elements.
if ($element->getType() === 'group') {
// Group element.
// The id will be something like 'fgroup_id_NAME'. E.g. fgroup_id_mygroup.
$elementcontext['wrapperid'] = $elementcontext['id'];
// Ensure group elements pass through the group name as the element name.
$elementcontext['name'] = $elementcontext['groupname'];
} else {
// Non grouped element.
// Creates an id like 'fitem_id_NAME'. E.g. fitem_id_mytextelement.
$elementcontext['wrapperid'] = 'fitem_' . $elementcontext['id'];
}
$context = array(
'element' => $elementcontext,
'label' => $label,
'text' => $text,
'required' => $required,
'advanced' => $advanced,
'helpbutton' => $helpbutton,
'error' => $error
);
return $this->render_from_template($templatename, $context);
}
} catch (Exception $e) {
// No template for this element.
return false;
}
} | php | public function mform_element($element, $required, $advanced, $error, $ingroup) {
$templatename = 'core_form/element-' . $element->getType();
if ($ingroup) {
$templatename .= "-inline";
}
try {
// We call this to generate a file not found exception if there is no template.
// We don't want to call export_for_template if there is no template.
core\output\mustache_template_finder::get_template_filepath($templatename);
if ($element instanceof templatable) {
$elementcontext = $element->export_for_template($this);
$helpbutton = '';
if (method_exists($element, 'getHelpButton')) {
$helpbutton = $element->getHelpButton();
}
$label = $element->getLabel();
$text = '';
if (method_exists($element, 'getText')) {
// There currently exists code that adds a form element with an empty label.
// If this is the case then set the label to the description.
if (empty($label)) {
$label = $element->getText();
} else {
$text = $element->getText();
}
}
// Generate the form element wrapper ids and names to pass to the template.
// This differs between group and non-group elements.
if ($element->getType() === 'group') {
// Group element.
// The id will be something like 'fgroup_id_NAME'. E.g. fgroup_id_mygroup.
$elementcontext['wrapperid'] = $elementcontext['id'];
// Ensure group elements pass through the group name as the element name.
$elementcontext['name'] = $elementcontext['groupname'];
} else {
// Non grouped element.
// Creates an id like 'fitem_id_NAME'. E.g. fitem_id_mytextelement.
$elementcontext['wrapperid'] = 'fitem_' . $elementcontext['id'];
}
$context = array(
'element' => $elementcontext,
'label' => $label,
'text' => $text,
'required' => $required,
'advanced' => $advanced,
'helpbutton' => $helpbutton,
'error' => $error
);
return $this->render_from_template($templatename, $context);
}
} catch (Exception $e) {
// No template for this element.
return false;
}
} | [
"public",
"function",
"mform_element",
"(",
"$",
"element",
",",
"$",
"required",
",",
"$",
"advanced",
",",
"$",
"error",
",",
"$",
"ingroup",
")",
"{",
"$",
"templatename",
"=",
"'core_form/element-'",
".",
"$",
"element",
"->",
"getType",
"(",
")",
";",
"if",
"(",
"$",
"ingroup",
")",
"{",
"$",
"templatename",
".=",
"\"-inline\"",
";",
"}",
"try",
"{",
"// We call this to generate a file not found exception if there is no template.",
"// We don't want to call export_for_template if there is no template.",
"core",
"\\",
"output",
"\\",
"mustache_template_finder",
"::",
"get_template_filepath",
"(",
"$",
"templatename",
")",
";",
"if",
"(",
"$",
"element",
"instanceof",
"templatable",
")",
"{",
"$",
"elementcontext",
"=",
"$",
"element",
"->",
"export_for_template",
"(",
"$",
"this",
")",
";",
"$",
"helpbutton",
"=",
"''",
";",
"if",
"(",
"method_exists",
"(",
"$",
"element",
",",
"'getHelpButton'",
")",
")",
"{",
"$",
"helpbutton",
"=",
"$",
"element",
"->",
"getHelpButton",
"(",
")",
";",
"}",
"$",
"label",
"=",
"$",
"element",
"->",
"getLabel",
"(",
")",
";",
"$",
"text",
"=",
"''",
";",
"if",
"(",
"method_exists",
"(",
"$",
"element",
",",
"'getText'",
")",
")",
"{",
"// There currently exists code that adds a form element with an empty label.",
"// If this is the case then set the label to the description.",
"if",
"(",
"empty",
"(",
"$",
"label",
")",
")",
"{",
"$",
"label",
"=",
"$",
"element",
"->",
"getText",
"(",
")",
";",
"}",
"else",
"{",
"$",
"text",
"=",
"$",
"element",
"->",
"getText",
"(",
")",
";",
"}",
"}",
"// Generate the form element wrapper ids and names to pass to the template.",
"// This differs between group and non-group elements.",
"if",
"(",
"$",
"element",
"->",
"getType",
"(",
")",
"===",
"'group'",
")",
"{",
"// Group element.",
"// The id will be something like 'fgroup_id_NAME'. E.g. fgroup_id_mygroup.",
"$",
"elementcontext",
"[",
"'wrapperid'",
"]",
"=",
"$",
"elementcontext",
"[",
"'id'",
"]",
";",
"// Ensure group elements pass through the group name as the element name.",
"$",
"elementcontext",
"[",
"'name'",
"]",
"=",
"$",
"elementcontext",
"[",
"'groupname'",
"]",
";",
"}",
"else",
"{",
"// Non grouped element.",
"// Creates an id like 'fitem_id_NAME'. E.g. fitem_id_mytextelement.",
"$",
"elementcontext",
"[",
"'wrapperid'",
"]",
"=",
"'fitem_'",
".",
"$",
"elementcontext",
"[",
"'id'",
"]",
";",
"}",
"$",
"context",
"=",
"array",
"(",
"'element'",
"=>",
"$",
"elementcontext",
",",
"'label'",
"=>",
"$",
"label",
",",
"'text'",
"=>",
"$",
"text",
",",
"'required'",
"=>",
"$",
"required",
",",
"'advanced'",
"=>",
"$",
"advanced",
",",
"'helpbutton'",
"=>",
"$",
"helpbutton",
",",
"'error'",
"=>",
"$",
"error",
")",
";",
"return",
"$",
"this",
"->",
"render_from_template",
"(",
"$",
"templatename",
",",
"$",
"context",
")",
";",
"}",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"// No template for this element.",
"return",
"false",
";",
"}",
"}"
] | Renders an mform element from a template.
@param HTML_QuickForm_element $element element
@param bool $required if input is required field
@param bool $advanced if input is an advanced field
@param string $error error message to display
@param bool $ingroup True if this element is rendered as part of a group
@return mixed string|bool | [
"Renders",
"an",
"mform",
"element",
"from",
"a",
"template",
"."
] | a411b499b98afc9901c24a9466c7e322946a04aa | https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputrenderers.php#L4560-L4619 |
Subsets and Splits
Yii Code Samples
Gathers all records from test, train, and validation sets that contain the word 'yii', providing a basic filtered view of the dataset relevant to Yii-related content.