Skip to content

Commit

Permalink
FilteCodes release 2.2.0 (2021-05-21)
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-milette committed May 23, 2021
1 parent b456377 commit ce01a62
Show file tree
Hide file tree
Showing 9 changed files with 280 additions and 261 deletions.
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Change Log
All notable changes to this project will be documented in this file.

## [2.1.7] 2021-05-19 BETA
## [2.2.0] 2021-05-22
### Added
- New {courseteachers} tag (ALPHA).
- New %7Bcoursemoduleid%7D tag.
- New option for you to define your own global {global_...} tags.
- New define custom global {global_...} tags (up to 20).
- New {courserequest} tag.
- New {courserequestmenu} tag.
- New {courserequestmenu0} tag.
Expand All @@ -16,6 +16,7 @@ All notable changes to this project will be documented in this file.
- New {supportname} tag.
- New {supportemail} tag.
- New {supportpage} tag.
- New {webpage} gets automatically substituted to {profile_field_webpage} as of Moodle 3.11.
### Updated
- {coursesummary} can now include other FilterCodes.
- {categorycards} titles now always display white.
Expand All @@ -25,7 +26,9 @@ All notable changes to this project will be documented in this file.
- {profile_field_...} of type Checkbox now displays Yes/No instead of a 1 or 0.
- {profile_field_...} of other types will now display value if field contains 0.
- {profile_field_...} tags will now be removed if user is not logged in.
- Updated documentation.
- {filtercodes} tag now works on all pages but only for users who have course:update capability.
- Custom menu tags should not be processed through the "URL to Link" (urltolink) filter. See README.md to update your theme.
- Documentation in this README.md file.
- Copyright notice for 2021.

## [2.1.0] 2020-11-23
Expand All @@ -47,8 +50,10 @@ All notable changes to this project will be documented in this file.
- New Moodle date/time format option for the {coursestartdate} tag.
- New Moodle date/time format option for the {courseenddate} tag.
- New Moodle date/time format option for the {coursecompletiondate} tag.
- New {now dateTimeFormat} tag.
- New {ifminsitemanager} tag.
- New {now} tag.
- New option to format the date/time {now dateTimeFormat}.

### Updated
- {courseprogress} and {courseprogressbar} now show zero progress if progress is 0.
- {alert} to allow for optional contextual class stying.
Expand Down
83 changes: 53 additions & 30 deletions README.md

Large diffs are not rendered by default.

28 changes: 5 additions & 23 deletions filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -441,9 +441,9 @@ public function filter($text, array $options = []) {
}
$menu .= '-{getstring}phpinfo{/getstring}|/admin/phpinfo.php' . PHP_EOL;
$menu .= '-###' . PHP_EOL;
$menu .= '-Layoutit|https://www.layoutit.com/build" target="popup" onclick="window.open(\'https://www.layoutit.com/build\',\'popup\',\'width=1340,height=700\'); return false;|Bootstrap Page Builder ({getstring}english{/getstring})' . PHP_EOL;
$menu .= '-Pixlr|https://pixlr.com/editor/" target="popup" onclick="window.open(\'https://pixlr.com/editor/\',\'popup\',\'width=1340,height=700\'); return false;|Photo Editor ({getstring}english{/getstring})' . PHP_EOL;
$menu .= '-ScreenApp|https://screenapp.io/#/recording" target="popup" onclick="window.open(\'https://screenapp.io/#/recording\',\'popup\',\'width=1340,height=700\'); return false;|Screen Recorder ({getstring}english{/getstring})' . PHP_EOL;
$menu .= '-{getstring:filtercodes}pagebuilder{/getstring}|{getstring:filtercodes}pagebuilderlink{/getstring}" target="popup" onclick="window.open(\'{getstring:filtercodes}pagebuilderlink{/getstring}\',\'popup\',\'width=1340,height=700\'); return false;' . PHP_EOL;
$menu .= '-{getstring:filtercodes}photoeditor{/getstring}|{getstring:filtercodes}photoeditorlink{/getstring}" target="popup" onclick="window.open(\'{getstring:filtercodes}photoeditorlink{/getstring}\',\'popup\',\'width=1340,height=700\'); return false;' . PHP_EOL;
$menu .= '-{getstring:filtercodes}screenrecorder{/getstring}|{getstring:filtercodes}screenrecorderlink{/getstring}" target="popup" onclick="window.open(\'{getstring:filtercodes}screenrecorderlink{/getstring}\',\'popup\',\'width=1340,height=700\'); return false;' . PHP_EOL;
$menu .= '-###' . PHP_EOL;
$menu .= '-MoodleDev docs|https://moodle.org/development|Moodle.org ({getstring}english{/getstring})' . PHP_EOL;
$menu .= '-MoodleDev forum|https://moodle.org/mod/forum/view.php?id=55|Moodle.org ({getstring}english{/getstring})' . PHP_EOL;
Expand Down Expand Up @@ -669,24 +669,6 @@ function ($matches) use ($USER) {
}
}

// Tags starting with: {support...}.
if (stripos($text, '{support') !== false) {
// Tag: {supportname}.
if (stripos($text, '{supportname}') !== false) {
$replace['/\{supportname\}/i'] = $CFG->supportname;
}

// Tag: {supportemail}.
if (stripos($text, '{supportemail}') !== false) {
$replace['/\{supportemail\}/i'] = $CFG->supportemail;
}

// Tag: {supportpage}.
if (stripos($text, '{supportpage}') !== false) {
$replace['/\{supportpage\}/i'] = $CFG->supportpage;
}
}

if (get_config('filter_filtercodes', 'enable_scrape')) { // Must be enabled in FilterCodes settings.
// Tag: {scrape url="" tag="" class="" id="" code=""}.
if (stripos($text, '{scrape ') !== false) {
Expand Down Expand Up @@ -1830,15 +1812,15 @@ function ($matches) {

// If the tag exists and is not set to "Not visible" in the custom profile field's settings.
if (isset($profiledata[$field->id]) && $isuser &&
($field->visible == '0' || !get_config('filter_filtercodes', 'ifprofilefiedonlyvisible'))) {
($field->visible == '0' || get_config('filter_filtercodes', 'ifprofilefiedonlyvisible'))) {
$data = trim($profiledata[$field->id]);
} else {
$data = '';
}

// If the value is empty or zero, remove the all of the tags and their contents for that field shortname.
if (empty($data)) {
$replace['/\{' . $tag . '(.*?)\}(.*?)\{\/' . $tag . '\}/ims'] = '';
$replace['/\{ ' . $tag . '(.*?)\}(.*?)\{\/' . $tag . '\}/ims'] = '';
continue;
}

Expand Down
11 changes: 9 additions & 2 deletions lang/en/filter_filtercodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
$string['courseteachershowpic_desc'] = 'If enabled, will display the teacher\'s profile picture in {courseteachers} tags.';
$string['courseteacherlinktype'] = 'Teacher link type';
$string['courseteacherlinktype_desc'] = 'Choose the type of link for the teacher\s link in the {courseteachers} tags.';
$string['ifprofilefiedonlyvisible'] = '{ifprofilefied} only visible.';
$string['ifprofilefiedonlyvisible_desc'] = 'Restrict the {ifprofilefied} tag to only access visible fields. Hidden fields will behave as if the field was empty. If unchecked, this tag will be able to check hidden user fields.';
$string['ifprofilefiedonlyvisible'] = '{ifprofile_field_} only visible.';
$string['ifprofilefiedonlyvisible_desc'] = 'Restrict the {ifprofile_field_...} tag to only access visible profile fields. Hidden fields will behave as if the field was empty. If unchecked, this tag will be able to check hidden user fields.';

$string['sizeb'] = 'B';
$string['sizekb'] = 'KB';
Expand All @@ -67,6 +67,13 @@
$string['globaltagnamedesc'] = 'This will be part of your tag name, prefixed with "global_". Example: If you enter "address" here, your tag will be called {global_address}". Must be a single string of letters only, no spaces, numbers or special characters are permitted.';
$string['globaltagcontenttitle'] = 'Content';
$string['globaltagcontentdesc'] = 'This is the content that your global tag will replace. Example: If your tag is called "{global_address}", that tag will be replaced by the content entered into this field.';
$string['pagebuilder'] = 'Page builder';
$string['pagebuilderlink'] = 'https://www.layoutit.com/build';
$string['photoeditor'] = 'Photo editor';
$string['photoeditorname'] = 'Pixlr';
$string['photoeditorlink'] = 'https://pixlr.com/editor/';
$string['screenrecorder'] = 'Screen recorder';
$string['screenrecorderlink'] = 'https://screenapp.io/#/recording';

$string['formquickquestion'] = '
<form action="{wwwroot}/local/contact/index.php" method="post" class="cf contact-us">
Expand Down
4 changes: 2 additions & 2 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ function filter_filtercodes_render_navbar_output() {

// Don't apply auto-linking filters.
$filtermanager = filter_manager::instance();
$filteroptions = array('originalformat' => FORMAT_HTML, 'noclean' => true);
$skipfilters = array('activitynames', 'data', 'glossary', 'sectionnames', 'bookchapters');
$filteroptions = ['originalformat' => FORMAT_HTML, 'noclean' => true];
$skipfilters = ['activitynames', 'data', 'glossary', 'sectionnames', 'bookchapters'];

// Filter Custom Menu.
$CFG->custommenuitems = $filtermanager->filter_text($CFG->custommenuitems,
Expand Down
5 changes: 4 additions & 1 deletion settings/general.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
$name = 'filter_filtercodes/courseteacherlinktype';
$title = get_string('courseteacherlinktype', 'filter_filtercodes');
$description = get_string('courseteacherlinktype_desc', 'filter_filtercodes');
$choices = ['' => get_string('none'), 'email' => get_string('issueremail', 'badges'), 'message' => get_string('message', 'message'), 'profile' => get_string('profile')];
$choices = ['' => get_string('none'),
'email' => get_string('issueremail', 'badges'),
'message' => get_string('message', 'message'),
'profile' => get_string('profile')];
$setting = new admin_setting_configselect($name, $title, $description, $default, $choices);
$settings->add($setting);
167 changes: 83 additions & 84 deletions settings/global.php
Original file line number Diff line number Diff line change
@@ -1,84 +1,83 @@
<?php
// This file is part of FilterCodes for Moodle - http://moodle.org/
//
// FilterCodes is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// FilterCodes is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Settings for global custom tags for FilterCodes.
*
* @package filter_filtercodes
* @copyright 2017-2021 TNG Consulting Inc. - www.tngconsulting.ca
* @author Michael Milette
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

// FilterCodes plugin.
$name = 'filter_filtercodes';

// Page Table of contents
$title = get_string('globaltagheadingtitle', $name);
$description = get_string('globaltagheadingdesc', $name);
$setting = new admin_setting_heading($name . '/globaltagheadingtitle', $title, $description);
$settings->add($setting);


// Number of tags.
$title = get_string('globaltagcount', $name);
$description = get_string('globaltagcountdesc', $name);
$default = 0;
$choices = [];
for ($i = 0; $i <= 20; $i++) {
$choices[$i] = $i;
}
$settings->add(new admin_setting_configselect($name . '/globaltagcount', $title, $description, $default, $choices));

// This is the descriptors for each FilterCodes tag.
$tagtitle = get_string('globaltagnametitle', $name);
$tagdescription = get_string('globaltagnamedesc', $name);
$contenttitle = get_string('globaltagcontenttitle', $name);
$contentdescription = get_string('globaltagcontentdesc', $name);
$format = get_string('htmlformat');
$default = '';

$globaltagcount = get_config($name, 'globaltagcount');
for ($i = 1; $i <= $globaltagcount; $i++) {
// Tag name.
$setting = new admin_setting_configtext($name . '/globalname' . $i,
$tagtitle . get_config($name, 'globalname' . $i),
$tagdescription, $default, PARAM_ALPHA);
$settings->add($setting);

// Tag content editor.
if (($editor = get_config($name, 'globaleditor' . $i)) == '') {
// First time. Initialize to Yes.
set_config('globaleditor' . $i, $editor = 1, $name);
}

if (empty($editor)) {
// Plain text area.
$setting = new admin_setting_configtextarea($name . '/globalcontent' . $i, $contenttitle,
$contentdescription, $default, PARAM_RAW);
} else {
// Rich text area.
$setting = new admin_setting_confightmleditor($name . '/globalcontent' . $i, $contenttitle,
$contentdescription, $default, PARAM_RAW);
}
$settings->add($setting);

// Content editor type.
$setting = new admin_setting_configcheckbox($name . '/globaleditor' . $i, $format, '', 1);
$settings->add($setting);
}
<?php
// This file is part of FilterCodes for Moodle - http://moodle.org/
//
// FilterCodes is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// FilterCodes is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Settings for global custom tags for FilterCodes.
*
* @package filter_filtercodes
* @copyright 2017-2021 TNG Consulting Inc. - www.tngconsulting.ca
* @author Michael Milette
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

defined('MOODLE_INTERNAL') || die();

// FilterCodes plugin.
$name = 'filter_filtercodes';

// Page Table of contents.
$title = get_string('globaltagheadingtitle', $name);
$description = get_string('globaltagheadingdesc', $name);
$setting = new admin_setting_heading($name . '/globaltagheadingtitle', $title, $description);
$settings->add($setting);

// Number of tags.
$title = get_string('globaltagcount', $name);
$description = get_string('globaltagcountdesc', $name);
$default = 0;
$choices = [];
for ($i = 0; $i <= 20; $i++) {
$choices[$i] = $i;
}
$settings->add(new admin_setting_configselect($name . '/globaltagcount', $title, $description, $default, $choices));

// This is the descriptors for each FilterCodes tag.
$tagtitle = get_string('globaltagnametitle', $name);
$tagdescription = get_string('globaltagnamedesc', $name);
$contenttitle = get_string('globaltagcontenttitle', $name);
$contentdescription = get_string('globaltagcontentdesc', $name);
$format = get_string('htmlformat');
$default = '';

$globaltagcount = get_config($name, 'globaltagcount');
for ($i = 1; $i <= $globaltagcount; $i++) {
// Tag name.
$setting = new admin_setting_configtext($name . '/globalname' . $i,
$tagtitle . get_config($name, 'globalname' . $i),
$tagdescription, $default, PARAM_ALPHA);
$settings->add($setting);

// Tag content editor.
if (($editor = get_config($name, 'globaleditor' . $i)) == '') {
// First time. Initialize to Yes.
set_config('globaleditor' . $i, $editor = 1, $name);
}

if (empty($editor)) {
// Plain text area.
$setting = new admin_setting_configtextarea($name . '/globalcontent' . $i, $contenttitle,
$contentdescription, $default, PARAM_RAW);
} else {
// Rich text area.
$setting = new admin_setting_confightmleditor($name . '/globalcontent' . $i, $contenttitle,
$contentdescription, $default, PARAM_RAW);
}
$settings->add($setting);

// Content editor type.
$setting = new admin_setting_configcheckbox($name . '/globaleditor' . $i, $format, '', 1);
$settings->add($setting);
}
Loading

0 comments on commit ce01a62

Please sign in to comment.