/** * Get the names of all the filters installed in this Moodle. * * @global object * @return array path => filter name from the appropriate lang file. e.g. * array('mod/glossary' => 'Glossary Auto-linking', 'filter/tex' => 'TeX Notation'); * sorted in alphabetical order of name. */ function filter_get_all_installed() { global $CFG; $filternames = array(); // TODO: deprecated since 2.2, will be out in 2.3, see MDL-29996 $filterlocations = array('mod', 'filter'); foreach ($filterlocations as $filterlocation) { // TODO: move get_list_of_plugins() to get_plugin_list() $filters = get_list_of_plugins($filterlocation); foreach ($filters as $filter) { // MDL-29994 - Ignore mod/data and mod/glossary filters forever, this will be out in 2.3 if ($filterlocation == 'mod' && ($filter == 'data' || $filter == 'glossary')) { continue; } $path = $filterlocation . '/' . $filter; if (is_readable($CFG->dirroot . '/' . $path . '/filter.php')) { $strfiltername = filter_get_name($path); $filternames[$path] = $strfiltername; } } } collatorlib::asort($filternames); return $filternames; }
/** * Get the names of all the filters installed in this Moodle. * * @return array path => filter name from the appropriate lang file. e.g. * array('tex' => 'TeX Notation'); * sorted in alphabetical order of name. */ function filter_get_all_installed() { global $CFG; $filternames = array(); foreach (core_component::get_plugin_list('filter') as $filter => $fulldir) { if (is_readable("{$fulldir}/filter.php")) { $filternames[$filter] = filter_get_name($filter); } } core_collator::asort($filternames); return $filternames; }
/** * Returns the language string for the given plugin. * * @param string $plugin the plugin code name * @param string $type the type of plugin (mod, block, filter) * @return string The plugin language string */ function get_plugin_name($plugin, $type = 'mod') { $plugin_name = ''; switch ($type) { case 'mod': $plugin_name = get_string('modulename', $plugin); break; case 'blocks': $plugin_name = get_string('pluginname', "block_{$plugin}"); if (empty($plugin_name) || $plugin_name == '[[pluginname]]') { if (($block = block_instance($plugin)) !== false) { $plugin_name = $block->get_title(); } else { $plugin_name = "[[{$plugin}]]"; } } break; case 'filter': $plugin_name = filter_get_name('filter/' . $plugin); break; default: $plugin_name = $plugin; break; } return $plugin_name; }
echo html_writer::start_tag('div'); echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey())); $table = new html_table(); $table->head = array(get_string('filter'), get_string('isactive', 'filters')); $table->align = array('left', 'left'); if ($settingscol) { $table->head[] = $strsettings; $table->align[] = 'left'; } $table->width = ' '; $table->data = array(); // iterate through filters adding to display table foreach ($availablefilters as $filter => $filterinfo) { $row = array(); // Filter name. $row[] = filter_get_name($filter); // Default/on/off choice. if ($filterinfo->inheritedstate == TEXTFILTER_ON) { $activechoices[TEXTFILTER_INHERIT] = $strdefaulton; } else { $activechoices[TEXTFILTER_INHERIT] = $strdefaultoff; } $row[] = html_writer::select($activechoices, str_replace('/', '_', $filter), $filterinfo->localstate, false); // Settings link, if required if ($settingscol) { $settings = ''; if ($filterinfo->hassettings) { $settings = '<a href="' . $baseurl->out(true, array('filter' => $filter)) . '">' . $strsettings . '</a>'; } $row[] = $settings; }
public function load_choices() { if (is_array($this->choices)) { return true; } $this->choices = array(); foreach (core_component::get_plugin_list('filter') as $plugin => $unused) { $this->choices[$plugin] = filter_get_name($plugin); } return true; }
break; case 'down': if (isset($filters[$filterpath])) { filter_set_global_state($filterpath, $filters[$filterpath]->active, 1); } break; case 'up': if (isset($filters[$filterpath])) { $oldpos = $filters[$filterpath]->sortorder; filter_set_global_state($filterpath, $filters[$filterpath]->active, -1); } break; case 'delete': // If not yet confirmed, display a confirmation message. if (!optional_param('confirm', '', PARAM_BOOL)) { $filtername = filter_get_name($filterpath); $title = get_string('deletefilterareyousure', 'admin', $filtername); echo $OUTPUT->header(); echo $OUTPUT->heading($title); $linkcontinue = new moodle_url($returnurl, array('action' => 'delete', 'filterpath' => $filterpath, 'confirm' => 1)); $formcancel = new single_button(new moodle_url($returnurl), get_string('no'), 'get'); echo $OUTPUT->confirm(get_string('deletefilterareyousuremessage', 'admin', $filtername), $linkcontinue, $formcancel); echo $OUTPUT->footer(); exit; } // Do the deletion. $title = get_string('deletingfilter', 'admin', $filterpath); echo $OUTPUT->header(); echo $OUTPUT->heading($title); // Delete all data for this plugin. filter_delete_all_for_filter($filterpath);
/** * Get the names of all the filters installed in this Moodle. * * @global object * @return array path => filter name from the appropriate lang file. e.g. * array('mod/glossary' => 'Glossary Auto-linking', 'filter/tex' => 'TeX Notation'); * sorted in alphabetical order of name. */ function filter_get_all_installed() { global $CFG; $filternames = array(); $filterlocations = array('mod', 'filter'); foreach ($filterlocations as $filterlocation) { $filters = get_list_of_plugins($filterlocation); foreach ($filters as $filter) { $path = $filterlocation . '/' . $filter; if (is_readable($CFG->dirroot . '/' . $path . '/filter.php')) { $strfiltername = filter_get_name($path); $filternames[$path] = $strfiltername; } } } textlib_get_instance()->asort($filternames); return $filternames; }
/** * Get the names of all the filters installed in this Moodle. * * @return array path => filter name from the appropriate lang file. e.g. * array('tex' => 'TeX Notation'); * sorted in alphabetical order of name. */ function filter_get_all_installed() { global $CFG; $filternames = array(); foreach (get_list_of_plugins('filter') as $filter) { if (is_readable("{$CFG->dirroot}/filter/{$filter}/filter.php")) { $filternames[$filter] = filter_get_name($filter); } } collatorlib::asort($filternames); return $filternames; }
function format_setting($name, $value, $ratings, $gradecategories, $groupmodes, $groupings, $indentmenu, $sectionmenu, $positionmenu, $uploadlimitmenu, $conditiongradeitemidmenu, $conditioncmidmenu, $conditioncmcompletionmenu, $conditionfieldnamemenu, $conditionfieldoperatormenu, $conditiongroupidmenu, $conditiongroupingidmenu, $conditionactionmenu, $completiontrackingmenu, $completionfields, $competencyrulemenu, $filters, $filtermenu, $filterdefaulton, $filterdefaultoff) { $plugin = 'block_taskchain_navigation'; switch ($name) { case 'availablefrom': case 'availableuntil': $name = get_string($name, $plugin); $value = $value ? userdate($value) : get_string('disable'); break; case 'availablecutoff': $name = get_string('cutoffdate', 'assign'); $value = $value ? userdate($value) : get_string('disable'); break; case 'visible': $name = get_string('visible'); $value = format_yesno($value, 'show', 'hide'); break; case 'rating': $name = get_string('rating', 'rating'); $value = $ratings[$value]; break; case 'maxgrade': $name = get_string('maximumgrade', $plugin); $value = $value . '%'; break; case 'gradepass': $name = get_string('gradepass', 'grades'); $value = $value . '%'; break; case 'gradecat': $name = get_string('gradecategory', 'grades'); $value = $gradecategories[$value]; break; case 'gradeitemhidden': $name = get_string('gradeitemhidden', $plugin); $value = format_yesno($value); break; case 'extracredit': $name = get_string('extracredit', 'grades'); $value = format_yesno($value); break; case 'regrade': $name = get_string('regrade', $plugin); $value = format_yesno($value); break; case 'groupmode': $name = get_string('groupmode'); $value = $groupmodes[$value]; break; case 'groupingid': $name = get_string('grouping', 'group'); $value = $groupings[$value]; break; case 'groupmembersonly': $name = get_string('groupmembersonly', 'group'); $value = format_yesno($value); break; case 'indent': $name = get_string('indent', $plugin); $value = $indentmenu[$value]; break; case 'section': $name = get_string('section'); $value = $sectionmenu[$value]; break; case 'position': $name = get_string('position', $plugin); $value = $positionmenu[$value]; break; case 'uploadlimit': $name = get_string('activityuploadlimit', $plugin); $value = $uploadlimitmenu[$value]; break; case 'removeconditions': $name = get_string('removeconditions', $plugin); $value = format_yesno($value); break; case 'conditiondate': $strman = get_string_manager(); $plugin = 'availability_date'; if ($strman->string_exists('pluginname', $plugin)) { // Moodle >= 2.7 $name = get_string('pluginname', $plugin); $from = 'short_from'; $until = 'short_until'; } else { // Moodle <= 2.6 $name = get_string('availability'); $plugin = 'condition'; $from = 'requires_date'; $until = 'requires_date_before'; } foreach ($value as $i => $v) { $str = $v->d == '>=' ? $from : $until; $str = get_string($str, $plugin, userdate($v->t)); $value[$i] = html_writer::tag('p', $str); } $value = implode('', $value); break; case 'conditionfield': $strman = get_string_manager(); if ($strman->string_exists('title', 'availability_grade')) { // Moodle >= 2.7 $name = get_string('conditiontitle', 'availability_profile'); } else { // Moodle <= 2.6 $name = get_string('availablefrom', 'condition'); } foreach ($value as $i => $v) { $value[$i] = html_writer::start_tag('p') . $conditionfieldnamemenu[$v->sf] . ' ' . $conditionfieldoperatormenu[$v->op] . ' ' . $v->v . html_writer::end_tag('p'); } $value = implode('', $value); break; case 'conditiongrade': $strman = get_string_manager(); if ($strman->string_exists('title', 'availability_grade')) { // Moodle >= 2.7 $name = get_string('title', 'availability_grade'); $grademin = get_string('option_min', 'availability_grade'); $grademax = get_string('option_max', 'availability_grade'); } else { // Moodle <= 2.6 $name = get_string('gradecondition', 'condition'); $grademin = get_string('grade_atleast', 'condition'); $grademax = get_string('grade_upto', 'condition'); } foreach ($value as $i => $v) { $value[$i] = html_writer::start_tag('p') . ltrim($conditiongradeitemidmenu[$v->id], '│└ ') . ' ' . $grademin . ' ' . $v->min . '% ' . $grademax . ' ' . $v->max . '%' . html_writer::end_tag('p'); } $value = implode('', $value); break; case 'conditiongroupid': foreach ($value as $i => $v) { $value[$i] = html_writer::tag('p', $conditiongroupidmenu[$v]); } $value = implode('', $value); break; case 'conditiongroupingid': foreach ($value as $i => $v) { $value[$i] = html_writer::tag('p', $conditiongroupingidmenu[$v]); } $value = implode('', $value); break; case 'conditionaction': $name = get_string('display', 'form'); foreach ($value as $i => $v) { $value[$i] = html_writer::tag('p', $conditionactionmenu[$v]); } $value = implode('', $value); break; case 'conditioncm': $strman = get_string_manager(); if ($strman->string_exists('activitycompletion', 'completion')) { // Moodle >= 2.7 $name = get_string('activitycompletion', 'completion'); } else { // Moodle <= 2.6 $name = get_string('completioncondition', 'condition'); } foreach ($value as $i => $v) { $str = array(); if ($v->ungraded) { $str[] = get_string('conditioncmungraded', $plugin); } if ($v->resources) { $str[] = get_string('conditioncmresources', $plugin); } if ($v->labels) { $str[] = get_string('conditioncmlabels', $plugin); } if ($str = implode(', ', $str)) { $str = block_taskchain_navigation::textlib('strtolower', " ({$str})"); } $value[$i] = html_writer::tag('p', $conditioncmidmenu[$v->cm] . "{$str} " . $conditioncmcompletionmenu[$v->e]); } $value = implode('', $value); break; case 'conditioncmlabels': case 'conditioncmresources': case 'conditioncmungraded': $name = get_string($name, $plugin); $value = format_yesno($value); break; case 'removecompletion': case 'erasecompletion': $name = get_string($name, $plugin); $value = format_yesno($value); break; case 'completiontracking': $name = get_string('completion', 'completion'); $value = $completiontrackingmenu[$value]; break; case 'completiondate': $name = get_string('completionexpected', 'completion'); $value = $value ? userdate($value) : get_string('disable'); break; case 'competencyrule': $name = get_string('uponcoursemodulecompletion', 'tool_lp'); $value = $competencyrulemenu[$value]; break; default: if (array_key_exists($name, $completionfields)) { $field = $completionfields[$name]; $name = $field->text; switch ($field->type) { case 'checkbox': $value = format_yesno($value); break; case 'duration': list($value, $unit) = convert_seconds_to_duration($value); $value .= ' ' . get_duration_units($unit); break; case 'select': $i = 1; $num = $value; $value = array(); while (($ii = pow(2, $i)) && $ii <= $num) { if ($ii & $num) { $value[] = strip_tags($field->options[$ii]); } $i++; } $value = array_filter($value); $value = implode(', ', $value); break; case 'textbox': $value = number_format($value); break; } } else { if (substr($name, 0, 6) == 'filter') { $name = substr($name, 6); switch ($value) { case TEXTFILTER_ON: case TEXTFILTER_OFF: $value = $filtermenu[$value]; break; case TEXTFILTER_INHERIT: if ($filters[$name]->inheritedstate == TEXTFILTER_ON) { $value = $filterdefaulton; } else { $value = $filterdefaultoff; } break; } $name = filter_get_name($name); } } } return array($name, $value); }