function get_table_row($filterinfo, $isfirstrow, $islastactive, $applytostrings) { global $CFG, $OUTPUT, $activechoices, $applytochoices, $filternames; //TODO: this is sloppy coding style!! $row = array(); $filter = $filterinfo->filter; // Filter name if (!empty($filternames[$filter])) { $row[] = $filternames[$filter]; } else { $row[] = '<span class="error">' . get_string('filemissing', '', $filter) . '</span>'; } // Disable/off/on $select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $filterinfo->active, null, 'active' . $filter); $select->set_label(get_string('isactive', 'filters'), array('class' => 'accesshide')); $row[] = $OUTPUT->render($select); // Re-order $updown = ''; $spacer = '<img src="' . $OUTPUT->pix_url('spacer') . '" class="iconsmall" alt="" />'; if ($filterinfo->active != TEXTFILTER_DISABLED) { if (!$isfirstrow) { $updown .= $OUTPUT->action_icon(filters_action_url($filter, 'up'), new pix_icon('t/up', get_string('up'), '', array('class' => 'iconsmall'))); } else { $updown .= $spacer; } if (!$islastactive) { $updown .= $OUTPUT->action_icon(filters_action_url($filter, 'down'), new pix_icon('t/down', get_string('down'), '', array('class' => 'iconsmall'))); } else { $updown .= $spacer; } } $row[] = $updown; // Apply to strings. $select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . $filter); $select->set_label(get_string('applyto', 'filters'), array('class' => 'accesshide')); $select->disabled = $filterinfo->active == TEXTFILTER_DISABLED; $row[] = $OUTPUT->render($select); // Settings link, if required if (filter_has_global_settings($filter)) { $row[] = '<a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=filtersetting' . $filter . '">' . get_string('settings') . '</a>'; } else { $row[] = ''; } // Delete $row[] = '<a href="' . filters_action_url($filter, 'delete') . '">' . get_string('delete') . '</a>'; return $row; }
/** * Construct table record. * * @param \core\plugininfo\filter $plugininfo * @param stdClass $state * @param bool $isfirstrow * @param bool $islastactive * @param bool $applytostrings * @return array data */ function get_table_row(\core\plugininfo\filter $plugininfo, $state, $isfirstrow, $islastactive, $applytostrings) { global $OUTPUT; $row = array(); $filter = $state->filter; $active = $plugininfo->is_installed_and_upgraded(); static $activechoices; static $applytochoices; if (!isset($activechoices)) { $activechoices = array(TEXTFILTER_DISABLED => get_string('disabled', 'core_filters'), TEXTFILTER_OFF => get_string('offbutavailable', 'core_filters'), TEXTFILTER_ON => get_string('on', 'core_filters')); $applytochoices = array(0 => get_string('content', 'core_filters'), 1 => get_string('contentandheadings', 'core_filters')); } // Filter name. $displayname = $plugininfo->displayname; if (!$plugininfo->rootdir) { $displayname = '<span class="error">' . $displayname . ' - ' . get_string('status_missing', 'core_plugin') . '</span>'; } else { if (!$active) { $displayname = '<span class="error">' . $displayname . ' - ' . get_string('error') . '</span>'; } } $row[] = $displayname; // Disable/off/on. $select = new single_select(filters_action_url($filter, 'setstate'), 'newstate', $activechoices, $state->active, null, 'active' . $filter); $select->set_label(get_string('isactive', 'filters'), array('class' => 'accesshide')); $row[] = $OUTPUT->render($select); // Re-order. $updown = ''; $spacer = '<img src="' . $OUTPUT->pix_url('spacer') . '" class="iconsmall" alt="" />'; if ($state->active != TEXTFILTER_DISABLED) { if (!$isfirstrow) { $updown .= $OUTPUT->action_icon(filters_action_url($filter, 'up'), new pix_icon('t/up', get_string('up'), '', array('class' => 'iconsmall'))); } else { $updown .= $spacer; } if (!$islastactive) { $updown .= $OUTPUT->action_icon(filters_action_url($filter, 'down'), new pix_icon('t/down', get_string('down'), '', array('class' => 'iconsmall'))); } else { $updown .= $spacer; } } $row[] = $updown; // Apply to strings. $select = new single_select(filters_action_url($filter, 'setapplyto'), 'stringstoo', $applytochoices, $applytostrings, null, 'applyto' . $filter); $select->set_label(get_string('applyto', 'filters'), array('class' => 'accesshide')); $select->disabled = $state->active == TEXTFILTER_DISABLED; $row[] = $OUTPUT->render($select); // Settings link, if required. if ($active and filter_has_global_settings($filter)) { $row[] = html_writer::link(new moodle_url('/admin/settings.php', array('section' => 'filtersetting' . $filter)), get_string('settings')); } else { $row[] = ''; } // Uninstall. $row[] = html_writer::link(filters_action_url($filter, 'delete'), get_string('uninstallplugin', 'core_admin')); return $row; }