mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +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 $resources = false;
|
||||||
static $activities = false;
|
static $activities = false;
|
||||||
|
|
||||||
|
$urlbase = "/course/mod.php?id=$course->id§ion=$section&sesskey=".sesskey().'&add=';
|
||||||
|
|
||||||
if ($resources === false) {
|
if ($resources === false) {
|
||||||
$resources = array();
|
$resources = array();
|
||||||
$activities = array();
|
$activities = array();
|
||||||
|
@ -1593,27 +1595,46 @@ function print_section_add_menus($course, $section, $modnames, $vertical=false,
|
||||||
include_once($libfile);
|
include_once($libfile);
|
||||||
$gettypesfunc = $modname.'_get_types';
|
$gettypesfunc = $modname.'_get_types';
|
||||||
if (function_exists($gettypesfunc)) {
|
if (function_exists($gettypesfunc)) {
|
||||||
$types = $gettypesfunc();
|
// NOTE: this is legacy stuff, module subtypes are very strongly discouraged!!
|
||||||
|
if ($types = $gettypesfunc()) {
|
||||||
|
$menu = array();
|
||||||
|
$atype = null;
|
||||||
|
$groupname = null;
|
||||||
foreach($types as $type) {
|
foreach($types as $type) {
|
||||||
$type->type = str_replace('&', '&', $type->type);
|
if ($type->typestr === '--') {
|
||||||
if (!isset($type->modclass) or !isset($type->typestr)) {
|
|
||||||
debugging('Incorrect activity type in '.$modname);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (strpos($type->typestr, '--') === 0) {
|
||||||
|
$groupname = str_replace('--', '', $type->typestr);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$type->type = str_replace('&', '&', $type->type);
|
||||||
if ($type->modclass == MOD_CLASS_RESOURCE) {
|
if ($type->modclass == MOD_CLASS_RESOURCE) {
|
||||||
$resources[$type->type] = $type->typestr;
|
$atype = MOD_CLASS_RESOURCE;
|
||||||
|
}
|
||||||
|
$menu[$urlbase.$type->type] = $type->typestr;
|
||||||
|
}
|
||||||
|
if (!is_null($groupname)) {
|
||||||
|
if ($atype == MOD_CLASS_RESOURCE) {
|
||||||
|
$resources[] = array($groupname=>$menu);
|
||||||
} else {
|
} else {
|
||||||
$activities[$type->type] = $type->typestr;
|
$activities[] = array($groupname=>$menu);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if ($atype == MOD_CLASS_RESOURCE) {
|
||||||
|
$resources = array_merge($resources, $menu);
|
||||||
|
} else {
|
||||||
|
$activities = array_merge($activities, $menu);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
|
$archetype = plugin_supports('mod', $modname, FEATURE_MOD_ARCHETYPE, MOD_ARCHETYPE_OTHER);
|
||||||
if ($archetype == MOD_ARCHETYPE_RESOURCE) {
|
if ($archetype == MOD_ARCHETYPE_RESOURCE) {
|
||||||
$resources[$modname] = $modnamestr;
|
$resources[$urlbase.$modname] = $modnamestr;
|
||||||
} else {
|
} else {
|
||||||
// all other archetypes are considered activity
|
// 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">';
|
$output .= '<div class="horizontal">';
|
||||||
}
|
}
|
||||||
|
|
||||||
$popupurl = "$CFG->wwwroot/course/mod.php?id=$course->id§ion=$section&sesskey=".sesskey();
|
|
||||||
|
|
||||||
if (!empty($resources)) {
|
if (!empty($resources)) {
|
||||||
$select = html_select::make_popup_form($popupurl, 'add', $resources, "ressection$section", null);
|
$select = new url_select($resources, '', array(''=>$straddresource), "ressection$section");
|
||||||
$select->nothinglabel = $straddresource;
|
|
||||||
$select->set_help_icon('resource/types', $straddresource);
|
$select->set_help_icon('resource/types', $straddresource);
|
||||||
$output .= $OUTPUT->select($select);
|
$output .= $OUTPUT->render($select);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($activities)) {
|
if (!empty($activities)) {
|
||||||
$select = html_select::make_popup_form($popupurl, 'add', $activities, "section$section", null);
|
$select = new url_select($activities, '', array(''=>$straddactivity), "section$section");
|
||||||
$select->nothinglabel = $straddactivity;
|
|
||||||
$select->set_help_icon('mods', $straddactivity);
|
$select->set_help_icon('mods', $straddactivity);
|
||||||
$output .= $OUTPUT->select($select);
|
$output .= $OUTPUT->render($select);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$vertical) {
|
if (!$vertical) {
|
||||||
|
|
|
@ -163,21 +163,6 @@ function label_get_post_actions() {
|
||||||
return array();
|
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.
|
* 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_COMPLETION_TRACKS_VIEWS: return false;
|
||||||
case FEATURE_GRADE_HAS_GRADE: return false;
|
case FEATURE_GRADE_HAS_GRADE: return false;
|
||||||
case FEATURE_GRADE_OUTCOMES: return false;
|
case FEATURE_GRADE_OUTCOMES: return false;
|
||||||
|
case FEATURE_MOD_ARCHETYPE: return MOD_ARCHETYPE_RESOURCE;
|
||||||
|
|
||||||
default: return null;
|
default: return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue