/** * Get an array of link type classes * * @return array **/ function pagemenu_get_link_classes() { $return = array(); foreach (pagemenu_get_links() as $type) { $return[$type] = mod_pagemenu_link::factory($type); } return $return; }
/** * This function makes all the necessary calls to {@link restore_decode_content_links_worker()} * function in order to mantain inter-activities during the restore process. * It's called from {@link restore_decode_content_links()} * function in restore process. * * @uses $CFG * @param object $restore Restore object * @return boolean **/ function pagemenu_decode_content_links_caller($restore) { global $CFG; $status = true; if ($links = get_records_sql("SELECT l.id, l.type\n FROM {$CFG->prefix}pagemenu p,\n {$CFG->prefix}pagemenu_links l\n WHERE p.id = l.pagemenuid\n AND p.course = {$restore->course_id}")) { // Include all link type classes require_once $CFG->dirroot . '/mod/pagemenu/link.class.php'; foreach (pagemenu_get_links() as $type) { $path = "{$CFG->dirroot}/mod/pagemenu/links/{$type}.class.php"; if (file_exists($path)) { require_once $path; } } $i = 0; foreach ($links as $link) { $deleteme = true; if ($data = get_records('pagemenu_link_data', 'linkid', $link->id)) { // Call statically for speed if (call_user_func(array("mod_pagemenu_link_{$link->type}", 'restore_data'), $data, $restore)) { $deleteme = false; } } if ($deleteme) { // Restore of data failed, link is useless pagemenu_delete_link($link->id); } // Do some output if (($i + 1) % 5 == 0) { if (!defined('RESTORE_SILENTLY')) { echo "."; if (($i + 1) % 100 == 0) { echo "<br />"; } } backup_flush(300); } $i++; } } return $status; }
} else { if ($data = $mform->get_data()) { // Save form data foreach (pagemenu_get_link_classes() as $link) { $link->save($data); } pagemenu_set_message(get_string('menuupdated', 'pagemenu'), 'notifysuccess'); redirect("{$CFG->wwwroot}/mod/pagemenu/edit.php?id={$cm->id}"); } else { if (!empty($linkaction)) { // These are special link actions that can be invoked by // a link class. EG: hide show page menu items if (!confirm_sesskey()) { error(get_string('confirmsesskeybad', 'error')); } if (!in_array($linkaction, pagemenu_get_links())) { error('Invalide link type'); } $link = mod_pagemenu_link::factory($linkaction); $link->handle_action(); redirect("{$CFG->wwwroot}/mod/pagemenu/edit.php?id={$cm->id}"); } } } pagemenu_print_header($cm, $course, $pagemenu, 'edit', $mform->focus()); // Don't display menu when editing a single link if (!($action == 'edit' and $linkid)) { echo pagemenu_build_menu($pagemenu->id, true); } // Print the form - remember it has duel purposes print_box_start('boxwidthwide boxaligncenter');