mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02:00
MDL-20204 more steps away from old popup_form
This commit is contained in:
parent
f1a3e072fa
commit
31dadc6fee
2 changed files with 38 additions and 35 deletions
|
@ -1577,6 +1577,8 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
|
|||
static $resources = false;
|
||||
static $activities = false;
|
||||
|
||||
$urlbase = "/course/mod.php?id=$course->id§ion=$section&sesskey=".sesskey().'&add=';
|
||||
|
||||
if ($resources === false) {
|
||||
$resources = array();
|
||||
$activities = array();
|
||||
|
@ -1593,27 +1595,46 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
|
|||
include_once($libfile);
|
||||
$gettypesfunc = $modname.'_get_types';
|
||||
if (function_exists($gettypesfunc)) {
|
||||
$types = $gettypesfunc();
|
||||
|
||||
foreach($types as $type) {
|
||||
$type->type = str_replace('&', '&', $type->type);
|
||||
if (!isset($type->modclass) or !isset($type->typestr)) {
|
||||
debugging('Incorrect activity type in '.$modname);
|
||||
continue;
|
||||
// NOTE: this is legacy stuff, module subtypes are very strongly discouraged!!
|
||||
if ($types = $gettypesfunc()) {
|
||||
$menu = array();
|
||||
$atype = null;
|
||||
$groupname = null;
|
||||
foreach($types as $type) {
|
||||
if ($type->typestr === '--') {
|
||||
continue;
|
||||
}
|
||||
if (strpos($type->typestr, '--') === 0) {
|
||||
$groupname = str_replace('--', '', $type->typestr);
|
||||
continue;
|
||||
}
|
||||
$type->type = str_replace('&', '&', $type->type);
|
||||
if ($type->modclass == MOD_CLASS_RESOURCE) {
|
||||
$atype = MOD_CLASS_RESOURCE;
|
||||
}
|
||||
$menu[$urlbase.$type->type] = $type->typestr;
|
||||
}
|
||||
if ($type->modclass == MOD_CLASS_RESOURCE) {
|
||||
$resources[$type->type] = $type->typestr;
|
||||
if (!is_null($groupname)) {
|
||||
if ($atype == MOD_CLASS_RESOURCE) {
|
||||
$resources[] = array($groupname=>$menu);
|
||||
} else {
|
||||
$activities[] = array($groupname=>$menu);
|
||||
}
|
||||
} else {
|
||||
$activities[$type->type] = $type->typestr;
|
||||
if ($atype == MOD_CLASS_RESOURCE) {
|
||||
$resources = array_merge($resources, $menu);
|
||||
} else {
|
||||
$activities = array_merge($activities, $menu);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
|
||||
if ($archetype == MOD_ARCHETYPE_RESOURCE) {
|
||||
$resources[$modname] = $modnamestr;
|
||||
$resources[$urlbase.$modname] = $modnamestr;
|
||||
} else {
|
||||
// all other archetypes are considered activity
|
||||
$activities[$modname] = $modnamestr;
|
||||
$activities[$urlbase.$modname] = $modnamestr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1628,20 +1649,16 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
|
|||
$output .= '<div class="horizontal">';
|
||||
}
|
||||
|
||||
$popupurl = "$CFG->wwwroot/course/mod.php?id=$course->id§ion=$section&sesskey=".sesskey();
|
||||
|
||||
if (!empty($resources)) {
|
||||
$select = html_select::make_popup_form($popupurl, 'add', $resources, "ressection$section", null);
|
||||
$select->nothinglabel = $straddresource;
|
||||
$select = new url_select($resources, '', array(''=>$straddresource), "ressection$section");
|
||||
$select->set_help_icon('resource/types', $straddresource);
|
||||
$output .= $OUTPUT->select($select);
|
||||
$output .= $OUTPUT->render($select);
|
||||
}
|
||||
|
||||
if (!empty($activities)) {
|
||||
$select = html_select::make_popup_form($popupurl, 'add', $activities, "section$section", null);
|
||||
$select->nothinglabel = $straddactivity;
|
||||
$select = new url_select($activities, '', array(''=>$straddactivity), "section$section");
|
||||
$select->set_help_icon('mods', $straddactivity);
|
||||
$output .= $OUTPUT->select($select);
|
||||
$output .= $OUTPUT->render($select);
|
||||
}
|
||||
|
||||
if (!$vertical) {
|
||||
|
|
|
@ -163,21 +163,6 @@ function label_get_post_actions() {
|
|||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return object
|
||||
*/
|
||||
function label_get_types() {
|
||||
$types = array();
|
||||
|
||||
$type = new object();
|
||||
$type->modclass = MOD_CLASS_RESOURCE;
|
||||
$type->type = "label";
|
||||
$type->typestr = get_string('resourcetypelabel', 'resource');
|
||||
$types[] = $type;
|
||||
|
||||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function is used by the reset_course_userdata function in moodlelib.
|
||||
*
|
||||
|
@ -219,6 +204,7 @@ function label_supports($feature) {
|
|||
case FEATURE_COMPLETION_TRACKS_VIEWS: return false;
|
||||
case FEATURE_GRADE_HAS_GRADE: return false;
|
||||
case FEATURE_GRADE_OUTCOMES: return false;
|
||||
case FEATURE_MOD_ARCHETYPE: return MOD_ARCHETYPE_RESOURCE;
|
||||
|
||||
default: return null;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue