/** * Form definition. */ public function definition() { $mform = $this->_form; // ID of existing tour. $mform->addElement('hidden', 'id'); $mform->setType('id', PARAM_INT); // Name of the tour. $mform->addElement('text', 'name', get_string('name', 'tool_usertours')); $mform->addRule('name', get_string('required'), 'required', null, 'client'); $mform->setType('name', PARAM_TEXT); // Admin-only descriptions. $mform->addElement('textarea', 'description', get_string('description', 'tool_usertours')); $mform->setType('description', PARAM_RAW); // Application. $mform->addElement('text', 'pathmatch', get_string('pathmatch', 'tool_usertours')); $mform->setType('pathmatch', PARAM_RAW); $mform->addHelpButton('pathmatch', 'pathmatch', 'tool_usertours'); $mform->addElement('checkbox', 'enabled', get_string('tourisenabled', 'tool_usertours')); // Configuration. $this->tour->add_config_to_form($mform); // Filters. $mform->addElement('header', 'filters', get_string('filter_header', 'tool_usertours')); $mform->addElement('static', 'filterhelp', '', get_string('filter_help', 'tool_usertours')); foreach (helper::get_all_filters() as $filterclass) { $filterclass::add_filter_to_form($mform); } $this->add_action_buttons(); }
/** * Returns relevant URL. * * @return \moodle_url */ public function get_url() { return \tool_usertours\helper::get_edit_step_link($this->other['tourid'], $this->objectid); }
/** * Extend the user navigation to bootstrap tours. */ function tool_usertours_extend_navigation_user() { \tool_usertours\helper::bootstrap(); }
/** * Returns relevant URL. * * @return \moodle_url */ public function get_url() { return \tool_usertours\helper::get_view_tour_link($this->objectid); }
/** * Format the current row's actions column. * * @param step $step The step for this row. * @return string */ protected function col_actions(step $step) { $actions = []; if ($step->is_first_step()) { $actions[] = helper::get_filler_icon(); } else { $actions[] = helper::format_icon_link($step->get_moveup_link(), 't/up', get_string('movestepup', 'tool_usertours')); } if ($step->is_last_step()) { $actions[] = helper::get_filler_icon(); } else { $actions[] = helper::format_icon_link($step->get_movedown_link(), 't/down', get_string('movestepdown', 'tool_usertours')); } $actions[] = helper::format_icon_link($step->get_edit_link(), 't/edit', get_string('edit')); $actions[] = helper::format_icon_link($step->get_delete_link(), 't/delete', get_string('delete'), 'moodle', ['data-action' => 'delete', 'data-id' => $step->get_id()]); return implode(' ', $actions); }
/** * Move a step up or down. * * @param int $id The step to move. */ protected function move_step($id) { require_sesskey(); $direction = required_param('direction', PARAM_INT); $step = step::instance($id); $currentsortorder = $step->get_sortorder(); $targetsortorder = $currentsortorder + $direction; $tour = $step->get_tour(); $swapwith = helper::get_step_from_sortorder($tour->get_id(), $targetsortorder); // Set the sort order to something out of the way. $step->set_sortorder(-1); $step->persist(); // Swap the two sort orders. $swapwith->set_sortorder($currentsortorder); $swapwith->persist(); $step->set_sortorder($targetsortorder); $step->persist(); // Reset the sort order. $tour->reset_step_sortorder(); redirect($tour->get_view_link()); }
/** * Create the import tour form. */ public function __construct() { parent::__construct(\tool_usertours\helper::get_import_tour_link()); }
/** * Format the current row's actions column. * * @param tour $tour The tour for this row. * @return string */ protected function col_actions(tour $tour) { $actions = []; if ($tour->is_first_tour()) { $actions[] = helper::get_filler_icon(); } else { $actions[] = helper::format_icon_link($tour->get_moveup_link(), 't/up', get_string('movetourup', 'tool_usertours')); } if ($tour->is_last_tour($this->tourcount)) { $actions[] = helper::get_filler_icon(); } else { $actions[] = helper::format_icon_link($tour->get_movedown_link(), 't/down', get_string('movetourdown', 'tool_usertours')); } $actions[] = helper::format_icon_link($tour->get_view_link(), 't/viewdetails', get_string('view')); $actions[] = helper::format_icon_link($tour->get_edit_link(), 't/edit', get_string('edit')); $actions[] = helper::format_icon_link($tour->get_export_link(), 't/export', get_string('exporttour', 'tool_usertours'), 'tool_usertours'); $actions[] = helper::format_icon_link($tour->get_delete_link(), 't/delete', get_string('delete'), null, ['data-action' => 'delete', 'data-id' => $tour->get_id()]); return implode(' ', $actions); }