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
|
|---|---|---|---|---|---|---|---|---|---|---|---|
219,700
|
moodle/moodle
|
lib/classes/update/code_manager.php
|
code_manager.get_archived_plugin_version
|
public function get_archived_plugin_version($component, $version) {
if (empty($component) or empty($version)) {
return false;
}
$archzip = $this->temproot.'/archive/'.$component.'/'.$version.'.zip';
if (file_exists($archzip)) {
return $archzip;
}
return false;
}
|
php
|
public function get_archived_plugin_version($component, $version) {
if (empty($component) or empty($version)) {
return false;
}
$archzip = $this->temproot.'/archive/'.$component.'/'.$version.'.zip';
if (file_exists($archzip)) {
return $archzip;
}
return false;
}
|
[
"public",
"function",
"get_archived_plugin_version",
"(",
"$",
"component",
",",
"$",
"version",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"component",
")",
"or",
"empty",
"(",
"$",
"version",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"archzip",
"=",
"$",
"this",
"->",
"temproot",
".",
"'/archive/'",
".",
"$",
"component",
".",
"'/'",
".",
"$",
"version",
".",
"'.zip'",
";",
"if",
"(",
"file_exists",
"(",
"$",
"archzip",
")",
")",
"{",
"return",
"$",
"archzip",
";",
"}",
"return",
"false",
";",
"}"
] |
Return the path to the ZIP file with the archive of the given plugin version.
@param string $component
@param int $version
@return string|bool false if not found, full path otherwise
|
[
"Return",
"the",
"path",
"to",
"the",
"ZIP",
"file",
"with",
"the",
"archive",
"of",
"the",
"given",
"plugin",
"version",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/update/code_manager.php#L290-L303
|
219,701
|
moodle/moodle
|
lib/classes/update/code_manager.php
|
code_manager.list_plugin_folder_files
|
public function list_plugin_folder_files($folderpath) {
$folder = new RecursiveDirectoryIterator($folderpath);
$iterator = new RecursiveIteratorIterator($folder);
$folderpathinfo = new SplFileInfo($folderpath);
$strip = strlen($folderpathinfo->getPathInfo()->getRealPath()) + 1;
$files = array();
foreach ($iterator as $fileinfo) {
if ($fileinfo->getFilename() === '..') {
continue;
}
if (strpos($fileinfo->getRealPath(), $folderpathinfo->getRealPath()) !== 0) {
throw new moodle_exception('unexpected_filepath_mismatch', 'core_plugin');
}
$key = substr($fileinfo->getRealPath(), $strip);
if ($fileinfo->isDir() and substr($key, -1) !== '/') {
$key .= '/';
}
$files[str_replace(DIRECTORY_SEPARATOR, '/', $key)] = str_replace(DIRECTORY_SEPARATOR, '/', $fileinfo->getRealPath());
}
return $files;
}
|
php
|
public function list_plugin_folder_files($folderpath) {
$folder = new RecursiveDirectoryIterator($folderpath);
$iterator = new RecursiveIteratorIterator($folder);
$folderpathinfo = new SplFileInfo($folderpath);
$strip = strlen($folderpathinfo->getPathInfo()->getRealPath()) + 1;
$files = array();
foreach ($iterator as $fileinfo) {
if ($fileinfo->getFilename() === '..') {
continue;
}
if (strpos($fileinfo->getRealPath(), $folderpathinfo->getRealPath()) !== 0) {
throw new moodle_exception('unexpected_filepath_mismatch', 'core_plugin');
}
$key = substr($fileinfo->getRealPath(), $strip);
if ($fileinfo->isDir() and substr($key, -1) !== '/') {
$key .= '/';
}
$files[str_replace(DIRECTORY_SEPARATOR, '/', $key)] = str_replace(DIRECTORY_SEPARATOR, '/', $fileinfo->getRealPath());
}
return $files;
}
|
[
"public",
"function",
"list_plugin_folder_files",
"(",
"$",
"folderpath",
")",
"{",
"$",
"folder",
"=",
"new",
"RecursiveDirectoryIterator",
"(",
"$",
"folderpath",
")",
";",
"$",
"iterator",
"=",
"new",
"RecursiveIteratorIterator",
"(",
"$",
"folder",
")",
";",
"$",
"folderpathinfo",
"=",
"new",
"SplFileInfo",
"(",
"$",
"folderpath",
")",
";",
"$",
"strip",
"=",
"strlen",
"(",
"$",
"folderpathinfo",
"->",
"getPathInfo",
"(",
")",
"->",
"getRealPath",
"(",
")",
")",
"+",
"1",
";",
"$",
"files",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"iterator",
"as",
"$",
"fileinfo",
")",
"{",
"if",
"(",
"$",
"fileinfo",
"->",
"getFilename",
"(",
")",
"===",
"'..'",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"fileinfo",
"->",
"getRealPath",
"(",
")",
",",
"$",
"folderpathinfo",
"->",
"getRealPath",
"(",
")",
")",
"!==",
"0",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'unexpected_filepath_mismatch'",
",",
"'core_plugin'",
")",
";",
"}",
"$",
"key",
"=",
"substr",
"(",
"$",
"fileinfo",
"->",
"getRealPath",
"(",
")",
",",
"$",
"strip",
")",
";",
"if",
"(",
"$",
"fileinfo",
"->",
"isDir",
"(",
")",
"and",
"substr",
"(",
"$",
"key",
",",
"-",
"1",
")",
"!==",
"'/'",
")",
"{",
"$",
"key",
".=",
"'/'",
";",
"}",
"$",
"files",
"[",
"str_replace",
"(",
"DIRECTORY_SEPARATOR",
",",
"'/'",
",",
"$",
"key",
")",
"]",
"=",
"str_replace",
"(",
"DIRECTORY_SEPARATOR",
",",
"'/'",
",",
"$",
"fileinfo",
"->",
"getRealPath",
"(",
")",
")",
";",
"}",
"return",
"$",
"files",
";",
"}"
] |
Returns list of all files in the given directory.
Given a path like /full/path/to/mod/workshop, it returns array like
[workshop/] => /full/path/to/mod/workshop
[workshop/lang/] => /full/path/to/mod/workshop/lang
[workshop/lang/workshop.php] => /full/path/to/mod/workshop/lang/workshop.php
...
Which mathes the format used by Moodle file packers.
@param string $folderpath full path to the plugin directory
@return array (string)relpath => (string)fullpath
|
[
"Returns",
"list",
"of",
"all",
"files",
"in",
"the",
"given",
"directory",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/update/code_manager.php#L320-L341
|
219,702
|
moodle/moodle
|
lib/classes/update/code_manager.php
|
code_manager.get_plugin_zip_root_dir
|
public function get_plugin_zip_root_dir($zipfilepath) {
$fp = get_file_packer('application/zip');
$files = $fp->list_files($zipfilepath);
if (empty($files)) {
return false;
}
$rootdirname = null;
foreach ($files as $file) {
$pathnameitems = explode('/', $file->pathname);
if (empty($pathnameitems)) {
return false;
}
// Set the expected name of the root directory in the first
// iteration of the loop.
if ($rootdirname === null) {
$rootdirname = $pathnameitems[0];
}
// Require the same root directory for all files in the ZIP
// package.
if ($rootdirname !== $pathnameitems[0]) {
return false;
}
}
return $rootdirname;
}
|
php
|
public function get_plugin_zip_root_dir($zipfilepath) {
$fp = get_file_packer('application/zip');
$files = $fp->list_files($zipfilepath);
if (empty($files)) {
return false;
}
$rootdirname = null;
foreach ($files as $file) {
$pathnameitems = explode('/', $file->pathname);
if (empty($pathnameitems)) {
return false;
}
// Set the expected name of the root directory in the first
// iteration of the loop.
if ($rootdirname === null) {
$rootdirname = $pathnameitems[0];
}
// Require the same root directory for all files in the ZIP
// package.
if ($rootdirname !== $pathnameitems[0]) {
return false;
}
}
return $rootdirname;
}
|
[
"public",
"function",
"get_plugin_zip_root_dir",
"(",
"$",
"zipfilepath",
")",
"{",
"$",
"fp",
"=",
"get_file_packer",
"(",
"'application/zip'",
")",
";",
"$",
"files",
"=",
"$",
"fp",
"->",
"list_files",
"(",
"$",
"zipfilepath",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"files",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"rootdirname",
"=",
"null",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
")",
"{",
"$",
"pathnameitems",
"=",
"explode",
"(",
"'/'",
",",
"$",
"file",
"->",
"pathname",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"pathnameitems",
")",
")",
"{",
"return",
"false",
";",
"}",
"// Set the expected name of the root directory in the first",
"// iteration of the loop.",
"if",
"(",
"$",
"rootdirname",
"===",
"null",
")",
"{",
"$",
"rootdirname",
"=",
"$",
"pathnameitems",
"[",
"0",
"]",
";",
"}",
"// Require the same root directory for all files in the ZIP",
"// package.",
"if",
"(",
"$",
"rootdirname",
"!==",
"$",
"pathnameitems",
"[",
"0",
"]",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"$",
"rootdirname",
";",
"}"
] |
Detects the plugin's name from its ZIP file.
Plugin ZIP packages are expected to contain a single directory and the
directory name would become the plugin name once extracted to the Moodle
dirroot.
@param string $zipfilepath full path to the ZIP files
@return string|bool false on error
|
[
"Detects",
"the",
"plugin",
"s",
"name",
"from",
"its",
"ZIP",
"file",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/update/code_manager.php#L353-L381
|
219,703
|
moodle/moodle
|
lib/classes/update/code_manager.php
|
code_manager.download_plugin_zip_file
|
protected function download_plugin_zip_file($url, $tofile) {
if (file_exists($tofile)) {
$this->debug('Error fetching plugin ZIP: target location exists.');
return false;
}
$status = $this->download_file_content($url, $tofile);
if (!$status) {
$this->debug('Error fetching plugin ZIP.');
@unlink($tofile);
return false;
}
return true;
}
|
php
|
protected function download_plugin_zip_file($url, $tofile) {
if (file_exists($tofile)) {
$this->debug('Error fetching plugin ZIP: target location exists.');
return false;
}
$status = $this->download_file_content($url, $tofile);
if (!$status) {
$this->debug('Error fetching plugin ZIP.');
@unlink($tofile);
return false;
}
return true;
}
|
[
"protected",
"function",
"download_plugin_zip_file",
"(",
"$",
"url",
",",
"$",
"tofile",
")",
"{",
"if",
"(",
"file_exists",
"(",
"$",
"tofile",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"'Error fetching plugin ZIP: target location exists.'",
")",
";",
"return",
"false",
";",
"}",
"$",
"status",
"=",
"$",
"this",
"->",
"download_file_content",
"(",
"$",
"url",
",",
"$",
"tofile",
")",
";",
"if",
"(",
"!",
"$",
"status",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"'Error fetching plugin ZIP.'",
")",
";",
"@",
"unlink",
"(",
"$",
"tofile",
")",
";",
"return",
"false",
";",
"}",
"return",
"true",
";",
"}"
] |
Download the ZIP file with the plugin package from the given location
@param string $url URL to the file
@param string $tofile full path to where to store the downloaded file
@return bool false on error
|
[
"Download",
"the",
"ZIP",
"file",
"with",
"the",
"plugin",
"package",
"from",
"the",
"given",
"location"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/update/code_manager.php#L409-L425
|
219,704
|
moodle/moodle
|
lib/classes/update/code_manager.php
|
code_manager.rename_extracted_rootdir
|
protected function rename_extracted_rootdir($dirname, $rootdir, array $files) {
if (!is_dir($dirname)) {
$this->debug('Unable to rename rootdir of non-existing content');
return $files;
}
if (file_exists($dirname.'/'.$rootdir)) {
// This typically means the real root dir already has the $rootdir name.
return $files;
}
$found = null; // The name of the first subdirectory under the $dirname.
foreach (scandir($dirname) as $item) {
if (substr($item, 0, 1) === '.') {
continue;
}
if (is_dir($dirname.'/'.$item)) {
if ($found !== null and $found !== $item) {
// Multiple directories found.
throw new moodle_exception('unexpected_archive_structure', 'core_plugin');
}
$found = $item;
}
}
if (!is_null($found)) {
if (rename($dirname.'/'.$found, $dirname.'/'.$rootdir)) {
$newfiles = array();
foreach ($files as $filepath => $status) {
$newpath = preg_replace('~^'.preg_quote($found.'/').'~', preg_quote($rootdir.'/'), $filepath);
$newfiles[$newpath] = $status;
}
return $newfiles;
}
}
return $files;
}
|
php
|
protected function rename_extracted_rootdir($dirname, $rootdir, array $files) {
if (!is_dir($dirname)) {
$this->debug('Unable to rename rootdir of non-existing content');
return $files;
}
if (file_exists($dirname.'/'.$rootdir)) {
// This typically means the real root dir already has the $rootdir name.
return $files;
}
$found = null; // The name of the first subdirectory under the $dirname.
foreach (scandir($dirname) as $item) {
if (substr($item, 0, 1) === '.') {
continue;
}
if (is_dir($dirname.'/'.$item)) {
if ($found !== null and $found !== $item) {
// Multiple directories found.
throw new moodle_exception('unexpected_archive_structure', 'core_plugin');
}
$found = $item;
}
}
if (!is_null($found)) {
if (rename($dirname.'/'.$found, $dirname.'/'.$rootdir)) {
$newfiles = array();
foreach ($files as $filepath => $status) {
$newpath = preg_replace('~^'.preg_quote($found.'/').'~', preg_quote($rootdir.'/'), $filepath);
$newfiles[$newpath] = $status;
}
return $newfiles;
}
}
return $files;
}
|
[
"protected",
"function",
"rename_extracted_rootdir",
"(",
"$",
"dirname",
",",
"$",
"rootdir",
",",
"array",
"$",
"files",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"dirname",
")",
")",
"{",
"$",
"this",
"->",
"debug",
"(",
"'Unable to rename rootdir of non-existing content'",
")",
";",
"return",
"$",
"files",
";",
"}",
"if",
"(",
"file_exists",
"(",
"$",
"dirname",
".",
"'/'",
".",
"$",
"rootdir",
")",
")",
"{",
"// This typically means the real root dir already has the $rootdir name.",
"return",
"$",
"files",
";",
"}",
"$",
"found",
"=",
"null",
";",
"// The name of the first subdirectory under the $dirname.",
"foreach",
"(",
"scandir",
"(",
"$",
"dirname",
")",
"as",
"$",
"item",
")",
"{",
"if",
"(",
"substr",
"(",
"$",
"item",
",",
"0",
",",
"1",
")",
"===",
"'.'",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"is_dir",
"(",
"$",
"dirname",
".",
"'/'",
".",
"$",
"item",
")",
")",
"{",
"if",
"(",
"$",
"found",
"!==",
"null",
"and",
"$",
"found",
"!==",
"$",
"item",
")",
"{",
"// Multiple directories found.",
"throw",
"new",
"moodle_exception",
"(",
"'unexpected_archive_structure'",
",",
"'core_plugin'",
")",
";",
"}",
"$",
"found",
"=",
"$",
"item",
";",
"}",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"found",
")",
")",
"{",
"if",
"(",
"rename",
"(",
"$",
"dirname",
".",
"'/'",
".",
"$",
"found",
",",
"$",
"dirname",
".",
"'/'",
".",
"$",
"rootdir",
")",
")",
"{",
"$",
"newfiles",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"filepath",
"=>",
"$",
"status",
")",
"{",
"$",
"newpath",
"=",
"preg_replace",
"(",
"'~^'",
".",
"preg_quote",
"(",
"$",
"found",
".",
"'/'",
")",
".",
"'~'",
",",
"preg_quote",
"(",
"$",
"rootdir",
".",
"'/'",
")",
",",
"$",
"filepath",
")",
";",
"$",
"newfiles",
"[",
"$",
"newpath",
"]",
"=",
"$",
"status",
";",
"}",
"return",
"$",
"newfiles",
";",
"}",
"}",
"return",
"$",
"files",
";",
"}"
] |
Renames the root directory of the extracted ZIP package.
This internal helper method assumes that the plugin ZIP package has been
extracted into a temporary empty directory so the plugin folder is the
only folder there. The ZIP package is supposed to be validated so that
it contains just a single root folder.
@param string $dirname fullpath location of the extracted ZIP package
@param string $rootdir the requested name of the root directory
@param array $files list of extracted files
@return array eventually amended list of extracted files
|
[
"Renames",
"the",
"root",
"directory",
"of",
"the",
"extracted",
"ZIP",
"package",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/update/code_manager.php#L463-L501
|
219,705
|
moodle/moodle
|
lib/classes/update/code_manager.php
|
code_manager.set_plugin_files_permissions
|
protected function set_plugin_files_permissions($targetdir, array $files) {
$dirpermissions = fileperms($targetdir);
$filepermissions = ($dirpermissions & 0666);
foreach ($files as $subpath => $notusedhere) {
$path = $targetdir.'/'.$subpath;
if (is_dir($path)) {
@chmod($path, $dirpermissions);
} else {
@chmod($path, $filepermissions);
}
}
}
|
php
|
protected function set_plugin_files_permissions($targetdir, array $files) {
$dirpermissions = fileperms($targetdir);
$filepermissions = ($dirpermissions & 0666);
foreach ($files as $subpath => $notusedhere) {
$path = $targetdir.'/'.$subpath;
if (is_dir($path)) {
@chmod($path, $dirpermissions);
} else {
@chmod($path, $filepermissions);
}
}
}
|
[
"protected",
"function",
"set_plugin_files_permissions",
"(",
"$",
"targetdir",
",",
"array",
"$",
"files",
")",
"{",
"$",
"dirpermissions",
"=",
"fileperms",
"(",
"$",
"targetdir",
")",
";",
"$",
"filepermissions",
"=",
"(",
"$",
"dirpermissions",
"&",
"0666",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"subpath",
"=>",
"$",
"notusedhere",
")",
"{",
"$",
"path",
"=",
"$",
"targetdir",
".",
"'/'",
".",
"$",
"subpath",
";",
"if",
"(",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"@",
"chmod",
"(",
"$",
"path",
",",
"$",
"dirpermissions",
")",
";",
"}",
"else",
"{",
"@",
"chmod",
"(",
"$",
"path",
",",
"$",
"filepermissions",
")",
";",
"}",
"}",
"}"
] |
Sets the permissions of extracted subdirs and files
As a result of unzipping, the subdirs and files are created with
permissions set to $CFG->directorypermissions and $CFG->filepermissions.
These are too benevolent by default (777 and 666 respectively) for PHP
scripts and may lead to HTTP 500 errors in some environments.
To fix this behaviour, we inherit the permissions of the plugin root
directory itself.
@param string $targetdir full path to the directory the ZIP file was extracted to
@param array $files list of extracted files
|
[
"Sets",
"the",
"permissions",
"of",
"extracted",
"subdirs",
"and",
"files"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/update/code_manager.php#L517-L530
|
219,706
|
moodle/moodle
|
lib/classes/update/code_manager.php
|
code_manager.move_extracted_plugin_files
|
protected function move_extracted_plugin_files($sourcedir, $targetdir, array $files) {
global $CFG;
foreach ($files as $file => $status) {
if ($status !== true) {
throw new moodle_exception('corrupted_archive_structure', 'core_plugin', '', $file, $status);
}
$source = $sourcedir.'/'.$file;
$target = $targetdir.'/'.$file;
if (is_dir($source)) {
continue;
} else {
if (!is_dir(dirname($target))) {
mkdir(dirname($target), $CFG->directorypermissions, true);
}
rename($source, $target);
}
}
}
|
php
|
protected function move_extracted_plugin_files($sourcedir, $targetdir, array $files) {
global $CFG;
foreach ($files as $file => $status) {
if ($status !== true) {
throw new moodle_exception('corrupted_archive_structure', 'core_plugin', '', $file, $status);
}
$source = $sourcedir.'/'.$file;
$target = $targetdir.'/'.$file;
if (is_dir($source)) {
continue;
} else {
if (!is_dir(dirname($target))) {
mkdir(dirname($target), $CFG->directorypermissions, true);
}
rename($source, $target);
}
}
}
|
[
"protected",
"function",
"move_extracted_plugin_files",
"(",
"$",
"sourcedir",
",",
"$",
"targetdir",
",",
"array",
"$",
"files",
")",
"{",
"global",
"$",
"CFG",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"file",
"=>",
"$",
"status",
")",
"{",
"if",
"(",
"$",
"status",
"!==",
"true",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'corrupted_archive_structure'",
",",
"'core_plugin'",
",",
"''",
",",
"$",
"file",
",",
"$",
"status",
")",
";",
"}",
"$",
"source",
"=",
"$",
"sourcedir",
".",
"'/'",
".",
"$",
"file",
";",
"$",
"target",
"=",
"$",
"targetdir",
".",
"'/'",
".",
"$",
"file",
";",
"if",
"(",
"is_dir",
"(",
"$",
"source",
")",
")",
"{",
"continue",
";",
"}",
"else",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"dirname",
"(",
"$",
"target",
")",
")",
")",
"{",
"mkdir",
"(",
"dirname",
"(",
"$",
"target",
")",
",",
"$",
"CFG",
"->",
"directorypermissions",
",",
"true",
")",
";",
"}",
"rename",
"(",
"$",
"source",
",",
"$",
"target",
")",
";",
"}",
"}",
"}"
] |
Moves the extracted contents of the plugin ZIP into the target location.
@param string $sourcedir full path to the directory the ZIP file was extracted to
@param mixed $targetdir full path to the directory where the files should be moved to
@param array $files list of extracted files
|
[
"Moves",
"the",
"extracted",
"contents",
"of",
"the",
"plugin",
"ZIP",
"into",
"the",
"target",
"location",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/classes/update/code_manager.php#L539-L560
|
219,707
|
moodle/moodle
|
lib/adodb/drivers/adodb-postgres7.inc.php
|
ADODB_postgres7.SelectLimit
|
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
{
$offsetStr = ($offset >= 0) ? " OFFSET ".((integer)$offset) : '';
$limitStr = ($nrows >= 0) ? " LIMIT ".((integer)$nrows) : '';
if ($secs2cache)
$rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
else
$rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr);
return $rs;
}
|
php
|
function SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs2cache=0)
{
$offsetStr = ($offset >= 0) ? " OFFSET ".((integer)$offset) : '';
$limitStr = ($nrows >= 0) ? " LIMIT ".((integer)$nrows) : '';
if ($secs2cache)
$rs = $this->CacheExecute($secs2cache,$sql."$limitStr$offsetStr",$inputarr);
else
$rs = $this->Execute($sql."$limitStr$offsetStr",$inputarr);
return $rs;
}
|
[
"function",
"SelectLimit",
"(",
"$",
"sql",
",",
"$",
"nrows",
"=",
"-",
"1",
",",
"$",
"offset",
"=",
"-",
"1",
",",
"$",
"inputarr",
"=",
"false",
",",
"$",
"secs2cache",
"=",
"0",
")",
"{",
"$",
"offsetStr",
"=",
"(",
"$",
"offset",
">=",
"0",
")",
"?",
"\" OFFSET \"",
".",
"(",
"(",
"integer",
")",
"$",
"offset",
")",
":",
"''",
";",
"$",
"limitStr",
"=",
"(",
"$",
"nrows",
">=",
"0",
")",
"?",
"\" LIMIT \"",
".",
"(",
"(",
"integer",
")",
"$",
"nrows",
")",
":",
"''",
";",
"if",
"(",
"$",
"secs2cache",
")",
"$",
"rs",
"=",
"$",
"this",
"->",
"CacheExecute",
"(",
"$",
"secs2cache",
",",
"$",
"sql",
".",
"\"$limitStr$offsetStr\"",
",",
"$",
"inputarr",
")",
";",
"else",
"$",
"rs",
"=",
"$",
"this",
"->",
"Execute",
"(",
"$",
"sql",
".",
"\"$limitStr$offsetStr\"",
",",
"$",
"inputarr",
")",
";",
"return",
"$",
"rs",
";",
"}"
] |
which makes obsolete the LIMIT limit,offset syntax
|
[
"which",
"makes",
"obsolete",
"the",
"LIMIT",
"limit",
"offset",
"syntax"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/drivers/adodb-postgres7.inc.php#L110-L120
|
219,708
|
moodle/moodle
|
lib/adodb/drivers/adodb-postgres7.inc.php
|
ADODB_postgres7._generateMetaColumnsSQL
|
protected function _generateMetaColumnsSQL($table, $schema)
{
if ($schema) {
return sprintf($this->metaColumnsSQL1, $table, $table, $table, $schema);
}
else {
return sprintf($this->metaColumnsSQL, $table, $table, $schema);
}
}
|
php
|
protected function _generateMetaColumnsSQL($table, $schema)
{
if ($schema) {
return sprintf($this->metaColumnsSQL1, $table, $table, $table, $schema);
}
else {
return sprintf($this->metaColumnsSQL, $table, $table, $schema);
}
}
|
[
"protected",
"function",
"_generateMetaColumnsSQL",
"(",
"$",
"table",
",",
"$",
"schema",
")",
"{",
"if",
"(",
"$",
"schema",
")",
"{",
"return",
"sprintf",
"(",
"$",
"this",
"->",
"metaColumnsSQL1",
",",
"$",
"table",
",",
"$",
"table",
",",
"$",
"table",
",",
"$",
"schema",
")",
";",
"}",
"else",
"{",
"return",
"sprintf",
"(",
"$",
"this",
"->",
"metaColumnsSQL",
",",
"$",
"table",
",",
"$",
"table",
",",
"$",
"schema",
")",
";",
"}",
"}"
] |
Generate the SQL to retrieve MetaColumns data
@param string $table Table name
@param string $schema Schema name (can be blank)
@return string SQL statement to execute
|
[
"Generate",
"the",
"SQL",
"to",
"retrieve",
"MetaColumns",
"data"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/drivers/adodb-postgres7.inc.php#L139-L147
|
219,709
|
moodle/moodle
|
lib/adodb/drivers/adodb-postgres7.inc.php
|
ADODB_postgres7._old_MetaForeignKeys
|
function _old_MetaForeignKeys($table, $owner=false, $upper=false)
{
$sql = 'SELECT t.tgargs as args
FROM
pg_trigger t,pg_class c,pg_proc p
WHERE
t.tgenabled AND
t.tgrelid = c.oid AND
t.tgfoid = p.oid AND
p.proname = \'RI_FKey_check_ins\' AND
c.relname = \''.strtolower($table).'\'
ORDER BY
t.tgrelid';
$rs = $this->Execute($sql);
if (!$rs || $rs->EOF) return false;
$arr = $rs->GetArray();
$a = array();
foreach($arr as $v) {
$data = explode(chr(0), $v['args']);
$size = count($data)-1; //-1 because the last node is empty
for($i = 4; $i < $size; $i++) {
if ($upper)
$a[strtoupper($data[2])][] = strtoupper($data[$i].'='.$data[++$i]);
else
$a[$data[2]][] = $data[$i].'='.$data[++$i];
}
}
return $a;
}
|
php
|
function _old_MetaForeignKeys($table, $owner=false, $upper=false)
{
$sql = 'SELECT t.tgargs as args
FROM
pg_trigger t,pg_class c,pg_proc p
WHERE
t.tgenabled AND
t.tgrelid = c.oid AND
t.tgfoid = p.oid AND
p.proname = \'RI_FKey_check_ins\' AND
c.relname = \''.strtolower($table).'\'
ORDER BY
t.tgrelid';
$rs = $this->Execute($sql);
if (!$rs || $rs->EOF) return false;
$arr = $rs->GetArray();
$a = array();
foreach($arr as $v) {
$data = explode(chr(0), $v['args']);
$size = count($data)-1; //-1 because the last node is empty
for($i = 4; $i < $size; $i++) {
if ($upper)
$a[strtoupper($data[2])][] = strtoupper($data[$i].'='.$data[++$i]);
else
$a[$data[2]][] = $data[$i].'='.$data[++$i];
}
}
return $a;
}
|
[
"function",
"_old_MetaForeignKeys",
"(",
"$",
"table",
",",
"$",
"owner",
"=",
"false",
",",
"$",
"upper",
"=",
"false",
")",
"{",
"$",
"sql",
"=",
"'SELECT t.tgargs as args\n\t\tFROM\n\t\tpg_trigger t,pg_class c,pg_proc p\n\t\tWHERE\n\t\tt.tgenabled AND\n\t\tt.tgrelid = c.oid AND\n\t\tt.tgfoid = p.oid AND\n\t\tp.proname = \\'RI_FKey_check_ins\\' AND\n\t\tc.relname = \\''",
".",
"strtolower",
"(",
"$",
"table",
")",
".",
"'\\'\n\t\tORDER BY\n\t\t\tt.tgrelid'",
";",
"$",
"rs",
"=",
"$",
"this",
"->",
"Execute",
"(",
"$",
"sql",
")",
";",
"if",
"(",
"!",
"$",
"rs",
"||",
"$",
"rs",
"->",
"EOF",
")",
"return",
"false",
";",
"$",
"arr",
"=",
"$",
"rs",
"->",
"GetArray",
"(",
")",
";",
"$",
"a",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"v",
")",
"{",
"$",
"data",
"=",
"explode",
"(",
"chr",
"(",
"0",
")",
",",
"$",
"v",
"[",
"'args'",
"]",
")",
";",
"$",
"size",
"=",
"count",
"(",
"$",
"data",
")",
"-",
"1",
";",
"//-1 because the last node is empty",
"for",
"(",
"$",
"i",
"=",
"4",
";",
"$",
"i",
"<",
"$",
"size",
";",
"$",
"i",
"++",
")",
"{",
"if",
"(",
"$",
"upper",
")",
"$",
"a",
"[",
"strtoupper",
"(",
"$",
"data",
"[",
"2",
"]",
")",
"]",
"[",
"]",
"=",
"strtoupper",
"(",
"$",
"data",
"[",
"$",
"i",
"]",
".",
"'='",
".",
"$",
"data",
"[",
"++",
"$",
"i",
"]",
")",
";",
"else",
"$",
"a",
"[",
"$",
"data",
"[",
"2",
"]",
"]",
"[",
"]",
"=",
"$",
"data",
"[",
"$",
"i",
"]",
".",
"'='",
".",
"$",
"data",
"[",
"++",
"$",
"i",
"]",
";",
"}",
"}",
"return",
"$",
"a",
";",
"}"
] |
from Edward Jaramilla, improved version - works on pg 7.4
|
[
"from",
"Edward",
"Jaramilla",
"improved",
"version",
"-",
"works",
"on",
"pg",
"7",
".",
"4"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/drivers/adodb-postgres7.inc.php#L201-L232
|
219,710
|
moodle/moodle
|
lib/adodb/drivers/adodb-postgres7.inc.php
|
ADODB_postgres7.GetCharSet
|
function GetCharSet()
{
//we will use ADO's builtin property charSet
$this->charSet = @pg_client_encoding($this->_connectionID);
if (!$this->charSet) {
return false;
} else {
return $this->charSet;
}
}
|
php
|
function GetCharSet()
{
//we will use ADO's builtin property charSet
$this->charSet = @pg_client_encoding($this->_connectionID);
if (!$this->charSet) {
return false;
} else {
return $this->charSet;
}
}
|
[
"function",
"GetCharSet",
"(",
")",
"{",
"//we will use ADO's builtin property charSet",
"$",
"this",
"->",
"charSet",
"=",
"@",
"pg_client_encoding",
"(",
"$",
"this",
"->",
"_connectionID",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"charSet",
")",
"{",
"return",
"false",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"charSet",
";",
"}",
"}"
] |
it will return 'SQL_ANSI' always
|
[
"it",
"will",
"return",
"SQL_ANSI",
"always"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/drivers/adodb-postgres7.inc.php#L277-L286
|
219,711
|
moodle/moodle
|
lib/adodb/drivers/adodb-postgres7.inc.php
|
ADODB_postgres7.SetCharSet
|
function SetCharSet($charset_name)
{
$this->GetCharSet();
if ($this->charSet !== $charset_name) {
$if = pg_set_client_encoding($this->_connectionID, $charset_name);
if ($if == "0" & $this->GetCharSet() == $charset_name) {
return true;
} else return false;
} else return true;
}
|
php
|
function SetCharSet($charset_name)
{
$this->GetCharSet();
if ($this->charSet !== $charset_name) {
$if = pg_set_client_encoding($this->_connectionID, $charset_name);
if ($if == "0" & $this->GetCharSet() == $charset_name) {
return true;
} else return false;
} else return true;
}
|
[
"function",
"SetCharSet",
"(",
"$",
"charset_name",
")",
"{",
"$",
"this",
"->",
"GetCharSet",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"charSet",
"!==",
"$",
"charset_name",
")",
"{",
"$",
"if",
"=",
"pg_set_client_encoding",
"(",
"$",
"this",
"->",
"_connectionID",
",",
"$",
"charset_name",
")",
";",
"if",
"(",
"$",
"if",
"==",
"\"0\"",
"&",
"$",
"this",
"->",
"GetCharSet",
"(",
")",
"==",
"$",
"charset_name",
")",
"{",
"return",
"true",
";",
"}",
"else",
"return",
"false",
";",
"}",
"else",
"return",
"true",
";",
"}"
] |
SetCharSet - switch the client encoding
|
[
"SetCharSet",
"-",
"switch",
"the",
"client",
"encoding"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/adodb/drivers/adodb-postgres7.inc.php#L289-L298
|
219,712
|
moodle/moodle
|
question/type/match/backup/moodle2/restore_qtype_match_plugin.class.php
|
restore_qtype_match_plugin.recode_legacy_state_answer
|
public function recode_legacy_state_answer($state) {
$answer = $state->answer;
$resultarr = array();
foreach (explode(',', $answer) as $pair) {
$pairarr = explode('-', $pair);
$id = $pairarr[0];
$code = $pairarr[1];
$newid = $this->get_mappingid('qtype_match_subquestions', $id);
if ($code) {
$newcode = $this->get_mappingid('qtype_match_subquestion_codes', $code);
} else {
$newcode = $code;
}
$resultarr[] = $newid . '-' . $newcode;
}
return implode(',', $resultarr);
}
|
php
|
public function recode_legacy_state_answer($state) {
$answer = $state->answer;
$resultarr = array();
foreach (explode(',', $answer) as $pair) {
$pairarr = explode('-', $pair);
$id = $pairarr[0];
$code = $pairarr[1];
$newid = $this->get_mappingid('qtype_match_subquestions', $id);
if ($code) {
$newcode = $this->get_mappingid('qtype_match_subquestion_codes', $code);
} else {
$newcode = $code;
}
$resultarr[] = $newid . '-' . $newcode;
}
return implode(',', $resultarr);
}
|
[
"public",
"function",
"recode_legacy_state_answer",
"(",
"$",
"state",
")",
"{",
"$",
"answer",
"=",
"$",
"state",
"->",
"answer",
";",
"$",
"resultarr",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"explode",
"(",
"','",
",",
"$",
"answer",
")",
"as",
"$",
"pair",
")",
"{",
"$",
"pairarr",
"=",
"explode",
"(",
"'-'",
",",
"$",
"pair",
")",
";",
"$",
"id",
"=",
"$",
"pairarr",
"[",
"0",
"]",
";",
"$",
"code",
"=",
"$",
"pairarr",
"[",
"1",
"]",
";",
"$",
"newid",
"=",
"$",
"this",
"->",
"get_mappingid",
"(",
"'qtype_match_subquestions'",
",",
"$",
"id",
")",
";",
"if",
"(",
"$",
"code",
")",
"{",
"$",
"newcode",
"=",
"$",
"this",
"->",
"get_mappingid",
"(",
"'qtype_match_subquestion_codes'",
",",
"$",
"code",
")",
";",
"}",
"else",
"{",
"$",
"newcode",
"=",
"$",
"code",
";",
"}",
"$",
"resultarr",
"[",
"]",
"=",
"$",
"newid",
".",
"'-'",
".",
"$",
"newcode",
";",
"}",
"return",
"implode",
"(",
"','",
",",
"$",
"resultarr",
")",
";",
"}"
] |
Given one question_states record, return the answer
recoded pointing to all the restored stuff for match questions.
answer is one comma separated list of hypen separated pairs
containing question_match_sub->id and question_match_sub->code, which
has been remapped to be qtype_match_subquestions->id, since code no longer exists.
|
[
"Given",
"one",
"question_states",
"record",
"return",
"the",
"answer",
"recoded",
"pointing",
"to",
"all",
"the",
"restored",
"stuff",
"for",
"match",
"questions",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/type/match/backup/moodle2/restore_qtype_match_plugin.class.php#L201-L217
|
219,713
|
moodle/moodle
|
course/classes/search/section.php
|
section.get_document_recordset
|
public function get_document_recordset($modifiedfrom = 0, \context $context = null) {
global $DB;
list ($contextjoin, $contextparams) = $this->get_course_level_context_restriction_sql($context, 'c');
if ($contextjoin === null) {
return null;
}
$comparetext = $DB->sql_compare_text('cs.summary', 1);
return $DB->get_recordset_sql("
SELECT cs.id,
cs.course,
cs.section,
cs.name,
cs.summary,
cs.summaryformat,
cs.timemodified
FROM {course_sections} cs
JOIN {course} c ON c.id = cs.course
$contextjoin
WHERE cs.timemodified >= ?
AND (cs.name != ? OR $comparetext != ?)
ORDER BY cs.timemodified ASC", array_merge($contextparams, [$modifiedfrom, '', '']));
}
|
php
|
public function get_document_recordset($modifiedfrom = 0, \context $context = null) {
global $DB;
list ($contextjoin, $contextparams) = $this->get_course_level_context_restriction_sql($context, 'c');
if ($contextjoin === null) {
return null;
}
$comparetext = $DB->sql_compare_text('cs.summary', 1);
return $DB->get_recordset_sql("
SELECT cs.id,
cs.course,
cs.section,
cs.name,
cs.summary,
cs.summaryformat,
cs.timemodified
FROM {course_sections} cs
JOIN {course} c ON c.id = cs.course
$contextjoin
WHERE cs.timemodified >= ?
AND (cs.name != ? OR $comparetext != ?)
ORDER BY cs.timemodified ASC", array_merge($contextparams, [$modifiedfrom, '', '']));
}
|
[
"public",
"function",
"get_document_recordset",
"(",
"$",
"modifiedfrom",
"=",
"0",
",",
"\\",
"context",
"$",
"context",
"=",
"null",
")",
"{",
"global",
"$",
"DB",
";",
"list",
"(",
"$",
"contextjoin",
",",
"$",
"contextparams",
")",
"=",
"$",
"this",
"->",
"get_course_level_context_restriction_sql",
"(",
"$",
"context",
",",
"'c'",
")",
";",
"if",
"(",
"$",
"contextjoin",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"$",
"comparetext",
"=",
"$",
"DB",
"->",
"sql_compare_text",
"(",
"'cs.summary'",
",",
"1",
")",
";",
"return",
"$",
"DB",
"->",
"get_recordset_sql",
"(",
"\"\n SELECT cs.id,\n cs.course,\n cs.section,\n cs.name,\n cs.summary,\n cs.summaryformat,\n cs.timemodified\n FROM {course_sections} cs\n JOIN {course} c ON c.id = cs.course\n $contextjoin\n WHERE cs.timemodified >= ?\n AND (cs.name != ? OR $comparetext != ?)\n ORDER BY cs.timemodified ASC\"",
",",
"array_merge",
"(",
"$",
"contextparams",
",",
"[",
"$",
"modifiedfrom",
",",
"''",
",",
"''",
"]",
")",
")",
";",
"}"
] |
Returns recordset containing required data for indexing course sections.
@param int $modifiedfrom timestamp
@param \context|null $context Restriction context
@return \moodle_recordset|null Recordset or null if no change possible
|
[
"Returns",
"recordset",
"containing",
"required",
"data",
"for",
"indexing",
"course",
"sections",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/search/section.php#L54-L78
|
219,714
|
moodle/moodle
|
course/classes/search/section.php
|
section.check_access
|
public function check_access($id) {
global $DB;
// Check we can get the section and the course modinfo.
$sectionrec = $DB->get_record('course_sections', ['id' => $id], '*', IGNORE_MISSING);
if (!$sectionrec) {
return \core_search\manager::ACCESS_DELETED;
}
try {
$modinfo = get_fast_modinfo($sectionrec->course);
} catch (\moodle_exception $e) {
return \core_search\manager::ACCESS_DELETED;
}
$section = $modinfo->get_section_info($sectionrec->section, IGNORE_MISSING);
if (!$section) {
return \core_search\manager::ACCESS_DELETED;
}
// Check access to course and that the section is visible to current user.
if (can_access_course($modinfo->get_course()) && $section->uservisible) {
return \core_search\manager::ACCESS_GRANTED;
}
return \core_search\manager::ACCESS_DENIED;
}
|
php
|
public function check_access($id) {
global $DB;
// Check we can get the section and the course modinfo.
$sectionrec = $DB->get_record('course_sections', ['id' => $id], '*', IGNORE_MISSING);
if (!$sectionrec) {
return \core_search\manager::ACCESS_DELETED;
}
try {
$modinfo = get_fast_modinfo($sectionrec->course);
} catch (\moodle_exception $e) {
return \core_search\manager::ACCESS_DELETED;
}
$section = $modinfo->get_section_info($sectionrec->section, IGNORE_MISSING);
if (!$section) {
return \core_search\manager::ACCESS_DELETED;
}
// Check access to course and that the section is visible to current user.
if (can_access_course($modinfo->get_course()) && $section->uservisible) {
return \core_search\manager::ACCESS_GRANTED;
}
return \core_search\manager::ACCESS_DENIED;
}
|
[
"public",
"function",
"check_access",
"(",
"$",
"id",
")",
"{",
"global",
"$",
"DB",
";",
"// Check we can get the section and the course modinfo.",
"$",
"sectionrec",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"'course_sections'",
",",
"[",
"'id'",
"=>",
"$",
"id",
"]",
",",
"'*'",
",",
"IGNORE_MISSING",
")",
";",
"if",
"(",
"!",
"$",
"sectionrec",
")",
"{",
"return",
"\\",
"core_search",
"\\",
"manager",
"::",
"ACCESS_DELETED",
";",
"}",
"try",
"{",
"$",
"modinfo",
"=",
"get_fast_modinfo",
"(",
"$",
"sectionrec",
"->",
"course",
")",
";",
"}",
"catch",
"(",
"\\",
"moodle_exception",
"$",
"e",
")",
"{",
"return",
"\\",
"core_search",
"\\",
"manager",
"::",
"ACCESS_DELETED",
";",
"}",
"$",
"section",
"=",
"$",
"modinfo",
"->",
"get_section_info",
"(",
"$",
"sectionrec",
"->",
"section",
",",
"IGNORE_MISSING",
")",
";",
"if",
"(",
"!",
"$",
"section",
")",
"{",
"return",
"\\",
"core_search",
"\\",
"manager",
"::",
"ACCESS_DELETED",
";",
"}",
"// Check access to course and that the section is visible to current user.",
"if",
"(",
"can_access_course",
"(",
"$",
"modinfo",
"->",
"get_course",
"(",
")",
")",
"&&",
"$",
"section",
"->",
"uservisible",
")",
"{",
"return",
"\\",
"core_search",
"\\",
"manager",
"::",
"ACCESS_GRANTED",
";",
"}",
"return",
"\\",
"core_search",
"\\",
"manager",
"::",
"ACCESS_DENIED",
";",
"}"
] |
Whether the user can access the section or not.
@param int $id The course section id.
@return int One of the \core_search\manager:ACCESS_xx constants
|
[
"Whether",
"the",
"user",
"can",
"access",
"the",
"section",
"or",
"not",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/search/section.php#L123-L147
|
219,715
|
moodle/moodle
|
course/classes/search/section.php
|
section.get_doc_url
|
public function get_doc_url(\core_search\document $doc) {
global $DB;
$section = $DB->get_field('course_sections', 'section', ['id' => $doc->get('itemid')], MUST_EXIST);
$format = course_get_format($doc->get('courseid'));
return $format->get_view_url($section);
}
|
php
|
public function get_doc_url(\core_search\document $doc) {
global $DB;
$section = $DB->get_field('course_sections', 'section', ['id' => $doc->get('itemid')], MUST_EXIST);
$format = course_get_format($doc->get('courseid'));
return $format->get_view_url($section);
}
|
[
"public",
"function",
"get_doc_url",
"(",
"\\",
"core_search",
"\\",
"document",
"$",
"doc",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"section",
"=",
"$",
"DB",
"->",
"get_field",
"(",
"'course_sections'",
",",
"'section'",
",",
"[",
"'id'",
"=>",
"$",
"doc",
"->",
"get",
"(",
"'itemid'",
")",
"]",
",",
"MUST_EXIST",
")",
";",
"$",
"format",
"=",
"course_get_format",
"(",
"$",
"doc",
"->",
"get",
"(",
"'courseid'",
")",
")",
";",
"return",
"$",
"format",
"->",
"get_view_url",
"(",
"$",
"section",
")",
";",
"}"
] |
Gets a link to the section.
@param \core_search\document $doc
@return \moodle_url
|
[
"Gets",
"a",
"link",
"to",
"the",
"section",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/search/section.php#L155-L160
|
219,716
|
moodle/moodle
|
course/classes/analytics/target/course_competencies.php
|
course_competencies.get_num_competencies_in_course
|
protected function get_num_competencies_in_course ($courseid) {
if (!isset($this->coursecompetencies[$courseid])) {
$ccs = \core_competency\api::count_competencies_in_course($courseid);
// Save the number of competencies per course to avoid another database access in calculate_sample().
$this->coursecompetencies[$courseid] = $ccs;
} else {
$ccs = $this->coursecompetencies[$courseid];
}
return $ccs;
}
|
php
|
protected function get_num_competencies_in_course ($courseid) {
if (!isset($this->coursecompetencies[$courseid])) {
$ccs = \core_competency\api::count_competencies_in_course($courseid);
// Save the number of competencies per course to avoid another database access in calculate_sample().
$this->coursecompetencies[$courseid] = $ccs;
} else {
$ccs = $this->coursecompetencies[$courseid];
}
return $ccs;
}
|
[
"protected",
"function",
"get_num_competencies_in_course",
"(",
"$",
"courseid",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"coursecompetencies",
"[",
"$",
"courseid",
"]",
")",
")",
"{",
"$",
"ccs",
"=",
"\\",
"core_competency",
"\\",
"api",
"::",
"count_competencies_in_course",
"(",
"$",
"courseid",
")",
";",
"// Save the number of competencies per course to avoid another database access in calculate_sample().",
"$",
"this",
"->",
"coursecompetencies",
"[",
"$",
"courseid",
"]",
"=",
"$",
"ccs",
";",
"}",
"else",
"{",
"$",
"ccs",
"=",
"$",
"this",
"->",
"coursecompetencies",
"[",
"$",
"courseid",
"]",
";",
"}",
"return",
"$",
"ccs",
";",
"}"
] |
Count the competencies in a course.
Save the value in $coursecompetencies array to prevent new accesses to the database.
@param int $courseid The course id.
@return int Number of competencies assigned to the course.
|
[
"Count",
"the",
"competencies",
"in",
"a",
"course",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/analytics/target/course_competencies.php#L52-L62
|
219,717
|
moodle/moodle
|
course/classes/analytics/target/course_competencies.php
|
course_competencies.calculate_sample
|
protected function calculate_sample($sampleid, \core_analytics\analysable $course, $starttime = false, $endtime = false) {
$userenrol = $this->retrieve('user_enrolments', $sampleid);
$key = $course->get_id();
// Number of competencies in the course.
$ccs = $this->get_num_competencies_in_course($key);
// Number of proficient competencies in the same course for the user.
$ucs = \core_competency\api::count_proficient_competencies_in_course_for_user($key, $userenrol->userid);
// If they are the equals, the user achieved all the competencies assigned to the course.
if ($ccs == $ucs) {
return 0;
}
return 1;
}
|
php
|
protected function calculate_sample($sampleid, \core_analytics\analysable $course, $starttime = false, $endtime = false) {
$userenrol = $this->retrieve('user_enrolments', $sampleid);
$key = $course->get_id();
// Number of competencies in the course.
$ccs = $this->get_num_competencies_in_course($key);
// Number of proficient competencies in the same course for the user.
$ucs = \core_competency\api::count_proficient_competencies_in_course_for_user($key, $userenrol->userid);
// If they are the equals, the user achieved all the competencies assigned to the course.
if ($ccs == $ucs) {
return 0;
}
return 1;
}
|
[
"protected",
"function",
"calculate_sample",
"(",
"$",
"sampleid",
",",
"\\",
"core_analytics",
"\\",
"analysable",
"$",
"course",
",",
"$",
"starttime",
"=",
"false",
",",
"$",
"endtime",
"=",
"false",
")",
"{",
"$",
"userenrol",
"=",
"$",
"this",
"->",
"retrieve",
"(",
"'user_enrolments'",
",",
"$",
"sampleid",
")",
";",
"$",
"key",
"=",
"$",
"course",
"->",
"get_id",
"(",
")",
";",
"// Number of competencies in the course.",
"$",
"ccs",
"=",
"$",
"this",
"->",
"get_num_competencies_in_course",
"(",
"$",
"key",
")",
";",
"// Number of proficient competencies in the same course for the user.",
"$",
"ucs",
"=",
"\\",
"core_competency",
"\\",
"api",
"::",
"count_proficient_competencies_in_course_for_user",
"(",
"$",
"key",
",",
"$",
"userenrol",
"->",
"userid",
")",
";",
"// If they are the equals, the user achieved all the competencies assigned to the course.",
"if",
"(",
"$",
"ccs",
"==",
"$",
"ucs",
")",
"{",
"return",
"0",
";",
"}",
"return",
"1",
";",
"}"
] |
To have the proficiency or not in each of the competencies assigned to the course sets the target value.
@param int $sampleid
@param \core_analytics\analysable $course
@param int $starttime
@param int $endtime
@return float 0 -> competencies achieved, 1 -> competencies not achieved
|
[
"To",
"have",
"the",
"proficiency",
"or",
"not",
"in",
"each",
"of",
"the",
"competencies",
"assigned",
"to",
"the",
"course",
"sets",
"the",
"target",
"value",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/analytics/target/course_competencies.php#L119-L135
|
219,718
|
moodle/moodle
|
lib/horde/framework/Horde/Imap/Client/Ids/Map.php
|
Horde_Imap_Client_Ids_Map.update
|
public function update($ids)
{
if (empty($ids)) {
return false;
} elseif (empty($this->_ids)) {
$this->_ids = $ids;
$change = true;
} else {
$change = false;
foreach ($ids as $k => $v) {
if (!isset($this->_ids[$k]) || ($this->_ids[$k] != $v)) {
$this->_ids[$k] = $v;
$change = true;
}
}
}
if ($change) {
$this->_sorted = false;
}
return $change;
}
|
php
|
public function update($ids)
{
if (empty($ids)) {
return false;
} elseif (empty($this->_ids)) {
$this->_ids = $ids;
$change = true;
} else {
$change = false;
foreach ($ids as $k => $v) {
if (!isset($this->_ids[$k]) || ($this->_ids[$k] != $v)) {
$this->_ids[$k] = $v;
$change = true;
}
}
}
if ($change) {
$this->_sorted = false;
}
return $change;
}
|
[
"public",
"function",
"update",
"(",
"$",
"ids",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"ids",
")",
")",
"{",
"return",
"false",
";",
"}",
"elseif",
"(",
"empty",
"(",
"$",
"this",
"->",
"_ids",
")",
")",
"{",
"$",
"this",
"->",
"_ids",
"=",
"$",
"ids",
";",
"$",
"change",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"change",
"=",
"false",
";",
"foreach",
"(",
"$",
"ids",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_ids",
"[",
"$",
"k",
"]",
")",
"||",
"(",
"$",
"this",
"->",
"_ids",
"[",
"$",
"k",
"]",
"!=",
"$",
"v",
")",
")",
"{",
"$",
"this",
"->",
"_ids",
"[",
"$",
"k",
"]",
"=",
"$",
"v",
";",
"$",
"change",
"=",
"true",
";",
"}",
"}",
"}",
"if",
"(",
"$",
"change",
")",
"{",
"$",
"this",
"->",
"_sorted",
"=",
"false",
";",
"}",
"return",
"$",
"change",
";",
"}"
] |
Updates the mapping.
@param array $ids Array of sequence -> UID mapping.
@return boolean True if the mapping changed.
|
[
"Updates",
"the",
"mapping",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Ids/Map.php#L79-L101
|
219,719
|
moodle/moodle
|
lib/horde/framework/Horde/Imap/Client/Ids/Map.php
|
Horde_Imap_Client_Ids_Map.remove
|
public function remove(Horde_Imap_Client_Ids $ids)
{
/* For sequence numbers, we need to reindex anytime we have an index
* that appears equal to or after a previously seen index. If an IMAP
* server is smart, it will expunge in reverse order instead. */
if ($ids->sequence) {
$remove = $ids->ids;
} else {
$ids->sort();
$remove = array_reverse(array_keys($this->lookup($ids)));
}
if (empty($remove)) {
return;
}
$this->sort();
if (count($remove) == count($this->_ids) &&
!array_diff($remove, array_keys($this->_ids))) {
$this->_ids = array();
return;
}
/* Find the minimum sequence number to remove. We know entries before
* this are untouched so no need to process them multiple times. */
$first = min($remove);
$edit = $newids = array();
foreach (array_keys($this->_ids) as $i => $seq) {
if ($seq >= $first) {
$i += (($seq == $first) ? 0 : 1);
$newids = array_slice($this->_ids, 0, $i, true);
$edit = array_slice($this->_ids, $i + (($seq == $first) ? 0 : 1), null, true);
break;
}
}
if (!empty($edit)) {
foreach ($remove as $val) {
$found = false;
$tmp = array();
foreach (array_keys($edit) as $i => $seq) {
if ($found) {
$tmp[$seq - 1] = $edit[$seq];
} elseif ($seq >= $val) {
$tmp = array_slice($edit, 0, ($seq == $val) ? $i : $i + 1, true);
$found = true;
}
}
$edit = $tmp;
}
}
$this->_ids = $newids + $edit;
}
|
php
|
public function remove(Horde_Imap_Client_Ids $ids)
{
/* For sequence numbers, we need to reindex anytime we have an index
* that appears equal to or after a previously seen index. If an IMAP
* server is smart, it will expunge in reverse order instead. */
if ($ids->sequence) {
$remove = $ids->ids;
} else {
$ids->sort();
$remove = array_reverse(array_keys($this->lookup($ids)));
}
if (empty($remove)) {
return;
}
$this->sort();
if (count($remove) == count($this->_ids) &&
!array_diff($remove, array_keys($this->_ids))) {
$this->_ids = array();
return;
}
/* Find the minimum sequence number to remove. We know entries before
* this are untouched so no need to process them multiple times. */
$first = min($remove);
$edit = $newids = array();
foreach (array_keys($this->_ids) as $i => $seq) {
if ($seq >= $first) {
$i += (($seq == $first) ? 0 : 1);
$newids = array_slice($this->_ids, 0, $i, true);
$edit = array_slice($this->_ids, $i + (($seq == $first) ? 0 : 1), null, true);
break;
}
}
if (!empty($edit)) {
foreach ($remove as $val) {
$found = false;
$tmp = array();
foreach (array_keys($edit) as $i => $seq) {
if ($found) {
$tmp[$seq - 1] = $edit[$seq];
} elseif ($seq >= $val) {
$tmp = array_slice($edit, 0, ($seq == $val) ? $i : $i + 1, true);
$found = true;
}
}
$edit = $tmp;
}
}
$this->_ids = $newids + $edit;
}
|
[
"public",
"function",
"remove",
"(",
"Horde_Imap_Client_Ids",
"$",
"ids",
")",
"{",
"/* For sequence numbers, we need to reindex anytime we have an index\n * that appears equal to or after a previously seen index. If an IMAP\n * server is smart, it will expunge in reverse order instead. */",
"if",
"(",
"$",
"ids",
"->",
"sequence",
")",
"{",
"$",
"remove",
"=",
"$",
"ids",
"->",
"ids",
";",
"}",
"else",
"{",
"$",
"ids",
"->",
"sort",
"(",
")",
";",
"$",
"remove",
"=",
"array_reverse",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"lookup",
"(",
"$",
"ids",
")",
")",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"$",
"remove",
")",
")",
"{",
"return",
";",
"}",
"$",
"this",
"->",
"sort",
"(",
")",
";",
"if",
"(",
"count",
"(",
"$",
"remove",
")",
"==",
"count",
"(",
"$",
"this",
"->",
"_ids",
")",
"&&",
"!",
"array_diff",
"(",
"$",
"remove",
",",
"array_keys",
"(",
"$",
"this",
"->",
"_ids",
")",
")",
")",
"{",
"$",
"this",
"->",
"_ids",
"=",
"array",
"(",
")",
";",
"return",
";",
"}",
"/* Find the minimum sequence number to remove. We know entries before\n * this are untouched so no need to process them multiple times. */",
"$",
"first",
"=",
"min",
"(",
"$",
"remove",
")",
";",
"$",
"edit",
"=",
"$",
"newids",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"this",
"->",
"_ids",
")",
"as",
"$",
"i",
"=>",
"$",
"seq",
")",
"{",
"if",
"(",
"$",
"seq",
">=",
"$",
"first",
")",
"{",
"$",
"i",
"+=",
"(",
"(",
"$",
"seq",
"==",
"$",
"first",
")",
"?",
"0",
":",
"1",
")",
";",
"$",
"newids",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"_ids",
",",
"0",
",",
"$",
"i",
",",
"true",
")",
";",
"$",
"edit",
"=",
"array_slice",
"(",
"$",
"this",
"->",
"_ids",
",",
"$",
"i",
"+",
"(",
"(",
"$",
"seq",
"==",
"$",
"first",
")",
"?",
"0",
":",
"1",
")",
",",
"null",
",",
"true",
")",
";",
"break",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"edit",
")",
")",
"{",
"foreach",
"(",
"$",
"remove",
"as",
"$",
"val",
")",
"{",
"$",
"found",
"=",
"false",
";",
"$",
"tmp",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"$",
"edit",
")",
"as",
"$",
"i",
"=>",
"$",
"seq",
")",
"{",
"if",
"(",
"$",
"found",
")",
"{",
"$",
"tmp",
"[",
"$",
"seq",
"-",
"1",
"]",
"=",
"$",
"edit",
"[",
"$",
"seq",
"]",
";",
"}",
"elseif",
"(",
"$",
"seq",
">=",
"$",
"val",
")",
"{",
"$",
"tmp",
"=",
"array_slice",
"(",
"$",
"edit",
",",
"0",
",",
"(",
"$",
"seq",
"==",
"$",
"val",
")",
"?",
"$",
"i",
":",
"$",
"i",
"+",
"1",
",",
"true",
")",
";",
"$",
"found",
"=",
"true",
";",
"}",
"}",
"$",
"edit",
"=",
"$",
"tmp",
";",
"}",
"}",
"$",
"this",
"->",
"_ids",
"=",
"$",
"newids",
"+",
"$",
"edit",
";",
"}"
] |
Removes messages from the ID mapping.
@param Horde_Imap_Client_Ids $ids IDs to remove.
|
[
"Removes",
"messages",
"from",
"the",
"ID",
"mapping",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Ids/Map.php#L126-L182
|
219,720
|
moodle/moodle
|
lib/horde/framework/Horde/Imap/Client/Ids/Map.php
|
Horde_Imap_Client_Ids_Map.sort
|
public function sort()
{
if (!$this->_sorted) {
ksort($this->_ids, SORT_NUMERIC);
$this->_sorted = true;
}
}
|
php
|
public function sort()
{
if (!$this->_sorted) {
ksort($this->_ids, SORT_NUMERIC);
$this->_sorted = true;
}
}
|
[
"public",
"function",
"sort",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"_sorted",
")",
"{",
"ksort",
"(",
"$",
"this",
"->",
"_ids",
",",
"SORT_NUMERIC",
")",
";",
"$",
"this",
"->",
"_sorted",
"=",
"true",
";",
"}",
"}"
] |
Sort the map.
|
[
"Sort",
"the",
"map",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/horde/framework/Horde/Imap/Client/Ids/Map.php#L187-L193
|
219,721
|
moodle/moodle
|
lib/boxlib.php
|
boxnet_client.get_file_info
|
public function get_file_info($fileid) {
$this->reset_state();
$result = $this->request($this->make_url("/files/$fileid"));
return json_decode($result);
}
|
php
|
public function get_file_info($fileid) {
$this->reset_state();
$result = $this->request($this->make_url("/files/$fileid"));
return json_decode($result);
}
|
[
"public",
"function",
"get_file_info",
"(",
"$",
"fileid",
")",
"{",
"$",
"this",
"->",
"reset_state",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"this",
"->",
"make_url",
"(",
"\"/files/$fileid\"",
")",
")",
";",
"return",
"json_decode",
"(",
"$",
"result",
")",
";",
"}"
] |
Get info of a file.
@param int $fileid File ID.
@return object
|
[
"Get",
"info",
"of",
"a",
"file",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/boxlib.php#L91-L95
|
219,722
|
moodle/moodle
|
lib/boxlib.php
|
boxnet_client.get_folder_items
|
public function get_folder_items($folderid = 0) {
$this->reset_state();
$result = $this->request($this->make_url("/folders/$folderid/items",
array('fields' => 'id,name,type,modified_at,size,owned_by')));
return json_decode($result);
}
|
php
|
public function get_folder_items($folderid = 0) {
$this->reset_state();
$result = $this->request($this->make_url("/folders/$folderid/items",
array('fields' => 'id,name,type,modified_at,size,owned_by')));
return json_decode($result);
}
|
[
"public",
"function",
"get_folder_items",
"(",
"$",
"folderid",
"=",
"0",
")",
"{",
"$",
"this",
"->",
"reset_state",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"this",
"->",
"make_url",
"(",
"\"/folders/$folderid/items\"",
",",
"array",
"(",
"'fields'",
"=>",
"'id,name,type,modified_at,size,owned_by'",
")",
")",
")",
";",
"return",
"json_decode",
"(",
"$",
"result",
")",
";",
"}"
] |
Get a folder content.
@param int $folderid Folder ID.
@return object
|
[
"Get",
"a",
"folder",
"content",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/boxlib.php#L103-L108
|
219,723
|
moodle/moodle
|
lib/boxlib.php
|
boxnet_client.log_out
|
public function log_out() {
if ($accesstoken = $this->get_accesstoken()) {
$params = array(
'client_id' => $this->get_clientid(),
'client_secret' => $this->get_clientsecret(),
'token' => $accesstoken->token
);
$this->reset_state();
$this->post($this->revoke_url(), $params);
}
parent::log_out();
}
|
php
|
public function log_out() {
if ($accesstoken = $this->get_accesstoken()) {
$params = array(
'client_id' => $this->get_clientid(),
'client_secret' => $this->get_clientsecret(),
'token' => $accesstoken->token
);
$this->reset_state();
$this->post($this->revoke_url(), $params);
}
parent::log_out();
}
|
[
"public",
"function",
"log_out",
"(",
")",
"{",
"if",
"(",
"$",
"accesstoken",
"=",
"$",
"this",
"->",
"get_accesstoken",
"(",
")",
")",
"{",
"$",
"params",
"=",
"array",
"(",
"'client_id'",
"=>",
"$",
"this",
"->",
"get_clientid",
"(",
")",
",",
"'client_secret'",
"=>",
"$",
"this",
"->",
"get_clientsecret",
"(",
")",
",",
"'token'",
"=>",
"$",
"accesstoken",
"->",
"token",
")",
";",
"$",
"this",
"->",
"reset_state",
"(",
")",
";",
"$",
"this",
"->",
"post",
"(",
"$",
"this",
"->",
"revoke_url",
"(",
")",
",",
"$",
"params",
")",
";",
"}",
"parent",
"::",
"log_out",
"(",
")",
";",
"}"
] |
Log out.
@return void
|
[
"Log",
"out",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/boxlib.php#L115-L126
|
219,724
|
moodle/moodle
|
lib/boxlib.php
|
boxnet_client.make_url
|
protected function make_url($uri, $params = array(), $uploadapi = false) {
$api = $uploadapi ? self::UPLOAD_API : self::API;
$url = new moodle_url($api . '/' . ltrim($uri, '/'), $params);
return $url->out(false);
}
|
php
|
protected function make_url($uri, $params = array(), $uploadapi = false) {
$api = $uploadapi ? self::UPLOAD_API : self::API;
$url = new moodle_url($api . '/' . ltrim($uri, '/'), $params);
return $url->out(false);
}
|
[
"protected",
"function",
"make_url",
"(",
"$",
"uri",
",",
"$",
"params",
"=",
"array",
"(",
")",
",",
"$",
"uploadapi",
"=",
"false",
")",
"{",
"$",
"api",
"=",
"$",
"uploadapi",
"?",
"self",
"::",
"UPLOAD_API",
":",
"self",
"::",
"API",
";",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"$",
"api",
".",
"'/'",
".",
"ltrim",
"(",
"$",
"uri",
",",
"'/'",
")",
",",
"$",
"params",
")",
";",
"return",
"$",
"url",
"->",
"out",
"(",
"false",
")",
";",
"}"
] |
Build a request URL.
@param string $uri The URI to request.
@param array $params Query string parameters.
@param bool $uploadapi Whether this works with the upload API or not.
@return string
|
[
"Build",
"a",
"request",
"URL",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/boxlib.php#L136-L140
|
219,725
|
moodle/moodle
|
lib/boxlib.php
|
boxnet_client.share_file
|
public function share_file($fileid, $businesscheck = true) {
// Sharing the file, this requires a PUT request with data within it. We cannot use
// the standard PUT request 'CURLOPT_PUT' because it expects a file.
$data = array('shared_link' => array('access' => 'open', 'permissions' =>
array('can_download' => true, 'can_preview' => true)));
$options = array(
'CURLOPT_CUSTOMREQUEST' => 'PUT',
'CURLOPT_POSTFIELDS' => json_encode($data)
);
$this->reset_state();
$result = $this->request($this->make_url("/files/$fileid"), $options);
$result = json_decode($result);
if ($businesscheck) {
// Checks that the user has the right to share the file. If not, throw an exception.
$this->reset_state();
$this->head($result->shared_link->download_url);
$info = $this->get_info();
if ($info['http_code'] == 403) {
throw new moodle_exception('No permission to share the file');
}
}
return $result->shared_link;
}
|
php
|
public function share_file($fileid, $businesscheck = true) {
// Sharing the file, this requires a PUT request with data within it. We cannot use
// the standard PUT request 'CURLOPT_PUT' because it expects a file.
$data = array('shared_link' => array('access' => 'open', 'permissions' =>
array('can_download' => true, 'can_preview' => true)));
$options = array(
'CURLOPT_CUSTOMREQUEST' => 'PUT',
'CURLOPT_POSTFIELDS' => json_encode($data)
);
$this->reset_state();
$result = $this->request($this->make_url("/files/$fileid"), $options);
$result = json_decode($result);
if ($businesscheck) {
// Checks that the user has the right to share the file. If not, throw an exception.
$this->reset_state();
$this->head($result->shared_link->download_url);
$info = $this->get_info();
if ($info['http_code'] == 403) {
throw new moodle_exception('No permission to share the file');
}
}
return $result->shared_link;
}
|
[
"public",
"function",
"share_file",
"(",
"$",
"fileid",
",",
"$",
"businesscheck",
"=",
"true",
")",
"{",
"// Sharing the file, this requires a PUT request with data within it. We cannot use",
"// the standard PUT request 'CURLOPT_PUT' because it expects a file.",
"$",
"data",
"=",
"array",
"(",
"'shared_link'",
"=>",
"array",
"(",
"'access'",
"=>",
"'open'",
",",
"'permissions'",
"=>",
"array",
"(",
"'can_download'",
"=>",
"true",
",",
"'can_preview'",
"=>",
"true",
")",
")",
")",
";",
"$",
"options",
"=",
"array",
"(",
"'CURLOPT_CUSTOMREQUEST'",
"=>",
"'PUT'",
",",
"'CURLOPT_POSTFIELDS'",
"=>",
"json_encode",
"(",
"$",
"data",
")",
")",
";",
"$",
"this",
"->",
"reset_state",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"request",
"(",
"$",
"this",
"->",
"make_url",
"(",
"\"/files/$fileid\"",
")",
",",
"$",
"options",
")",
";",
"$",
"result",
"=",
"json_decode",
"(",
"$",
"result",
")",
";",
"if",
"(",
"$",
"businesscheck",
")",
"{",
"// Checks that the user has the right to share the file. If not, throw an exception.",
"$",
"this",
"->",
"reset_state",
"(",
")",
";",
"$",
"this",
"->",
"head",
"(",
"$",
"result",
"->",
"shared_link",
"->",
"download_url",
")",
";",
"$",
"info",
"=",
"$",
"this",
"->",
"get_info",
"(",
")",
";",
"if",
"(",
"$",
"info",
"[",
"'http_code'",
"]",
"==",
"403",
")",
"{",
"throw",
"new",
"moodle_exception",
"(",
"'No permission to share the file'",
")",
";",
"}",
"}",
"return",
"$",
"result",
"->",
"shared_link",
";",
"}"
] |
Share a file and return the link to it.
@param string $fileid The file ID.
@param bool $businesscheck Whether or not to check if the user can share files, has a business account.
@return object
|
[
"Share",
"a",
"file",
"and",
"return",
"the",
"link",
"to",
"it",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/boxlib.php#L190-L214
|
219,726
|
moodle/moodle
|
question/type/ddwtos/renderer.php
|
qtype_ddwtos_renderer.clear_wrong
|
public function clear_wrong(question_attempt $qa, $reallyclear = true) {
$question = $qa->get_question();
$response = $qa->get_last_qt_data();
if (!empty($response) && $reallyclear) {
$cleanresponse = $question->clear_wrong_from_response($response);
} else {
$cleanresponse = $response;
}
$output = '';
foreach ($question->places as $place => $group) {
$fieldname = $question->field($place);
if (array_key_exists($fieldname, $response)) {
$value = (string) $response[$fieldname];
} else {
$value = '0';
}
if (array_key_exists($fieldname, $cleanresponse)) {
$cleanvalue = (string) $cleanresponse[$fieldname];
} else {
$cleanvalue = '0';
}
if ($cleanvalue === $value) {
// Normal case: just one hidden input, to store the
// current value and be the value submitted.
$output .= html_writer::empty_tag('input', array(
'type' => 'hidden',
'id' => $this->box_id($qa, 'p' . $place),
'class' => 'placeinput place' . $place . ' group' . $group,
'name' => $qa->get_qt_field_name($fieldname),
'value' => s($value)));
} else {
// The case, which only happens when the question is read-only, where
// we want to show the drag item in a given place (first hidden input),
// but when submitted, we want it to go to a different place (second input).
$output .= html_writer::empty_tag('input', array(
'type' => 'hidden',
'id' => $this->box_id($qa, 'p' . $place),
'class' => 'placeinput place' . $place . ' group' . $group,
'value' => s($value))) .
html_writer::empty_tag('input', array(
'type' => 'hidden',
'name' => $qa->get_qt_field_name($fieldname),
'value' => s($cleanvalue)));
}
}
return $output;
}
|
php
|
public function clear_wrong(question_attempt $qa, $reallyclear = true) {
$question = $qa->get_question();
$response = $qa->get_last_qt_data();
if (!empty($response) && $reallyclear) {
$cleanresponse = $question->clear_wrong_from_response($response);
} else {
$cleanresponse = $response;
}
$output = '';
foreach ($question->places as $place => $group) {
$fieldname = $question->field($place);
if (array_key_exists($fieldname, $response)) {
$value = (string) $response[$fieldname];
} else {
$value = '0';
}
if (array_key_exists($fieldname, $cleanresponse)) {
$cleanvalue = (string) $cleanresponse[$fieldname];
} else {
$cleanvalue = '0';
}
if ($cleanvalue === $value) {
// Normal case: just one hidden input, to store the
// current value and be the value submitted.
$output .= html_writer::empty_tag('input', array(
'type' => 'hidden',
'id' => $this->box_id($qa, 'p' . $place),
'class' => 'placeinput place' . $place . ' group' . $group,
'name' => $qa->get_qt_field_name($fieldname),
'value' => s($value)));
} else {
// The case, which only happens when the question is read-only, where
// we want to show the drag item in a given place (first hidden input),
// but when submitted, we want it to go to a different place (second input).
$output .= html_writer::empty_tag('input', array(
'type' => 'hidden',
'id' => $this->box_id($qa, 'p' . $place),
'class' => 'placeinput place' . $place . ' group' . $group,
'value' => s($value))) .
html_writer::empty_tag('input', array(
'type' => 'hidden',
'name' => $qa->get_qt_field_name($fieldname),
'value' => s($cleanvalue)));
}
}
return $output;
}
|
[
"public",
"function",
"clear_wrong",
"(",
"question_attempt",
"$",
"qa",
",",
"$",
"reallyclear",
"=",
"true",
")",
"{",
"$",
"question",
"=",
"$",
"qa",
"->",
"get_question",
"(",
")",
";",
"$",
"response",
"=",
"$",
"qa",
"->",
"get_last_qt_data",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"response",
")",
"&&",
"$",
"reallyclear",
")",
"{",
"$",
"cleanresponse",
"=",
"$",
"question",
"->",
"clear_wrong_from_response",
"(",
"$",
"response",
")",
";",
"}",
"else",
"{",
"$",
"cleanresponse",
"=",
"$",
"response",
";",
"}",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"question",
"->",
"places",
"as",
"$",
"place",
"=>",
"$",
"group",
")",
"{",
"$",
"fieldname",
"=",
"$",
"question",
"->",
"field",
"(",
"$",
"place",
")",
";",
"if",
"(",
"array_key_exists",
"(",
"$",
"fieldname",
",",
"$",
"response",
")",
")",
"{",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"response",
"[",
"$",
"fieldname",
"]",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"'0'",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"$",
"fieldname",
",",
"$",
"cleanresponse",
")",
")",
"{",
"$",
"cleanvalue",
"=",
"(",
"string",
")",
"$",
"cleanresponse",
"[",
"$",
"fieldname",
"]",
";",
"}",
"else",
"{",
"$",
"cleanvalue",
"=",
"'0'",
";",
"}",
"if",
"(",
"$",
"cleanvalue",
"===",
"$",
"value",
")",
"{",
"// Normal case: just one hidden input, to store the",
"// current value and be the value submitted.",
"$",
"output",
".=",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'id'",
"=>",
"$",
"this",
"->",
"box_id",
"(",
"$",
"qa",
",",
"'p'",
".",
"$",
"place",
")",
",",
"'class'",
"=>",
"'placeinput place'",
".",
"$",
"place",
".",
"' group'",
".",
"$",
"group",
",",
"'name'",
"=>",
"$",
"qa",
"->",
"get_qt_field_name",
"(",
"$",
"fieldname",
")",
",",
"'value'",
"=>",
"s",
"(",
"$",
"value",
")",
")",
")",
";",
"}",
"else",
"{",
"// The case, which only happens when the question is read-only, where",
"// we want to show the drag item in a given place (first hidden input),",
"// but when submitted, we want it to go to a different place (second input).",
"$",
"output",
".=",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'id'",
"=>",
"$",
"this",
"->",
"box_id",
"(",
"$",
"qa",
",",
"'p'",
".",
"$",
"place",
")",
",",
"'class'",
"=>",
"'placeinput place'",
".",
"$",
"place",
".",
"' group'",
".",
"$",
"group",
",",
"'value'",
"=>",
"s",
"(",
"$",
"value",
")",
")",
")",
".",
"html_writer",
"::",
"empty_tag",
"(",
"'input'",
",",
"array",
"(",
"'type'",
"=>",
"'hidden'",
",",
"'name'",
"=>",
"$",
"qa",
"->",
"get_qt_field_name",
"(",
"$",
"fieldname",
")",
",",
"'value'",
"=>",
"s",
"(",
"$",
"cleanvalue",
")",
")",
")",
";",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] |
Actually, this question type abuses this method to always output the
hidden fields it needs.
@param question_attempt $qa the question attempt.
@param bool $reallyclear whether we are really clearing the responses, or just outputting them.
@return string HTML to output.
|
[
"Actually",
"this",
"question",
"type",
"abuses",
"this",
"method",
"to",
"always",
"output",
"the",
"hidden",
"fields",
"it",
"needs",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/type/ddwtos/renderer.php#L144-L192
|
219,727
|
moodle/moodle
|
lib/php-css-parser/OutputFormat.php
|
OutputFormatter.safely
|
public function safely($cCode) {
if($this->oFormat->get('IgnoreExceptions')) {
// If output exceptions are ignored, run the code with exception guards
try {
return $cCode();
} catch (OutputException $e) {
return null;
} //Do nothing
} else {
// Run the code as-is
return $cCode();
}
}
|
php
|
public function safely($cCode) {
if($this->oFormat->get('IgnoreExceptions')) {
// If output exceptions are ignored, run the code with exception guards
try {
return $cCode();
} catch (OutputException $e) {
return null;
} //Do nothing
} else {
// Run the code as-is
return $cCode();
}
}
|
[
"public",
"function",
"safely",
"(",
"$",
"cCode",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"oFormat",
"->",
"get",
"(",
"'IgnoreExceptions'",
")",
")",
"{",
"// If output exceptions are ignored, run the code with exception guards",
"try",
"{",
"return",
"$",
"cCode",
"(",
")",
";",
"}",
"catch",
"(",
"OutputException",
"$",
"e",
")",
"{",
"return",
"null",
";",
"}",
"//Do nothing",
"}",
"else",
"{",
"// Run the code as-is",
"return",
"$",
"cCode",
"(",
")",
";",
"}",
"}"
] |
Runs the given code, either swallowing or passing exceptions, depending on the bIgnoreExceptions setting.
|
[
"Runs",
"the",
"given",
"code",
"either",
"swallowing",
"or",
"passing",
"exceptions",
"depending",
"on",
"the",
"bIgnoreExceptions",
"setting",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/php-css-parser/OutputFormat.php#L229-L241
|
219,728
|
moodle/moodle
|
question/category_class.php
|
question_category_object.initialize
|
public function initialize($page, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts) {
$lastlist = null;
foreach ($contexts as $context){
$this->editlists[$context->id] = new question_category_list('ul', '', true, $this->pageurl, $page, 'cpage', QUESTION_PAGE_LENGTH, $context);
$this->editlists[$context->id]->lastlist =& $lastlist;
if ($lastlist!== null){
$lastlist->nextlist =& $this->editlists[$context->id];
}
$lastlist =& $this->editlists[$context->id];
}
$count = 1;
$paged = false;
foreach ($this->editlists as $key => $list){
list($paged, $count) = $this->editlists[$key]->list_from_records($paged, $count);
}
$this->catform = new question_category_edit_form($this->pageurl, compact('contexts', 'currentcat'));
if (!$currentcat){
$this->catform->set_data(array('parent'=>$defaultcategory));
}
}
|
php
|
public function initialize($page, $contexts, $currentcat, $defaultcategory, $todelete, $addcontexts) {
$lastlist = null;
foreach ($contexts as $context){
$this->editlists[$context->id] = new question_category_list('ul', '', true, $this->pageurl, $page, 'cpage', QUESTION_PAGE_LENGTH, $context);
$this->editlists[$context->id]->lastlist =& $lastlist;
if ($lastlist!== null){
$lastlist->nextlist =& $this->editlists[$context->id];
}
$lastlist =& $this->editlists[$context->id];
}
$count = 1;
$paged = false;
foreach ($this->editlists as $key => $list){
list($paged, $count) = $this->editlists[$key]->list_from_records($paged, $count);
}
$this->catform = new question_category_edit_form($this->pageurl, compact('contexts', 'currentcat'));
if (!$currentcat){
$this->catform->set_data(array('parent'=>$defaultcategory));
}
}
|
[
"public",
"function",
"initialize",
"(",
"$",
"page",
",",
"$",
"contexts",
",",
"$",
"currentcat",
",",
"$",
"defaultcategory",
",",
"$",
"todelete",
",",
"$",
"addcontexts",
")",
"{",
"$",
"lastlist",
"=",
"null",
";",
"foreach",
"(",
"$",
"contexts",
"as",
"$",
"context",
")",
"{",
"$",
"this",
"->",
"editlists",
"[",
"$",
"context",
"->",
"id",
"]",
"=",
"new",
"question_category_list",
"(",
"'ul'",
",",
"''",
",",
"true",
",",
"$",
"this",
"->",
"pageurl",
",",
"$",
"page",
",",
"'cpage'",
",",
"QUESTION_PAGE_LENGTH",
",",
"$",
"context",
")",
";",
"$",
"this",
"->",
"editlists",
"[",
"$",
"context",
"->",
"id",
"]",
"->",
"lastlist",
"=",
"&",
"$",
"lastlist",
";",
"if",
"(",
"$",
"lastlist",
"!==",
"null",
")",
"{",
"$",
"lastlist",
"->",
"nextlist",
"=",
"&",
"$",
"this",
"->",
"editlists",
"[",
"$",
"context",
"->",
"id",
"]",
";",
"}",
"$",
"lastlist",
"=",
"&",
"$",
"this",
"->",
"editlists",
"[",
"$",
"context",
"->",
"id",
"]",
";",
"}",
"$",
"count",
"=",
"1",
";",
"$",
"paged",
"=",
"false",
";",
"foreach",
"(",
"$",
"this",
"->",
"editlists",
"as",
"$",
"key",
"=>",
"$",
"list",
")",
"{",
"list",
"(",
"$",
"paged",
",",
"$",
"count",
")",
"=",
"$",
"this",
"->",
"editlists",
"[",
"$",
"key",
"]",
"->",
"list_from_records",
"(",
"$",
"paged",
",",
"$",
"count",
")",
";",
"}",
"$",
"this",
"->",
"catform",
"=",
"new",
"question_category_edit_form",
"(",
"$",
"this",
"->",
"pageurl",
",",
"compact",
"(",
"'contexts'",
",",
"'currentcat'",
")",
")",
";",
"if",
"(",
"!",
"$",
"currentcat",
")",
"{",
"$",
"this",
"->",
"catform",
"->",
"set_data",
"(",
"array",
"(",
"'parent'",
"=>",
"$",
"defaultcategory",
")",
")",
";",
"}",
"}"
] |
Initializes this classes general category-related variables
|
[
"Initializes",
"this",
"classes",
"general",
"category",
"-",
"related",
"variables"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/category_class.php#L247-L267
|
219,729
|
moodle/moodle
|
question/category_class.php
|
question_category_object.get_course_ids
|
public function get_course_ids($categories) {
$courseids = array();
foreach ($categories as $key=>$cat) {
$courseids[$key] = $cat->course;
if (!empty($cat->children)) {
$courseids = array_merge($courseids, $this->get_course_ids($cat->children));
}
}
return $courseids;
}
|
php
|
public function get_course_ids($categories) {
$courseids = array();
foreach ($categories as $key=>$cat) {
$courseids[$key] = $cat->course;
if (!empty($cat->children)) {
$courseids = array_merge($courseids, $this->get_course_ids($cat->children));
}
}
return $courseids;
}
|
[
"public",
"function",
"get_course_ids",
"(",
"$",
"categories",
")",
"{",
"$",
"courseids",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"categories",
"as",
"$",
"key",
"=>",
"$",
"cat",
")",
"{",
"$",
"courseids",
"[",
"$",
"key",
"]",
"=",
"$",
"cat",
"->",
"course",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"cat",
"->",
"children",
")",
")",
"{",
"$",
"courseids",
"=",
"array_merge",
"(",
"$",
"courseids",
",",
"$",
"this",
"->",
"get_course_ids",
"(",
"$",
"cat",
"->",
"children",
")",
")",
";",
"}",
"}",
"return",
"$",
"courseids",
";",
"}"
] |
gets all the courseids for the given categories
@param array categories contains category objects in a tree representation
@return array courseids flat array in form categoryid=>courseid
|
[
"gets",
"all",
"the",
"courseids",
"for",
"the",
"given",
"categories"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/category_class.php#L323-L332
|
219,730
|
moodle/moodle
|
question/category_class.php
|
question_category_object.set_viable_parents
|
public function set_viable_parents(&$parentstrings, $category) {
unset($parentstrings[$category->id]);
if (isset($category->children)) {
foreach ($category->children as $child) {
$this->set_viable_parents($parentstrings, $child);
}
}
}
|
php
|
public function set_viable_parents(&$parentstrings, $category) {
unset($parentstrings[$category->id]);
if (isset($category->children)) {
foreach ($category->children as $child) {
$this->set_viable_parents($parentstrings, $child);
}
}
}
|
[
"public",
"function",
"set_viable_parents",
"(",
"&",
"$",
"parentstrings",
",",
"$",
"category",
")",
"{",
"unset",
"(",
"$",
"parentstrings",
"[",
"$",
"category",
"->",
"id",
"]",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"category",
"->",
"children",
")",
")",
"{",
"foreach",
"(",
"$",
"category",
"->",
"children",
"as",
"$",
"child",
")",
"{",
"$",
"this",
"->",
"set_viable_parents",
"(",
"$",
"parentstrings",
",",
"$",
"child",
")",
";",
"}",
"}",
"}"
] |
Sets the viable parents
Viable parents are any except for the category itself, or any of it's descendants
The parentstrings parameter is passed by reference and changed by this function.
@param array parentstrings a list of parentstrings
@param object category
|
[
"Sets",
"the",
"viable",
"parents"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/category_class.php#L361-L369
|
219,731
|
moodle/moodle
|
question/category_class.php
|
question_category_object.get_question_categories
|
public function get_question_categories($parent=null, $sort="sortorder ASC") {
global $COURSE, $DB;
if (is_null($parent)) {
$categories = $DB->get_records('question_categories', array('course' => $COURSE->id), $sort);
} else {
$select = "parent = ? AND course = ?";
$categories = $DB->get_records_select('question_categories', $select, array($parent, $COURSE->id), $sort);
}
return $categories;
}
|
php
|
public function get_question_categories($parent=null, $sort="sortorder ASC") {
global $COURSE, $DB;
if (is_null($parent)) {
$categories = $DB->get_records('question_categories', array('course' => $COURSE->id), $sort);
} else {
$select = "parent = ? AND course = ?";
$categories = $DB->get_records_select('question_categories', $select, array($parent, $COURSE->id), $sort);
}
return $categories;
}
|
[
"public",
"function",
"get_question_categories",
"(",
"$",
"parent",
"=",
"null",
",",
"$",
"sort",
"=",
"\"sortorder ASC\"",
")",
"{",
"global",
"$",
"COURSE",
",",
"$",
"DB",
";",
"if",
"(",
"is_null",
"(",
"$",
"parent",
")",
")",
"{",
"$",
"categories",
"=",
"$",
"DB",
"->",
"get_records",
"(",
"'question_categories'",
",",
"array",
"(",
"'course'",
"=>",
"$",
"COURSE",
"->",
"id",
")",
",",
"$",
"sort",
")",
";",
"}",
"else",
"{",
"$",
"select",
"=",
"\"parent = ? AND course = ?\"",
";",
"$",
"categories",
"=",
"$",
"DB",
"->",
"get_records_select",
"(",
"'question_categories'",
",",
"$",
"select",
",",
"array",
"(",
"$",
"parent",
",",
"$",
"COURSE",
"->",
"id",
")",
",",
"$",
"sort",
")",
";",
"}",
"return",
"$",
"categories",
";",
"}"
] |
Gets question categories
@param int parent - if given, restrict records to those with this parent id.
@param string sort - [[sortfield [,sortfield]] {ASC|DESC}]
@return array categories
|
[
"Gets",
"question",
"categories"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/category_class.php#L378-L387
|
219,732
|
moodle/moodle
|
question/category_class.php
|
question_category_object.delete_category
|
public function delete_category($categoryid) {
global $CFG, $DB;
question_can_delete_cat($categoryid);
if (!$category = $DB->get_record("question_categories", array("id" => $categoryid))) { // security
print_error('unknowcategory');
}
/// Send the children categories to live with their grandparent
$DB->set_field("question_categories", "parent", $category->parent, array("parent" => $category->id));
/// Finally delete the category itself
$DB->delete_records("question_categories", array("id" => $category->id));
// Log the deletion of this category.
$event = \core\event\question_category_deleted::create_from_question_category_instance($category);
$event->add_record_snapshot('question_categories', $category);
$event->trigger();
}
|
php
|
public function delete_category($categoryid) {
global $CFG, $DB;
question_can_delete_cat($categoryid);
if (!$category = $DB->get_record("question_categories", array("id" => $categoryid))) { // security
print_error('unknowcategory');
}
/// Send the children categories to live with their grandparent
$DB->set_field("question_categories", "parent", $category->parent, array("parent" => $category->id));
/// Finally delete the category itself
$DB->delete_records("question_categories", array("id" => $category->id));
// Log the deletion of this category.
$event = \core\event\question_category_deleted::create_from_question_category_instance($category);
$event->add_record_snapshot('question_categories', $category);
$event->trigger();
}
|
[
"public",
"function",
"delete_category",
"(",
"$",
"categoryid",
")",
"{",
"global",
"$",
"CFG",
",",
"$",
"DB",
";",
"question_can_delete_cat",
"(",
"$",
"categoryid",
")",
";",
"if",
"(",
"!",
"$",
"category",
"=",
"$",
"DB",
"->",
"get_record",
"(",
"\"question_categories\"",
",",
"array",
"(",
"\"id\"",
"=>",
"$",
"categoryid",
")",
")",
")",
"{",
"// security",
"print_error",
"(",
"'unknowcategory'",
")",
";",
"}",
"/// Send the children categories to live with their grandparent",
"$",
"DB",
"->",
"set_field",
"(",
"\"question_categories\"",
",",
"\"parent\"",
",",
"$",
"category",
"->",
"parent",
",",
"array",
"(",
"\"parent\"",
"=>",
"$",
"category",
"->",
"id",
")",
")",
";",
"/// Finally delete the category itself",
"$",
"DB",
"->",
"delete_records",
"(",
"\"question_categories\"",
",",
"array",
"(",
"\"id\"",
"=>",
"$",
"category",
"->",
"id",
")",
")",
";",
"// Log the deletion of this category.",
"$",
"event",
"=",
"\\",
"core",
"\\",
"event",
"\\",
"question_category_deleted",
"::",
"create_from_question_category_instance",
"(",
"$",
"category",
")",
";",
"$",
"event",
"->",
"add_record_snapshot",
"(",
"'question_categories'",
",",
"$",
"category",
")",
";",
"$",
"event",
"->",
"trigger",
"(",
")",
";",
"}"
] |
Deletes an existing question category
@param int deletecat id of category to delete
|
[
"Deletes",
"an",
"existing",
"question",
"category"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/category_class.php#L394-L411
|
219,733
|
moodle/moodle
|
question/category_class.php
|
question_category_object.add_category
|
public function add_category($newparent, $newcategory, $newinfo, $return = false, $newinfoformat = FORMAT_HTML,
$idnumber = null) {
global $DB;
if (empty($newcategory)) {
print_error('categorynamecantbeblank', 'question');
}
list($parentid, $contextid) = explode(',', $newparent);
//moodle_form makes sure select element output is legal no need for further cleaning
require_capability('moodle/question:managecategory', context::instance_by_id($contextid));
if ($parentid) {
if(!($DB->get_field('question_categories', 'contextid', array('id' => $parentid)) == $contextid)) {
print_error('cannotinsertquestioncatecontext', 'question', '', array('cat'=>$newcategory, 'ctx'=>$contextid));
}
}
if ((string) $idnumber === '') {
$idnumber = null;
} else if (!empty($contextid)) {
// While this check already exists in the form validation, this is a backstop preventing unnecessary errors.
if ($DB->record_exists('question_categories',
['idnumber' => $idnumber, 'contextid' => $contextid])) {
$idnumber = null;
}
}
$cat = new stdClass();
$cat->parent = $parentid;
$cat->contextid = $contextid;
$cat->name = $newcategory;
$cat->info = $newinfo;
$cat->infoformat = $newinfoformat;
$cat->sortorder = 999;
$cat->stamp = make_unique_id_code();
if ($idnumber) {
$cat->idnumber = $idnumber;
}
$categoryid = $DB->insert_record("question_categories", $cat);
// Log the creation of this category.
$category = new stdClass();
$category->id = $categoryid;
$category->contextid = $contextid;
$event = \core\event\question_category_created::create_from_question_category_instance($category);
$event->trigger();
if ($return) {
return $categoryid;
} else {
redirect($this->pageurl);//always redirect after successful action
}
}
|
php
|
public function add_category($newparent, $newcategory, $newinfo, $return = false, $newinfoformat = FORMAT_HTML,
$idnumber = null) {
global $DB;
if (empty($newcategory)) {
print_error('categorynamecantbeblank', 'question');
}
list($parentid, $contextid) = explode(',', $newparent);
//moodle_form makes sure select element output is legal no need for further cleaning
require_capability('moodle/question:managecategory', context::instance_by_id($contextid));
if ($parentid) {
if(!($DB->get_field('question_categories', 'contextid', array('id' => $parentid)) == $contextid)) {
print_error('cannotinsertquestioncatecontext', 'question', '', array('cat'=>$newcategory, 'ctx'=>$contextid));
}
}
if ((string) $idnumber === '') {
$idnumber = null;
} else if (!empty($contextid)) {
// While this check already exists in the form validation, this is a backstop preventing unnecessary errors.
if ($DB->record_exists('question_categories',
['idnumber' => $idnumber, 'contextid' => $contextid])) {
$idnumber = null;
}
}
$cat = new stdClass();
$cat->parent = $parentid;
$cat->contextid = $contextid;
$cat->name = $newcategory;
$cat->info = $newinfo;
$cat->infoformat = $newinfoformat;
$cat->sortorder = 999;
$cat->stamp = make_unique_id_code();
if ($idnumber) {
$cat->idnumber = $idnumber;
}
$categoryid = $DB->insert_record("question_categories", $cat);
// Log the creation of this category.
$category = new stdClass();
$category->id = $categoryid;
$category->contextid = $contextid;
$event = \core\event\question_category_created::create_from_question_category_instance($category);
$event->trigger();
if ($return) {
return $categoryid;
} else {
redirect($this->pageurl);//always redirect after successful action
}
}
|
[
"public",
"function",
"add_category",
"(",
"$",
"newparent",
",",
"$",
"newcategory",
",",
"$",
"newinfo",
",",
"$",
"return",
"=",
"false",
",",
"$",
"newinfoformat",
"=",
"FORMAT_HTML",
",",
"$",
"idnumber",
"=",
"null",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"empty",
"(",
"$",
"newcategory",
")",
")",
"{",
"print_error",
"(",
"'categorynamecantbeblank'",
",",
"'question'",
")",
";",
"}",
"list",
"(",
"$",
"parentid",
",",
"$",
"contextid",
")",
"=",
"explode",
"(",
"','",
",",
"$",
"newparent",
")",
";",
"//moodle_form makes sure select element output is legal no need for further cleaning",
"require_capability",
"(",
"'moodle/question:managecategory'",
",",
"context",
"::",
"instance_by_id",
"(",
"$",
"contextid",
")",
")",
";",
"if",
"(",
"$",
"parentid",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"DB",
"->",
"get_field",
"(",
"'question_categories'",
",",
"'contextid'",
",",
"array",
"(",
"'id'",
"=>",
"$",
"parentid",
")",
")",
"==",
"$",
"contextid",
")",
")",
"{",
"print_error",
"(",
"'cannotinsertquestioncatecontext'",
",",
"'question'",
",",
"''",
",",
"array",
"(",
"'cat'",
"=>",
"$",
"newcategory",
",",
"'ctx'",
"=>",
"$",
"contextid",
")",
")",
";",
"}",
"}",
"if",
"(",
"(",
"string",
")",
"$",
"idnumber",
"===",
"''",
")",
"{",
"$",
"idnumber",
"=",
"null",
";",
"}",
"else",
"if",
"(",
"!",
"empty",
"(",
"$",
"contextid",
")",
")",
"{",
"// While this check already exists in the form validation, this is a backstop preventing unnecessary errors.",
"if",
"(",
"$",
"DB",
"->",
"record_exists",
"(",
"'question_categories'",
",",
"[",
"'idnumber'",
"=>",
"$",
"idnumber",
",",
"'contextid'",
"=>",
"$",
"contextid",
"]",
")",
")",
"{",
"$",
"idnumber",
"=",
"null",
";",
"}",
"}",
"$",
"cat",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"cat",
"->",
"parent",
"=",
"$",
"parentid",
";",
"$",
"cat",
"->",
"contextid",
"=",
"$",
"contextid",
";",
"$",
"cat",
"->",
"name",
"=",
"$",
"newcategory",
";",
"$",
"cat",
"->",
"info",
"=",
"$",
"newinfo",
";",
"$",
"cat",
"->",
"infoformat",
"=",
"$",
"newinfoformat",
";",
"$",
"cat",
"->",
"sortorder",
"=",
"999",
";",
"$",
"cat",
"->",
"stamp",
"=",
"make_unique_id_code",
"(",
")",
";",
"if",
"(",
"$",
"idnumber",
")",
"{",
"$",
"cat",
"->",
"idnumber",
"=",
"$",
"idnumber",
";",
"}",
"$",
"categoryid",
"=",
"$",
"DB",
"->",
"insert_record",
"(",
"\"question_categories\"",
",",
"$",
"cat",
")",
";",
"// Log the creation of this category.",
"$",
"category",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"category",
"->",
"id",
"=",
"$",
"categoryid",
";",
"$",
"category",
"->",
"contextid",
"=",
"$",
"contextid",
";",
"$",
"event",
"=",
"\\",
"core",
"\\",
"event",
"\\",
"question_category_created",
"::",
"create_from_question_category_instance",
"(",
"$",
"category",
")",
";",
"$",
"event",
"->",
"trigger",
"(",
")",
";",
"if",
"(",
"$",
"return",
")",
"{",
"return",
"$",
"categoryid",
";",
"}",
"else",
"{",
"redirect",
"(",
"$",
"this",
"->",
"pageurl",
")",
";",
"//always redirect after successful action",
"}",
"}"
] |
Creates a new category with given params
|
[
"Creates",
"a",
"new",
"category",
"with",
"given",
"params"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/category_class.php#L438-L489
|
219,734
|
moodle/moodle
|
mod/quiz/report/statistics/classes/calculator.php
|
calculator.attempt_counts_and_averages
|
protected function attempt_counts_and_averages($quizid, \core\dml\sql_join $groupstudentsjoins) {
global $DB;
$attempttotals = new \stdClass();
foreach (array_keys(quiz_get_grading_options()) as $which) {
list($fromqa, $whereqa, $qaparams) = quiz_statistics_attempts_sql($quizid, $groupstudentsjoins, $which);
$fromdb = $DB->get_record_sql("SELECT COUNT(*) AS rcount, AVG(sumgrades) AS average FROM $fromqa WHERE $whereqa",
$qaparams);
$fieldprefix = static::using_attempts_string_id($which);
$attempttotals->{$fieldprefix.'avg'} = $fromdb->average;
$attempttotals->{$fieldprefix.'count'} = $fromdb->rcount;
}
return $attempttotals;
}
|
php
|
protected function attempt_counts_and_averages($quizid, \core\dml\sql_join $groupstudentsjoins) {
global $DB;
$attempttotals = new \stdClass();
foreach (array_keys(quiz_get_grading_options()) as $which) {
list($fromqa, $whereqa, $qaparams) = quiz_statistics_attempts_sql($quizid, $groupstudentsjoins, $which);
$fromdb = $DB->get_record_sql("SELECT COUNT(*) AS rcount, AVG(sumgrades) AS average FROM $fromqa WHERE $whereqa",
$qaparams);
$fieldprefix = static::using_attempts_string_id($which);
$attempttotals->{$fieldprefix.'avg'} = $fromdb->average;
$attempttotals->{$fieldprefix.'count'} = $fromdb->rcount;
}
return $attempttotals;
}
|
[
"protected",
"function",
"attempt_counts_and_averages",
"(",
"$",
"quizid",
",",
"\\",
"core",
"\\",
"dml",
"\\",
"sql_join",
"$",
"groupstudentsjoins",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"attempttotals",
"=",
"new",
"\\",
"stdClass",
"(",
")",
";",
"foreach",
"(",
"array_keys",
"(",
"quiz_get_grading_options",
"(",
")",
")",
"as",
"$",
"which",
")",
"{",
"list",
"(",
"$",
"fromqa",
",",
"$",
"whereqa",
",",
"$",
"qaparams",
")",
"=",
"quiz_statistics_attempts_sql",
"(",
"$",
"quizid",
",",
"$",
"groupstudentsjoins",
",",
"$",
"which",
")",
";",
"$",
"fromdb",
"=",
"$",
"DB",
"->",
"get_record_sql",
"(",
"\"SELECT COUNT(*) AS rcount, AVG(sumgrades) AS average FROM $fromqa WHERE $whereqa\"",
",",
"$",
"qaparams",
")",
";",
"$",
"fieldprefix",
"=",
"static",
"::",
"using_attempts_string_id",
"(",
"$",
"which",
")",
";",
"$",
"attempttotals",
"->",
"{",
"$",
"fieldprefix",
".",
"'avg'",
"}",
"=",
"$",
"fromdb",
"->",
"average",
";",
"$",
"attempttotals",
"->",
"{",
"$",
"fieldprefix",
".",
"'count'",
"}",
"=",
"$",
"fromdb",
"->",
"rcount",
";",
"}",
"return",
"$",
"attempttotals",
";",
"}"
] |
Calculating count and mean of marks for first and ALL attempts by students.
See : http://docs.moodle.org/dev/Quiz_item_analysis_calculations_in_practise
#Calculating_MEAN_of_grades_for_all_attempts_by_students
@param int $quizid
@param \core\dml\sql_join $groupstudentsjoins Contains joins, wheres, params for students in this group.
@return \stdClass with properties with count and avg with prefixes firstattempts, highestattempts, etc.
|
[
"Calculating",
"count",
"and",
"mean",
"of",
"marks",
"for",
"first",
"and",
"ALL",
"attempts",
"by",
"students",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/statistics/classes/calculator.php#L209-L224
|
219,735
|
moodle/moodle
|
mod/quiz/report/statistics/classes/calculator.php
|
calculator.median
|
protected function median($s, $fromqa, $whereqa, $qaparams) {
global $DB;
if ($s % 2 == 0) {
// An even number of attempts.
$limitoffset = $s / 2 - 1;
$limit = 2;
} else {
$limitoffset = floor($s / 2);
$limit = 1;
}
$sql = "SELECT quiza.id, quiza.sumgrades
FROM $fromqa
WHERE $whereqa
ORDER BY sumgrades";
$medianmarks = $DB->get_records_sql_menu($sql, $qaparams, $limitoffset, $limit);
return array_sum($medianmarks) / count($medianmarks);
}
|
php
|
protected function median($s, $fromqa, $whereqa, $qaparams) {
global $DB;
if ($s % 2 == 0) {
// An even number of attempts.
$limitoffset = $s / 2 - 1;
$limit = 2;
} else {
$limitoffset = floor($s / 2);
$limit = 1;
}
$sql = "SELECT quiza.id, quiza.sumgrades
FROM $fromqa
WHERE $whereqa
ORDER BY sumgrades";
$medianmarks = $DB->get_records_sql_menu($sql, $qaparams, $limitoffset, $limit);
return array_sum($medianmarks) / count($medianmarks);
}
|
[
"protected",
"function",
"median",
"(",
"$",
"s",
",",
"$",
"fromqa",
",",
"$",
"whereqa",
",",
"$",
"qaparams",
")",
"{",
"global",
"$",
"DB",
";",
"if",
"(",
"$",
"s",
"%",
"2",
"==",
"0",
")",
"{",
"// An even number of attempts.",
"$",
"limitoffset",
"=",
"$",
"s",
"/",
"2",
"-",
"1",
";",
"$",
"limit",
"=",
"2",
";",
"}",
"else",
"{",
"$",
"limitoffset",
"=",
"floor",
"(",
"$",
"s",
"/",
"2",
")",
";",
"$",
"limit",
"=",
"1",
";",
"}",
"$",
"sql",
"=",
"\"SELECT quiza.id, quiza.sumgrades\n FROM $fromqa\n WHERE $whereqa\n ORDER BY sumgrades\"",
";",
"$",
"medianmarks",
"=",
"$",
"DB",
"->",
"get_records_sql_menu",
"(",
"$",
"sql",
",",
"$",
"qaparams",
",",
"$",
"limitoffset",
",",
"$",
"limit",
")",
";",
"return",
"array_sum",
"(",
"$",
"medianmarks",
")",
"/",
"count",
"(",
"$",
"medianmarks",
")",
";",
"}"
] |
Median mark.
http://docs.moodle.org/dev/Quiz_statistics_calculations#Median_Score
@param $s integer count of attempts
@param $fromqa string
@param $whereqa string
@param $qaparams string
@return float
|
[
"Median",
"mark",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/statistics/classes/calculator.php#L237-L256
|
219,736
|
moodle/moodle
|
mod/quiz/report/statistics/classes/calculator.php
|
calculator.sum_of_powers_of_difference_to_mean
|
protected function sum_of_powers_of_difference_to_mean($mean, $fromqa, $whereqa, $qaparams) {
global $DB;
$sql = "SELECT
SUM(POWER((quiza.sumgrades - $mean), 2)) AS power2,
SUM(POWER((quiza.sumgrades - $mean), 3)) AS power3,
SUM(POWER((quiza.sumgrades - $mean), 4)) AS power4
FROM $fromqa
WHERE $whereqa";
$params = array('mean1' => $mean, 'mean2' => $mean, 'mean3' => $mean) + $qaparams;
return $DB->get_record_sql($sql, $params, MUST_EXIST);
}
|
php
|
protected function sum_of_powers_of_difference_to_mean($mean, $fromqa, $whereqa, $qaparams) {
global $DB;
$sql = "SELECT
SUM(POWER((quiza.sumgrades - $mean), 2)) AS power2,
SUM(POWER((quiza.sumgrades - $mean), 3)) AS power3,
SUM(POWER((quiza.sumgrades - $mean), 4)) AS power4
FROM $fromqa
WHERE $whereqa";
$params = array('mean1' => $mean, 'mean2' => $mean, 'mean3' => $mean) + $qaparams;
return $DB->get_record_sql($sql, $params, MUST_EXIST);
}
|
[
"protected",
"function",
"sum_of_powers_of_difference_to_mean",
"(",
"$",
"mean",
",",
"$",
"fromqa",
",",
"$",
"whereqa",
",",
"$",
"qaparams",
")",
"{",
"global",
"$",
"DB",
";",
"$",
"sql",
"=",
"\"SELECT\n SUM(POWER((quiza.sumgrades - $mean), 2)) AS power2,\n SUM(POWER((quiza.sumgrades - $mean), 3)) AS power3,\n SUM(POWER((quiza.sumgrades - $mean), 4)) AS power4\n FROM $fromqa\n WHERE $whereqa\"",
";",
"$",
"params",
"=",
"array",
"(",
"'mean1'",
"=>",
"$",
"mean",
",",
"'mean2'",
"=>",
"$",
"mean",
",",
"'mean3'",
"=>",
"$",
"mean",
")",
"+",
"$",
"qaparams",
";",
"return",
"$",
"DB",
"->",
"get_record_sql",
"(",
"$",
"sql",
",",
"$",
"params",
",",
"MUST_EXIST",
")",
";",
"}"
] |
Fetch the sum of squared, cubed and to the power 4 differences between sumgrade and it's mean.
Explanation here : http://docs.moodle.org/dev/Quiz_item_analysis_calculations_in_practise
#Calculating_Standard_Deviation.2C_Skewness_and_Kurtosis_of_grades_for_all_attempts_by_students
@param $mean
@param $fromqa
@param $whereqa
@param $qaparams
@return object with properties power2, power3, power4
|
[
"Fetch",
"the",
"sum",
"of",
"squared",
"cubed",
"and",
"to",
"the",
"power",
"4",
"differences",
"between",
"sumgrade",
"and",
"it",
"s",
"mean",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/quiz/report/statistics/classes/calculator.php#L270-L282
|
219,737
|
moodle/moodle
|
question/type/ddmarker/edit_ddmarker_form.php
|
qtype_ddmarker_edit_form.get_image_size_in_draft_area
|
public function get_image_size_in_draft_area($draftitemid) {
global $USER;
$usercontext = context_user::instance($USER->id);
$fs = get_file_storage();
$draftfiles = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id');
if ($draftfiles) {
foreach ($draftfiles as $file) {
if ($file->is_directory()) {
continue;
}
// Just return the data for the first good file, there should only be one.
$imageinfo = $file->get_imageinfo();
$width = $imageinfo['width'];
$height = $imageinfo['height'];
return array($width, $height);
}
}
return null;
}
|
php
|
public function get_image_size_in_draft_area($draftitemid) {
global $USER;
$usercontext = context_user::instance($USER->id);
$fs = get_file_storage();
$draftfiles = $fs->get_area_files($usercontext->id, 'user', 'draft', $draftitemid, 'id');
if ($draftfiles) {
foreach ($draftfiles as $file) {
if ($file->is_directory()) {
continue;
}
// Just return the data for the first good file, there should only be one.
$imageinfo = $file->get_imageinfo();
$width = $imageinfo['width'];
$height = $imageinfo['height'];
return array($width, $height);
}
}
return null;
}
|
[
"public",
"function",
"get_image_size_in_draft_area",
"(",
"$",
"draftitemid",
")",
"{",
"global",
"$",
"USER",
";",
"$",
"usercontext",
"=",
"context_user",
"::",
"instance",
"(",
"$",
"USER",
"->",
"id",
")",
";",
"$",
"fs",
"=",
"get_file_storage",
"(",
")",
";",
"$",
"draftfiles",
"=",
"$",
"fs",
"->",
"get_area_files",
"(",
"$",
"usercontext",
"->",
"id",
",",
"'user'",
",",
"'draft'",
",",
"$",
"draftitemid",
",",
"'id'",
")",
";",
"if",
"(",
"$",
"draftfiles",
")",
"{",
"foreach",
"(",
"$",
"draftfiles",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"file",
"->",
"is_directory",
"(",
")",
")",
"{",
"continue",
";",
"}",
"// Just return the data for the first good file, there should only be one.",
"$",
"imageinfo",
"=",
"$",
"file",
"->",
"get_imageinfo",
"(",
")",
";",
"$",
"width",
"=",
"$",
"imageinfo",
"[",
"'width'",
"]",
";",
"$",
"height",
"=",
"$",
"imageinfo",
"[",
"'height'",
"]",
";",
"return",
"array",
"(",
"$",
"width",
",",
"$",
"height",
")",
";",
"}",
"}",
"return",
"null",
";",
"}"
] |
Gets the width and height of a draft image.
@param int $draftitemid ID of the draft image
@return array Return array of the width and height of the draft image.
|
[
"Gets",
"the",
"width",
"and",
"height",
"of",
"a",
"draft",
"image",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/question/type/ddmarker/edit_ddmarker_form.php#L266-L284
|
219,738
|
moodle/moodle
|
lib/flickrlib.php
|
phpFlickr.buildPhotoURL
|
function buildPhotoURL ($photo, $size = "Medium")
{
//receives an array (can use the individual photo data returned
//from an API call) and returns a URL (doesn't mean that the
//file size exists)
$sizes = array(
"square" => "_s",
"thumbnail" => "_t",
"small" => "_m",
"medium" => "",
"large" => "_b",
"original" => "_o"
);
$size = strtolower($size);
if (!array_key_exists($size, $sizes)) {
$size = "medium";
}
if ($size == "original") {
$url = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['originalsecret'] . "_o" . "." . $photo['originalformat'];
} else {
$url = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['secret'] . $sizes[$size] . ".jpg";
}
return $url;
}
|
php
|
function buildPhotoURL ($photo, $size = "Medium")
{
//receives an array (can use the individual photo data returned
//from an API call) and returns a URL (doesn't mean that the
//file size exists)
$sizes = array(
"square" => "_s",
"thumbnail" => "_t",
"small" => "_m",
"medium" => "",
"large" => "_b",
"original" => "_o"
);
$size = strtolower($size);
if (!array_key_exists($size, $sizes)) {
$size = "medium";
}
if ($size == "original") {
$url = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['originalsecret'] . "_o" . "." . $photo['originalformat'];
} else {
$url = "http://farm" . $photo['farm'] . ".static.flickr.com/" . $photo['server'] . "/" . $photo['id'] . "_" . $photo['secret'] . $sizes[$size] . ".jpg";
}
return $url;
}
|
[
"function",
"buildPhotoURL",
"(",
"$",
"photo",
",",
"$",
"size",
"=",
"\"Medium\"",
")",
"{",
"//receives an array (can use the individual photo data returned",
"//from an API call) and returns a URL (doesn't mean that the",
"//file size exists)",
"$",
"sizes",
"=",
"array",
"(",
"\"square\"",
"=>",
"\"_s\"",
",",
"\"thumbnail\"",
"=>",
"\"_t\"",
",",
"\"small\"",
"=>",
"\"_m\"",
",",
"\"medium\"",
"=>",
"\"\"",
",",
"\"large\"",
"=>",
"\"_b\"",
",",
"\"original\"",
"=>",
"\"_o\"",
")",
";",
"$",
"size",
"=",
"strtolower",
"(",
"$",
"size",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"size",
",",
"$",
"sizes",
")",
")",
"{",
"$",
"size",
"=",
"\"medium\"",
";",
"}",
"if",
"(",
"$",
"size",
"==",
"\"original\"",
")",
"{",
"$",
"url",
"=",
"\"http://farm\"",
".",
"$",
"photo",
"[",
"'farm'",
"]",
".",
"\".static.flickr.com/\"",
".",
"$",
"photo",
"[",
"'server'",
"]",
".",
"\"/\"",
".",
"$",
"photo",
"[",
"'id'",
"]",
".",
"\"_\"",
".",
"$",
"photo",
"[",
"'originalsecret'",
"]",
".",
"\"_o\"",
".",
"\".\"",
".",
"$",
"photo",
"[",
"'originalformat'",
"]",
";",
"}",
"else",
"{",
"$",
"url",
"=",
"\"http://farm\"",
".",
"$",
"photo",
"[",
"'farm'",
"]",
".",
"\".static.flickr.com/\"",
".",
"$",
"photo",
"[",
"'server'",
"]",
".",
"\"/\"",
".",
"$",
"photo",
"[",
"'id'",
"]",
".",
"\"_\"",
".",
"$",
"photo",
"[",
"'secret'",
"]",
".",
"$",
"sizes",
"[",
"$",
"size",
"]",
".",
"\".jpg\"",
";",
"}",
"return",
"$",
"url",
";",
"}"
] |
These functions are front ends for the flickr calls
|
[
"These",
"functions",
"are",
"front",
"ends",
"for",
"the",
"flickr",
"calls"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/flickrlib.php#L208-L233
|
219,739
|
moodle/moodle
|
lib/flickrlib.php
|
phpFlickr.groups_pools_add
|
function groups_pools_add ($photo_id, $group_id)
{
/** http://www.flickr.com/services/api/flickr.groups.pools.add.html */
$this->request("flickr.groups.pools.add", array("photo_id"=>$photo_id, "group_id"=>$group_id), TRUE);
return $this->parsed_response ? true : false;
}
|
php
|
function groups_pools_add ($photo_id, $group_id)
{
/** http://www.flickr.com/services/api/flickr.groups.pools.add.html */
$this->request("flickr.groups.pools.add", array("photo_id"=>$photo_id, "group_id"=>$group_id), TRUE);
return $this->parsed_response ? true : false;
}
|
[
"function",
"groups_pools_add",
"(",
"$",
"photo_id",
",",
"$",
"group_id",
")",
"{",
"/** http://www.flickr.com/services/api/flickr.groups.pools.add.html */",
"$",
"this",
"->",
"request",
"(",
"\"flickr.groups.pools.add\"",
",",
"array",
"(",
"\"photo_id\"",
"=>",
"$",
"photo_id",
",",
"\"group_id\"",
"=>",
"$",
"group_id",
")",
",",
"TRUE",
")",
";",
"return",
"$",
"this",
"->",
"parsed_response",
"?",
"true",
":",
"false",
";",
"}"
] |
Groups Pools Methods
|
[
"Groups",
"Pools",
"Methods"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/flickrlib.php#L411-L416
|
219,740
|
moodle/moodle
|
lib/flickrlib.php
|
phpFlickr.photos_comments_addComment
|
function photos_comments_addComment($photo_id, $comment_text) {
/** http://www.flickr.com/services/api/flickr.photos.comments.addComment.html */
$this->request("flickr.photos.comments.addComment", array("photo_id" => $photo_id, "comment_text"=>$comment_text), TRUE);
return $this->parsed_response ? $this->parsed_response['comment'] : false;
}
|
php
|
function photos_comments_addComment($photo_id, $comment_text) {
/** http://www.flickr.com/services/api/flickr.photos.comments.addComment.html */
$this->request("flickr.photos.comments.addComment", array("photo_id" => $photo_id, "comment_text"=>$comment_text), TRUE);
return $this->parsed_response ? $this->parsed_response['comment'] : false;
}
|
[
"function",
"photos_comments_addComment",
"(",
"$",
"photo_id",
",",
"$",
"comment_text",
")",
"{",
"/** http://www.flickr.com/services/api/flickr.photos.comments.addComment.html */",
"$",
"this",
"->",
"request",
"(",
"\"flickr.photos.comments.addComment\"",
",",
"array",
"(",
"\"photo_id\"",
"=>",
"$",
"photo_id",
",",
"\"comment_text\"",
"=>",
"$",
"comment_text",
")",
",",
"TRUE",
")",
";",
"return",
"$",
"this",
"->",
"parsed_response",
"?",
"$",
"this",
"->",
"parsed_response",
"[",
"'comment'",
"]",
":",
"false",
";",
"}"
] |
Photos - Comments Methods
|
[
"Photos",
"-",
"Comments",
"Methods"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/flickrlib.php#L728-L732
|
219,741
|
moodle/moodle
|
lib/flickrlib.php
|
phpFlickr.photos_geo_getLocation
|
function photos_geo_getLocation($photo_id)
{
/** http://www.flickr.com/services/api/flickr.photos.geo.getLocation.html */
$this->request("flickr.photos.geo.getLocation", array("photo_id"=>$photo_id));
return $this->parsed_response ? $this->parsed_response['photo'] : false;
}
|
php
|
function photos_geo_getLocation($photo_id)
{
/** http://www.flickr.com/services/api/flickr.photos.geo.getLocation.html */
$this->request("flickr.photos.geo.getLocation", array("photo_id"=>$photo_id));
return $this->parsed_response ? $this->parsed_response['photo'] : false;
}
|
[
"function",
"photos_geo_getLocation",
"(",
"$",
"photo_id",
")",
"{",
"/** http://www.flickr.com/services/api/flickr.photos.geo.getLocation.html */",
"$",
"this",
"->",
"request",
"(",
"\"flickr.photos.geo.getLocation\"",
",",
"array",
"(",
"\"photo_id\"",
"=>",
"$",
"photo_id",
")",
")",
";",
"return",
"$",
"this",
"->",
"parsed_response",
"?",
"$",
"this",
"->",
"parsed_response",
"[",
"'photo'",
"]",
":",
"false",
";",
"}"
] |
Photos - Geo Methods
|
[
"Photos",
"-",
"Geo",
"Methods"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/flickrlib.php#L754-L759
|
219,742
|
moodle/moodle
|
lib/flickrlib.php
|
phpFlickr.photos_notes_add
|
function photos_notes_add($photo_id, $note_x, $note_y, $note_w, $note_h, $note_text)
{
/** http://www.flickr.com/services/api/flickr.photos.notes.add.html */
$this->request("flickr.photos.notes.add", array("photo_id" => $photo_id, "note_x" => $note_x, "note_y" => $note_y, "note_w" => $note_w, "note_h" => $note_h, "note_text" => $note_text), TRUE);
return $this->parsed_response ? $this->parsed_response['note'] : false;
}
|
php
|
function photos_notes_add($photo_id, $note_x, $note_y, $note_w, $note_h, $note_text)
{
/** http://www.flickr.com/services/api/flickr.photos.notes.add.html */
$this->request("flickr.photos.notes.add", array("photo_id" => $photo_id, "note_x" => $note_x, "note_y" => $note_y, "note_w" => $note_w, "note_h" => $note_h, "note_text" => $note_text), TRUE);
return $this->parsed_response ? $this->parsed_response['note'] : false;
}
|
[
"function",
"photos_notes_add",
"(",
"$",
"photo_id",
",",
"$",
"note_x",
",",
"$",
"note_y",
",",
"$",
"note_w",
",",
"$",
"note_h",
",",
"$",
"note_text",
")",
"{",
"/** http://www.flickr.com/services/api/flickr.photos.notes.add.html */",
"$",
"this",
"->",
"request",
"(",
"\"flickr.photos.notes.add\"",
",",
"array",
"(",
"\"photo_id\"",
"=>",
"$",
"photo_id",
",",
"\"note_x\"",
"=>",
"$",
"note_x",
",",
"\"note_y\"",
"=>",
"$",
"note_y",
",",
"\"note_w\"",
"=>",
"$",
"note_w",
",",
"\"note_h\"",
"=>",
"$",
"note_h",
",",
"\"note_text\"",
"=>",
"$",
"note_text",
")",
",",
"TRUE",
")",
";",
"return",
"$",
"this",
"->",
"parsed_response",
"?",
"$",
"this",
"->",
"parsed_response",
"[",
"'note'",
"]",
":",
"false",
";",
"}"
] |
Photos - Notes Methods
|
[
"Photos",
"-",
"Notes",
"Methods"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/flickrlib.php#L806-L811
|
219,743
|
moodle/moodle
|
lib/flickrlib.php
|
phpFlickr.photos_transform_rotate
|
function photos_transform_rotate($photo_id, $degrees)
{
/** http://www.flickr.com/services/api/flickr.photos.transform.rotate.html */
$this->request("flickr.photos.transform.rotate", array("photo_id" => $photo_id, "degrees" => $degrees), TRUE);
return $this->parsed_response ? true : false;
}
|
php
|
function photos_transform_rotate($photo_id, $degrees)
{
/** http://www.flickr.com/services/api/flickr.photos.transform.rotate.html */
$this->request("flickr.photos.transform.rotate", array("photo_id" => $photo_id, "degrees" => $degrees), TRUE);
return $this->parsed_response ? true : false;
}
|
[
"function",
"photos_transform_rotate",
"(",
"$",
"photo_id",
",",
"$",
"degrees",
")",
"{",
"/** http://www.flickr.com/services/api/flickr.photos.transform.rotate.html */",
"$",
"this",
"->",
"request",
"(",
"\"flickr.photos.transform.rotate\"",
",",
"array",
"(",
"\"photo_id\"",
"=>",
"$",
"photo_id",
",",
"\"degrees\"",
"=>",
"$",
"degrees",
")",
",",
"TRUE",
")",
";",
"return",
"$",
"this",
"->",
"parsed_response",
"?",
"true",
":",
"false",
";",
"}"
] |
Photos - Transform Methods
|
[
"Photos",
"-",
"Transform",
"Methods"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/flickrlib.php#L828-L833
|
219,744
|
moodle/moodle
|
lib/flickrlib.php
|
phpFlickr.photos_upload_checkTickets
|
function photos_upload_checkTickets($tickets)
{
/** http://www.flickr.com/services/api/flickr.photos.upload.checkTickets.html */
if (is_array($tickets)) {
$tickets = implode(",", $tickets);
}
$this->request("flickr.photos.upload.checkTickets", array("tickets" => $tickets), TRUE);
return $this->parsed_response ? $this->parsed_response['uploader']['ticket'] : false;
}
|
php
|
function photos_upload_checkTickets($tickets)
{
/** http://www.flickr.com/services/api/flickr.photos.upload.checkTickets.html */
if (is_array($tickets)) {
$tickets = implode(",", $tickets);
}
$this->request("flickr.photos.upload.checkTickets", array("tickets" => $tickets), TRUE);
return $this->parsed_response ? $this->parsed_response['uploader']['ticket'] : false;
}
|
[
"function",
"photos_upload_checkTickets",
"(",
"$",
"tickets",
")",
"{",
"/** http://www.flickr.com/services/api/flickr.photos.upload.checkTickets.html */",
"if",
"(",
"is_array",
"(",
"$",
"tickets",
")",
")",
"{",
"$",
"tickets",
"=",
"implode",
"(",
"\",\"",
",",
"$",
"tickets",
")",
";",
"}",
"$",
"this",
"->",
"request",
"(",
"\"flickr.photos.upload.checkTickets\"",
",",
"array",
"(",
"\"tickets\"",
"=>",
"$",
"tickets",
")",
",",
"TRUE",
")",
";",
"return",
"$",
"this",
"->",
"parsed_response",
"?",
"$",
"this",
"->",
"parsed_response",
"[",
"'uploader'",
"]",
"[",
"'ticket'",
"]",
":",
"false",
";",
"}"
] |
Photos - Upload Methods
|
[
"Photos",
"-",
"Upload",
"Methods"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/flickrlib.php#L836-L844
|
219,745
|
moodle/moodle
|
lib/flickrlib.php
|
phpFlickr.photosets_comments_addComment
|
function photosets_comments_addComment($photoset_id, $comment_text) {
/** http://www.flickr.com/services/api/flickr.photosets.comments.addComment.html */
$this->request("flickr.photosets.comments.addComment", array("photoset_id" => $photoset_id, "comment_text"=>$comment_text), TRUE);
return $this->parsed_response ? $this->parsed_response['comment'] : false;
}
|
php
|
function photosets_comments_addComment($photoset_id, $comment_text) {
/** http://www.flickr.com/services/api/flickr.photosets.comments.addComment.html */
$this->request("flickr.photosets.comments.addComment", array("photoset_id" => $photoset_id, "comment_text"=>$comment_text), TRUE);
return $this->parsed_response ? $this->parsed_response['comment'] : false;
}
|
[
"function",
"photosets_comments_addComment",
"(",
"$",
"photoset_id",
",",
"$",
"comment_text",
")",
"{",
"/** http://www.flickr.com/services/api/flickr.photosets.comments.addComment.html */",
"$",
"this",
"->",
"request",
"(",
"\"flickr.photosets.comments.addComment\"",
",",
"array",
"(",
"\"photoset_id\"",
"=>",
"$",
"photoset_id",
",",
"\"comment_text\"",
"=>",
"$",
"comment_text",
")",
",",
"TRUE",
")",
";",
"return",
"$",
"this",
"->",
"parsed_response",
"?",
"$",
"this",
"->",
"parsed_response",
"[",
"'comment'",
"]",
":",
"false",
";",
"}"
] |
Photosets Comments Methods
|
[
"Photosets",
"Comments",
"Methods"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/flickrlib.php#L928-L932
|
219,746
|
moodle/moodle
|
course/classes/analytics/indicator/activities_due.php
|
activities_due.get_provide_event_action_num_params
|
private function get_provide_event_action_num_params(string $modulename) {
$functionname = 'mod_' . $modulename . '_core_calendar_provide_event_action';
$reflection = new \ReflectionFunction($functionname);
return $reflection->getNumberOfParameters();
}
|
php
|
private function get_provide_event_action_num_params(string $modulename) {
$functionname = 'mod_' . $modulename . '_core_calendar_provide_event_action';
$reflection = new \ReflectionFunction($functionname);
return $reflection->getNumberOfParameters();
}
|
[
"private",
"function",
"get_provide_event_action_num_params",
"(",
"string",
"$",
"modulename",
")",
"{",
"$",
"functionname",
"=",
"'mod_'",
".",
"$",
"modulename",
".",
"'_core_calendar_provide_event_action'",
";",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"functionname",
")",
";",
"return",
"$",
"reflection",
"->",
"getNumberOfParameters",
"(",
")",
";",
"}"
] |
Returns the number of params declared in core_calendar_provide_event_action's implementation.
@param string $modulename The module name
@return int
|
[
"Returns",
"the",
"number",
"of",
"params",
"declared",
"in",
"core_calendar_provide_event_action",
"s",
"implementation",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/classes/analytics/indicator/activities_due.php#L95-L99
|
219,747
|
moodle/moodle
|
mod/assign/extensionform.php
|
mod_assign_extension_form.validation
|
public function validation($data, $files) {
$errors = parent::validation($data, $files);
if ($this->instance->duedate && $data['extensionduedate']) {
if ($this->instance->duedate > $data['extensionduedate']) {
$errors['extensionduedate'] = get_string('extensionnotafterduedate', 'assign');
}
}
if ($this->instance->allowsubmissionsfromdate && $data['extensionduedate']) {
if ($this->instance->allowsubmissionsfromdate > $data['extensionduedate']) {
$errors['extensionduedate'] = get_string('extensionnotafterfromdate', 'assign');
}
}
return $errors;
}
|
php
|
public function validation($data, $files) {
$errors = parent::validation($data, $files);
if ($this->instance->duedate && $data['extensionduedate']) {
if ($this->instance->duedate > $data['extensionduedate']) {
$errors['extensionduedate'] = get_string('extensionnotafterduedate', 'assign');
}
}
if ($this->instance->allowsubmissionsfromdate && $data['extensionduedate']) {
if ($this->instance->allowsubmissionsfromdate > $data['extensionduedate']) {
$errors['extensionduedate'] = get_string('extensionnotafterfromdate', 'assign');
}
}
return $errors;
}
|
[
"public",
"function",
"validation",
"(",
"$",
"data",
",",
"$",
"files",
")",
"{",
"$",
"errors",
"=",
"parent",
"::",
"validation",
"(",
"$",
"data",
",",
"$",
"files",
")",
";",
"if",
"(",
"$",
"this",
"->",
"instance",
"->",
"duedate",
"&&",
"$",
"data",
"[",
"'extensionduedate'",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"instance",
"->",
"duedate",
">",
"$",
"data",
"[",
"'extensionduedate'",
"]",
")",
"{",
"$",
"errors",
"[",
"'extensionduedate'",
"]",
"=",
"get_string",
"(",
"'extensionnotafterduedate'",
",",
"'assign'",
")",
";",
"}",
"}",
"if",
"(",
"$",
"this",
"->",
"instance",
"->",
"allowsubmissionsfromdate",
"&&",
"$",
"data",
"[",
"'extensionduedate'",
"]",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"instance",
"->",
"allowsubmissionsfromdate",
">",
"$",
"data",
"[",
"'extensionduedate'",
"]",
")",
"{",
"$",
"errors",
"[",
"'extensionduedate'",
"]",
"=",
"get_string",
"(",
"'extensionnotafterfromdate'",
",",
"'assign'",
")",
";",
"}",
"}",
"return",
"$",
"errors",
";",
"}"
] |
Perform validation on the extension form
@param array $data
@param array $files
|
[
"Perform",
"validation",
"on",
"the",
"extension",
"form"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/assign/extensionform.php#L121-L135
|
219,748
|
moodle/moodle
|
mod/lti/service/toolproxy/classes/local/resources/toolproxy.php
|
toolproxy.lti_extract_parameters
|
private static function lti_extract_parameters($parameters) {
$params = array();
foreach ($parameters as $parameter) {
if (isset($parameter->variable)) {
$value = '$' . $parameter->variable;
} else {
$value = $parameter->fixed;
if (strlen($value) > 0) {
$first = substr($value, 0, 1);
if (($first == '$') || ($first == '\\')) {
$value = '\\' . $value;
}
}
}
$params[] = "{$parameter->name}={$value}";
}
return implode("\n", $params);
}
|
php
|
private static function lti_extract_parameters($parameters) {
$params = array();
foreach ($parameters as $parameter) {
if (isset($parameter->variable)) {
$value = '$' . $parameter->variable;
} else {
$value = $parameter->fixed;
if (strlen($value) > 0) {
$first = substr($value, 0, 1);
if (($first == '$') || ($first == '\\')) {
$value = '\\' . $value;
}
}
}
$params[] = "{$parameter->name}={$value}";
}
return implode("\n", $params);
}
|
[
"private",
"static",
"function",
"lti_extract_parameters",
"(",
"$",
"parameters",
")",
"{",
"$",
"params",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"parameters",
"as",
"$",
"parameter",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"parameter",
"->",
"variable",
")",
")",
"{",
"$",
"value",
"=",
"'$'",
".",
"$",
"parameter",
"->",
"variable",
";",
"}",
"else",
"{",
"$",
"value",
"=",
"$",
"parameter",
"->",
"fixed",
";",
"if",
"(",
"strlen",
"(",
"$",
"value",
")",
">",
"0",
")",
"{",
"$",
"first",
"=",
"substr",
"(",
"$",
"value",
",",
"0",
",",
"1",
")",
";",
"if",
"(",
"(",
"$",
"first",
"==",
"'$'",
")",
"||",
"(",
"$",
"first",
"==",
"'\\\\'",
")",
")",
"{",
"$",
"value",
"=",
"'\\\\'",
".",
"$",
"value",
";",
"}",
"}",
"}",
"$",
"params",
"[",
"]",
"=",
"\"{$parameter->name}={$value}\"",
";",
"}",
"return",
"implode",
"(",
"\"\\n\"",
",",
"$",
"params",
")",
";",
"}"
] |
Extracts the message parameters from the tool proxy entry
@param array $parameters Parameter section of a message
@return String containing parameters
|
[
"Extracts",
"the",
"message",
"parameters",
"from",
"the",
"tool",
"proxy",
"entry"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/mod/lti/service/toolproxy/classes/local/resources/toolproxy.php#L278-L298
|
219,749
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.course_info_box
|
public function course_info_box(stdClass $course) {
$content = '';
$content .= $this->output->box_start('generalbox info');
$chelper = new coursecat_helper();
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED);
$content .= $this->coursecat_coursebox($chelper, $course);
$content .= $this->output->box_end();
return $content;
}
|
php
|
public function course_info_box(stdClass $course) {
$content = '';
$content .= $this->output->box_start('generalbox info');
$chelper = new coursecat_helper();
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED);
$content .= $this->coursecat_coursebox($chelper, $course);
$content .= $this->output->box_end();
return $content;
}
|
[
"public",
"function",
"course_info_box",
"(",
"stdClass",
"$",
"course",
")",
"{",
"$",
"content",
"=",
"''",
";",
"$",
"content",
".=",
"$",
"this",
"->",
"output",
"->",
"box_start",
"(",
"'generalbox info'",
")",
";",
"$",
"chelper",
"=",
"new",
"coursecat_helper",
"(",
")",
";",
"$",
"chelper",
"->",
"set_show_courses",
"(",
"self",
"::",
"COURSECAT_SHOW_COURSES_EXPANDED",
")",
";",
"$",
"content",
".=",
"$",
"this",
"->",
"coursecat_coursebox",
"(",
"$",
"chelper",
",",
"$",
"course",
")",
";",
"$",
"content",
".=",
"$",
"this",
"->",
"output",
"->",
"box_end",
"(",
")",
";",
"return",
"$",
"content",
";",
"}"
] |
Renders course info box.
@param stdClass $course
@return string
|
[
"Renders",
"course",
"info",
"box",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L84-L92
|
219,750
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.course_modchooser
|
public function course_modchooser($modules, $course) {
if (!$this->page->requires->should_create_one_time_item_now('core_course_modchooser')) {
return '';
}
$modchooser = new \core_course\output\modchooser($course, $modules);
return $this->render($modchooser);
}
|
php
|
public function course_modchooser($modules, $course) {
if (!$this->page->requires->should_create_one_time_item_now('core_course_modchooser')) {
return '';
}
$modchooser = new \core_course\output\modchooser($course, $modules);
return $this->render($modchooser);
}
|
[
"public",
"function",
"course_modchooser",
"(",
"$",
"modules",
",",
"$",
"course",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"should_create_one_time_item_now",
"(",
"'core_course_modchooser'",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"modchooser",
"=",
"new",
"\\",
"core_course",
"\\",
"output",
"\\",
"modchooser",
"(",
"$",
"course",
",",
"$",
"modules",
")",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"modchooser",
")",
";",
"}"
] |
Build the HTML for the module chooser javascript popup
@param array $modules A set of modules as returned form @see
get_module_metadata
@param object $course The course that will be displayed
@return string The composed HTML for the module
|
[
"Build",
"the",
"HTML",
"for",
"the",
"module",
"chooser",
"javascript",
"popup"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L143-L149
|
219,751
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.course_section_cm_edit_actions
|
public function course_section_cm_edit_actions($actions, cm_info $mod = null, $displayoptions = array()) {
global $CFG;
if (empty($actions)) {
return '';
}
if (isset($displayoptions['ownerselector'])) {
$ownerselector = $displayoptions['ownerselector'];
} else if ($mod) {
$ownerselector = '#module-'.$mod->id;
} else {
debugging('You should upgrade your call to '.__FUNCTION__.' and provide $mod', DEBUG_DEVELOPER);
$ownerselector = 'li.activity';
}
if (isset($displayoptions['constraintselector'])) {
$constraint = $displayoptions['constraintselector'];
} else {
$constraint = '.course-content';
}
$menu = new action_menu();
$menu->set_owner_selector($ownerselector);
$menu->set_constraint($constraint);
$menu->set_alignment(action_menu::TR, action_menu::BR);
$menu->set_menu_trigger(get_string('edit'));
foreach ($actions as $action) {
if ($action instanceof action_menu_link) {
$action->add_class('cm-edit-action');
}
$menu->add($action);
}
$menu->attributes['class'] .= ' section-cm-edit-actions commands';
// Prioritise the menu ahead of all other actions.
$menu->prioritise = true;
return $this->render($menu);
}
|
php
|
public function course_section_cm_edit_actions($actions, cm_info $mod = null, $displayoptions = array()) {
global $CFG;
if (empty($actions)) {
return '';
}
if (isset($displayoptions['ownerselector'])) {
$ownerselector = $displayoptions['ownerselector'];
} else if ($mod) {
$ownerselector = '#module-'.$mod->id;
} else {
debugging('You should upgrade your call to '.__FUNCTION__.' and provide $mod', DEBUG_DEVELOPER);
$ownerselector = 'li.activity';
}
if (isset($displayoptions['constraintselector'])) {
$constraint = $displayoptions['constraintselector'];
} else {
$constraint = '.course-content';
}
$menu = new action_menu();
$menu->set_owner_selector($ownerselector);
$menu->set_constraint($constraint);
$menu->set_alignment(action_menu::TR, action_menu::BR);
$menu->set_menu_trigger(get_string('edit'));
foreach ($actions as $action) {
if ($action instanceof action_menu_link) {
$action->add_class('cm-edit-action');
}
$menu->add($action);
}
$menu->attributes['class'] .= ' section-cm-edit-actions commands';
// Prioritise the menu ahead of all other actions.
$menu->prioritise = true;
return $this->render($menu);
}
|
[
"public",
"function",
"course_section_cm_edit_actions",
"(",
"$",
"actions",
",",
"cm_info",
"$",
"mod",
"=",
"null",
",",
"$",
"displayoptions",
"=",
"array",
"(",
")",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"empty",
"(",
"$",
"actions",
")",
")",
"{",
"return",
"''",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"displayoptions",
"[",
"'ownerselector'",
"]",
")",
")",
"{",
"$",
"ownerselector",
"=",
"$",
"displayoptions",
"[",
"'ownerselector'",
"]",
";",
"}",
"else",
"if",
"(",
"$",
"mod",
")",
"{",
"$",
"ownerselector",
"=",
"'#module-'",
".",
"$",
"mod",
"->",
"id",
";",
"}",
"else",
"{",
"debugging",
"(",
"'You should upgrade your call to '",
".",
"__FUNCTION__",
".",
"' and provide $mod'",
",",
"DEBUG_DEVELOPER",
")",
";",
"$",
"ownerselector",
"=",
"'li.activity'",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"displayoptions",
"[",
"'constraintselector'",
"]",
")",
")",
"{",
"$",
"constraint",
"=",
"$",
"displayoptions",
"[",
"'constraintselector'",
"]",
";",
"}",
"else",
"{",
"$",
"constraint",
"=",
"'.course-content'",
";",
"}",
"$",
"menu",
"=",
"new",
"action_menu",
"(",
")",
";",
"$",
"menu",
"->",
"set_owner_selector",
"(",
"$",
"ownerselector",
")",
";",
"$",
"menu",
"->",
"set_constraint",
"(",
"$",
"constraint",
")",
";",
"$",
"menu",
"->",
"set_alignment",
"(",
"action_menu",
"::",
"TR",
",",
"action_menu",
"::",
"BR",
")",
";",
"$",
"menu",
"->",
"set_menu_trigger",
"(",
"get_string",
"(",
"'edit'",
")",
")",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")",
"{",
"if",
"(",
"$",
"action",
"instanceof",
"action_menu_link",
")",
"{",
"$",
"action",
"->",
"add_class",
"(",
"'cm-edit-action'",
")",
";",
"}",
"$",
"menu",
"->",
"add",
"(",
"$",
"action",
")",
";",
"}",
"$",
"menu",
"->",
"attributes",
"[",
"'class'",
"]",
".=",
"' section-cm-edit-actions commands'",
";",
"// Prioritise the menu ahead of all other actions.",
"$",
"menu",
"->",
"prioritise",
"=",
"true",
";",
"return",
"$",
"this",
"->",
"render",
"(",
"$",
"menu",
")",
";",
"}"
] |
Renders HTML for displaying the sequence of course module editing buttons
@see course_get_cm_edit_actions()
@param action_link[] $actions Array of action_link objects
@param cm_info $mod The module we are displaying actions for.
@param array $displayoptions additional display options:
ownerselector => A JS/CSS selector that can be used to find an cm node.
If specified the owning node will be given the class 'action-menu-shown' when the action
menu is being displayed.
constraintselector => A JS/CSS selector that can be used to find the parent node for which to constrain
the action menu to when it is being displayed.
donotenhance => If set to true the action menu that gets displayed won't be enhanced by JS.
@return string
|
[
"Renders",
"HTML",
"for",
"displaying",
"the",
"sequence",
"of",
"course",
"module",
"editing",
"buttons"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L203-L243
|
219,752
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.course_search_form
|
public function course_search_form($value = '', $format = 'plain') {
static $count = 0;
$formid = 'coursesearch';
if ((++$count) > 1) {
$formid .= $count;
}
switch ($format) {
case 'navbar' :
$formid = 'coursesearchnavbar';
$inputid = 'navsearchbox';
$inputsize = 20;
break;
case 'short' :
$inputid = 'shortsearchbox';
$inputsize = 12;
break;
default :
$inputid = 'coursesearchbox';
$inputsize = 30;
}
$data = (object) [
'searchurl' => (new moodle_url('/course/search.php'))->out(false),
'id' => $formid,
'inputid' => $inputid,
'inputsize' => $inputsize,
'value' => $value
];
if ($format != 'navbar') {
$helpicon = new \help_icon('coursesearch', 'core');
$data->helpicon = $helpicon->export_for_template($this);
}
return $this->render_from_template('core_course/course_search_form', $data);
}
|
php
|
public function course_search_form($value = '', $format = 'plain') {
static $count = 0;
$formid = 'coursesearch';
if ((++$count) > 1) {
$formid .= $count;
}
switch ($format) {
case 'navbar' :
$formid = 'coursesearchnavbar';
$inputid = 'navsearchbox';
$inputsize = 20;
break;
case 'short' :
$inputid = 'shortsearchbox';
$inputsize = 12;
break;
default :
$inputid = 'coursesearchbox';
$inputsize = 30;
}
$data = (object) [
'searchurl' => (new moodle_url('/course/search.php'))->out(false),
'id' => $formid,
'inputid' => $inputid,
'inputsize' => $inputsize,
'value' => $value
];
if ($format != 'navbar') {
$helpicon = new \help_icon('coursesearch', 'core');
$data->helpicon = $helpicon->export_for_template($this);
}
return $this->render_from_template('core_course/course_search_form', $data);
}
|
[
"public",
"function",
"course_search_form",
"(",
"$",
"value",
"=",
"''",
",",
"$",
"format",
"=",
"'plain'",
")",
"{",
"static",
"$",
"count",
"=",
"0",
";",
"$",
"formid",
"=",
"'coursesearch'",
";",
"if",
"(",
"(",
"++",
"$",
"count",
")",
">",
"1",
")",
"{",
"$",
"formid",
".=",
"$",
"count",
";",
"}",
"switch",
"(",
"$",
"format",
")",
"{",
"case",
"'navbar'",
":",
"$",
"formid",
"=",
"'coursesearchnavbar'",
";",
"$",
"inputid",
"=",
"'navsearchbox'",
";",
"$",
"inputsize",
"=",
"20",
";",
"break",
";",
"case",
"'short'",
":",
"$",
"inputid",
"=",
"'shortsearchbox'",
";",
"$",
"inputsize",
"=",
"12",
";",
"break",
";",
"default",
":",
"$",
"inputid",
"=",
"'coursesearchbox'",
";",
"$",
"inputsize",
"=",
"30",
";",
"}",
"$",
"data",
"=",
"(",
"object",
")",
"[",
"'searchurl'",
"=>",
"(",
"new",
"moodle_url",
"(",
"'/course/search.php'",
")",
")",
"->",
"out",
"(",
"false",
")",
",",
"'id'",
"=>",
"$",
"formid",
",",
"'inputid'",
"=>",
"$",
"inputid",
",",
"'inputsize'",
"=>",
"$",
"inputsize",
",",
"'value'",
"=>",
"$",
"value",
"]",
";",
"if",
"(",
"$",
"format",
"!=",
"'navbar'",
")",
"{",
"$",
"helpicon",
"=",
"new",
"\\",
"help_icon",
"(",
"'coursesearch'",
",",
"'core'",
")",
";",
"$",
"data",
"->",
"helpicon",
"=",
"$",
"helpicon",
"->",
"export_for_template",
"(",
"$",
"this",
")",
";",
"}",
"return",
"$",
"this",
"->",
"render_from_template",
"(",
"'core_course/course_search_form'",
",",
"$",
"data",
")",
";",
"}"
] |
Renders html to display a course search form.
@param string $value default value to populate the search field
@param string $format display format - 'plain' (default), 'short' or 'navbar'
@return string
|
[
"Renders",
"html",
"to",
"display",
"a",
"course",
"search",
"form",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L353-L388
|
219,753
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.is_cm_conditionally_hidden
|
protected function is_cm_conditionally_hidden(cm_info $mod) {
global $CFG;
$conditionalhidden = false;
if (!empty($CFG->enableavailability)) {
$info = new \core_availability\info_module($mod);
$conditionalhidden = !$info->is_available_for_all();
}
return $conditionalhidden;
}
|
php
|
protected function is_cm_conditionally_hidden(cm_info $mod) {
global $CFG;
$conditionalhidden = false;
if (!empty($CFG->enableavailability)) {
$info = new \core_availability\info_module($mod);
$conditionalhidden = !$info->is_available_for_all();
}
return $conditionalhidden;
}
|
[
"protected",
"function",
"is_cm_conditionally_hidden",
"(",
"cm_info",
"$",
"mod",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"conditionalhidden",
"=",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"CFG",
"->",
"enableavailability",
")",
")",
"{",
"$",
"info",
"=",
"new",
"\\",
"core_availability",
"\\",
"info_module",
"(",
"$",
"mod",
")",
";",
"$",
"conditionalhidden",
"=",
"!",
"$",
"info",
"->",
"is_available_for_all",
"(",
")",
";",
"}",
"return",
"$",
"conditionalhidden",
";",
"}"
] |
Checks if course module has any conditions that may make it unavailable for
all or some of the students
This function is internal and is only used to create CSS classes for the module name/text
@param cm_info $mod
@return bool
|
[
"Checks",
"if",
"course",
"module",
"has",
"any",
"conditions",
"that",
"may",
"make",
"it",
"unavailable",
"for",
"all",
"or",
"some",
"of",
"the",
"students"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L532-L540
|
219,754
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.availability_info
|
public function availability_info($text, $additionalclasses = '') {
$data = ['text' => $text, 'classes' => $additionalclasses];
$additionalclasses = array_filter(explode(' ', $additionalclasses));
if (in_array('ishidden', $additionalclasses)) {
$data['ishidden'] = 1;
} else if (in_array('isstealth', $additionalclasses)) {
$data['isstealth'] = 1;
} else if (in_array('isrestricted', $additionalclasses)) {
$data['isrestricted'] = 1;
if (in_array('isfullinfo', $additionalclasses)) {
$data['isfullinfo'] = 1;
}
}
return $this->render_from_template('core/availability_info', $data);
}
|
php
|
public function availability_info($text, $additionalclasses = '') {
$data = ['text' => $text, 'classes' => $additionalclasses];
$additionalclasses = array_filter(explode(' ', $additionalclasses));
if (in_array('ishidden', $additionalclasses)) {
$data['ishidden'] = 1;
} else if (in_array('isstealth', $additionalclasses)) {
$data['isstealth'] = 1;
} else if (in_array('isrestricted', $additionalclasses)) {
$data['isrestricted'] = 1;
if (in_array('isfullinfo', $additionalclasses)) {
$data['isfullinfo'] = 1;
}
}
return $this->render_from_template('core/availability_info', $data);
}
|
[
"public",
"function",
"availability_info",
"(",
"$",
"text",
",",
"$",
"additionalclasses",
"=",
"''",
")",
"{",
"$",
"data",
"=",
"[",
"'text'",
"=>",
"$",
"text",
",",
"'classes'",
"=>",
"$",
"additionalclasses",
"]",
";",
"$",
"additionalclasses",
"=",
"array_filter",
"(",
"explode",
"(",
"' '",
",",
"$",
"additionalclasses",
")",
")",
";",
"if",
"(",
"in_array",
"(",
"'ishidden'",
",",
"$",
"additionalclasses",
")",
")",
"{",
"$",
"data",
"[",
"'ishidden'",
"]",
"=",
"1",
";",
"}",
"else",
"if",
"(",
"in_array",
"(",
"'isstealth'",
",",
"$",
"additionalclasses",
")",
")",
"{",
"$",
"data",
"[",
"'isstealth'",
"]",
"=",
"1",
";",
"}",
"else",
"if",
"(",
"in_array",
"(",
"'isrestricted'",
",",
"$",
"additionalclasses",
")",
")",
"{",
"$",
"data",
"[",
"'isrestricted'",
"]",
"=",
"1",
";",
"if",
"(",
"in_array",
"(",
"'isfullinfo'",
",",
"$",
"additionalclasses",
")",
")",
"{",
"$",
"data",
"[",
"'isfullinfo'",
"]",
"=",
"1",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"render_from_template",
"(",
"'core/availability_info'",
",",
"$",
"data",
")",
";",
"}"
] |
Displays availability info for a course section or course module
@param string $text
@param string $additionalclasses
@return string
|
[
"Displays",
"availability",
"info",
"for",
"a",
"course",
"section",
"or",
"course",
"module"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L704-L724
|
219,755
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.course_section_cm_list_item
|
public function course_section_cm_list_item($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array()) {
$output = '';
if ($modulehtml = $this->course_section_cm($course, $completioninfo, $mod, $sectionreturn, $displayoptions)) {
$modclasses = 'activity ' . $mod->modname . ' modtype_' . $mod->modname . ' ' . $mod->extraclasses;
$output .= html_writer::tag('li', $modulehtml, array('class' => $modclasses, 'id' => 'module-' . $mod->id));
}
return $output;
}
|
php
|
public function course_section_cm_list_item($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array()) {
$output = '';
if ($modulehtml = $this->course_section_cm($course, $completioninfo, $mod, $sectionreturn, $displayoptions)) {
$modclasses = 'activity ' . $mod->modname . ' modtype_' . $mod->modname . ' ' . $mod->extraclasses;
$output .= html_writer::tag('li', $modulehtml, array('class' => $modclasses, 'id' => 'module-' . $mod->id));
}
return $output;
}
|
[
"public",
"function",
"course_section_cm_list_item",
"(",
"$",
"course",
",",
"&",
"$",
"completioninfo",
",",
"cm_info",
"$",
"mod",
",",
"$",
"sectionreturn",
",",
"$",
"displayoptions",
"=",
"array",
"(",
")",
")",
"{",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"$",
"modulehtml",
"=",
"$",
"this",
"->",
"course_section_cm",
"(",
"$",
"course",
",",
"$",
"completioninfo",
",",
"$",
"mod",
",",
"$",
"sectionreturn",
",",
"$",
"displayoptions",
")",
")",
"{",
"$",
"modclasses",
"=",
"'activity '",
".",
"$",
"mod",
"->",
"modname",
".",
"' modtype_'",
".",
"$",
"mod",
"->",
"modname",
".",
"' '",
".",
"$",
"mod",
"->",
"extraclasses",
";",
"$",
"output",
".=",
"html_writer",
"::",
"tag",
"(",
"'li'",
",",
"$",
"modulehtml",
",",
"array",
"(",
"'class'",
"=>",
"$",
"modclasses",
",",
"'id'",
"=>",
"'module-'",
".",
"$",
"mod",
"->",
"id",
")",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Renders HTML to display one course module for display within a section.
This function calls:
{@link core_course_renderer::course_section_cm()}
@param stdClass $course
@param completion_info $completioninfo
@param cm_info $mod
@param int|null $sectionreturn
@param array $displayoptions
@return String
|
[
"Renders",
"HTML",
"to",
"display",
"one",
"course",
"module",
"for",
"display",
"within",
"a",
"section",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L798-L805
|
219,756
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.course_section_cm
|
public function course_section_cm($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array()) {
$output = '';
// We return empty string (because course module will not be displayed at all)
// if:
// 1) The activity is not visible to users
// and
// 2) The 'availableinfo' is empty, i.e. the activity was
// hidden in a way that leaves no info, such as using the
// eye icon.
if (!$mod->is_visible_on_course_page()) {
return $output;
}
$indentclasses = 'mod-indent';
if (!empty($mod->indent)) {
$indentclasses .= ' mod-indent-'.$mod->indent;
if ($mod->indent > 15) {
$indentclasses .= ' mod-indent-huge';
}
}
$output .= html_writer::start_tag('div');
if ($this->page->user_is_editing()) {
$output .= course_get_cm_move($mod, $sectionreturn);
}
$output .= html_writer::start_tag('div', array('class' => 'mod-indent-outer'));
// This div is used to indent the content.
$output .= html_writer::div('', $indentclasses);
// Start a wrapper for the actual content to keep the indentation consistent
$output .= html_writer::start_tag('div');
// Display the link to the module (or do nothing if module has no url)
$cmname = $this->course_section_cm_name($mod, $displayoptions);
if (!empty($cmname)) {
// Start the div for the activity title, excluding the edit icons.
$output .= html_writer::start_tag('div', array('class' => 'activityinstance'));
$output .= $cmname;
// Module can put text after the link (e.g. forum unread)
$output .= $mod->afterlink;
// Closing the tag which contains everything but edit icons. Content part of the module should not be part of this.
$output .= html_writer::end_tag('div'); // .activityinstance
}
// If there is content but NO link (eg label), then display the
// content here (BEFORE any icons). In this case cons must be
// displayed after the content so that it makes more sense visually
// and for accessibility reasons, e.g. if you have a one-line label
// it should work similarly (at least in terms of ordering) to an
// activity.
$contentpart = $this->course_section_cm_text($mod, $displayoptions);
$url = $mod->url;
if (empty($url)) {
$output .= $contentpart;
}
$modicons = '';
if ($this->page->user_is_editing()) {
$editactions = course_get_cm_edit_actions($mod, $mod->indent, $sectionreturn);
$modicons .= ' '. $this->course_section_cm_edit_actions($editactions, $mod, $displayoptions);
$modicons .= $mod->afterediticons;
}
$modicons .= $this->course_section_cm_completion($course, $completioninfo, $mod, $displayoptions);
if (!empty($modicons)) {
$output .= html_writer::span($modicons, 'actions');
}
// Show availability info (if module is not available).
$output .= $this->course_section_cm_availability($mod, $displayoptions);
// If there is content AND a link, then display the content here
// (AFTER any icons). Otherwise it was displayed before
if (!empty($url)) {
$output .= $contentpart;
}
$output .= html_writer::end_tag('div'); // $indentclasses
// End of indentation div.
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
return $output;
}
|
php
|
public function course_section_cm($course, &$completioninfo, cm_info $mod, $sectionreturn, $displayoptions = array()) {
$output = '';
// We return empty string (because course module will not be displayed at all)
// if:
// 1) The activity is not visible to users
// and
// 2) The 'availableinfo' is empty, i.e. the activity was
// hidden in a way that leaves no info, such as using the
// eye icon.
if (!$mod->is_visible_on_course_page()) {
return $output;
}
$indentclasses = 'mod-indent';
if (!empty($mod->indent)) {
$indentclasses .= ' mod-indent-'.$mod->indent;
if ($mod->indent > 15) {
$indentclasses .= ' mod-indent-huge';
}
}
$output .= html_writer::start_tag('div');
if ($this->page->user_is_editing()) {
$output .= course_get_cm_move($mod, $sectionreturn);
}
$output .= html_writer::start_tag('div', array('class' => 'mod-indent-outer'));
// This div is used to indent the content.
$output .= html_writer::div('', $indentclasses);
// Start a wrapper for the actual content to keep the indentation consistent
$output .= html_writer::start_tag('div');
// Display the link to the module (or do nothing if module has no url)
$cmname = $this->course_section_cm_name($mod, $displayoptions);
if (!empty($cmname)) {
// Start the div for the activity title, excluding the edit icons.
$output .= html_writer::start_tag('div', array('class' => 'activityinstance'));
$output .= $cmname;
// Module can put text after the link (e.g. forum unread)
$output .= $mod->afterlink;
// Closing the tag which contains everything but edit icons. Content part of the module should not be part of this.
$output .= html_writer::end_tag('div'); // .activityinstance
}
// If there is content but NO link (eg label), then display the
// content here (BEFORE any icons). In this case cons must be
// displayed after the content so that it makes more sense visually
// and for accessibility reasons, e.g. if you have a one-line label
// it should work similarly (at least in terms of ordering) to an
// activity.
$contentpart = $this->course_section_cm_text($mod, $displayoptions);
$url = $mod->url;
if (empty($url)) {
$output .= $contentpart;
}
$modicons = '';
if ($this->page->user_is_editing()) {
$editactions = course_get_cm_edit_actions($mod, $mod->indent, $sectionreturn);
$modicons .= ' '. $this->course_section_cm_edit_actions($editactions, $mod, $displayoptions);
$modicons .= $mod->afterediticons;
}
$modicons .= $this->course_section_cm_completion($course, $completioninfo, $mod, $displayoptions);
if (!empty($modicons)) {
$output .= html_writer::span($modicons, 'actions');
}
// Show availability info (if module is not available).
$output .= $this->course_section_cm_availability($mod, $displayoptions);
// If there is content AND a link, then display the content here
// (AFTER any icons). Otherwise it was displayed before
if (!empty($url)) {
$output .= $contentpart;
}
$output .= html_writer::end_tag('div'); // $indentclasses
// End of indentation div.
$output .= html_writer::end_tag('div');
$output .= html_writer::end_tag('div');
return $output;
}
|
[
"public",
"function",
"course_section_cm",
"(",
"$",
"course",
",",
"&",
"$",
"completioninfo",
",",
"cm_info",
"$",
"mod",
",",
"$",
"sectionreturn",
",",
"$",
"displayoptions",
"=",
"array",
"(",
")",
")",
"{",
"$",
"output",
"=",
"''",
";",
"// We return empty string (because course module will not be displayed at all)",
"// if:",
"// 1) The activity is not visible to users",
"// and",
"// 2) The 'availableinfo' is empty, i.e. the activity was",
"// hidden in a way that leaves no info, such as using the",
"// eye icon.",
"if",
"(",
"!",
"$",
"mod",
"->",
"is_visible_on_course_page",
"(",
")",
")",
"{",
"return",
"$",
"output",
";",
"}",
"$",
"indentclasses",
"=",
"'mod-indent'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"mod",
"->",
"indent",
")",
")",
"{",
"$",
"indentclasses",
".=",
"' mod-indent-'",
".",
"$",
"mod",
"->",
"indent",
";",
"if",
"(",
"$",
"mod",
"->",
"indent",
">",
"15",
")",
"{",
"$",
"indentclasses",
".=",
"' mod-indent-huge'",
";",
"}",
"}",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"user_is_editing",
"(",
")",
")",
"{",
"$",
"output",
".=",
"course_get_cm_move",
"(",
"$",
"mod",
",",
"$",
"sectionreturn",
")",
";",
"}",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'mod-indent-outer'",
")",
")",
";",
"// This div is used to indent the content.",
"$",
"output",
".=",
"html_writer",
"::",
"div",
"(",
"''",
",",
"$",
"indentclasses",
")",
";",
"// Start a wrapper for the actual content to keep the indentation consistent",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
")",
";",
"// Display the link to the module (or do nothing if module has no url)",
"$",
"cmname",
"=",
"$",
"this",
"->",
"course_section_cm_name",
"(",
"$",
"mod",
",",
"$",
"displayoptions",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"cmname",
")",
")",
"{",
"// Start the div for the activity title, excluding the edit icons.",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'activityinstance'",
")",
")",
";",
"$",
"output",
".=",
"$",
"cmname",
";",
"// Module can put text after the link (e.g. forum unread)",
"$",
"output",
".=",
"$",
"mod",
"->",
"afterlink",
";",
"// Closing the tag which contains everything but edit icons. Content part of the module should not be part of this.",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"// .activityinstance",
"}",
"// If there is content but NO link (eg label), then display the",
"// content here (BEFORE any icons). In this case cons must be",
"// displayed after the content so that it makes more sense visually",
"// and for accessibility reasons, e.g. if you have a one-line label",
"// it should work similarly (at least in terms of ordering) to an",
"// activity.",
"$",
"contentpart",
"=",
"$",
"this",
"->",
"course_section_cm_text",
"(",
"$",
"mod",
",",
"$",
"displayoptions",
")",
";",
"$",
"url",
"=",
"$",
"mod",
"->",
"url",
";",
"if",
"(",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"$",
"output",
".=",
"$",
"contentpart",
";",
"}",
"$",
"modicons",
"=",
"''",
";",
"if",
"(",
"$",
"this",
"->",
"page",
"->",
"user_is_editing",
"(",
")",
")",
"{",
"$",
"editactions",
"=",
"course_get_cm_edit_actions",
"(",
"$",
"mod",
",",
"$",
"mod",
"->",
"indent",
",",
"$",
"sectionreturn",
")",
";",
"$",
"modicons",
".=",
"' '",
".",
"$",
"this",
"->",
"course_section_cm_edit_actions",
"(",
"$",
"editactions",
",",
"$",
"mod",
",",
"$",
"displayoptions",
")",
";",
"$",
"modicons",
".=",
"$",
"mod",
"->",
"afterediticons",
";",
"}",
"$",
"modicons",
".=",
"$",
"this",
"->",
"course_section_cm_completion",
"(",
"$",
"course",
",",
"$",
"completioninfo",
",",
"$",
"mod",
",",
"$",
"displayoptions",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"modicons",
")",
")",
"{",
"$",
"output",
".=",
"html_writer",
"::",
"span",
"(",
"$",
"modicons",
",",
"'actions'",
")",
";",
"}",
"// Show availability info (if module is not available).",
"$",
"output",
".=",
"$",
"this",
"->",
"course_section_cm_availability",
"(",
"$",
"mod",
",",
"$",
"displayoptions",
")",
";",
"// If there is content AND a link, then display the content here",
"// (AFTER any icons). Otherwise it was displayed before",
"if",
"(",
"!",
"empty",
"(",
"$",
"url",
")",
")",
"{",
"$",
"output",
".=",
"$",
"contentpart",
";",
"}",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"// $indentclasses",
"// End of indentation div.",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"return",
"$",
"output",
";",
"}"
] |
Renders HTML to display one course module in a course section
This includes link, content, availability, completion info and additional information
that module type wants to display (i.e. number of unread forum posts)
This function calls:
{@link core_course_renderer::course_section_cm_name()}
{@link core_course_renderer::course_section_cm_text()}
{@link core_course_renderer::course_section_cm_availability()}
{@link core_course_renderer::course_section_cm_completion()}
{@link course_get_cm_edit_actions()}
{@link core_course_renderer::course_section_cm_edit_actions()}
@param stdClass $course
@param completion_info $completioninfo
@param cm_info $mod
@param int|null $sectionreturn
@param array $displayoptions
@return string
|
[
"Renders",
"HTML",
"to",
"display",
"one",
"course",
"module",
"in",
"a",
"course",
"section"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L828-L920
|
219,757
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.course_section_cm_unavailable_error_message
|
public function course_section_cm_unavailable_error_message(cm_info $cm) {
if ($cm->uservisible) {
return null;
}
if (!$cm->availableinfo) {
return get_string('activityiscurrentlyhidden');
}
$altname = get_accesshide(' ' . $cm->modfullname);
$name = html_writer::empty_tag('img', array('src' => $cm->get_icon_url(),
'class' => 'iconlarge activityicon', 'alt' => ' ', 'role' => 'presentation')) .
html_writer::tag('span', ' '.$cm->get_formatted_name() . $altname, array('class' => 'instancename'));
$formattedinfo = \core_availability\info::format_info($cm->availableinfo, $cm->get_course());
return html_writer::div($name, 'activityinstance-error') .
html_writer::div($formattedinfo, 'availabilityinfo-error');
}
|
php
|
public function course_section_cm_unavailable_error_message(cm_info $cm) {
if ($cm->uservisible) {
return null;
}
if (!$cm->availableinfo) {
return get_string('activityiscurrentlyhidden');
}
$altname = get_accesshide(' ' . $cm->modfullname);
$name = html_writer::empty_tag('img', array('src' => $cm->get_icon_url(),
'class' => 'iconlarge activityicon', 'alt' => ' ', 'role' => 'presentation')) .
html_writer::tag('span', ' '.$cm->get_formatted_name() . $altname, array('class' => 'instancename'));
$formattedinfo = \core_availability\info::format_info($cm->availableinfo, $cm->get_course());
return html_writer::div($name, 'activityinstance-error') .
html_writer::div($formattedinfo, 'availabilityinfo-error');
}
|
[
"public",
"function",
"course_section_cm_unavailable_error_message",
"(",
"cm_info",
"$",
"cm",
")",
"{",
"if",
"(",
"$",
"cm",
"->",
"uservisible",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"$",
"cm",
"->",
"availableinfo",
")",
"{",
"return",
"get_string",
"(",
"'activityiscurrentlyhidden'",
")",
";",
"}",
"$",
"altname",
"=",
"get_accesshide",
"(",
"' '",
".",
"$",
"cm",
"->",
"modfullname",
")",
";",
"$",
"name",
"=",
"html_writer",
"::",
"empty_tag",
"(",
"'img'",
",",
"array",
"(",
"'src'",
"=>",
"$",
"cm",
"->",
"get_icon_url",
"(",
")",
",",
"'class'",
"=>",
"'iconlarge activityicon'",
",",
"'alt'",
"=>",
"' '",
",",
"'role'",
"=>",
"'presentation'",
")",
")",
".",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"' '",
".",
"$",
"cm",
"->",
"get_formatted_name",
"(",
")",
".",
"$",
"altname",
",",
"array",
"(",
"'class'",
"=>",
"'instancename'",
")",
")",
";",
"$",
"formattedinfo",
"=",
"\\",
"core_availability",
"\\",
"info",
"::",
"format_info",
"(",
"$",
"cm",
"->",
"availableinfo",
",",
"$",
"cm",
"->",
"get_course",
"(",
")",
")",
";",
"return",
"html_writer",
"::",
"div",
"(",
"$",
"name",
",",
"'activityinstance-error'",
")",
".",
"html_writer",
"::",
"div",
"(",
"$",
"formattedinfo",
",",
"'availabilityinfo-error'",
")",
";",
"}"
] |
Message displayed to the user when they try to access unavailable activity following URL
This method is a very simplified version of {@link course_section_cm()} to be part of the error
notification only. It also does not check if module is visible on course page or not.
The message will be displayed inside notification!
@param cm_info $cm
@return string
|
[
"Message",
"displayed",
"to",
"the",
"user",
"when",
"they",
"try",
"to",
"access",
"unavailable",
"activity",
"following",
"URL"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L933-L948
|
219,758
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.course_section_cm_list
|
public function course_section_cm_list($course, $section, $sectionreturn = null, $displayoptions = array()) {
global $USER;
$output = '';
$modinfo = get_fast_modinfo($course);
if (is_object($section)) {
$section = $modinfo->get_section_info($section->section);
} else {
$section = $modinfo->get_section_info($section);
}
$completioninfo = new completion_info($course);
// check if we are currently in the process of moving a module with JavaScript disabled
$ismoving = $this->page->user_is_editing() && ismoving($course->id);
if ($ismoving) {
$movingpix = new pix_icon('movehere', get_string('movehere'), 'moodle', array('class' => 'movetarget'));
$strmovefull = strip_tags(get_string("movefull", "", "'$USER->activitycopyname'"));
}
// Get the list of modules visible to user (excluding the module being moved if there is one)
$moduleshtml = array();
if (!empty($modinfo->sections[$section->section])) {
foreach ($modinfo->sections[$section->section] as $modnumber) {
$mod = $modinfo->cms[$modnumber];
if ($ismoving and $mod->id == $USER->activitycopy) {
// do not display moving mod
continue;
}
if ($modulehtml = $this->course_section_cm_list_item($course,
$completioninfo, $mod, $sectionreturn, $displayoptions)) {
$moduleshtml[$modnumber] = $modulehtml;
}
}
}
$sectionoutput = '';
if (!empty($moduleshtml) || $ismoving) {
foreach ($moduleshtml as $modnumber => $modulehtml) {
if ($ismoving) {
$movingurl = new moodle_url('/course/mod.php', array('moveto' => $modnumber, 'sesskey' => sesskey()));
$sectionoutput .= html_writer::tag('li',
html_writer::link($movingurl, $this->output->render($movingpix), array('title' => $strmovefull)),
array('class' => 'movehere'));
}
$sectionoutput .= $modulehtml;
}
if ($ismoving) {
$movingurl = new moodle_url('/course/mod.php', array('movetosection' => $section->id, 'sesskey' => sesskey()));
$sectionoutput .= html_writer::tag('li',
html_writer::link($movingurl, $this->output->render($movingpix), array('title' => $strmovefull)),
array('class' => 'movehere'));
}
}
// Always output the section module list.
$output .= html_writer::tag('ul', $sectionoutput, array('class' => 'section img-text'));
return $output;
}
|
php
|
public function course_section_cm_list($course, $section, $sectionreturn = null, $displayoptions = array()) {
global $USER;
$output = '';
$modinfo = get_fast_modinfo($course);
if (is_object($section)) {
$section = $modinfo->get_section_info($section->section);
} else {
$section = $modinfo->get_section_info($section);
}
$completioninfo = new completion_info($course);
// check if we are currently in the process of moving a module with JavaScript disabled
$ismoving = $this->page->user_is_editing() && ismoving($course->id);
if ($ismoving) {
$movingpix = new pix_icon('movehere', get_string('movehere'), 'moodle', array('class' => 'movetarget'));
$strmovefull = strip_tags(get_string("movefull", "", "'$USER->activitycopyname'"));
}
// Get the list of modules visible to user (excluding the module being moved if there is one)
$moduleshtml = array();
if (!empty($modinfo->sections[$section->section])) {
foreach ($modinfo->sections[$section->section] as $modnumber) {
$mod = $modinfo->cms[$modnumber];
if ($ismoving and $mod->id == $USER->activitycopy) {
// do not display moving mod
continue;
}
if ($modulehtml = $this->course_section_cm_list_item($course,
$completioninfo, $mod, $sectionreturn, $displayoptions)) {
$moduleshtml[$modnumber] = $modulehtml;
}
}
}
$sectionoutput = '';
if (!empty($moduleshtml) || $ismoving) {
foreach ($moduleshtml as $modnumber => $modulehtml) {
if ($ismoving) {
$movingurl = new moodle_url('/course/mod.php', array('moveto' => $modnumber, 'sesskey' => sesskey()));
$sectionoutput .= html_writer::tag('li',
html_writer::link($movingurl, $this->output->render($movingpix), array('title' => $strmovefull)),
array('class' => 'movehere'));
}
$sectionoutput .= $modulehtml;
}
if ($ismoving) {
$movingurl = new moodle_url('/course/mod.php', array('movetosection' => $section->id, 'sesskey' => sesskey()));
$sectionoutput .= html_writer::tag('li',
html_writer::link($movingurl, $this->output->render($movingpix), array('title' => $strmovefull)),
array('class' => 'movehere'));
}
}
// Always output the section module list.
$output .= html_writer::tag('ul', $sectionoutput, array('class' => 'section img-text'));
return $output;
}
|
[
"public",
"function",
"course_section_cm_list",
"(",
"$",
"course",
",",
"$",
"section",
",",
"$",
"sectionreturn",
"=",
"null",
",",
"$",
"displayoptions",
"=",
"array",
"(",
")",
")",
"{",
"global",
"$",
"USER",
";",
"$",
"output",
"=",
"''",
";",
"$",
"modinfo",
"=",
"get_fast_modinfo",
"(",
"$",
"course",
")",
";",
"if",
"(",
"is_object",
"(",
"$",
"section",
")",
")",
"{",
"$",
"section",
"=",
"$",
"modinfo",
"->",
"get_section_info",
"(",
"$",
"section",
"->",
"section",
")",
";",
"}",
"else",
"{",
"$",
"section",
"=",
"$",
"modinfo",
"->",
"get_section_info",
"(",
"$",
"section",
")",
";",
"}",
"$",
"completioninfo",
"=",
"new",
"completion_info",
"(",
"$",
"course",
")",
";",
"// check if we are currently in the process of moving a module with JavaScript disabled",
"$",
"ismoving",
"=",
"$",
"this",
"->",
"page",
"->",
"user_is_editing",
"(",
")",
"&&",
"ismoving",
"(",
"$",
"course",
"->",
"id",
")",
";",
"if",
"(",
"$",
"ismoving",
")",
"{",
"$",
"movingpix",
"=",
"new",
"pix_icon",
"(",
"'movehere'",
",",
"get_string",
"(",
"'movehere'",
")",
",",
"'moodle'",
",",
"array",
"(",
"'class'",
"=>",
"'movetarget'",
")",
")",
";",
"$",
"strmovefull",
"=",
"strip_tags",
"(",
"get_string",
"(",
"\"movefull\"",
",",
"\"\"",
",",
"\"'$USER->activitycopyname'\"",
")",
")",
";",
"}",
"// Get the list of modules visible to user (excluding the module being moved if there is one)",
"$",
"moduleshtml",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"modinfo",
"->",
"sections",
"[",
"$",
"section",
"->",
"section",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"modinfo",
"->",
"sections",
"[",
"$",
"section",
"->",
"section",
"]",
"as",
"$",
"modnumber",
")",
"{",
"$",
"mod",
"=",
"$",
"modinfo",
"->",
"cms",
"[",
"$",
"modnumber",
"]",
";",
"if",
"(",
"$",
"ismoving",
"and",
"$",
"mod",
"->",
"id",
"==",
"$",
"USER",
"->",
"activitycopy",
")",
"{",
"// do not display moving mod",
"continue",
";",
"}",
"if",
"(",
"$",
"modulehtml",
"=",
"$",
"this",
"->",
"course_section_cm_list_item",
"(",
"$",
"course",
",",
"$",
"completioninfo",
",",
"$",
"mod",
",",
"$",
"sectionreturn",
",",
"$",
"displayoptions",
")",
")",
"{",
"$",
"moduleshtml",
"[",
"$",
"modnumber",
"]",
"=",
"$",
"modulehtml",
";",
"}",
"}",
"}",
"$",
"sectionoutput",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"moduleshtml",
")",
"||",
"$",
"ismoving",
")",
"{",
"foreach",
"(",
"$",
"moduleshtml",
"as",
"$",
"modnumber",
"=>",
"$",
"modulehtml",
")",
"{",
"if",
"(",
"$",
"ismoving",
")",
"{",
"$",
"movingurl",
"=",
"new",
"moodle_url",
"(",
"'/course/mod.php'",
",",
"array",
"(",
"'moveto'",
"=>",
"$",
"modnumber",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"$",
"sectionoutput",
".=",
"html_writer",
"::",
"tag",
"(",
"'li'",
",",
"html_writer",
"::",
"link",
"(",
"$",
"movingurl",
",",
"$",
"this",
"->",
"output",
"->",
"render",
"(",
"$",
"movingpix",
")",
",",
"array",
"(",
"'title'",
"=>",
"$",
"strmovefull",
")",
")",
",",
"array",
"(",
"'class'",
"=>",
"'movehere'",
")",
")",
";",
"}",
"$",
"sectionoutput",
".=",
"$",
"modulehtml",
";",
"}",
"if",
"(",
"$",
"ismoving",
")",
"{",
"$",
"movingurl",
"=",
"new",
"moodle_url",
"(",
"'/course/mod.php'",
",",
"array",
"(",
"'movetosection'",
"=>",
"$",
"section",
"->",
"id",
",",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
")",
")",
";",
"$",
"sectionoutput",
".=",
"html_writer",
"::",
"tag",
"(",
"'li'",
",",
"html_writer",
"::",
"link",
"(",
"$",
"movingurl",
",",
"$",
"this",
"->",
"output",
"->",
"render",
"(",
"$",
"movingpix",
")",
",",
"array",
"(",
"'title'",
"=>",
"$",
"strmovefull",
")",
")",
",",
"array",
"(",
"'class'",
"=>",
"'movehere'",
")",
")",
";",
"}",
"}",
"// Always output the section module list.",
"$",
"output",
".=",
"html_writer",
"::",
"tag",
"(",
"'ul'",
",",
"$",
"sectionoutput",
",",
"array",
"(",
"'class'",
"=>",
"'section img-text'",
")",
")",
";",
"return",
"$",
"output",
";",
"}"
] |
Renders HTML to display a list of course modules in a course section
Also displays "move here" controls in Javascript-disabled mode
This function calls {@link core_course_renderer::course_section_cm()}
@param stdClass $course course object
@param int|stdClass|section_info $section relative section number or section object
@param int $sectionreturn section number to return to
@param int $displayoptions
@return void
|
[
"Renders",
"HTML",
"to",
"display",
"a",
"list",
"of",
"course",
"modules",
"in",
"a",
"course",
"section",
"Also",
"displays",
"move",
"here",
"controls",
"in",
"Javascript",
"-",
"disabled",
"mode"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L962-L1024
|
219,759
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.courses_list
|
public function courses_list($courses, $showcategoryname = false, $additionalclasses = null, $paginationurl = null, $totalcount = null, $page = 0, $perpage = null) {
global $CFG;
// create instance of coursecat_helper to pass display options to function rendering courses list
$chelper = new coursecat_helper();
if ($showcategoryname) {
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT);
} else {
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED);
}
if ($totalcount !== null && $paginationurl !== null) {
// add options to display pagination
if ($perpage === null) {
$perpage = $CFG->coursesperpage;
}
$chelper->set_courses_display_options(array(
'limit' => $perpage,
'offset' => ((int)$page) * $perpage,
'paginationurl' => $paginationurl,
));
} else if ($paginationurl !== null) {
// add options to display 'View more' link
$chelper->set_courses_display_options(array('viewmoreurl' => $paginationurl));
$totalcount = count($courses) + 1; // has to be bigger than count($courses) otherwise link will not be displayed
}
$chelper->set_attributes(array('class' => $additionalclasses));
$content = $this->coursecat_courses($chelper, $courses, $totalcount);
return $content;
}
|
php
|
public function courses_list($courses, $showcategoryname = false, $additionalclasses = null, $paginationurl = null, $totalcount = null, $page = 0, $perpage = null) {
global $CFG;
// create instance of coursecat_helper to pass display options to function rendering courses list
$chelper = new coursecat_helper();
if ($showcategoryname) {
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT);
} else {
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED);
}
if ($totalcount !== null && $paginationurl !== null) {
// add options to display pagination
if ($perpage === null) {
$perpage = $CFG->coursesperpage;
}
$chelper->set_courses_display_options(array(
'limit' => $perpage,
'offset' => ((int)$page) * $perpage,
'paginationurl' => $paginationurl,
));
} else if ($paginationurl !== null) {
// add options to display 'View more' link
$chelper->set_courses_display_options(array('viewmoreurl' => $paginationurl));
$totalcount = count($courses) + 1; // has to be bigger than count($courses) otherwise link will not be displayed
}
$chelper->set_attributes(array('class' => $additionalclasses));
$content = $this->coursecat_courses($chelper, $courses, $totalcount);
return $content;
}
|
[
"public",
"function",
"courses_list",
"(",
"$",
"courses",
",",
"$",
"showcategoryname",
"=",
"false",
",",
"$",
"additionalclasses",
"=",
"null",
",",
"$",
"paginationurl",
"=",
"null",
",",
"$",
"totalcount",
"=",
"null",
",",
"$",
"page",
"=",
"0",
",",
"$",
"perpage",
"=",
"null",
")",
"{",
"global",
"$",
"CFG",
";",
"// create instance of coursecat_helper to pass display options to function rendering courses list",
"$",
"chelper",
"=",
"new",
"coursecat_helper",
"(",
")",
";",
"if",
"(",
"$",
"showcategoryname",
")",
"{",
"$",
"chelper",
"->",
"set_show_courses",
"(",
"self",
"::",
"COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT",
")",
";",
"}",
"else",
"{",
"$",
"chelper",
"->",
"set_show_courses",
"(",
"self",
"::",
"COURSECAT_SHOW_COURSES_EXPANDED",
")",
";",
"}",
"if",
"(",
"$",
"totalcount",
"!==",
"null",
"&&",
"$",
"paginationurl",
"!==",
"null",
")",
"{",
"// add options to display pagination",
"if",
"(",
"$",
"perpage",
"===",
"null",
")",
"{",
"$",
"perpage",
"=",
"$",
"CFG",
"->",
"coursesperpage",
";",
"}",
"$",
"chelper",
"->",
"set_courses_display_options",
"(",
"array",
"(",
"'limit'",
"=>",
"$",
"perpage",
",",
"'offset'",
"=>",
"(",
"(",
"int",
")",
"$",
"page",
")",
"*",
"$",
"perpage",
",",
"'paginationurl'",
"=>",
"$",
"paginationurl",
",",
")",
")",
";",
"}",
"else",
"if",
"(",
"$",
"paginationurl",
"!==",
"null",
")",
"{",
"// add options to display 'View more' link",
"$",
"chelper",
"->",
"set_courses_display_options",
"(",
"array",
"(",
"'viewmoreurl'",
"=>",
"$",
"paginationurl",
")",
")",
";",
"$",
"totalcount",
"=",
"count",
"(",
"$",
"courses",
")",
"+",
"1",
";",
"// has to be bigger than count($courses) otherwise link will not be displayed",
"}",
"$",
"chelper",
"->",
"set_attributes",
"(",
"array",
"(",
"'class'",
"=>",
"$",
"additionalclasses",
")",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"coursecat_courses",
"(",
"$",
"chelper",
",",
"$",
"courses",
",",
"$",
"totalcount",
")",
";",
"return",
"$",
"content",
";",
"}"
] |
Displays a custom list of courses with paging bar if necessary
If $paginationurl is specified but $totalcount is not, the link 'View more'
appears under the list.
If both $paginationurl and $totalcount are specified, and $totalcount is
bigger than count($courses), a paging bar is displayed above and under the
courses list.
@param array $courses array of course records (or instances of core_course_list_element) to show on this page
@param bool $showcategoryname whether to add category name to the course description
@param string $additionalclasses additional CSS classes to add to the div.courses
@param moodle_url $paginationurl url to view more or url to form links to the other pages in paging bar
@param int $totalcount total number of courses on all pages, if omitted $paginationurl will be displayed as 'View more' link
@param int $page current page number (defaults to 0 referring to the first page)
@param int $perpage number of records per page (defaults to $CFG->coursesperpage)
@return string
|
[
"Displays",
"a",
"custom",
"list",
"of",
"courses",
"with",
"paging",
"bar",
"if",
"necessary"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L1045-L1072
|
219,760
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.coursecat_category_content
|
protected function coursecat_category_content(coursecat_helper $chelper, $coursecat, $depth) {
$content = '';
// Subcategories
$content .= $this->coursecat_subcategories($chelper, $coursecat, $depth);
// AUTO show courses: Courses will be shown expanded if this is not nested category,
// and number of courses no bigger than $CFG->courseswithsummarieslimit.
$showcoursesauto = $chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_AUTO;
if ($showcoursesauto && $depth) {
// this is definitely collapsed mode
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_COLLAPSED);
}
// Courses
if ($chelper->get_show_courses() > core_course_renderer::COURSECAT_SHOW_COURSES_COUNT) {
$courses = array();
if (!$chelper->get_courses_display_option('nodisplay')) {
$courses = $coursecat->get_courses($chelper->get_courses_display_options());
}
if ($viewmoreurl = $chelper->get_courses_display_option('viewmoreurl')) {
// the option for 'View more' link was specified, display more link (if it is link to category view page, add category id)
if ($viewmoreurl->compare(new moodle_url('/course/index.php'), URL_MATCH_BASE)) {
$chelper->set_courses_display_option('viewmoreurl', new moodle_url($viewmoreurl, array('categoryid' => $coursecat->id)));
}
}
$content .= $this->coursecat_courses($chelper, $courses, $coursecat->get_courses_count());
}
if ($showcoursesauto) {
// restore the show_courses back to AUTO
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_AUTO);
}
return $content;
}
|
php
|
protected function coursecat_category_content(coursecat_helper $chelper, $coursecat, $depth) {
$content = '';
// Subcategories
$content .= $this->coursecat_subcategories($chelper, $coursecat, $depth);
// AUTO show courses: Courses will be shown expanded if this is not nested category,
// and number of courses no bigger than $CFG->courseswithsummarieslimit.
$showcoursesauto = $chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_AUTO;
if ($showcoursesauto && $depth) {
// this is definitely collapsed mode
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_COLLAPSED);
}
// Courses
if ($chelper->get_show_courses() > core_course_renderer::COURSECAT_SHOW_COURSES_COUNT) {
$courses = array();
if (!$chelper->get_courses_display_option('nodisplay')) {
$courses = $coursecat->get_courses($chelper->get_courses_display_options());
}
if ($viewmoreurl = $chelper->get_courses_display_option('viewmoreurl')) {
// the option for 'View more' link was specified, display more link (if it is link to category view page, add category id)
if ($viewmoreurl->compare(new moodle_url('/course/index.php'), URL_MATCH_BASE)) {
$chelper->set_courses_display_option('viewmoreurl', new moodle_url($viewmoreurl, array('categoryid' => $coursecat->id)));
}
}
$content .= $this->coursecat_courses($chelper, $courses, $coursecat->get_courses_count());
}
if ($showcoursesauto) {
// restore the show_courses back to AUTO
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_AUTO);
}
return $content;
}
|
[
"protected",
"function",
"coursecat_category_content",
"(",
"coursecat_helper",
"$",
"chelper",
",",
"$",
"coursecat",
",",
"$",
"depth",
")",
"{",
"$",
"content",
"=",
"''",
";",
"// Subcategories",
"$",
"content",
".=",
"$",
"this",
"->",
"coursecat_subcategories",
"(",
"$",
"chelper",
",",
"$",
"coursecat",
",",
"$",
"depth",
")",
";",
"// AUTO show courses: Courses will be shown expanded if this is not nested category,",
"// and number of courses no bigger than $CFG->courseswithsummarieslimit.",
"$",
"showcoursesauto",
"=",
"$",
"chelper",
"->",
"get_show_courses",
"(",
")",
"==",
"self",
"::",
"COURSECAT_SHOW_COURSES_AUTO",
";",
"if",
"(",
"$",
"showcoursesauto",
"&&",
"$",
"depth",
")",
"{",
"// this is definitely collapsed mode",
"$",
"chelper",
"->",
"set_show_courses",
"(",
"self",
"::",
"COURSECAT_SHOW_COURSES_COLLAPSED",
")",
";",
"}",
"// Courses",
"if",
"(",
"$",
"chelper",
"->",
"get_show_courses",
"(",
")",
">",
"core_course_renderer",
"::",
"COURSECAT_SHOW_COURSES_COUNT",
")",
"{",
"$",
"courses",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"$",
"chelper",
"->",
"get_courses_display_option",
"(",
"'nodisplay'",
")",
")",
"{",
"$",
"courses",
"=",
"$",
"coursecat",
"->",
"get_courses",
"(",
"$",
"chelper",
"->",
"get_courses_display_options",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"viewmoreurl",
"=",
"$",
"chelper",
"->",
"get_courses_display_option",
"(",
"'viewmoreurl'",
")",
")",
"{",
"// the option for 'View more' link was specified, display more link (if it is link to category view page, add category id)",
"if",
"(",
"$",
"viewmoreurl",
"->",
"compare",
"(",
"new",
"moodle_url",
"(",
"'/course/index.php'",
")",
",",
"URL_MATCH_BASE",
")",
")",
"{",
"$",
"chelper",
"->",
"set_courses_display_option",
"(",
"'viewmoreurl'",
",",
"new",
"moodle_url",
"(",
"$",
"viewmoreurl",
",",
"array",
"(",
"'categoryid'",
"=>",
"$",
"coursecat",
"->",
"id",
")",
")",
")",
";",
"}",
"}",
"$",
"content",
".=",
"$",
"this",
"->",
"coursecat_courses",
"(",
"$",
"chelper",
",",
"$",
"courses",
",",
"$",
"coursecat",
"->",
"get_courses_count",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"showcoursesauto",
")",
"{",
"// restore the show_courses back to AUTO",
"$",
"chelper",
"->",
"set_show_courses",
"(",
"self",
"::",
"COURSECAT_SHOW_COURSES_AUTO",
")",
";",
"}",
"return",
"$",
"content",
";",
"}"
] |
Returns HTML to display the subcategories and courses in the given category
This method is re-used by AJAX to expand content of not loaded category
@param coursecat_helper $chelper various display options
@param core_course_category $coursecat
@param int $depth depth of the category in the current tree
@return string
|
[
"Returns",
"HTML",
"to",
"display",
"the",
"subcategories",
"and",
"courses",
"in",
"the",
"given",
"category"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L1428-L1462
|
219,761
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.coursecat_category
|
protected function coursecat_category(coursecat_helper $chelper, $coursecat, $depth) {
// open category tag
$classes = array('category');
if (empty($coursecat->visible)) {
$classes[] = 'dimmed_category';
}
if ($chelper->get_subcat_depth() > 0 && $depth >= $chelper->get_subcat_depth()) {
// do not load content
$categorycontent = '';
$classes[] = 'notloaded';
if ($coursecat->get_children_count() ||
($chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_COLLAPSED && $coursecat->get_courses_count())) {
$classes[] = 'with_children';
$classes[] = 'collapsed';
}
} else {
// load category content
$categorycontent = $this->coursecat_category_content($chelper, $coursecat, $depth);
$classes[] = 'loaded';
if (!empty($categorycontent)) {
$classes[] = 'with_children';
// Category content loaded with children.
$this->categoryexpandedonload = true;
}
}
// Make sure JS file to expand category content is included.
$this->coursecat_include_js();
$content = html_writer::start_tag('div', array(
'class' => join(' ', $classes),
'data-categoryid' => $coursecat->id,
'data-depth' => $depth,
'data-showcourses' => $chelper->get_show_courses(),
'data-type' => self::COURSECAT_TYPE_CATEGORY,
));
// category name
$categoryname = $coursecat->get_formatted_name();
$categoryname = html_writer::link(new moodle_url('/course/index.php',
array('categoryid' => $coursecat->id)),
$categoryname);
if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_COUNT
&& ($coursescount = $coursecat->get_courses_count())) {
$categoryname .= html_writer::tag('span', ' ('. $coursescount.')',
array('title' => get_string('numberofcourses'), 'class' => 'numberofcourse'));
}
$content .= html_writer::start_tag('div', array('class' => 'info'));
$content .= html_writer::tag(($depth > 1) ? 'h4' : 'h3', $categoryname, array('class' => 'categoryname'));
$content .= html_writer::end_tag('div'); // .info
// add category content to the output
$content .= html_writer::tag('div', $categorycontent, array('class' => 'content'));
$content .= html_writer::end_tag('div'); // .category
// Return the course category tree HTML
return $content;
}
|
php
|
protected function coursecat_category(coursecat_helper $chelper, $coursecat, $depth) {
// open category tag
$classes = array('category');
if (empty($coursecat->visible)) {
$classes[] = 'dimmed_category';
}
if ($chelper->get_subcat_depth() > 0 && $depth >= $chelper->get_subcat_depth()) {
// do not load content
$categorycontent = '';
$classes[] = 'notloaded';
if ($coursecat->get_children_count() ||
($chelper->get_show_courses() >= self::COURSECAT_SHOW_COURSES_COLLAPSED && $coursecat->get_courses_count())) {
$classes[] = 'with_children';
$classes[] = 'collapsed';
}
} else {
// load category content
$categorycontent = $this->coursecat_category_content($chelper, $coursecat, $depth);
$classes[] = 'loaded';
if (!empty($categorycontent)) {
$classes[] = 'with_children';
// Category content loaded with children.
$this->categoryexpandedonload = true;
}
}
// Make sure JS file to expand category content is included.
$this->coursecat_include_js();
$content = html_writer::start_tag('div', array(
'class' => join(' ', $classes),
'data-categoryid' => $coursecat->id,
'data-depth' => $depth,
'data-showcourses' => $chelper->get_show_courses(),
'data-type' => self::COURSECAT_TYPE_CATEGORY,
));
// category name
$categoryname = $coursecat->get_formatted_name();
$categoryname = html_writer::link(new moodle_url('/course/index.php',
array('categoryid' => $coursecat->id)),
$categoryname);
if ($chelper->get_show_courses() == self::COURSECAT_SHOW_COURSES_COUNT
&& ($coursescount = $coursecat->get_courses_count())) {
$categoryname .= html_writer::tag('span', ' ('. $coursescount.')',
array('title' => get_string('numberofcourses'), 'class' => 'numberofcourse'));
}
$content .= html_writer::start_tag('div', array('class' => 'info'));
$content .= html_writer::tag(($depth > 1) ? 'h4' : 'h3', $categoryname, array('class' => 'categoryname'));
$content .= html_writer::end_tag('div'); // .info
// add category content to the output
$content .= html_writer::tag('div', $categorycontent, array('class' => 'content'));
$content .= html_writer::end_tag('div'); // .category
// Return the course category tree HTML
return $content;
}
|
[
"protected",
"function",
"coursecat_category",
"(",
"coursecat_helper",
"$",
"chelper",
",",
"$",
"coursecat",
",",
"$",
"depth",
")",
"{",
"// open category tag",
"$",
"classes",
"=",
"array",
"(",
"'category'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"coursecat",
"->",
"visible",
")",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'dimmed_category'",
";",
"}",
"if",
"(",
"$",
"chelper",
"->",
"get_subcat_depth",
"(",
")",
">",
"0",
"&&",
"$",
"depth",
">=",
"$",
"chelper",
"->",
"get_subcat_depth",
"(",
")",
")",
"{",
"// do not load content",
"$",
"categorycontent",
"=",
"''",
";",
"$",
"classes",
"[",
"]",
"=",
"'notloaded'",
";",
"if",
"(",
"$",
"coursecat",
"->",
"get_children_count",
"(",
")",
"||",
"(",
"$",
"chelper",
"->",
"get_show_courses",
"(",
")",
">=",
"self",
"::",
"COURSECAT_SHOW_COURSES_COLLAPSED",
"&&",
"$",
"coursecat",
"->",
"get_courses_count",
"(",
")",
")",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'with_children'",
";",
"$",
"classes",
"[",
"]",
"=",
"'collapsed'",
";",
"}",
"}",
"else",
"{",
"// load category content",
"$",
"categorycontent",
"=",
"$",
"this",
"->",
"coursecat_category_content",
"(",
"$",
"chelper",
",",
"$",
"coursecat",
",",
"$",
"depth",
")",
";",
"$",
"classes",
"[",
"]",
"=",
"'loaded'",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"categorycontent",
")",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'with_children'",
";",
"// Category content loaded with children.",
"$",
"this",
"->",
"categoryexpandedonload",
"=",
"true",
";",
"}",
"}",
"// Make sure JS file to expand category content is included.",
"$",
"this",
"->",
"coursecat_include_js",
"(",
")",
";",
"$",
"content",
"=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"join",
"(",
"' '",
",",
"$",
"classes",
")",
",",
"'data-categoryid'",
"=>",
"$",
"coursecat",
"->",
"id",
",",
"'data-depth'",
"=>",
"$",
"depth",
",",
"'data-showcourses'",
"=>",
"$",
"chelper",
"->",
"get_show_courses",
"(",
")",
",",
"'data-type'",
"=>",
"self",
"::",
"COURSECAT_TYPE_CATEGORY",
",",
")",
")",
";",
"// category name",
"$",
"categoryname",
"=",
"$",
"coursecat",
"->",
"get_formatted_name",
"(",
")",
";",
"$",
"categoryname",
"=",
"html_writer",
"::",
"link",
"(",
"new",
"moodle_url",
"(",
"'/course/index.php'",
",",
"array",
"(",
"'categoryid'",
"=>",
"$",
"coursecat",
"->",
"id",
")",
")",
",",
"$",
"categoryname",
")",
";",
"if",
"(",
"$",
"chelper",
"->",
"get_show_courses",
"(",
")",
"==",
"self",
"::",
"COURSECAT_SHOW_COURSES_COUNT",
"&&",
"(",
"$",
"coursescount",
"=",
"$",
"coursecat",
"->",
"get_courses_count",
"(",
")",
")",
")",
"{",
"$",
"categoryname",
".=",
"html_writer",
"::",
"tag",
"(",
"'span'",
",",
"' ('",
".",
"$",
"coursescount",
".",
"')'",
",",
"array",
"(",
"'title'",
"=>",
"get_string",
"(",
"'numberofcourses'",
")",
",",
"'class'",
"=>",
"'numberofcourse'",
")",
")",
";",
"}",
"$",
"content",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'info'",
")",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"tag",
"(",
"(",
"$",
"depth",
">",
"1",
")",
"?",
"'h4'",
":",
"'h3'",
",",
"$",
"categoryname",
",",
"array",
"(",
"'class'",
"=>",
"'categoryname'",
")",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"// .info",
"// add category content to the output",
"$",
"content",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"categorycontent",
",",
"array",
"(",
"'class'",
"=>",
"'content'",
")",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"// .category",
"// Return the course category tree HTML",
"return",
"$",
"content",
";",
"}"
] |
Returns HTML to display a course category as a part of a tree
This is an internal function, to display a particular category and all its contents
use {@link core_course_renderer::course_category()}
@param coursecat_helper $chelper various display options
@param core_course_category $coursecat
@param int $depth depth of this category in the current tree
@return string
|
[
"Returns",
"HTML",
"to",
"display",
"a",
"course",
"category",
"as",
"a",
"part",
"of",
"a",
"tree"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L1475-L1534
|
219,762
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.coursecat_tree
|
protected function coursecat_tree(coursecat_helper $chelper, $coursecat) {
// Reset the category expanded flag for this course category tree first.
$this->categoryexpandedonload = false;
$categorycontent = $this->coursecat_category_content($chelper, $coursecat, 0);
if (empty($categorycontent)) {
return '';
}
// Start content generation
$content = '';
$attributes = $chelper->get_and_erase_attributes('course_category_tree clearfix');
$content .= html_writer::start_tag('div', $attributes);
if ($coursecat->get_children_count()) {
$classes = array(
'collapseexpand',
);
// Check if the category content contains subcategories with children's content loaded.
if ($this->categoryexpandedonload) {
$classes[] = 'collapse-all';
$linkname = get_string('collapseall');
} else {
$linkname = get_string('expandall');
}
// Only show the collapse/expand if there are children to expand.
$content .= html_writer::start_tag('div', array('class' => 'collapsible-actions'));
$content .= html_writer::link('#', $linkname, array('class' => implode(' ', $classes)));
$content .= html_writer::end_tag('div');
$this->page->requires->strings_for_js(array('collapseall', 'expandall'), 'moodle');
}
$content .= html_writer::tag('div', $categorycontent, array('class' => 'content'));
$content .= html_writer::end_tag('div'); // .course_category_tree
return $content;
}
|
php
|
protected function coursecat_tree(coursecat_helper $chelper, $coursecat) {
// Reset the category expanded flag for this course category tree first.
$this->categoryexpandedonload = false;
$categorycontent = $this->coursecat_category_content($chelper, $coursecat, 0);
if (empty($categorycontent)) {
return '';
}
// Start content generation
$content = '';
$attributes = $chelper->get_and_erase_attributes('course_category_tree clearfix');
$content .= html_writer::start_tag('div', $attributes);
if ($coursecat->get_children_count()) {
$classes = array(
'collapseexpand',
);
// Check if the category content contains subcategories with children's content loaded.
if ($this->categoryexpandedonload) {
$classes[] = 'collapse-all';
$linkname = get_string('collapseall');
} else {
$linkname = get_string('expandall');
}
// Only show the collapse/expand if there are children to expand.
$content .= html_writer::start_tag('div', array('class' => 'collapsible-actions'));
$content .= html_writer::link('#', $linkname, array('class' => implode(' ', $classes)));
$content .= html_writer::end_tag('div');
$this->page->requires->strings_for_js(array('collapseall', 'expandall'), 'moodle');
}
$content .= html_writer::tag('div', $categorycontent, array('class' => 'content'));
$content .= html_writer::end_tag('div'); // .course_category_tree
return $content;
}
|
[
"protected",
"function",
"coursecat_tree",
"(",
"coursecat_helper",
"$",
"chelper",
",",
"$",
"coursecat",
")",
"{",
"// Reset the category expanded flag for this course category tree first.",
"$",
"this",
"->",
"categoryexpandedonload",
"=",
"false",
";",
"$",
"categorycontent",
"=",
"$",
"this",
"->",
"coursecat_category_content",
"(",
"$",
"chelper",
",",
"$",
"coursecat",
",",
"0",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"categorycontent",
")",
")",
"{",
"return",
"''",
";",
"}",
"// Start content generation",
"$",
"content",
"=",
"''",
";",
"$",
"attributes",
"=",
"$",
"chelper",
"->",
"get_and_erase_attributes",
"(",
"'course_category_tree clearfix'",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"$",
"attributes",
")",
";",
"if",
"(",
"$",
"coursecat",
"->",
"get_children_count",
"(",
")",
")",
"{",
"$",
"classes",
"=",
"array",
"(",
"'collapseexpand'",
",",
")",
";",
"// Check if the category content contains subcategories with children's content loaded.",
"if",
"(",
"$",
"this",
"->",
"categoryexpandedonload",
")",
"{",
"$",
"classes",
"[",
"]",
"=",
"'collapse-all'",
";",
"$",
"linkname",
"=",
"get_string",
"(",
"'collapseall'",
")",
";",
"}",
"else",
"{",
"$",
"linkname",
"=",
"get_string",
"(",
"'expandall'",
")",
";",
"}",
"// Only show the collapse/expand if there are children to expand.",
"$",
"content",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'collapsible-actions'",
")",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"link",
"(",
"'#'",
",",
"$",
"linkname",
",",
"array",
"(",
"'class'",
"=>",
"implode",
"(",
"' '",
",",
"$",
"classes",
")",
")",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"$",
"this",
"->",
"page",
"->",
"requires",
"->",
"strings_for_js",
"(",
"array",
"(",
"'collapseall'",
",",
"'expandall'",
")",
",",
"'moodle'",
")",
";",
"}",
"$",
"content",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"categorycontent",
",",
"array",
"(",
"'class'",
"=>",
"'content'",
")",
")",
";",
"$",
"content",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"// .course_category_tree",
"return",
"$",
"content",
";",
"}"
] |
Returns HTML to display a tree of subcategories and courses in the given category
@param coursecat_helper $chelper various display options
@param core_course_category $coursecat top category (this category's name and description will NOT be added to the tree)
@return string
|
[
"Returns",
"HTML",
"to",
"display",
"a",
"tree",
"of",
"subcategories",
"and",
"courses",
"in",
"the",
"given",
"category"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L1543-L1581
|
219,763
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.search_courses
|
public function search_courses($searchcriteria) {
global $CFG;
$content = '';
if (!empty($searchcriteria)) {
// print search results
$displayoptions = array('sort' => array('displayname' => 1));
// take the current page and number of results per page from query
$perpage = optional_param('perpage', 0, PARAM_RAW);
if ($perpage !== 'all') {
$displayoptions['limit'] = ((int)$perpage <= 0) ? $CFG->coursesperpage : (int)$perpage;
$page = optional_param('page', 0, PARAM_INT);
$displayoptions['offset'] = $displayoptions['limit'] * $page;
}
// options 'paginationurl' and 'paginationallowall' are only used in method coursecat_courses()
$displayoptions['paginationurl'] = new moodle_url('/course/search.php', $searchcriteria);
$displayoptions['paginationallowall'] = true; // allow adding link 'View all'
$class = 'course-search-result';
foreach ($searchcriteria as $key => $value) {
if (!empty($value)) {
$class .= ' course-search-result-'. $key;
}
}
$chelper = new coursecat_helper();
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT)->
set_courses_display_options($displayoptions)->
set_search_criteria($searchcriteria)->
set_attributes(array('class' => $class));
$courses = core_course_category::search_courses($searchcriteria, $chelper->get_courses_display_options());
$totalcount = core_course_category::search_courses_count($searchcriteria);
$courseslist = $this->coursecat_courses($chelper, $courses, $totalcount);
if (!$totalcount) {
if (!empty($searchcriteria['search'])) {
$content .= $this->heading(get_string('nocoursesfound', '', $searchcriteria['search']));
} else {
$content .= $this->heading(get_string('novalidcourses'));
}
} else {
$content .= $this->heading(get_string('searchresults'). ": $totalcount");
$content .= $courseslist;
}
if (!empty($searchcriteria['search'])) {
// print search form only if there was a search by search string, otherwise it is confusing
$content .= $this->box_start('generalbox mdl-align');
$content .= $this->course_search_form($searchcriteria['search']);
$content .= $this->box_end();
}
} else {
// just print search form
$content .= $this->box_start('generalbox mdl-align');
$content .= $this->course_search_form();
$content .= $this->box_end();
}
return $content;
}
|
php
|
public function search_courses($searchcriteria) {
global $CFG;
$content = '';
if (!empty($searchcriteria)) {
// print search results
$displayoptions = array('sort' => array('displayname' => 1));
// take the current page and number of results per page from query
$perpage = optional_param('perpage', 0, PARAM_RAW);
if ($perpage !== 'all') {
$displayoptions['limit'] = ((int)$perpage <= 0) ? $CFG->coursesperpage : (int)$perpage;
$page = optional_param('page', 0, PARAM_INT);
$displayoptions['offset'] = $displayoptions['limit'] * $page;
}
// options 'paginationurl' and 'paginationallowall' are only used in method coursecat_courses()
$displayoptions['paginationurl'] = new moodle_url('/course/search.php', $searchcriteria);
$displayoptions['paginationallowall'] = true; // allow adding link 'View all'
$class = 'course-search-result';
foreach ($searchcriteria as $key => $value) {
if (!empty($value)) {
$class .= ' course-search-result-'. $key;
}
}
$chelper = new coursecat_helper();
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT)->
set_courses_display_options($displayoptions)->
set_search_criteria($searchcriteria)->
set_attributes(array('class' => $class));
$courses = core_course_category::search_courses($searchcriteria, $chelper->get_courses_display_options());
$totalcount = core_course_category::search_courses_count($searchcriteria);
$courseslist = $this->coursecat_courses($chelper, $courses, $totalcount);
if (!$totalcount) {
if (!empty($searchcriteria['search'])) {
$content .= $this->heading(get_string('nocoursesfound', '', $searchcriteria['search']));
} else {
$content .= $this->heading(get_string('novalidcourses'));
}
} else {
$content .= $this->heading(get_string('searchresults'). ": $totalcount");
$content .= $courseslist;
}
if (!empty($searchcriteria['search'])) {
// print search form only if there was a search by search string, otherwise it is confusing
$content .= $this->box_start('generalbox mdl-align');
$content .= $this->course_search_form($searchcriteria['search']);
$content .= $this->box_end();
}
} else {
// just print search form
$content .= $this->box_start('generalbox mdl-align');
$content .= $this->course_search_form();
$content .= $this->box_end();
}
return $content;
}
|
[
"public",
"function",
"search_courses",
"(",
"$",
"searchcriteria",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"content",
"=",
"''",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"searchcriteria",
")",
")",
"{",
"// print search results",
"$",
"displayoptions",
"=",
"array",
"(",
"'sort'",
"=>",
"array",
"(",
"'displayname'",
"=>",
"1",
")",
")",
";",
"// take the current page and number of results per page from query",
"$",
"perpage",
"=",
"optional_param",
"(",
"'perpage'",
",",
"0",
",",
"PARAM_RAW",
")",
";",
"if",
"(",
"$",
"perpage",
"!==",
"'all'",
")",
"{",
"$",
"displayoptions",
"[",
"'limit'",
"]",
"=",
"(",
"(",
"int",
")",
"$",
"perpage",
"<=",
"0",
")",
"?",
"$",
"CFG",
"->",
"coursesperpage",
":",
"(",
"int",
")",
"$",
"perpage",
";",
"$",
"page",
"=",
"optional_param",
"(",
"'page'",
",",
"0",
",",
"PARAM_INT",
")",
";",
"$",
"displayoptions",
"[",
"'offset'",
"]",
"=",
"$",
"displayoptions",
"[",
"'limit'",
"]",
"*",
"$",
"page",
";",
"}",
"// options 'paginationurl' and 'paginationallowall' are only used in method coursecat_courses()",
"$",
"displayoptions",
"[",
"'paginationurl'",
"]",
"=",
"new",
"moodle_url",
"(",
"'/course/search.php'",
",",
"$",
"searchcriteria",
")",
";",
"$",
"displayoptions",
"[",
"'paginationallowall'",
"]",
"=",
"true",
";",
"// allow adding link 'View all'",
"$",
"class",
"=",
"'course-search-result'",
";",
"foreach",
"(",
"$",
"searchcriteria",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"class",
".=",
"' course-search-result-'",
".",
"$",
"key",
";",
"}",
"}",
"$",
"chelper",
"=",
"new",
"coursecat_helper",
"(",
")",
";",
"$",
"chelper",
"->",
"set_show_courses",
"(",
"self",
"::",
"COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT",
")",
"->",
"set_courses_display_options",
"(",
"$",
"displayoptions",
")",
"->",
"set_search_criteria",
"(",
"$",
"searchcriteria",
")",
"->",
"set_attributes",
"(",
"array",
"(",
"'class'",
"=>",
"$",
"class",
")",
")",
";",
"$",
"courses",
"=",
"core_course_category",
"::",
"search_courses",
"(",
"$",
"searchcriteria",
",",
"$",
"chelper",
"->",
"get_courses_display_options",
"(",
")",
")",
";",
"$",
"totalcount",
"=",
"core_course_category",
"::",
"search_courses_count",
"(",
"$",
"searchcriteria",
")",
";",
"$",
"courseslist",
"=",
"$",
"this",
"->",
"coursecat_courses",
"(",
"$",
"chelper",
",",
"$",
"courses",
",",
"$",
"totalcount",
")",
";",
"if",
"(",
"!",
"$",
"totalcount",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"searchcriteria",
"[",
"'search'",
"]",
")",
")",
"{",
"$",
"content",
".=",
"$",
"this",
"->",
"heading",
"(",
"get_string",
"(",
"'nocoursesfound'",
",",
"''",
",",
"$",
"searchcriteria",
"[",
"'search'",
"]",
")",
")",
";",
"}",
"else",
"{",
"$",
"content",
".=",
"$",
"this",
"->",
"heading",
"(",
"get_string",
"(",
"'novalidcourses'",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"content",
".=",
"$",
"this",
"->",
"heading",
"(",
"get_string",
"(",
"'searchresults'",
")",
".",
"\": $totalcount\"",
")",
";",
"$",
"content",
".=",
"$",
"courseslist",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"searchcriteria",
"[",
"'search'",
"]",
")",
")",
"{",
"// print search form only if there was a search by search string, otherwise it is confusing",
"$",
"content",
".=",
"$",
"this",
"->",
"box_start",
"(",
"'generalbox mdl-align'",
")",
";",
"$",
"content",
".=",
"$",
"this",
"->",
"course_search_form",
"(",
"$",
"searchcriteria",
"[",
"'search'",
"]",
")",
";",
"$",
"content",
".=",
"$",
"this",
"->",
"box_end",
"(",
")",
";",
"}",
"}",
"else",
"{",
"// just print search form",
"$",
"content",
".=",
"$",
"this",
"->",
"box_start",
"(",
"'generalbox mdl-align'",
")",
";",
"$",
"content",
".=",
"$",
"this",
"->",
"course_search_form",
"(",
")",
";",
"$",
"content",
".=",
"$",
"this",
"->",
"box_end",
"(",
")",
";",
"}",
"return",
"$",
"content",
";",
"}"
] |
Renders html to display search result page
@param array $searchcriteria may contain elements: search, blocklist, modulelist, tagid
@return string
|
[
"Renders",
"html",
"to",
"display",
"search",
"result",
"page"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L1762-L1820
|
219,764
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.tagged_courses
|
public function tagged_courses($tagid, $exclusivemode = true, $ctx = 0, $rec = true, $displayoptions = null) {
global $CFG;
if (empty($displayoptions)) {
$displayoptions = array();
}
$showcategories = !core_course_category::is_simple_site();
$displayoptions += array('limit' => $CFG->coursesperpage, 'offset' => 0);
$chelper = new coursecat_helper();
$searchcriteria = array('tagid' => $tagid, 'ctx' => $ctx, 'rec' => $rec);
$chelper->set_show_courses($showcategories ? self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT :
self::COURSECAT_SHOW_COURSES_EXPANDED)->
set_search_criteria($searchcriteria)->
set_courses_display_options($displayoptions)->
set_attributes(array('class' => 'course-search-result course-search-result-tagid'));
// (we set the same css class as in search results by tagid)
if ($totalcount = core_course_category::search_courses_count($searchcriteria)) {
$courses = core_course_category::search_courses($searchcriteria, $chelper->get_courses_display_options());
if ($exclusivemode) {
return $this->coursecat_courses($chelper, $courses, $totalcount);
} else {
$tagfeed = new core_tag\output\tagfeed();
$img = $this->output->pix_icon('i/course', '');
foreach ($courses as $course) {
$url = course_get_url($course);
$imgwithlink = html_writer::link($url, $img);
$coursename = html_writer::link($url, $course->get_formatted_name());
$details = '';
if ($showcategories && ($cat = core_course_category::get($course->category, IGNORE_MISSING))) {
$details = get_string('category').': '.
html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)),
$cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed'));
}
$tagfeed->add($imgwithlink, $coursename, $details);
}
return $this->output->render_from_template('core_tag/tagfeed', $tagfeed->export_for_template($this->output));
}
}
return '';
}
|
php
|
public function tagged_courses($tagid, $exclusivemode = true, $ctx = 0, $rec = true, $displayoptions = null) {
global $CFG;
if (empty($displayoptions)) {
$displayoptions = array();
}
$showcategories = !core_course_category::is_simple_site();
$displayoptions += array('limit' => $CFG->coursesperpage, 'offset' => 0);
$chelper = new coursecat_helper();
$searchcriteria = array('tagid' => $tagid, 'ctx' => $ctx, 'rec' => $rec);
$chelper->set_show_courses($showcategories ? self::COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT :
self::COURSECAT_SHOW_COURSES_EXPANDED)->
set_search_criteria($searchcriteria)->
set_courses_display_options($displayoptions)->
set_attributes(array('class' => 'course-search-result course-search-result-tagid'));
// (we set the same css class as in search results by tagid)
if ($totalcount = core_course_category::search_courses_count($searchcriteria)) {
$courses = core_course_category::search_courses($searchcriteria, $chelper->get_courses_display_options());
if ($exclusivemode) {
return $this->coursecat_courses($chelper, $courses, $totalcount);
} else {
$tagfeed = new core_tag\output\tagfeed();
$img = $this->output->pix_icon('i/course', '');
foreach ($courses as $course) {
$url = course_get_url($course);
$imgwithlink = html_writer::link($url, $img);
$coursename = html_writer::link($url, $course->get_formatted_name());
$details = '';
if ($showcategories && ($cat = core_course_category::get($course->category, IGNORE_MISSING))) {
$details = get_string('category').': '.
html_writer::link(new moodle_url('/course/index.php', array('categoryid' => $cat->id)),
$cat->get_formatted_name(), array('class' => $cat->visible ? '' : 'dimmed'));
}
$tagfeed->add($imgwithlink, $coursename, $details);
}
return $this->output->render_from_template('core_tag/tagfeed', $tagfeed->export_for_template($this->output));
}
}
return '';
}
|
[
"public",
"function",
"tagged_courses",
"(",
"$",
"tagid",
",",
"$",
"exclusivemode",
"=",
"true",
",",
"$",
"ctx",
"=",
"0",
",",
"$",
"rec",
"=",
"true",
",",
"$",
"displayoptions",
"=",
"null",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"empty",
"(",
"$",
"displayoptions",
")",
")",
"{",
"$",
"displayoptions",
"=",
"array",
"(",
")",
";",
"}",
"$",
"showcategories",
"=",
"!",
"core_course_category",
"::",
"is_simple_site",
"(",
")",
";",
"$",
"displayoptions",
"+=",
"array",
"(",
"'limit'",
"=>",
"$",
"CFG",
"->",
"coursesperpage",
",",
"'offset'",
"=>",
"0",
")",
";",
"$",
"chelper",
"=",
"new",
"coursecat_helper",
"(",
")",
";",
"$",
"searchcriteria",
"=",
"array",
"(",
"'tagid'",
"=>",
"$",
"tagid",
",",
"'ctx'",
"=>",
"$",
"ctx",
",",
"'rec'",
"=>",
"$",
"rec",
")",
";",
"$",
"chelper",
"->",
"set_show_courses",
"(",
"$",
"showcategories",
"?",
"self",
"::",
"COURSECAT_SHOW_COURSES_EXPANDED_WITH_CAT",
":",
"self",
"::",
"COURSECAT_SHOW_COURSES_EXPANDED",
")",
"->",
"set_search_criteria",
"(",
"$",
"searchcriteria",
")",
"->",
"set_courses_display_options",
"(",
"$",
"displayoptions",
")",
"->",
"set_attributes",
"(",
"array",
"(",
"'class'",
"=>",
"'course-search-result course-search-result-tagid'",
")",
")",
";",
"// (we set the same css class as in search results by tagid)",
"if",
"(",
"$",
"totalcount",
"=",
"core_course_category",
"::",
"search_courses_count",
"(",
"$",
"searchcriteria",
")",
")",
"{",
"$",
"courses",
"=",
"core_course_category",
"::",
"search_courses",
"(",
"$",
"searchcriteria",
",",
"$",
"chelper",
"->",
"get_courses_display_options",
"(",
")",
")",
";",
"if",
"(",
"$",
"exclusivemode",
")",
"{",
"return",
"$",
"this",
"->",
"coursecat_courses",
"(",
"$",
"chelper",
",",
"$",
"courses",
",",
"$",
"totalcount",
")",
";",
"}",
"else",
"{",
"$",
"tagfeed",
"=",
"new",
"core_tag",
"\\",
"output",
"\\",
"tagfeed",
"(",
")",
";",
"$",
"img",
"=",
"$",
"this",
"->",
"output",
"->",
"pix_icon",
"(",
"'i/course'",
",",
"''",
")",
";",
"foreach",
"(",
"$",
"courses",
"as",
"$",
"course",
")",
"{",
"$",
"url",
"=",
"course_get_url",
"(",
"$",
"course",
")",
";",
"$",
"imgwithlink",
"=",
"html_writer",
"::",
"link",
"(",
"$",
"url",
",",
"$",
"img",
")",
";",
"$",
"coursename",
"=",
"html_writer",
"::",
"link",
"(",
"$",
"url",
",",
"$",
"course",
"->",
"get_formatted_name",
"(",
")",
")",
";",
"$",
"details",
"=",
"''",
";",
"if",
"(",
"$",
"showcategories",
"&&",
"(",
"$",
"cat",
"=",
"core_course_category",
"::",
"get",
"(",
"$",
"course",
"->",
"category",
",",
"IGNORE_MISSING",
")",
")",
")",
"{",
"$",
"details",
"=",
"get_string",
"(",
"'category'",
")",
".",
"': '",
".",
"html_writer",
"::",
"link",
"(",
"new",
"moodle_url",
"(",
"'/course/index.php'",
",",
"array",
"(",
"'categoryid'",
"=>",
"$",
"cat",
"->",
"id",
")",
")",
",",
"$",
"cat",
"->",
"get_formatted_name",
"(",
")",
",",
"array",
"(",
"'class'",
"=>",
"$",
"cat",
"->",
"visible",
"?",
"''",
":",
"'dimmed'",
")",
")",
";",
"}",
"$",
"tagfeed",
"->",
"add",
"(",
"$",
"imgwithlink",
",",
"$",
"coursename",
",",
"$",
"details",
")",
";",
"}",
"return",
"$",
"this",
"->",
"output",
"->",
"render_from_template",
"(",
"'core_tag/tagfeed'",
",",
"$",
"tagfeed",
"->",
"export_for_template",
"(",
"$",
"this",
"->",
"output",
")",
")",
";",
"}",
"}",
"return",
"''",
";",
"}"
] |
Renders html to print list of courses tagged with particular tag
@param int $tagid id of the tag
@param bool $exclusivemode if set to true it means that no other entities tagged with this tag
are displayed on the page and the per-page limit may be bigger
@param int $fromctx context id where the link was displayed, may be used by callbacks
to display items in the same context first
@param int $ctx context id where to search for records
@param bool $rec search in subcontexts as well
@param array $displayoptions
@return string empty string if no courses are marked with this tag or rendered list of courses
|
[
"Renders",
"html",
"to",
"print",
"list",
"of",
"courses",
"tagged",
"with",
"particular",
"tag"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L1835-L1873
|
219,765
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.frontpage_remote_course
|
protected function frontpage_remote_course(stdClass $course) {
$url = new moodle_url('/auth/mnet/jump.php', array(
'hostid' => $course->hostid,
'wantsurl' => '/course/view.php?id='. $course->remoteid
));
$output = '';
$output .= html_writer::start_tag('div', array('class' => 'coursebox remotecoursebox clearfix'));
$output .= html_writer::start_tag('div', array('class' => 'info'));
$output .= html_writer::start_tag('h3', array('class' => 'name'));
$output .= html_writer::link($url, format_string($course->fullname), array('title' => get_string('entercourse')));
$output .= html_writer::end_tag('h3'); // .name
$output .= html_writer::tag('div', '', array('class' => 'moreinfo'));
$output .= html_writer::end_tag('div'); // .info
$output .= html_writer::start_tag('div', array('class' => 'content'));
$output .= html_writer::start_tag('div', array('class' => 'summary'));
$options = new stdClass();
$options->noclean = true;
$options->para = false;
$options->overflowdiv = true;
$output .= format_text($course->summary, $course->summaryformat, $options);
$output .= html_writer::end_tag('div'); // .summary
$addinfo = format_string($course->hostname) . ' : '
. format_string($course->cat_name) . ' : '
. format_string($course->shortname);
$output .= html_writer::tag('div', $addinfo, array('class' => 'remotecourseinfo'));
$output .= html_writer::end_tag('div'); // .content
$output .= html_writer::end_tag('div'); // .coursebox
return $output;
}
|
php
|
protected function frontpage_remote_course(stdClass $course) {
$url = new moodle_url('/auth/mnet/jump.php', array(
'hostid' => $course->hostid,
'wantsurl' => '/course/view.php?id='. $course->remoteid
));
$output = '';
$output .= html_writer::start_tag('div', array('class' => 'coursebox remotecoursebox clearfix'));
$output .= html_writer::start_tag('div', array('class' => 'info'));
$output .= html_writer::start_tag('h3', array('class' => 'name'));
$output .= html_writer::link($url, format_string($course->fullname), array('title' => get_string('entercourse')));
$output .= html_writer::end_tag('h3'); // .name
$output .= html_writer::tag('div', '', array('class' => 'moreinfo'));
$output .= html_writer::end_tag('div'); // .info
$output .= html_writer::start_tag('div', array('class' => 'content'));
$output .= html_writer::start_tag('div', array('class' => 'summary'));
$options = new stdClass();
$options->noclean = true;
$options->para = false;
$options->overflowdiv = true;
$output .= format_text($course->summary, $course->summaryformat, $options);
$output .= html_writer::end_tag('div'); // .summary
$addinfo = format_string($course->hostname) . ' : '
. format_string($course->cat_name) . ' : '
. format_string($course->shortname);
$output .= html_writer::tag('div', $addinfo, array('class' => 'remotecourseinfo'));
$output .= html_writer::end_tag('div'); // .content
$output .= html_writer::end_tag('div'); // .coursebox
return $output;
}
|
[
"protected",
"function",
"frontpage_remote_course",
"(",
"stdClass",
"$",
"course",
")",
"{",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"'/auth/mnet/jump.php'",
",",
"array",
"(",
"'hostid'",
"=>",
"$",
"course",
"->",
"hostid",
",",
"'wantsurl'",
"=>",
"'/course/view.php?id='",
".",
"$",
"course",
"->",
"remoteid",
")",
")",
";",
"$",
"output",
"=",
"''",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'coursebox remotecoursebox clearfix'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'info'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'h3'",
",",
"array",
"(",
"'class'",
"=>",
"'name'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"link",
"(",
"$",
"url",
",",
"format_string",
"(",
"$",
"course",
"->",
"fullname",
")",
",",
"array",
"(",
"'title'",
"=>",
"get_string",
"(",
"'entercourse'",
")",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'h3'",
")",
";",
"// .name",
"$",
"output",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"''",
",",
"array",
"(",
"'class'",
"=>",
"'moreinfo'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"// .info",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'content'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'summary'",
")",
")",
";",
"$",
"options",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"options",
"->",
"noclean",
"=",
"true",
";",
"$",
"options",
"->",
"para",
"=",
"false",
";",
"$",
"options",
"->",
"overflowdiv",
"=",
"true",
";",
"$",
"output",
".=",
"format_text",
"(",
"$",
"course",
"->",
"summary",
",",
"$",
"course",
"->",
"summaryformat",
",",
"$",
"options",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"// .summary",
"$",
"addinfo",
"=",
"format_string",
"(",
"$",
"course",
"->",
"hostname",
")",
".",
"' : '",
".",
"format_string",
"(",
"$",
"course",
"->",
"cat_name",
")",
".",
"' : '",
".",
"format_string",
"(",
"$",
"course",
"->",
"shortname",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"addinfo",
",",
"array",
"(",
"'class'",
"=>",
"'remotecourseinfo'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"// .content",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"// .coursebox",
"return",
"$",
"output",
";",
"}"
] |
Returns HTML to display one remote course
@param stdClass $course remote course information, contains properties:
id, remoteid, shortname, fullname, hostid, summary, summaryformat, cat_name, hostname
@return string
|
[
"Returns",
"HTML",
"to",
"display",
"one",
"remote",
"course"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L1882-L1911
|
219,766
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.frontpage_remote_host
|
protected function frontpage_remote_host($host) {
$output = '';
$output .= html_writer::start_tag('div', array('class' => 'coursebox remotehost clearfix'));
$output .= html_writer::start_tag('div', array('class' => 'info'));
$output .= html_writer::start_tag('h3', array('class' => 'name'));
$output .= html_writer::link($host['url'], s($host['name']), array('title' => s($host['name'])));
$output .= html_writer::end_tag('h3'); // .name
$output .= html_writer::tag('div', '', array('class' => 'moreinfo'));
$output .= html_writer::end_tag('div'); // .info
$output .= html_writer::start_tag('div', array('class' => 'content'));
$output .= html_writer::start_tag('div', array('class' => 'summary'));
$output .= $host['count'] . ' ' . get_string('courses');
$output .= html_writer::end_tag('div'); // .content
$output .= html_writer::end_tag('div'); // .coursebox
return $output;
}
|
php
|
protected function frontpage_remote_host($host) {
$output = '';
$output .= html_writer::start_tag('div', array('class' => 'coursebox remotehost clearfix'));
$output .= html_writer::start_tag('div', array('class' => 'info'));
$output .= html_writer::start_tag('h3', array('class' => 'name'));
$output .= html_writer::link($host['url'], s($host['name']), array('title' => s($host['name'])));
$output .= html_writer::end_tag('h3'); // .name
$output .= html_writer::tag('div', '', array('class' => 'moreinfo'));
$output .= html_writer::end_tag('div'); // .info
$output .= html_writer::start_tag('div', array('class' => 'content'));
$output .= html_writer::start_tag('div', array('class' => 'summary'));
$output .= $host['count'] . ' ' . get_string('courses');
$output .= html_writer::end_tag('div'); // .content
$output .= html_writer::end_tag('div'); // .coursebox
return $output;
}
|
[
"protected",
"function",
"frontpage_remote_host",
"(",
"$",
"host",
")",
"{",
"$",
"output",
"=",
"''",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'coursebox remotehost clearfix'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'info'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'h3'",
",",
"array",
"(",
"'class'",
"=>",
"'name'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"link",
"(",
"$",
"host",
"[",
"'url'",
"]",
",",
"s",
"(",
"$",
"host",
"[",
"'name'",
"]",
")",
",",
"array",
"(",
"'title'",
"=>",
"s",
"(",
"$",
"host",
"[",
"'name'",
"]",
")",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'h3'",
")",
";",
"// .name",
"$",
"output",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"''",
",",
"array",
"(",
"'class'",
"=>",
"'moreinfo'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"// .info",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'content'",
")",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'summary'",
")",
")",
";",
"$",
"output",
".=",
"$",
"host",
"[",
"'count'",
"]",
".",
"' '",
".",
"get_string",
"(",
"'courses'",
")",
";",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"// .content",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"// .coursebox",
"return",
"$",
"output",
";",
"}"
] |
Returns HTML to display one remote host
@param array $host host information, contains properties: name, url, count
@return string
|
[
"Returns",
"HTML",
"to",
"display",
"one",
"remote",
"host"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L1919-L1934
|
219,767
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.frontpage_my_courses
|
public function frontpage_my_courses() {
global $USER, $CFG, $DB;
if (!isloggedin() or isguestuser()) {
return '';
}
$output = '';
$courses = enrol_get_my_courses('summary, summaryformat');
$rhosts = array();
$rcourses = array();
if (!empty($CFG->mnet_dispatcher_mode) && $CFG->mnet_dispatcher_mode==='strict') {
$rcourses = get_my_remotecourses($USER->id);
$rhosts = get_my_remotehosts();
}
if (!empty($courses) || !empty($rcourses) || !empty($rhosts)) {
$chelper = new coursecat_helper();
$totalcount = count($courses);
if (count($courses) > $CFG->frontpagecourselimit) {
// There are more enrolled courses than we can display, display link to 'My courses'.
$courses = array_slice($courses, 0, $CFG->frontpagecourselimit, true);
$chelper->set_courses_display_options(array(
'viewmoreurl' => new moodle_url('/my/'),
'viewmoretext' => new lang_string('mycourses')
));
} else if (core_course_category::top()->is_uservisible()) {
// All enrolled courses are displayed, display link to 'All courses' if there are more courses in system.
$chelper->set_courses_display_options(array(
'viewmoreurl' => new moodle_url('/course/index.php'),
'viewmoretext' => new lang_string('fulllistofcourses')
));
$totalcount = $DB->count_records('course') - 1;
}
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->
set_attributes(array('class' => 'frontpage-course-list-enrolled'));
$output .= $this->coursecat_courses($chelper, $courses, $totalcount);
// MNET
if (!empty($rcourses)) {
// at the IDP, we know of all the remote courses
$output .= html_writer::start_tag('div', array('class' => 'courses'));
foreach ($rcourses as $course) {
$output .= $this->frontpage_remote_course($course);
}
$output .= html_writer::end_tag('div'); // .courses
} elseif (!empty($rhosts)) {
// non-IDP, we know of all the remote servers, but not courses
$output .= html_writer::start_tag('div', array('class' => 'courses'));
foreach ($rhosts as $host) {
$output .= $this->frontpage_remote_host($host);
}
$output .= html_writer::end_tag('div'); // .courses
}
}
return $output;
}
|
php
|
public function frontpage_my_courses() {
global $USER, $CFG, $DB;
if (!isloggedin() or isguestuser()) {
return '';
}
$output = '';
$courses = enrol_get_my_courses('summary, summaryformat');
$rhosts = array();
$rcourses = array();
if (!empty($CFG->mnet_dispatcher_mode) && $CFG->mnet_dispatcher_mode==='strict') {
$rcourses = get_my_remotecourses($USER->id);
$rhosts = get_my_remotehosts();
}
if (!empty($courses) || !empty($rcourses) || !empty($rhosts)) {
$chelper = new coursecat_helper();
$totalcount = count($courses);
if (count($courses) > $CFG->frontpagecourselimit) {
// There are more enrolled courses than we can display, display link to 'My courses'.
$courses = array_slice($courses, 0, $CFG->frontpagecourselimit, true);
$chelper->set_courses_display_options(array(
'viewmoreurl' => new moodle_url('/my/'),
'viewmoretext' => new lang_string('mycourses')
));
} else if (core_course_category::top()->is_uservisible()) {
// All enrolled courses are displayed, display link to 'All courses' if there are more courses in system.
$chelper->set_courses_display_options(array(
'viewmoreurl' => new moodle_url('/course/index.php'),
'viewmoretext' => new lang_string('fulllistofcourses')
));
$totalcount = $DB->count_records('course') - 1;
}
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->
set_attributes(array('class' => 'frontpage-course-list-enrolled'));
$output .= $this->coursecat_courses($chelper, $courses, $totalcount);
// MNET
if (!empty($rcourses)) {
// at the IDP, we know of all the remote courses
$output .= html_writer::start_tag('div', array('class' => 'courses'));
foreach ($rcourses as $course) {
$output .= $this->frontpage_remote_course($course);
}
$output .= html_writer::end_tag('div'); // .courses
} elseif (!empty($rhosts)) {
// non-IDP, we know of all the remote servers, but not courses
$output .= html_writer::start_tag('div', array('class' => 'courses'));
foreach ($rhosts as $host) {
$output .= $this->frontpage_remote_host($host);
}
$output .= html_writer::end_tag('div'); // .courses
}
}
return $output;
}
|
[
"public",
"function",
"frontpage_my_courses",
"(",
")",
"{",
"global",
"$",
"USER",
",",
"$",
"CFG",
",",
"$",
"DB",
";",
"if",
"(",
"!",
"isloggedin",
"(",
")",
"or",
"isguestuser",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"output",
"=",
"''",
";",
"$",
"courses",
"=",
"enrol_get_my_courses",
"(",
"'summary, summaryformat'",
")",
";",
"$",
"rhosts",
"=",
"array",
"(",
")",
";",
"$",
"rcourses",
"=",
"array",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"CFG",
"->",
"mnet_dispatcher_mode",
")",
"&&",
"$",
"CFG",
"->",
"mnet_dispatcher_mode",
"===",
"'strict'",
")",
"{",
"$",
"rcourses",
"=",
"get_my_remotecourses",
"(",
"$",
"USER",
"->",
"id",
")",
";",
"$",
"rhosts",
"=",
"get_my_remotehosts",
"(",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"courses",
")",
"||",
"!",
"empty",
"(",
"$",
"rcourses",
")",
"||",
"!",
"empty",
"(",
"$",
"rhosts",
")",
")",
"{",
"$",
"chelper",
"=",
"new",
"coursecat_helper",
"(",
")",
";",
"$",
"totalcount",
"=",
"count",
"(",
"$",
"courses",
")",
";",
"if",
"(",
"count",
"(",
"$",
"courses",
")",
">",
"$",
"CFG",
"->",
"frontpagecourselimit",
")",
"{",
"// There are more enrolled courses than we can display, display link to 'My courses'.",
"$",
"courses",
"=",
"array_slice",
"(",
"$",
"courses",
",",
"0",
",",
"$",
"CFG",
"->",
"frontpagecourselimit",
",",
"true",
")",
";",
"$",
"chelper",
"->",
"set_courses_display_options",
"(",
"array",
"(",
"'viewmoreurl'",
"=>",
"new",
"moodle_url",
"(",
"'/my/'",
")",
",",
"'viewmoretext'",
"=>",
"new",
"lang_string",
"(",
"'mycourses'",
")",
")",
")",
";",
"}",
"else",
"if",
"(",
"core_course_category",
"::",
"top",
"(",
")",
"->",
"is_uservisible",
"(",
")",
")",
"{",
"// All enrolled courses are displayed, display link to 'All courses' if there are more courses in system.",
"$",
"chelper",
"->",
"set_courses_display_options",
"(",
"array",
"(",
"'viewmoreurl'",
"=>",
"new",
"moodle_url",
"(",
"'/course/index.php'",
")",
",",
"'viewmoretext'",
"=>",
"new",
"lang_string",
"(",
"'fulllistofcourses'",
")",
")",
")",
";",
"$",
"totalcount",
"=",
"$",
"DB",
"->",
"count_records",
"(",
"'course'",
")",
"-",
"1",
";",
"}",
"$",
"chelper",
"->",
"set_show_courses",
"(",
"self",
"::",
"COURSECAT_SHOW_COURSES_EXPANDED",
")",
"->",
"set_attributes",
"(",
"array",
"(",
"'class'",
"=>",
"'frontpage-course-list-enrolled'",
")",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"coursecat_courses",
"(",
"$",
"chelper",
",",
"$",
"courses",
",",
"$",
"totalcount",
")",
";",
"// MNET",
"if",
"(",
"!",
"empty",
"(",
"$",
"rcourses",
")",
")",
"{",
"// at the IDP, we know of all the remote courses",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'courses'",
")",
")",
";",
"foreach",
"(",
"$",
"rcourses",
"as",
"$",
"course",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"frontpage_remote_course",
"(",
"$",
"course",
")",
";",
"}",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"// .courses",
"}",
"elseif",
"(",
"!",
"empty",
"(",
"$",
"rhosts",
")",
")",
"{",
"// non-IDP, we know of all the remote servers, but not courses",
"$",
"output",
".=",
"html_writer",
"::",
"start_tag",
"(",
"'div'",
",",
"array",
"(",
"'class'",
"=>",
"'courses'",
")",
")",
";",
"foreach",
"(",
"$",
"rhosts",
"as",
"$",
"host",
")",
"{",
"$",
"output",
".=",
"$",
"this",
"->",
"frontpage_remote_host",
"(",
"$",
"host",
")",
";",
"}",
"$",
"output",
".=",
"html_writer",
"::",
"end_tag",
"(",
"'div'",
")",
";",
"// .courses",
"}",
"}",
"return",
"$",
"output",
";",
"}"
] |
Returns HTML to print list of courses user is enrolled to for the frontpage
Also lists remote courses or remote hosts if MNET authorisation is used
@return string
|
[
"Returns",
"HTML",
"to",
"print",
"list",
"of",
"courses",
"user",
"is",
"enrolled",
"to",
"for",
"the",
"frontpage"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L1943-L2000
|
219,768
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.frontpage_available_courses
|
public function frontpage_available_courses() {
global $CFG;
$chelper = new coursecat_helper();
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->
set_courses_display_options(array(
'recursive' => true,
'limit' => $CFG->frontpagecourselimit,
'viewmoreurl' => new moodle_url('/course/index.php'),
'viewmoretext' => new lang_string('fulllistofcourses')));
$chelper->set_attributes(array('class' => 'frontpage-course-list-all'));
$courses = core_course_category::top()->get_courses($chelper->get_courses_display_options());
$totalcount = core_course_category::top()->get_courses_count($chelper->get_courses_display_options());
if (!$totalcount && !$this->page->user_is_editing() && has_capability('moodle/course:create', context_system::instance())) {
// Print link to create a new course, for the 1st available category.
return $this->add_new_course_button();
}
return $this->coursecat_courses($chelper, $courses, $totalcount);
}
|
php
|
public function frontpage_available_courses() {
global $CFG;
$chelper = new coursecat_helper();
$chelper->set_show_courses(self::COURSECAT_SHOW_COURSES_EXPANDED)->
set_courses_display_options(array(
'recursive' => true,
'limit' => $CFG->frontpagecourselimit,
'viewmoreurl' => new moodle_url('/course/index.php'),
'viewmoretext' => new lang_string('fulllistofcourses')));
$chelper->set_attributes(array('class' => 'frontpage-course-list-all'));
$courses = core_course_category::top()->get_courses($chelper->get_courses_display_options());
$totalcount = core_course_category::top()->get_courses_count($chelper->get_courses_display_options());
if (!$totalcount && !$this->page->user_is_editing() && has_capability('moodle/course:create', context_system::instance())) {
// Print link to create a new course, for the 1st available category.
return $this->add_new_course_button();
}
return $this->coursecat_courses($chelper, $courses, $totalcount);
}
|
[
"public",
"function",
"frontpage_available_courses",
"(",
")",
"{",
"global",
"$",
"CFG",
";",
"$",
"chelper",
"=",
"new",
"coursecat_helper",
"(",
")",
";",
"$",
"chelper",
"->",
"set_show_courses",
"(",
"self",
"::",
"COURSECAT_SHOW_COURSES_EXPANDED",
")",
"->",
"set_courses_display_options",
"(",
"array",
"(",
"'recursive'",
"=>",
"true",
",",
"'limit'",
"=>",
"$",
"CFG",
"->",
"frontpagecourselimit",
",",
"'viewmoreurl'",
"=>",
"new",
"moodle_url",
"(",
"'/course/index.php'",
")",
",",
"'viewmoretext'",
"=>",
"new",
"lang_string",
"(",
"'fulllistofcourses'",
")",
")",
")",
";",
"$",
"chelper",
"->",
"set_attributes",
"(",
"array",
"(",
"'class'",
"=>",
"'frontpage-course-list-all'",
")",
")",
";",
"$",
"courses",
"=",
"core_course_category",
"::",
"top",
"(",
")",
"->",
"get_courses",
"(",
"$",
"chelper",
"->",
"get_courses_display_options",
"(",
")",
")",
";",
"$",
"totalcount",
"=",
"core_course_category",
"::",
"top",
"(",
")",
"->",
"get_courses_count",
"(",
"$",
"chelper",
"->",
"get_courses_display_options",
"(",
")",
")",
";",
"if",
"(",
"!",
"$",
"totalcount",
"&&",
"!",
"$",
"this",
"->",
"page",
"->",
"user_is_editing",
"(",
")",
"&&",
"has_capability",
"(",
"'moodle/course:create'",
",",
"context_system",
"::",
"instance",
"(",
")",
")",
")",
"{",
"// Print link to create a new course, for the 1st available category.",
"return",
"$",
"this",
"->",
"add_new_course_button",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"coursecat_courses",
"(",
"$",
"chelper",
",",
"$",
"courses",
",",
"$",
"totalcount",
")",
";",
"}"
] |
Returns HTML to print list of available courses for the frontpage
@return string
|
[
"Returns",
"HTML",
"to",
"print",
"list",
"of",
"available",
"courses",
"for",
"the",
"frontpage"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2007-L2026
|
219,769
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.add_new_course_button
|
public function add_new_course_button() {
global $CFG;
// Print link to create a new course, for the 1st available category.
$output = $this->container_start('buttons');
$url = new moodle_url('/course/edit.php', array('category' => $CFG->defaultrequestcategory, 'returnto' => 'topcat'));
$output .= $this->single_button($url, get_string('addnewcourse'), 'get');
$output .= $this->container_end('buttons');
return $output;
}
|
php
|
public function add_new_course_button() {
global $CFG;
// Print link to create a new course, for the 1st available category.
$output = $this->container_start('buttons');
$url = new moodle_url('/course/edit.php', array('category' => $CFG->defaultrequestcategory, 'returnto' => 'topcat'));
$output .= $this->single_button($url, get_string('addnewcourse'), 'get');
$output .= $this->container_end('buttons');
return $output;
}
|
[
"public",
"function",
"add_new_course_button",
"(",
")",
"{",
"global",
"$",
"CFG",
";",
"// Print link to create a new course, for the 1st available category.",
"$",
"output",
"=",
"$",
"this",
"->",
"container_start",
"(",
"'buttons'",
")",
";",
"$",
"url",
"=",
"new",
"moodle_url",
"(",
"'/course/edit.php'",
",",
"array",
"(",
"'category'",
"=>",
"$",
"CFG",
"->",
"defaultrequestcategory",
",",
"'returnto'",
"=>",
"'topcat'",
")",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"single_button",
"(",
"$",
"url",
",",
"get_string",
"(",
"'addnewcourse'",
")",
",",
"'get'",
")",
";",
"$",
"output",
".=",
"$",
"this",
"->",
"container_end",
"(",
"'buttons'",
")",
";",
"return",
"$",
"output",
";",
"}"
] |
Returns HTML to the "add new course" button for the page
@return string
|
[
"Returns",
"HTML",
"to",
"the",
"add",
"new",
"course",
"button",
"for",
"the",
"page"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2033-L2041
|
219,770
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.frontpage_combo_list
|
public function frontpage_combo_list() {
global $CFG;
// TODO MDL-10965 improve.
$tree = core_course_category::top();
if (!$tree->get_children_count()) {
return '';
}
$chelper = new coursecat_helper();
$chelper->set_subcat_depth($CFG->maxcategorydepth)->
set_categories_display_options(array(
'limit' => $CFG->coursesperpage,
'viewmoreurl' => new moodle_url('/course/index.php',
array('browse' => 'categories', 'page' => 1))
))->
set_courses_display_options(array(
'limit' => $CFG->coursesperpage,
'viewmoreurl' => new moodle_url('/course/index.php',
array('browse' => 'courses', 'page' => 1))
))->
set_attributes(array('class' => 'frontpage-category-combo'));
return $this->coursecat_tree($chelper, $tree);
}
|
php
|
public function frontpage_combo_list() {
global $CFG;
// TODO MDL-10965 improve.
$tree = core_course_category::top();
if (!$tree->get_children_count()) {
return '';
}
$chelper = new coursecat_helper();
$chelper->set_subcat_depth($CFG->maxcategorydepth)->
set_categories_display_options(array(
'limit' => $CFG->coursesperpage,
'viewmoreurl' => new moodle_url('/course/index.php',
array('browse' => 'categories', 'page' => 1))
))->
set_courses_display_options(array(
'limit' => $CFG->coursesperpage,
'viewmoreurl' => new moodle_url('/course/index.php',
array('browse' => 'courses', 'page' => 1))
))->
set_attributes(array('class' => 'frontpage-category-combo'));
return $this->coursecat_tree($chelper, $tree);
}
|
[
"public",
"function",
"frontpage_combo_list",
"(",
")",
"{",
"global",
"$",
"CFG",
";",
"// TODO MDL-10965 improve.",
"$",
"tree",
"=",
"core_course_category",
"::",
"top",
"(",
")",
";",
"if",
"(",
"!",
"$",
"tree",
"->",
"get_children_count",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"chelper",
"=",
"new",
"coursecat_helper",
"(",
")",
";",
"$",
"chelper",
"->",
"set_subcat_depth",
"(",
"$",
"CFG",
"->",
"maxcategorydepth",
")",
"->",
"set_categories_display_options",
"(",
"array",
"(",
"'limit'",
"=>",
"$",
"CFG",
"->",
"coursesperpage",
",",
"'viewmoreurl'",
"=>",
"new",
"moodle_url",
"(",
"'/course/index.php'",
",",
"array",
"(",
"'browse'",
"=>",
"'categories'",
",",
"'page'",
"=>",
"1",
")",
")",
")",
")",
"->",
"set_courses_display_options",
"(",
"array",
"(",
"'limit'",
"=>",
"$",
"CFG",
"->",
"coursesperpage",
",",
"'viewmoreurl'",
"=>",
"new",
"moodle_url",
"(",
"'/course/index.php'",
",",
"array",
"(",
"'browse'",
"=>",
"'courses'",
",",
"'page'",
"=>",
"1",
")",
")",
")",
")",
"->",
"set_attributes",
"(",
"array",
"(",
"'class'",
"=>",
"'frontpage-category-combo'",
")",
")",
";",
"return",
"$",
"this",
"->",
"coursecat_tree",
"(",
"$",
"chelper",
",",
"$",
"tree",
")",
";",
"}"
] |
Returns HTML to print tree with course categories and courses for the frontpage
@return string
|
[
"Returns",
"HTML",
"to",
"print",
"tree",
"with",
"course",
"categories",
"and",
"courses",
"for",
"the",
"frontpage"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2048-L2069
|
219,771
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.render_activity_navigation
|
public function render_activity_navigation(\core_course\output\activity_navigation $page) {
$data = $page->export_for_template($this->output);
return $this->output->render_from_template('core_course/activity_navigation', $data);
}
|
php
|
public function render_activity_navigation(\core_course\output\activity_navigation $page) {
$data = $page->export_for_template($this->output);
return $this->output->render_from_template('core_course/activity_navigation', $data);
}
|
[
"public",
"function",
"render_activity_navigation",
"(",
"\\",
"core_course",
"\\",
"output",
"\\",
"activity_navigation",
"$",
"page",
")",
"{",
"$",
"data",
"=",
"$",
"page",
"->",
"export_for_template",
"(",
"$",
"this",
"->",
"output",
")",
";",
"return",
"$",
"this",
"->",
"output",
"->",
"render_from_template",
"(",
"'core_course/activity_navigation'",
",",
"$",
"data",
")",
";",
"}"
] |
Renders the activity navigation.
Defer to template.
@param \core_course\output\activity_navigation $page
@return string html for the page
|
[
"Renders",
"the",
"activity",
"navigation",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2103-L2106
|
219,772
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.publicationselector
|
public function publicationselector($courseid) {
$text = '';
$advertiseurl = new moodle_url("/course/publish/metadata.php",
array('sesskey' => sesskey(), 'id' => $courseid, 'advertise' => true));
$advertisebutton = new single_button($advertiseurl, get_string('advertise', 'hub'));
$text .= $this->output->render($advertisebutton);
$text .= html_writer::tag('div', get_string('advertisepublication_help', 'hub'),
array('class' => 'publishhelp'));
$text .= html_writer::empty_tag('br'); // TODO Delete.
$uploadurl = new moodle_url("/course/publish/metadata.php",
array('sesskey' => sesskey(), 'id' => $courseid, 'share' => true));
$uploadbutton = new single_button($uploadurl, get_string('share', 'hub'));
$text .= $this->output->render($uploadbutton);
$text .= html_writer::tag('div', get_string('sharepublication_help', 'hub'),
array('class' => 'publishhelp'));
return $text;
}
|
php
|
public function publicationselector($courseid) {
$text = '';
$advertiseurl = new moodle_url("/course/publish/metadata.php",
array('sesskey' => sesskey(), 'id' => $courseid, 'advertise' => true));
$advertisebutton = new single_button($advertiseurl, get_string('advertise', 'hub'));
$text .= $this->output->render($advertisebutton);
$text .= html_writer::tag('div', get_string('advertisepublication_help', 'hub'),
array('class' => 'publishhelp'));
$text .= html_writer::empty_tag('br'); // TODO Delete.
$uploadurl = new moodle_url("/course/publish/metadata.php",
array('sesskey' => sesskey(), 'id' => $courseid, 'share' => true));
$uploadbutton = new single_button($uploadurl, get_string('share', 'hub'));
$text .= $this->output->render($uploadbutton);
$text .= html_writer::tag('div', get_string('sharepublication_help', 'hub'),
array('class' => 'publishhelp'));
return $text;
}
|
[
"public",
"function",
"publicationselector",
"(",
"$",
"courseid",
")",
"{",
"$",
"text",
"=",
"''",
";",
"$",
"advertiseurl",
"=",
"new",
"moodle_url",
"(",
"\"/course/publish/metadata.php\"",
",",
"array",
"(",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
",",
"'id'",
"=>",
"$",
"courseid",
",",
"'advertise'",
"=>",
"true",
")",
")",
";",
"$",
"advertisebutton",
"=",
"new",
"single_button",
"(",
"$",
"advertiseurl",
",",
"get_string",
"(",
"'advertise'",
",",
"'hub'",
")",
")",
";",
"$",
"text",
".=",
"$",
"this",
"->",
"output",
"->",
"render",
"(",
"$",
"advertisebutton",
")",
";",
"$",
"text",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"get_string",
"(",
"'advertisepublication_help'",
",",
"'hub'",
")",
",",
"array",
"(",
"'class'",
"=>",
"'publishhelp'",
")",
")",
";",
"$",
"text",
".=",
"html_writer",
"::",
"empty_tag",
"(",
"'br'",
")",
";",
"// TODO Delete.",
"$",
"uploadurl",
"=",
"new",
"moodle_url",
"(",
"\"/course/publish/metadata.php\"",
",",
"array",
"(",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
",",
"'id'",
"=>",
"$",
"courseid",
",",
"'share'",
"=>",
"true",
")",
")",
";",
"$",
"uploadbutton",
"=",
"new",
"single_button",
"(",
"$",
"uploadurl",
",",
"get_string",
"(",
"'share'",
",",
"'hub'",
")",
")",
";",
"$",
"text",
".=",
"$",
"this",
"->",
"output",
"->",
"render",
"(",
"$",
"uploadbutton",
")",
";",
"$",
"text",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"get_string",
"(",
"'sharepublication_help'",
",",
"'hub'",
")",
",",
"array",
"(",
"'class'",
"=>",
"'publishhelp'",
")",
")",
";",
"return",
"$",
"text",
";",
"}"
] |
Display the selector to advertise or publish a course
@param int $courseid
|
[
"Display",
"the",
"selector",
"to",
"advertise",
"or",
"publish",
"a",
"course"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2112-L2132
|
219,773
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.confirmunpublishing
|
public function confirmunpublishing($publication) {
$optionsyes = array('sesskey' => sesskey(), 'id' => $publication->courseid,
'hubcourseid' => $publication->hubcourseid,
'cancel' => true, 'publicationid' => $publication->id, 'confirm' => true);
$optionsno = array('sesskey' => sesskey(), 'id' => $publication->courseid);
$publication->hubname = html_writer::tag('a', 'Moodle.net',
array('href' => HUB_MOODLEORGHUBURL));
$formcontinue = new single_button(new moodle_url("/course/publish/index.php",
$optionsyes), get_string('unpublish', 'hub'), 'post');
$formcancel = new single_button(new moodle_url("/course/publish/index.php",
$optionsno), get_string('cancel'), 'get');
return $this->output->confirm(get_string('unpublishconfirmation', 'hub', $publication),
$formcontinue, $formcancel);
}
|
php
|
public function confirmunpublishing($publication) {
$optionsyes = array('sesskey' => sesskey(), 'id' => $publication->courseid,
'hubcourseid' => $publication->hubcourseid,
'cancel' => true, 'publicationid' => $publication->id, 'confirm' => true);
$optionsno = array('sesskey' => sesskey(), 'id' => $publication->courseid);
$publication->hubname = html_writer::tag('a', 'Moodle.net',
array('href' => HUB_MOODLEORGHUBURL));
$formcontinue = new single_button(new moodle_url("/course/publish/index.php",
$optionsyes), get_string('unpublish', 'hub'), 'post');
$formcancel = new single_button(new moodle_url("/course/publish/index.php",
$optionsno), get_string('cancel'), 'get');
return $this->output->confirm(get_string('unpublishconfirmation', 'hub', $publication),
$formcontinue, $formcancel);
}
|
[
"public",
"function",
"confirmunpublishing",
"(",
"$",
"publication",
")",
"{",
"$",
"optionsyes",
"=",
"array",
"(",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
",",
"'id'",
"=>",
"$",
"publication",
"->",
"courseid",
",",
"'hubcourseid'",
"=>",
"$",
"publication",
"->",
"hubcourseid",
",",
"'cancel'",
"=>",
"true",
",",
"'publicationid'",
"=>",
"$",
"publication",
"->",
"id",
",",
"'confirm'",
"=>",
"true",
")",
";",
"$",
"optionsno",
"=",
"array",
"(",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
",",
"'id'",
"=>",
"$",
"publication",
"->",
"courseid",
")",
";",
"$",
"publication",
"->",
"hubname",
"=",
"html_writer",
"::",
"tag",
"(",
"'a'",
",",
"'Moodle.net'",
",",
"array",
"(",
"'href'",
"=>",
"HUB_MOODLEORGHUBURL",
")",
")",
";",
"$",
"formcontinue",
"=",
"new",
"single_button",
"(",
"new",
"moodle_url",
"(",
"\"/course/publish/index.php\"",
",",
"$",
"optionsyes",
")",
",",
"get_string",
"(",
"'unpublish'",
",",
"'hub'",
")",
",",
"'post'",
")",
";",
"$",
"formcancel",
"=",
"new",
"single_button",
"(",
"new",
"moodle_url",
"(",
"\"/course/publish/index.php\"",
",",
"$",
"optionsno",
")",
",",
"get_string",
"(",
"'cancel'",
")",
",",
"'get'",
")",
";",
"return",
"$",
"this",
"->",
"output",
"->",
"confirm",
"(",
"get_string",
"(",
"'unpublishconfirmation'",
",",
"'hub'",
",",
"$",
"publication",
")",
",",
"$",
"formcontinue",
",",
"$",
"formcancel",
")",
";",
"}"
] |
Display unpublishing confirmation page
@param stdClass $publication
$publication->courseshortname
$publication->courseid
$publication->hubname
$publication->huburl
$publication->id
|
[
"Display",
"unpublishing",
"confirmation",
"page"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2215-L2228
|
219,774
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.sendingbackupinfo
|
public function sendingbackupinfo($backupfile) {
$sizeinfo = new stdClass();
$sizeinfo->total = number_format($backupfile->get_filesize() / 1000000, 2);
$html = html_writer::tag('div', get_string('sendingsize', 'hub', $sizeinfo),
array('class' => 'courseuploadtextinfo'));
return $html;
}
|
php
|
public function sendingbackupinfo($backupfile) {
$sizeinfo = new stdClass();
$sizeinfo->total = number_format($backupfile->get_filesize() / 1000000, 2);
$html = html_writer::tag('div', get_string('sendingsize', 'hub', $sizeinfo),
array('class' => 'courseuploadtextinfo'));
return $html;
}
|
[
"public",
"function",
"sendingbackupinfo",
"(",
"$",
"backupfile",
")",
"{",
"$",
"sizeinfo",
"=",
"new",
"stdClass",
"(",
")",
";",
"$",
"sizeinfo",
"->",
"total",
"=",
"number_format",
"(",
"$",
"backupfile",
"->",
"get_filesize",
"(",
")",
"/",
"1000000",
",",
"2",
")",
";",
"$",
"html",
"=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"get_string",
"(",
"'sendingsize'",
",",
"'hub'",
",",
"$",
"sizeinfo",
")",
",",
"array",
"(",
"'class'",
"=>",
"'courseuploadtextinfo'",
")",
")",
";",
"return",
"$",
"html",
";",
"}"
] |
Display waiting information about backup size during uploading backup process
@param object $backupfile the backup stored_file
@return $html string
|
[
"Display",
"waiting",
"information",
"about",
"backup",
"size",
"during",
"uploading",
"backup",
"process"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2235-L2241
|
219,775
|
moodle/moodle
|
course/renderer.php
|
core_course_renderer.sentbackupinfo
|
public function sentbackupinfo($id) {
$html = html_writer::tag('div', get_string('sent', 'hub'),
array('class' => 'courseuploadtextinfo'));
$publishindexurl = new moodle_url('/course/publish/index.php',
array('sesskey' => sesskey(), 'id' => $id,
'published' => true));
$continue = $this->output->render(
new single_button($publishindexurl, get_string('continue')));
$html .= html_writer::tag('div', $continue, array('class' => 'sharecoursecontinue'));
return $html;
}
|
php
|
public function sentbackupinfo($id) {
$html = html_writer::tag('div', get_string('sent', 'hub'),
array('class' => 'courseuploadtextinfo'));
$publishindexurl = new moodle_url('/course/publish/index.php',
array('sesskey' => sesskey(), 'id' => $id,
'published' => true));
$continue = $this->output->render(
new single_button($publishindexurl, get_string('continue')));
$html .= html_writer::tag('div', $continue, array('class' => 'sharecoursecontinue'));
return $html;
}
|
[
"public",
"function",
"sentbackupinfo",
"(",
"$",
"id",
")",
"{",
"$",
"html",
"=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"get_string",
"(",
"'sent'",
",",
"'hub'",
")",
",",
"array",
"(",
"'class'",
"=>",
"'courseuploadtextinfo'",
")",
")",
";",
"$",
"publishindexurl",
"=",
"new",
"moodle_url",
"(",
"'/course/publish/index.php'",
",",
"array",
"(",
"'sesskey'",
"=>",
"sesskey",
"(",
")",
",",
"'id'",
"=>",
"$",
"id",
",",
"'published'",
"=>",
"true",
")",
")",
";",
"$",
"continue",
"=",
"$",
"this",
"->",
"output",
"->",
"render",
"(",
"new",
"single_button",
"(",
"$",
"publishindexurl",
",",
"get_string",
"(",
"'continue'",
")",
")",
")",
";",
"$",
"html",
".=",
"html_writer",
"::",
"tag",
"(",
"'div'",
",",
"$",
"continue",
",",
"array",
"(",
"'class'",
"=>",
"'sharecoursecontinue'",
")",
")",
";",
"return",
"$",
"html",
";",
"}"
] |
Display upload successfull message and a button to the publish index page
@param int $id the course id
@return $html string
|
[
"Display",
"upload",
"successfull",
"message",
"and",
"a",
"button",
"to",
"the",
"publish",
"index",
"page"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2248-L2258
|
219,776
|
moodle/moodle
|
course/renderer.php
|
coursecat_helper.set_courses_display_options
|
public function set_courses_display_options($options) {
$this->coursesdisplayoptions = $options;
$this->set_show_courses($this->showcourses); // this will calculate special display options
return $this;
}
|
php
|
public function set_courses_display_options($options) {
$this->coursesdisplayoptions = $options;
$this->set_show_courses($this->showcourses); // this will calculate special display options
return $this;
}
|
[
"public",
"function",
"set_courses_display_options",
"(",
"$",
"options",
")",
"{",
"$",
"this",
"->",
"coursesdisplayoptions",
"=",
"$",
"options",
";",
"$",
"this",
"->",
"set_show_courses",
"(",
"$",
"this",
"->",
"showcourses",
")",
";",
"// this will calculate special display options",
"return",
"$",
"this",
";",
"}"
] |
Sets options to display list of courses
Options are later submitted as argument to core_course_category::get_courses() and/or core_course_category::search_courses()
Options that core_course_category::get_courses() accept:
- recursive - return courses from subcategories as well. Use with care,
this may be a huge list!
- summary - preloads fields 'summary' and 'summaryformat'
- coursecontacts - preloads course contacts
- customfields - preloads custom fields data
- isenrolled - preloads indication whether this user is enrolled in the course
- sort - list of fields to sort. Example
array('idnumber' => 1, 'shortname' => 1, 'id' => -1)
will sort by idnumber asc, shortname asc and id desc.
Default: array('sortorder' => 1)
Only cached fields may be used for sorting!
- offset
- limit - maximum number of children to return, 0 or null for no limit
Options summary and coursecontacts are filled automatically in the set_show_courses()
Also renderer can set here any additional options it wants to pass between renderer functions.
@param array $options
@return coursecat_helper
|
[
"Sets",
"options",
"to",
"display",
"list",
"of",
"courses"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2592-L2596
|
219,777
|
moodle/moodle
|
course/renderer.php
|
coursecat_helper.get_courses_display_option
|
public function get_courses_display_option($optionname, $defaultvalue = null) {
if (array_key_exists($optionname, $this->coursesdisplayoptions)) {
return $this->coursesdisplayoptions[$optionname];
} else {
return $defaultvalue;
}
}
|
php
|
public function get_courses_display_option($optionname, $defaultvalue = null) {
if (array_key_exists($optionname, $this->coursesdisplayoptions)) {
return $this->coursesdisplayoptions[$optionname];
} else {
return $defaultvalue;
}
}
|
[
"public",
"function",
"get_courses_display_option",
"(",
"$",
"optionname",
",",
"$",
"defaultvalue",
"=",
"null",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"optionname",
",",
"$",
"this",
"->",
"coursesdisplayoptions",
")",
")",
"{",
"return",
"$",
"this",
"->",
"coursesdisplayoptions",
"[",
"$",
"optionname",
"]",
";",
"}",
"else",
"{",
"return",
"$",
"defaultvalue",
";",
"}",
"}"
] |
Return the specified option to display list of courses
@param string $optionname option name
@param mixed $defaultvalue default value for option if it is not specified
@return mixed
|
[
"Return",
"the",
"specified",
"option",
"to",
"display",
"list",
"of",
"courses"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2619-L2625
|
219,778
|
moodle/moodle
|
course/renderer.php
|
coursecat_helper.get_categories_display_option
|
public function get_categories_display_option($optionname, $defaultvalue = null) {
if (array_key_exists($optionname, $this->categoriesdisplayoptions)) {
return $this->categoriesdisplayoptions[$optionname];
} else {
return $defaultvalue;
}
}
|
php
|
public function get_categories_display_option($optionname, $defaultvalue = null) {
if (array_key_exists($optionname, $this->categoriesdisplayoptions)) {
return $this->categoriesdisplayoptions[$optionname];
} else {
return $defaultvalue;
}
}
|
[
"public",
"function",
"get_categories_display_option",
"(",
"$",
"optionname",
",",
"$",
"defaultvalue",
"=",
"null",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"optionname",
",",
"$",
"this",
"->",
"categoriesdisplayoptions",
")",
")",
"{",
"return",
"$",
"this",
"->",
"categoriesdisplayoptions",
"[",
"$",
"optionname",
"]",
";",
"}",
"else",
"{",
"return",
"$",
"defaultvalue",
";",
"}",
"}"
] |
Return the specified option to display list of subcategories
@param string $optionname option name
@param mixed $defaultvalue default value for option if it is not specified
@return mixed
|
[
"Return",
"the",
"specified",
"option",
"to",
"display",
"list",
"of",
"subcategories"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2660-L2666
|
219,779
|
moodle/moodle
|
course/renderer.php
|
coursecat_helper.get_and_erase_attributes
|
public function get_and_erase_attributes($classname) {
$attributes = $this->attributes;
$this->attributes = array();
if (empty($attributes['class'])) {
$attributes['class'] = '';
}
$attributes['class'] = $classname . ' '. $attributes['class'];
return $attributes;
}
|
php
|
public function get_and_erase_attributes($classname) {
$attributes = $this->attributes;
$this->attributes = array();
if (empty($attributes['class'])) {
$attributes['class'] = '';
}
$attributes['class'] = $classname . ' '. $attributes['class'];
return $attributes;
}
|
[
"public",
"function",
"get_and_erase_attributes",
"(",
"$",
"classname",
")",
"{",
"$",
"attributes",
"=",
"$",
"this",
"->",
"attributes",
";",
"$",
"this",
"->",
"attributes",
"=",
"array",
"(",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"attributes",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"''",
";",
"}",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"$",
"classname",
".",
"' '",
".",
"$",
"attributes",
"[",
"'class'",
"]",
";",
"return",
"$",
"attributes",
";",
"}"
] |
Return all attributes and erases them so they are not applied again
@param string $classname adds additional class name to the beginning of $attributes['class']
@return array
|
[
"Return",
"all",
"attributes",
"and",
"erases",
"them",
"so",
"they",
"are",
"not",
"applied",
"again"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2696-L2704
|
219,780
|
moodle/moodle
|
course/renderer.php
|
coursecat_helper.get_category_formatted_description
|
public function get_category_formatted_description($coursecat, $options = null) {
if ($coursecat->id && $coursecat->is_uservisible() && !empty($coursecat->description)) {
if (!isset($coursecat->descriptionformat)) {
$descriptionformat = FORMAT_MOODLE;
} else {
$descriptionformat = $coursecat->descriptionformat;
}
if ($options === null) {
$options = array('noclean' => true, 'overflowdiv' => true);
} else {
$options = (array)$options;
}
$context = context_coursecat::instance($coursecat->id);
if (!isset($options['context'])) {
$options['context'] = $context;
}
$text = file_rewrite_pluginfile_urls($coursecat->description,
'pluginfile.php', $context->id, 'coursecat', 'description', null);
return format_text($text, $descriptionformat, $options);
}
return null;
}
|
php
|
public function get_category_formatted_description($coursecat, $options = null) {
if ($coursecat->id && $coursecat->is_uservisible() && !empty($coursecat->description)) {
if (!isset($coursecat->descriptionformat)) {
$descriptionformat = FORMAT_MOODLE;
} else {
$descriptionformat = $coursecat->descriptionformat;
}
if ($options === null) {
$options = array('noclean' => true, 'overflowdiv' => true);
} else {
$options = (array)$options;
}
$context = context_coursecat::instance($coursecat->id);
if (!isset($options['context'])) {
$options['context'] = $context;
}
$text = file_rewrite_pluginfile_urls($coursecat->description,
'pluginfile.php', $context->id, 'coursecat', 'description', null);
return format_text($text, $descriptionformat, $options);
}
return null;
}
|
[
"public",
"function",
"get_category_formatted_description",
"(",
"$",
"coursecat",
",",
"$",
"options",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"coursecat",
"->",
"id",
"&&",
"$",
"coursecat",
"->",
"is_uservisible",
"(",
")",
"&&",
"!",
"empty",
"(",
"$",
"coursecat",
"->",
"description",
")",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"coursecat",
"->",
"descriptionformat",
")",
")",
"{",
"$",
"descriptionformat",
"=",
"FORMAT_MOODLE",
";",
"}",
"else",
"{",
"$",
"descriptionformat",
"=",
"$",
"coursecat",
"->",
"descriptionformat",
";",
"}",
"if",
"(",
"$",
"options",
"===",
"null",
")",
"{",
"$",
"options",
"=",
"array",
"(",
"'noclean'",
"=>",
"true",
",",
"'overflowdiv'",
"=>",
"true",
")",
";",
"}",
"else",
"{",
"$",
"options",
"=",
"(",
"array",
")",
"$",
"options",
";",
"}",
"$",
"context",
"=",
"context_coursecat",
"::",
"instance",
"(",
"$",
"coursecat",
"->",
"id",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'context'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'context'",
"]",
"=",
"$",
"context",
";",
"}",
"$",
"text",
"=",
"file_rewrite_pluginfile_urls",
"(",
"$",
"coursecat",
"->",
"description",
",",
"'pluginfile.php'",
",",
"$",
"context",
"->",
"id",
",",
"'coursecat'",
",",
"'description'",
",",
"null",
")",
";",
"return",
"format_text",
"(",
"$",
"text",
",",
"$",
"descriptionformat",
",",
"$",
"options",
")",
";",
"}",
"return",
"null",
";",
"}"
] |
Returns formatted and filtered description of the given category
@param core_course_category $coursecat category
@param stdClass|array $options format options, by default [noclean,overflowdiv],
if context is not specified it will be added automatically
@return string|null
|
[
"Returns",
"formatted",
"and",
"filtered",
"description",
"of",
"the",
"given",
"category"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2727-L2748
|
219,781
|
moodle/moodle
|
course/renderer.php
|
coursecat_helper.get_course_formatted_summary
|
public function get_course_formatted_summary($course, $options = array()) {
global $CFG;
require_once($CFG->libdir. '/filelib.php');
if (!$course->has_summary()) {
return '';
}
$options = (array)$options;
$context = context_course::instance($course->id);
if (!isset($options['context'])) {
// TODO see MDL-38521
// option 1 (current), page context - no code required
// option 2, system context
// $options['context'] = context_system::instance();
// option 3, course context:
// $options['context'] = $context;
// option 4, course category context:
// $options['context'] = $context->get_parent_context();
}
$summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', null);
$summary = format_text($summary, $course->summaryformat, $options, $course->id);
if (!empty($this->searchcriteria['search'])) {
$summary = highlight($this->searchcriteria['search'], $summary);
}
return $summary;
}
|
php
|
public function get_course_formatted_summary($course, $options = array()) {
global $CFG;
require_once($CFG->libdir. '/filelib.php');
if (!$course->has_summary()) {
return '';
}
$options = (array)$options;
$context = context_course::instance($course->id);
if (!isset($options['context'])) {
// TODO see MDL-38521
// option 1 (current), page context - no code required
// option 2, system context
// $options['context'] = context_system::instance();
// option 3, course context:
// $options['context'] = $context;
// option 4, course category context:
// $options['context'] = $context->get_parent_context();
}
$summary = file_rewrite_pluginfile_urls($course->summary, 'pluginfile.php', $context->id, 'course', 'summary', null);
$summary = format_text($summary, $course->summaryformat, $options, $course->id);
if (!empty($this->searchcriteria['search'])) {
$summary = highlight($this->searchcriteria['search'], $summary);
}
return $summary;
}
|
[
"public",
"function",
"get_course_formatted_summary",
"(",
"$",
"course",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"global",
"$",
"CFG",
";",
"require_once",
"(",
"$",
"CFG",
"->",
"libdir",
".",
"'/filelib.php'",
")",
";",
"if",
"(",
"!",
"$",
"course",
"->",
"has_summary",
"(",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"options",
"=",
"(",
"array",
")",
"$",
"options",
";",
"$",
"context",
"=",
"context_course",
"::",
"instance",
"(",
"$",
"course",
"->",
"id",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'context'",
"]",
")",
")",
"{",
"// TODO see MDL-38521",
"// option 1 (current), page context - no code required",
"// option 2, system context",
"// $options['context'] = context_system::instance();",
"// option 3, course context:",
"// $options['context'] = $context;",
"// option 4, course category context:",
"// $options['context'] = $context->get_parent_context();",
"}",
"$",
"summary",
"=",
"file_rewrite_pluginfile_urls",
"(",
"$",
"course",
"->",
"summary",
",",
"'pluginfile.php'",
",",
"$",
"context",
"->",
"id",
",",
"'course'",
",",
"'summary'",
",",
"null",
")",
";",
"$",
"summary",
"=",
"format_text",
"(",
"$",
"summary",
",",
"$",
"course",
"->",
"summaryformat",
",",
"$",
"options",
",",
"$",
"course",
"->",
"id",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"searchcriteria",
"[",
"'search'",
"]",
")",
")",
"{",
"$",
"summary",
"=",
"highlight",
"(",
"$",
"this",
"->",
"searchcriteria",
"[",
"'search'",
"]",
",",
"$",
"summary",
")",
";",
"}",
"return",
"$",
"summary",
";",
"}"
] |
Returns given course's summary with proper embedded files urls and formatted
@param core_course_list_element $course
@param array|stdClass $options additional formatting options
@return string
|
[
"Returns",
"given",
"course",
"s",
"summary",
"with",
"proper",
"embedded",
"files",
"urls",
"and",
"formatted"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2757-L2781
|
219,782
|
moodle/moodle
|
course/renderer.php
|
coursecat_helper.get_course_formatted_name
|
public function get_course_formatted_name($course, $options = array()) {
$options = (array)$options;
if (!isset($options['context'])) {
$options['context'] = context_course::instance($course->id);
}
$name = format_string(get_course_display_name_for_list($course), true, $options);
if (!empty($this->searchcriteria['search'])) {
$name = highlight($this->searchcriteria['search'], $name);
}
return $name;
}
|
php
|
public function get_course_formatted_name($course, $options = array()) {
$options = (array)$options;
if (!isset($options['context'])) {
$options['context'] = context_course::instance($course->id);
}
$name = format_string(get_course_display_name_for_list($course), true, $options);
if (!empty($this->searchcriteria['search'])) {
$name = highlight($this->searchcriteria['search'], $name);
}
return $name;
}
|
[
"public",
"function",
"get_course_formatted_name",
"(",
"$",
"course",
",",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"options",
"=",
"(",
"array",
")",
"$",
"options",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'context'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'context'",
"]",
"=",
"context_course",
"::",
"instance",
"(",
"$",
"course",
"->",
"id",
")",
";",
"}",
"$",
"name",
"=",
"format_string",
"(",
"get_course_display_name_for_list",
"(",
"$",
"course",
")",
",",
"true",
",",
"$",
"options",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"searchcriteria",
"[",
"'search'",
"]",
")",
")",
"{",
"$",
"name",
"=",
"highlight",
"(",
"$",
"this",
"->",
"searchcriteria",
"[",
"'search'",
"]",
",",
"$",
"name",
")",
";",
"}",
"return",
"$",
"name",
";",
"}"
] |
Returns course name as it is configured to appear in courses lists formatted to course context
@param core_course_list_element $course
@param array|stdClass $options additional formatting options
@return string
|
[
"Returns",
"course",
"name",
"as",
"it",
"is",
"configured",
"to",
"appear",
"in",
"courses",
"lists",
"formatted",
"to",
"course",
"context"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/course/renderer.php#L2790-L2800
|
219,783
|
moodle/moodle
|
lib/outputcomponents.php
|
user_picture.fields
|
public static function fields($tableprefix = '', array $extrafields = NULL, $idalias = 'id', $fieldprefix = '') {
if (!$tableprefix and !$extrafields and !$idalias) {
return implode(',', self::$fields);
}
if ($tableprefix) {
$tableprefix .= '.';
}
foreach (self::$fields as $field) {
if ($field === 'id' and $idalias and $idalias !== 'id') {
$fields[$field] = "$tableprefix$field AS $idalias";
} else {
if ($fieldprefix and $field !== 'id') {
$fields[$field] = "$tableprefix$field AS $fieldprefix$field";
} else {
$fields[$field] = "$tableprefix$field";
}
}
}
// add extra fields if not already there
if ($extrafields) {
foreach ($extrafields as $e) {
if ($e === 'id' or isset($fields[$e])) {
continue;
}
if ($fieldprefix) {
$fields[$e] = "$tableprefix$e AS $fieldprefix$e";
} else {
$fields[$e] = "$tableprefix$e";
}
}
}
return implode(',', $fields);
}
|
php
|
public static function fields($tableprefix = '', array $extrafields = NULL, $idalias = 'id', $fieldprefix = '') {
if (!$tableprefix and !$extrafields and !$idalias) {
return implode(',', self::$fields);
}
if ($tableprefix) {
$tableprefix .= '.';
}
foreach (self::$fields as $field) {
if ($field === 'id' and $idalias and $idalias !== 'id') {
$fields[$field] = "$tableprefix$field AS $idalias";
} else {
if ($fieldprefix and $field !== 'id') {
$fields[$field] = "$tableprefix$field AS $fieldprefix$field";
} else {
$fields[$field] = "$tableprefix$field";
}
}
}
// add extra fields if not already there
if ($extrafields) {
foreach ($extrafields as $e) {
if ($e === 'id' or isset($fields[$e])) {
continue;
}
if ($fieldprefix) {
$fields[$e] = "$tableprefix$e AS $fieldprefix$e";
} else {
$fields[$e] = "$tableprefix$e";
}
}
}
return implode(',', $fields);
}
|
[
"public",
"static",
"function",
"fields",
"(",
"$",
"tableprefix",
"=",
"''",
",",
"array",
"$",
"extrafields",
"=",
"NULL",
",",
"$",
"idalias",
"=",
"'id'",
",",
"$",
"fieldprefix",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"tableprefix",
"and",
"!",
"$",
"extrafields",
"and",
"!",
"$",
"idalias",
")",
"{",
"return",
"implode",
"(",
"','",
",",
"self",
"::",
"$",
"fields",
")",
";",
"}",
"if",
"(",
"$",
"tableprefix",
")",
"{",
"$",
"tableprefix",
".=",
"'.'",
";",
"}",
"foreach",
"(",
"self",
"::",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"===",
"'id'",
"and",
"$",
"idalias",
"and",
"$",
"idalias",
"!==",
"'id'",
")",
"{",
"$",
"fields",
"[",
"$",
"field",
"]",
"=",
"\"$tableprefix$field AS $idalias\"",
";",
"}",
"else",
"{",
"if",
"(",
"$",
"fieldprefix",
"and",
"$",
"field",
"!==",
"'id'",
")",
"{",
"$",
"fields",
"[",
"$",
"field",
"]",
"=",
"\"$tableprefix$field AS $fieldprefix$field\"",
";",
"}",
"else",
"{",
"$",
"fields",
"[",
"$",
"field",
"]",
"=",
"\"$tableprefix$field\"",
";",
"}",
"}",
"}",
"// add extra fields if not already there",
"if",
"(",
"$",
"extrafields",
")",
"{",
"foreach",
"(",
"$",
"extrafields",
"as",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"===",
"'id'",
"or",
"isset",
"(",
"$",
"fields",
"[",
"$",
"e",
"]",
")",
")",
"{",
"continue",
";",
"}",
"if",
"(",
"$",
"fieldprefix",
")",
"{",
"$",
"fields",
"[",
"$",
"e",
"]",
"=",
"\"$tableprefix$e AS $fieldprefix$e\"",
";",
"}",
"else",
"{",
"$",
"fields",
"[",
"$",
"e",
"]",
"=",
"\"$tableprefix$e\"",
";",
"}",
"}",
"}",
"return",
"implode",
"(",
"','",
",",
"$",
"fields",
")",
";",
"}"
] |
Returns a list of required user fields, useful when fetching required user info from db.
In some cases we have to fetch the user data together with some other information,
the idalias is useful there because the id would otherwise override the main
id of the result record. Please note it has to be converted back to id before rendering.
@param string $tableprefix name of database table prefix in query
@param array $extrafields extra fields to be included in result (do not include TEXT columns because it would break SELECT DISTINCT in MSSQL and ORACLE)
@param string $idalias alias of id field
@param string $fieldprefix prefix to add to all columns in their aliases, does not apply to 'id'
@return string
|
[
"Returns",
"a",
"list",
"of",
"required",
"user",
"fields",
"useful",
"when",
"fetching",
"required",
"user",
"info",
"from",
"db",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L259-L291
|
219,784
|
moodle/moodle
|
lib/outputcomponents.php
|
user_picture.unalias
|
public static function unalias(stdClass $record, array $extrafields = null, $idalias = 'id', $fieldprefix = '') {
if (empty($idalias)) {
$idalias = 'id';
}
$return = new stdClass();
foreach (self::$fields as $field) {
if ($field === 'id') {
if (property_exists($record, $idalias)) {
$return->id = $record->{$idalias};
}
} else {
if (property_exists($record, $fieldprefix.$field)) {
$return->{$field} = $record->{$fieldprefix.$field};
}
}
}
// add extra fields if not already there
if ($extrafields) {
foreach ($extrafields as $e) {
if ($e === 'id' or property_exists($return, $e)) {
continue;
}
$return->{$e} = $record->{$fieldprefix.$e};
}
}
return $return;
}
|
php
|
public static function unalias(stdClass $record, array $extrafields = null, $idalias = 'id', $fieldprefix = '') {
if (empty($idalias)) {
$idalias = 'id';
}
$return = new stdClass();
foreach (self::$fields as $field) {
if ($field === 'id') {
if (property_exists($record, $idalias)) {
$return->id = $record->{$idalias};
}
} else {
if (property_exists($record, $fieldprefix.$field)) {
$return->{$field} = $record->{$fieldprefix.$field};
}
}
}
// add extra fields if not already there
if ($extrafields) {
foreach ($extrafields as $e) {
if ($e === 'id' or property_exists($return, $e)) {
continue;
}
$return->{$e} = $record->{$fieldprefix.$e};
}
}
return $return;
}
|
[
"public",
"static",
"function",
"unalias",
"(",
"stdClass",
"$",
"record",
",",
"array",
"$",
"extrafields",
"=",
"null",
",",
"$",
"idalias",
"=",
"'id'",
",",
"$",
"fieldprefix",
"=",
"''",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"idalias",
")",
")",
"{",
"$",
"idalias",
"=",
"'id'",
";",
"}",
"$",
"return",
"=",
"new",
"stdClass",
"(",
")",
";",
"foreach",
"(",
"self",
"::",
"$",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"===",
"'id'",
")",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"record",
",",
"$",
"idalias",
")",
")",
"{",
"$",
"return",
"->",
"id",
"=",
"$",
"record",
"->",
"{",
"$",
"idalias",
"}",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"property_exists",
"(",
"$",
"record",
",",
"$",
"fieldprefix",
".",
"$",
"field",
")",
")",
"{",
"$",
"return",
"->",
"{",
"$",
"field",
"}",
"=",
"$",
"record",
"->",
"{",
"$",
"fieldprefix",
".",
"$",
"field",
"}",
";",
"}",
"}",
"}",
"// add extra fields if not already there",
"if",
"(",
"$",
"extrafields",
")",
"{",
"foreach",
"(",
"$",
"extrafields",
"as",
"$",
"e",
")",
"{",
"if",
"(",
"$",
"e",
"===",
"'id'",
"or",
"property_exists",
"(",
"$",
"return",
",",
"$",
"e",
")",
")",
"{",
"continue",
";",
"}",
"$",
"return",
"->",
"{",
"$",
"e",
"}",
"=",
"$",
"record",
"->",
"{",
"$",
"fieldprefix",
".",
"$",
"e",
"}",
";",
"}",
"}",
"return",
"$",
"return",
";",
"}"
] |
Extract the aliased user fields from a given record
Given a record that was previously obtained using {@link self::fields()} with aliases,
this method extracts user related unaliased fields.
@param stdClass $record containing user picture fields
@param array $extrafields extra fields included in the $record
@param string $idalias alias of the id field
@param string $fieldprefix prefix added to all columns in their aliases, does not apply to 'id'
@return stdClass object with unaliased user fields
|
[
"Extract",
"the",
"aliased",
"user",
"fields",
"from",
"a",
"given",
"record"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L305-L335
|
219,785
|
moodle/moodle
|
lib/outputcomponents.php
|
help_icon.diag_strings
|
public function diag_strings() {
$sm = get_string_manager();
if (!$sm->string_exists($this->identifier, $this->component)) {
debugging("Help title string does not exist: [$this->identifier, $this->component]");
}
if (!$sm->string_exists($this->identifier.'_help', $this->component)) {
debugging("Help contents string does not exist: [{$this->identifier}_help, $this->component]");
}
}
|
php
|
public function diag_strings() {
$sm = get_string_manager();
if (!$sm->string_exists($this->identifier, $this->component)) {
debugging("Help title string does not exist: [$this->identifier, $this->component]");
}
if (!$sm->string_exists($this->identifier.'_help', $this->component)) {
debugging("Help contents string does not exist: [{$this->identifier}_help, $this->component]");
}
}
|
[
"public",
"function",
"diag_strings",
"(",
")",
"{",
"$",
"sm",
"=",
"get_string_manager",
"(",
")",
";",
"if",
"(",
"!",
"$",
"sm",
"->",
"string_exists",
"(",
"$",
"this",
"->",
"identifier",
",",
"$",
"this",
"->",
"component",
")",
")",
"{",
"debugging",
"(",
"\"Help title string does not exist: [$this->identifier, $this->component]\"",
")",
";",
"}",
"if",
"(",
"!",
"$",
"sm",
"->",
"string_exists",
"(",
"$",
"this",
"->",
"identifier",
".",
"'_help'",
",",
"$",
"this",
"->",
"component",
")",
")",
"{",
"debugging",
"(",
"\"Help contents string does not exist: [{$this->identifier}_help, $this->component]\"",
")",
";",
"}",
"}"
] |
Verifies that both help strings exists, shows debug warnings if not
|
[
"Verifies",
"that",
"both",
"help",
"strings",
"exists",
"shows",
"debug",
"warnings",
"if",
"not"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L496-L504
|
219,786
|
moodle/moodle
|
lib/outputcomponents.php
|
pix_icon.export_for_pix
|
public function export_for_pix() {
$title = isset($this->attributes['title']) ? $this->attributes['title'] : '';
if (empty($title)) {
$title = isset($this->attributes['alt']) ? $this->attributes['alt'] : '';
}
return [
'key' => $this->pix,
'component' => $this->component,
'title' => $title
];
}
|
php
|
public function export_for_pix() {
$title = isset($this->attributes['title']) ? $this->attributes['title'] : '';
if (empty($title)) {
$title = isset($this->attributes['alt']) ? $this->attributes['alt'] : '';
}
return [
'key' => $this->pix,
'component' => $this->component,
'title' => $title
];
}
|
[
"public",
"function",
"export_for_pix",
"(",
")",
"{",
"$",
"title",
"=",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'title'",
"]",
")",
"?",
"$",
"this",
"->",
"attributes",
"[",
"'title'",
"]",
":",
"''",
";",
"if",
"(",
"empty",
"(",
"$",
"title",
")",
")",
"{",
"$",
"title",
"=",
"isset",
"(",
"$",
"this",
"->",
"attributes",
"[",
"'alt'",
"]",
")",
"?",
"$",
"this",
"->",
"attributes",
"[",
"'alt'",
"]",
":",
"''",
";",
"}",
"return",
"[",
"'key'",
"=>",
"$",
"this",
"->",
"pix",
",",
"'component'",
"=>",
"$",
"this",
"->",
"component",
",",
"'title'",
"=>",
"$",
"title",
"]",
";",
"}"
] |
Much simpler version of export that will produce the data required to render this pix with the
pix helper in a mustache tag.
@return array
|
[
"Much",
"simpler",
"version",
"of",
"export",
"that",
"will",
"produce",
"the",
"data",
"required",
"to",
"render",
"this",
"pix",
"with",
"the",
"pix",
"helper",
"in",
"a",
"mustache",
"tag",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L753-L763
|
219,787
|
moodle/moodle
|
lib/outputcomponents.php
|
url_select.clean_url
|
protected function clean_url($value) {
global $CFG;
if (empty($value)) {
// Nothing.
} else if (strpos($value, $CFG->wwwroot . '/') === 0) {
$value = str_replace($CFG->wwwroot, '', $value);
} else if (strpos($value, '/') !== 0) {
debugging("Invalid url_select urls parameter: url '$value' is not local relative url!", DEBUG_DEVELOPER);
}
return $value;
}
|
php
|
protected function clean_url($value) {
global $CFG;
if (empty($value)) {
// Nothing.
} else if (strpos($value, $CFG->wwwroot . '/') === 0) {
$value = str_replace($CFG->wwwroot, '', $value);
} else if (strpos($value, '/') !== 0) {
debugging("Invalid url_select urls parameter: url '$value' is not local relative url!", DEBUG_DEVELOPER);
}
return $value;
}
|
[
"protected",
"function",
"clean_url",
"(",
"$",
"value",
")",
"{",
"global",
"$",
"CFG",
";",
"if",
"(",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"// Nothing.",
"}",
"else",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"$",
"CFG",
"->",
"wwwroot",
".",
"'/'",
")",
"===",
"0",
")",
"{",
"$",
"value",
"=",
"str_replace",
"(",
"$",
"CFG",
"->",
"wwwroot",
",",
"''",
",",
"$",
"value",
")",
";",
"}",
"else",
"if",
"(",
"strpos",
"(",
"$",
"value",
",",
"'/'",
")",
"!==",
"0",
")",
"{",
"debugging",
"(",
"\"Invalid url_select urls parameter: url '$value' is not local relative url!\"",
",",
"DEBUG_DEVELOPER",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
] |
Clean a URL.
@param string $value The URL.
@return The cleaned URL.
|
[
"Clean",
"a",
"URL",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L1341-L1355
|
219,788
|
moodle/moodle
|
lib/outputcomponents.php
|
url_select.flatten_options
|
protected function flatten_options($options, $nothing) {
$flattened = [];
foreach ($options as $value => $option) {
if (is_array($option)) {
foreach ($option as $groupname => $optoptions) {
if (!isset($flattened[$groupname])) {
$flattened[$groupname] = [
'name' => $groupname,
'isgroup' => true,
'options' => []
];
}
foreach ($optoptions as $optvalue => $optoption) {
$cleanedvalue = $this->clean_url($optvalue);
$flattened[$groupname]['options'][$cleanedvalue] = [
'name' => $optoption,
'value' => $cleanedvalue,
'selected' => $this->selected == $optvalue,
];
}
}
} else {
$cleanedvalue = $this->clean_url($value);
$flattened[$cleanedvalue] = [
'name' => $option,
'value' => $cleanedvalue,
'selected' => $this->selected == $value,
];
}
}
if (!empty($nothing)) {
$value = key($nothing);
$name = reset($nothing);
$flattened = [
$value => ['name' => $name, 'value' => $value, 'selected' => $this->selected == $value]
] + $flattened;
}
// Make non-associative array.
foreach ($flattened as $key => $value) {
if (!empty($value['options'])) {
$flattened[$key]['options'] = array_values($value['options']);
}
}
$flattened = array_values($flattened);
return $flattened;
}
|
php
|
protected function flatten_options($options, $nothing) {
$flattened = [];
foreach ($options as $value => $option) {
if (is_array($option)) {
foreach ($option as $groupname => $optoptions) {
if (!isset($flattened[$groupname])) {
$flattened[$groupname] = [
'name' => $groupname,
'isgroup' => true,
'options' => []
];
}
foreach ($optoptions as $optvalue => $optoption) {
$cleanedvalue = $this->clean_url($optvalue);
$flattened[$groupname]['options'][$cleanedvalue] = [
'name' => $optoption,
'value' => $cleanedvalue,
'selected' => $this->selected == $optvalue,
];
}
}
} else {
$cleanedvalue = $this->clean_url($value);
$flattened[$cleanedvalue] = [
'name' => $option,
'value' => $cleanedvalue,
'selected' => $this->selected == $value,
];
}
}
if (!empty($nothing)) {
$value = key($nothing);
$name = reset($nothing);
$flattened = [
$value => ['name' => $name, 'value' => $value, 'selected' => $this->selected == $value]
] + $flattened;
}
// Make non-associative array.
foreach ($flattened as $key => $value) {
if (!empty($value['options'])) {
$flattened[$key]['options'] = array_values($value['options']);
}
}
$flattened = array_values($flattened);
return $flattened;
}
|
[
"protected",
"function",
"flatten_options",
"(",
"$",
"options",
",",
"$",
"nothing",
")",
"{",
"$",
"flattened",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"value",
"=>",
"$",
"option",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"option",
")",
")",
"{",
"foreach",
"(",
"$",
"option",
"as",
"$",
"groupname",
"=>",
"$",
"optoptions",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"flattened",
"[",
"$",
"groupname",
"]",
")",
")",
"{",
"$",
"flattened",
"[",
"$",
"groupname",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"groupname",
",",
"'isgroup'",
"=>",
"true",
",",
"'options'",
"=>",
"[",
"]",
"]",
";",
"}",
"foreach",
"(",
"$",
"optoptions",
"as",
"$",
"optvalue",
"=>",
"$",
"optoption",
")",
"{",
"$",
"cleanedvalue",
"=",
"$",
"this",
"->",
"clean_url",
"(",
"$",
"optvalue",
")",
";",
"$",
"flattened",
"[",
"$",
"groupname",
"]",
"[",
"'options'",
"]",
"[",
"$",
"cleanedvalue",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"optoption",
",",
"'value'",
"=>",
"$",
"cleanedvalue",
",",
"'selected'",
"=>",
"$",
"this",
"->",
"selected",
"==",
"$",
"optvalue",
",",
"]",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"cleanedvalue",
"=",
"$",
"this",
"->",
"clean_url",
"(",
"$",
"value",
")",
";",
"$",
"flattened",
"[",
"$",
"cleanedvalue",
"]",
"=",
"[",
"'name'",
"=>",
"$",
"option",
",",
"'value'",
"=>",
"$",
"cleanedvalue",
",",
"'selected'",
"=>",
"$",
"this",
"->",
"selected",
"==",
"$",
"value",
",",
"]",
";",
"}",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"nothing",
")",
")",
"{",
"$",
"value",
"=",
"key",
"(",
"$",
"nothing",
")",
";",
"$",
"name",
"=",
"reset",
"(",
"$",
"nothing",
")",
";",
"$",
"flattened",
"=",
"[",
"$",
"value",
"=>",
"[",
"'name'",
"=>",
"$",
"name",
",",
"'value'",
"=>",
"$",
"value",
",",
"'selected'",
"=>",
"$",
"this",
"->",
"selected",
"==",
"$",
"value",
"]",
"]",
"+",
"$",
"flattened",
";",
"}",
"// Make non-associative array.",
"foreach",
"(",
"$",
"flattened",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
"[",
"'options'",
"]",
")",
")",
"{",
"$",
"flattened",
"[",
"$",
"key",
"]",
"[",
"'options'",
"]",
"=",
"array_values",
"(",
"$",
"value",
"[",
"'options'",
"]",
")",
";",
"}",
"}",
"$",
"flattened",
"=",
"array_values",
"(",
"$",
"flattened",
")",
";",
"return",
"$",
"flattened",
";",
"}"
] |
Flatten the options for Mustache.
This also cleans the URLs.
@param array $options The options.
@param array $nothing The nothing option.
@return array
|
[
"Flatten",
"the",
"options",
"for",
"Mustache",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L1366-L1416
|
219,789
|
moodle/moodle
|
lib/outputcomponents.php
|
html_writer.tag
|
public static function tag($tagname, $contents, array $attributes = null) {
return self::start_tag($tagname, $attributes) . $contents . self::end_tag($tagname);
}
|
php
|
public static function tag($tagname, $contents, array $attributes = null) {
return self::start_tag($tagname, $attributes) . $contents . self::end_tag($tagname);
}
|
[
"public",
"static",
"function",
"tag",
"(",
"$",
"tagname",
",",
"$",
"contents",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"return",
"self",
"::",
"start_tag",
"(",
"$",
"tagname",
",",
"$",
"attributes",
")",
".",
"$",
"contents",
".",
"self",
"::",
"end_tag",
"(",
"$",
"tagname",
")",
";",
"}"
] |
Outputs a tag with attributes and contents
@param string $tagname The name of tag ('a', 'img', 'span' etc.)
@param string $contents What goes between the opening and closing tags
@param array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
@return string HTML fragment
|
[
"Outputs",
"a",
"tag",
"with",
"attributes",
"and",
"contents"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L1642-L1644
|
219,790
|
moodle/moodle
|
lib/outputcomponents.php
|
html_writer.nonempty_tag
|
public static function nonempty_tag($tagname, $contents, array $attributes = null) {
if ($contents === '' || is_null($contents)) {
return '';
}
return self::tag($tagname, $contents, $attributes);
}
|
php
|
public static function nonempty_tag($tagname, $contents, array $attributes = null) {
if ($contents === '' || is_null($contents)) {
return '';
}
return self::tag($tagname, $contents, $attributes);
}
|
[
"public",
"static",
"function",
"nonempty_tag",
"(",
"$",
"tagname",
",",
"$",
"contents",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"contents",
"===",
"''",
"||",
"is_null",
"(",
"$",
"contents",
")",
")",
"{",
"return",
"''",
";",
"}",
"return",
"self",
"::",
"tag",
"(",
"$",
"tagname",
",",
"$",
"contents",
",",
"$",
"attributes",
")",
";",
"}"
] |
Outputs a tag, but only if the contents are not empty
@param string $tagname The name of tag ('a', 'img', 'span' etc.)
@param string $contents What goes between the opening and closing tags
@param array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
@return string HTML fragment
|
[
"Outputs",
"a",
"tag",
"but",
"only",
"if",
"the",
"contents",
"are",
"not",
"empty"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L1686-L1691
|
219,791
|
moodle/moodle
|
lib/outputcomponents.php
|
html_writer.attribute
|
public static function attribute($name, $value) {
if ($value instanceof moodle_url) {
return ' ' . $name . '="' . $value->out() . '"';
}
// special case, we do not want these in output
if ($value === null) {
return '';
}
// no sloppy trimming here!
return ' ' . $name . '="' . s($value) . '"';
}
|
php
|
public static function attribute($name, $value) {
if ($value instanceof moodle_url) {
return ' ' . $name . '="' . $value->out() . '"';
}
// special case, we do not want these in output
if ($value === null) {
return '';
}
// no sloppy trimming here!
return ' ' . $name . '="' . s($value) . '"';
}
|
[
"public",
"static",
"function",
"attribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"value",
"instanceof",
"moodle_url",
")",
"{",
"return",
"' '",
".",
"$",
"name",
".",
"'=\"'",
".",
"$",
"value",
"->",
"out",
"(",
")",
".",
"'\"'",
";",
"}",
"// special case, we do not want these in output",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"''",
";",
"}",
"// no sloppy trimming here!",
"return",
"' '",
".",
"$",
"name",
".",
"'=\"'",
".",
"s",
"(",
"$",
"value",
")",
".",
"'\"'",
";",
"}"
] |
Outputs a HTML attribute and value
@param string $name The name of the attribute ('src', 'href', 'class' etc.)
@param string $value The value of the attribute. The value will be escaped with {@link s()}
@return string HTML fragment
|
[
"Outputs",
"a",
"HTML",
"attribute",
"and",
"value"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L1700-L1712
|
219,792
|
moodle/moodle
|
lib/outputcomponents.php
|
html_writer.attributes
|
public static function attributes(array $attributes = null) {
$attributes = (array)$attributes;
$output = '';
foreach ($attributes as $name => $value) {
$output .= self::attribute($name, $value);
}
return $output;
}
|
php
|
public static function attributes(array $attributes = null) {
$attributes = (array)$attributes;
$output = '';
foreach ($attributes as $name => $value) {
$output .= self::attribute($name, $value);
}
return $output;
}
|
[
"public",
"static",
"function",
"attributes",
"(",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"attributes",
"=",
"(",
"array",
")",
"$",
"attributes",
";",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"attributes",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"$",
"output",
".=",
"self",
"::",
"attribute",
"(",
"$",
"name",
",",
"$",
"value",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Outputs a list of HTML attributes and values
@param array $attributes The tag attributes (array('src' => $url, 'class' => 'class1') etc.)
The values will be escaped with {@link s()}
@return string HTML fragment
|
[
"Outputs",
"a",
"list",
"of",
"HTML",
"attributes",
"and",
"values"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L1721-L1728
|
219,793
|
moodle/moodle
|
lib/outputcomponents.php
|
html_writer.img
|
public static function img($src, $alt, array $attributes = null) {
$attributes = (array)$attributes;
$attributes['src'] = $src;
$attributes['alt'] = $alt;
return self::empty_tag('img', $attributes);
}
|
php
|
public static function img($src, $alt, array $attributes = null) {
$attributes = (array)$attributes;
$attributes['src'] = $src;
$attributes['alt'] = $alt;
return self::empty_tag('img', $attributes);
}
|
[
"public",
"static",
"function",
"img",
"(",
"$",
"src",
",",
"$",
"alt",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"attributes",
"=",
"(",
"array",
")",
"$",
"attributes",
";",
"$",
"attributes",
"[",
"'src'",
"]",
"=",
"$",
"src",
";",
"$",
"attributes",
"[",
"'alt'",
"]",
"=",
"$",
"alt",
";",
"return",
"self",
"::",
"empty_tag",
"(",
"'img'",
",",
"$",
"attributes",
")",
";",
"}"
] |
Generates a simple image tag with attributes.
@param string $src The source of image
@param string $alt The alternate text for image
@param array $attributes The tag attributes (array('height' => $max_height, 'class' => 'class1') etc.)
@return string HTML fragment
|
[
"Generates",
"a",
"simple",
"image",
"tag",
"with",
"attributes",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L1738-L1744
|
219,794
|
moodle/moodle
|
lib/outputcomponents.php
|
html_writer.random_id
|
public static function random_id($base='random') {
static $counter = 0;
static $uniq;
if (!isset($uniq)) {
$uniq = uniqid();
}
$counter++;
return $base.$uniq.$counter;
}
|
php
|
public static function random_id($base='random') {
static $counter = 0;
static $uniq;
if (!isset($uniq)) {
$uniq = uniqid();
}
$counter++;
return $base.$uniq.$counter;
}
|
[
"public",
"static",
"function",
"random_id",
"(",
"$",
"base",
"=",
"'random'",
")",
"{",
"static",
"$",
"counter",
"=",
"0",
";",
"static",
"$",
"uniq",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"uniq",
")",
")",
"{",
"$",
"uniq",
"=",
"uniqid",
"(",
")",
";",
"}",
"$",
"counter",
"++",
";",
"return",
"$",
"base",
".",
"$",
"uniq",
".",
"$",
"counter",
";",
"}"
] |
Generates random html element id.
@staticvar int $counter
@staticvar type $uniq
@param string $base A string fragment that will be included in the random ID.
@return string A unique ID
|
[
"Generates",
"random",
"html",
"element",
"id",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L1754-L1764
|
219,795
|
moodle/moodle
|
lib/outputcomponents.php
|
html_writer.link
|
public static function link($url, $text, array $attributes = null) {
$attributes = (array)$attributes;
$attributes['href'] = $url;
return self::tag('a', $text, $attributes);
}
|
php
|
public static function link($url, $text, array $attributes = null) {
$attributes = (array)$attributes;
$attributes['href'] = $url;
return self::tag('a', $text, $attributes);
}
|
[
"public",
"static",
"function",
"link",
"(",
"$",
"url",
",",
"$",
"text",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"attributes",
"=",
"(",
"array",
")",
"$",
"attributes",
";",
"$",
"attributes",
"[",
"'href'",
"]",
"=",
"$",
"url",
";",
"return",
"self",
"::",
"tag",
"(",
"'a'",
",",
"$",
"text",
",",
"$",
"attributes",
")",
";",
"}"
] |
Generates a simple html link
@param string|moodle_url $url The URL
@param string $text The text
@param array $attributes HTML attributes
@return string HTML fragment
|
[
"Generates",
"a",
"simple",
"html",
"link"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L1774-L1778
|
219,796
|
moodle/moodle
|
lib/outputcomponents.php
|
html_writer.checkbox
|
public static function checkbox($name, $value, $checked = true, $label = '', array $attributes = null) {
$attributes = (array)$attributes;
$output = '';
if ($label !== '' and !is_null($label)) {
if (empty($attributes['id'])) {
$attributes['id'] = self::random_id('checkbox_');
}
}
$attributes['type'] = 'checkbox';
$attributes['value'] = $value;
$attributes['name'] = $name;
$attributes['checked'] = $checked ? 'checked' : null;
$output .= self::empty_tag('input', $attributes);
if ($label !== '' and !is_null($label)) {
$output .= self::tag('label', $label, array('for'=>$attributes['id']));
}
return $output;
}
|
php
|
public static function checkbox($name, $value, $checked = true, $label = '', array $attributes = null) {
$attributes = (array)$attributes;
$output = '';
if ($label !== '' and !is_null($label)) {
if (empty($attributes['id'])) {
$attributes['id'] = self::random_id('checkbox_');
}
}
$attributes['type'] = 'checkbox';
$attributes['value'] = $value;
$attributes['name'] = $name;
$attributes['checked'] = $checked ? 'checked' : null;
$output .= self::empty_tag('input', $attributes);
if ($label !== '' and !is_null($label)) {
$output .= self::tag('label', $label, array('for'=>$attributes['id']));
}
return $output;
}
|
[
"public",
"static",
"function",
"checkbox",
"(",
"$",
"name",
",",
"$",
"value",
",",
"$",
"checked",
"=",
"true",
",",
"$",
"label",
"=",
"''",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"attributes",
"=",
"(",
"array",
")",
"$",
"attributes",
";",
"$",
"output",
"=",
"''",
";",
"if",
"(",
"$",
"label",
"!==",
"''",
"and",
"!",
"is_null",
"(",
"$",
"label",
")",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"attributes",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"attributes",
"[",
"'id'",
"]",
"=",
"self",
"::",
"random_id",
"(",
"'checkbox_'",
")",
";",
"}",
"}",
"$",
"attributes",
"[",
"'type'",
"]",
"=",
"'checkbox'",
";",
"$",
"attributes",
"[",
"'value'",
"]",
"=",
"$",
"value",
";",
"$",
"attributes",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"$",
"attributes",
"[",
"'checked'",
"]",
"=",
"$",
"checked",
"?",
"'checked'",
":",
"null",
";",
"$",
"output",
".=",
"self",
"::",
"empty_tag",
"(",
"'input'",
",",
"$",
"attributes",
")",
";",
"if",
"(",
"$",
"label",
"!==",
"''",
"and",
"!",
"is_null",
"(",
"$",
"label",
")",
")",
"{",
"$",
"output",
".=",
"self",
"::",
"tag",
"(",
"'label'",
",",
"$",
"label",
",",
"array",
"(",
"'for'",
"=>",
"$",
"attributes",
"[",
"'id'",
"]",
")",
")",
";",
"}",
"return",
"$",
"output",
";",
"}"
] |
Generates a simple checkbox with optional label
@param string $name The name of the checkbox
@param string $value The value of the checkbox
@param bool $checked Whether the checkbox is checked
@param string $label The label for the checkbox
@param array $attributes Any attributes to apply to the checkbox
@return string html fragment
|
[
"Generates",
"a",
"simple",
"checkbox",
"with",
"optional",
"label"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L1790-L1811
|
219,797
|
moodle/moodle
|
lib/outputcomponents.php
|
html_writer.select
|
public static function select(array $options, $name, $selected = '', $nothing = array('' => 'choosedots'), array $attributes = null) {
$attributes = (array)$attributes;
if (is_array($nothing)) {
foreach ($nothing as $k=>$v) {
if ($v === 'choose' or $v === 'choosedots') {
$nothing[$k] = get_string('choosedots');
}
}
$options = $nothing + $options; // keep keys, do not override
} else if (is_string($nothing) and $nothing !== '') {
// BC
$options = array(''=>$nothing) + $options;
}
// we may accept more values if multiple attribute specified
$selected = (array)$selected;
foreach ($selected as $k=>$v) {
$selected[$k] = (string)$v;
}
if (!isset($attributes['id'])) {
$id = 'menu'.$name;
// name may contaion [], which would make an invalid id. e.g. numeric question type editing form, assignment quickgrading
$id = str_replace('[', '', $id);
$id = str_replace(']', '', $id);
$attributes['id'] = $id;
}
if (!isset($attributes['class'])) {
$class = 'menu'.$name;
// name may contaion [], which would make an invalid class. e.g. numeric question type editing form, assignment quickgrading
$class = str_replace('[', '', $class);
$class = str_replace(']', '', $class);
$attributes['class'] = $class;
}
$attributes['class'] = 'select custom-select ' . $attributes['class']; // Add 'select' selector always.
$attributes['name'] = $name;
if (!empty($attributes['disabled'])) {
$attributes['disabled'] = 'disabled';
} else {
unset($attributes['disabled']);
}
$output = '';
foreach ($options as $value=>$label) {
if (is_array($label)) {
// ignore key, it just has to be unique
$output .= self::select_optgroup(key($label), current($label), $selected);
} else {
$output .= self::select_option($label, $value, $selected);
}
}
return self::tag('select', $output, $attributes);
}
|
php
|
public static function select(array $options, $name, $selected = '', $nothing = array('' => 'choosedots'), array $attributes = null) {
$attributes = (array)$attributes;
if (is_array($nothing)) {
foreach ($nothing as $k=>$v) {
if ($v === 'choose' or $v === 'choosedots') {
$nothing[$k] = get_string('choosedots');
}
}
$options = $nothing + $options; // keep keys, do not override
} else if (is_string($nothing) and $nothing !== '') {
// BC
$options = array(''=>$nothing) + $options;
}
// we may accept more values if multiple attribute specified
$selected = (array)$selected;
foreach ($selected as $k=>$v) {
$selected[$k] = (string)$v;
}
if (!isset($attributes['id'])) {
$id = 'menu'.$name;
// name may contaion [], which would make an invalid id. e.g. numeric question type editing form, assignment quickgrading
$id = str_replace('[', '', $id);
$id = str_replace(']', '', $id);
$attributes['id'] = $id;
}
if (!isset($attributes['class'])) {
$class = 'menu'.$name;
// name may contaion [], which would make an invalid class. e.g. numeric question type editing form, assignment quickgrading
$class = str_replace('[', '', $class);
$class = str_replace(']', '', $class);
$attributes['class'] = $class;
}
$attributes['class'] = 'select custom-select ' . $attributes['class']; // Add 'select' selector always.
$attributes['name'] = $name;
if (!empty($attributes['disabled'])) {
$attributes['disabled'] = 'disabled';
} else {
unset($attributes['disabled']);
}
$output = '';
foreach ($options as $value=>$label) {
if (is_array($label)) {
// ignore key, it just has to be unique
$output .= self::select_optgroup(key($label), current($label), $selected);
} else {
$output .= self::select_option($label, $value, $selected);
}
}
return self::tag('select', $output, $attributes);
}
|
[
"public",
"static",
"function",
"select",
"(",
"array",
"$",
"options",
",",
"$",
"name",
",",
"$",
"selected",
"=",
"''",
",",
"$",
"nothing",
"=",
"array",
"(",
"''",
"=>",
"'choosedots'",
")",
",",
"array",
"$",
"attributes",
"=",
"null",
")",
"{",
"$",
"attributes",
"=",
"(",
"array",
")",
"$",
"attributes",
";",
"if",
"(",
"is_array",
"(",
"$",
"nothing",
")",
")",
"{",
"foreach",
"(",
"$",
"nothing",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"v",
"===",
"'choose'",
"or",
"$",
"v",
"===",
"'choosedots'",
")",
"{",
"$",
"nothing",
"[",
"$",
"k",
"]",
"=",
"get_string",
"(",
"'choosedots'",
")",
";",
"}",
"}",
"$",
"options",
"=",
"$",
"nothing",
"+",
"$",
"options",
";",
"// keep keys, do not override",
"}",
"else",
"if",
"(",
"is_string",
"(",
"$",
"nothing",
")",
"and",
"$",
"nothing",
"!==",
"''",
")",
"{",
"// BC",
"$",
"options",
"=",
"array",
"(",
"''",
"=>",
"$",
"nothing",
")",
"+",
"$",
"options",
";",
"}",
"// we may accept more values if multiple attribute specified",
"$",
"selected",
"=",
"(",
"array",
")",
"$",
"selected",
";",
"foreach",
"(",
"$",
"selected",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"$",
"selected",
"[",
"$",
"k",
"]",
"=",
"(",
"string",
")",
"$",
"v",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'id'",
"]",
")",
")",
"{",
"$",
"id",
"=",
"'menu'",
".",
"$",
"name",
";",
"// name may contaion [], which would make an invalid id. e.g. numeric question type editing form, assignment quickgrading",
"$",
"id",
"=",
"str_replace",
"(",
"'['",
",",
"''",
",",
"$",
"id",
")",
";",
"$",
"id",
"=",
"str_replace",
"(",
"']'",
",",
"''",
",",
"$",
"id",
")",
";",
"$",
"attributes",
"[",
"'id'",
"]",
"=",
"$",
"id",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'class'",
"]",
")",
")",
"{",
"$",
"class",
"=",
"'menu'",
".",
"$",
"name",
";",
"// name may contaion [], which would make an invalid class. e.g. numeric question type editing form, assignment quickgrading",
"$",
"class",
"=",
"str_replace",
"(",
"'['",
",",
"''",
",",
"$",
"class",
")",
";",
"$",
"class",
"=",
"str_replace",
"(",
"']'",
",",
"''",
",",
"$",
"class",
")",
";",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"$",
"class",
";",
"}",
"$",
"attributes",
"[",
"'class'",
"]",
"=",
"'select custom-select '",
".",
"$",
"attributes",
"[",
"'class'",
"]",
";",
"// Add 'select' selector always.",
"$",
"attributes",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"attributes",
"[",
"'disabled'",
"]",
")",
")",
"{",
"$",
"attributes",
"[",
"'disabled'",
"]",
"=",
"'disabled'",
";",
"}",
"else",
"{",
"unset",
"(",
"$",
"attributes",
"[",
"'disabled'",
"]",
")",
";",
"}",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"value",
"=>",
"$",
"label",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"label",
")",
")",
"{",
"// ignore key, it just has to be unique",
"$",
"output",
".=",
"self",
"::",
"select_optgroup",
"(",
"key",
"(",
"$",
"label",
")",
",",
"current",
"(",
"$",
"label",
")",
",",
"$",
"selected",
")",
";",
"}",
"else",
"{",
"$",
"output",
".=",
"self",
"::",
"select_option",
"(",
"$",
"label",
",",
"$",
"value",
",",
"$",
"selected",
")",
";",
"}",
"}",
"return",
"self",
"::",
"tag",
"(",
"'select'",
",",
"$",
"output",
",",
"$",
"attributes",
")",
";",
"}"
] |
Generates a simple select form field
@param array $options associative array value=>label ex.:
array(1=>'One, 2=>Two)
it is also possible to specify optgroup as complex label array ex.:
array(array('Odd'=>array(1=>'One', 3=>'Three)), array('Even'=>array(2=>'Two')))
array(1=>'One', '--1uniquekey'=>array('More'=>array(2=>'Two', 3=>'Three')))
@param string $name name of select element
@param string|array $selected value or array of values depending on multiple attribute
@param array|bool $nothing add nothing selected option, or false of not added
@param array $attributes html select element attributes
@return string HTML fragment
|
[
"Generates",
"a",
"simple",
"select",
"form",
"field"
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L1840-L1896
|
219,798
|
moodle/moodle
|
lib/outputcomponents.php
|
html_writer.select_option
|
private static function select_option($label, $value, array $selected) {
$attributes = array();
$value = (string)$value;
if (in_array($value, $selected, true)) {
$attributes['selected'] = 'selected';
}
$attributes['value'] = $value;
return self::tag('option', $label, $attributes);
}
|
php
|
private static function select_option($label, $value, array $selected) {
$attributes = array();
$value = (string)$value;
if (in_array($value, $selected, true)) {
$attributes['selected'] = 'selected';
}
$attributes['value'] = $value;
return self::tag('option', $label, $attributes);
}
|
[
"private",
"static",
"function",
"select_option",
"(",
"$",
"label",
",",
"$",
"value",
",",
"array",
"$",
"selected",
")",
"{",
"$",
"attributes",
"=",
"array",
"(",
")",
";",
"$",
"value",
"=",
"(",
"string",
")",
"$",
"value",
";",
"if",
"(",
"in_array",
"(",
"$",
"value",
",",
"$",
"selected",
",",
"true",
")",
")",
"{",
"$",
"attributes",
"[",
"'selected'",
"]",
"=",
"'selected'",
";",
"}",
"$",
"attributes",
"[",
"'value'",
"]",
"=",
"$",
"value",
";",
"return",
"self",
"::",
"tag",
"(",
"'option'",
",",
"$",
"label",
",",
"$",
"attributes",
")",
";",
"}"
] |
Returns HTML to display a select box option.
@param string $label The label to display as the option.
@param string|int $value The value the option represents
@param array $selected An array of selected options
@return string HTML fragment
|
[
"Returns",
"HTML",
"to",
"display",
"a",
"select",
"box",
"option",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L1906-L1914
|
219,799
|
moodle/moodle
|
lib/outputcomponents.php
|
html_writer.select_optgroup
|
private static function select_optgroup($groupname, $options, array $selected) {
if (empty($options)) {
return '';
}
$attributes = array('label'=>$groupname);
$output = '';
foreach ($options as $value=>$label) {
$output .= self::select_option($label, $value, $selected);
}
return self::tag('optgroup', $output, $attributes);
}
|
php
|
private static function select_optgroup($groupname, $options, array $selected) {
if (empty($options)) {
return '';
}
$attributes = array('label'=>$groupname);
$output = '';
foreach ($options as $value=>$label) {
$output .= self::select_option($label, $value, $selected);
}
return self::tag('optgroup', $output, $attributes);
}
|
[
"private",
"static",
"function",
"select_optgroup",
"(",
"$",
"groupname",
",",
"$",
"options",
",",
"array",
"$",
"selected",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
")",
")",
"{",
"return",
"''",
";",
"}",
"$",
"attributes",
"=",
"array",
"(",
"'label'",
"=>",
"$",
"groupname",
")",
";",
"$",
"output",
"=",
"''",
";",
"foreach",
"(",
"$",
"options",
"as",
"$",
"value",
"=>",
"$",
"label",
")",
"{",
"$",
"output",
".=",
"self",
"::",
"select_option",
"(",
"$",
"label",
",",
"$",
"value",
",",
"$",
"selected",
")",
";",
"}",
"return",
"self",
"::",
"tag",
"(",
"'optgroup'",
",",
"$",
"output",
",",
"$",
"attributes",
")",
";",
"}"
] |
Returns HTML to display a select box option group.
@param string $groupname The label to use for the group
@param array $options The options in the group
@param array $selected An array of selected values.
@return string HTML fragment.
|
[
"Returns",
"HTML",
"to",
"display",
"a",
"select",
"box",
"option",
"group",
"."
] |
a411b499b98afc9901c24a9466c7e322946a04aa
|
https://github.com/moodle/moodle/blob/a411b499b98afc9901c24a9466c7e322946a04aa/lib/outputcomponents.php#L1924-L1934
|
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.