diff --git a/CHANGES.txt b/CHANGES.txt index cb36366..dc892c5 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,8 @@ Change List ========= +Version 1.4.19(Build 2024012400) +- Added a template and code to support it, that allows you to call a renderer function from a template + Version 1.4.18(Build 2022122200) - will return an empty string for custom user profile fields that exist but are empty (previously returned the unparsed variable name) diff --git a/filter.php b/filter.php index e7860b3..59826b3 100644 --- a/filter.php +++ b/filter.php @@ -202,6 +202,22 @@ function filter_generico_callback(array $link) { } } + //If this is a renderer call, lets do it + //it will be a function in a renderer with a name that begins with "embed_" .. e.g "embed_something" + //the args filterprops will be a pipe delimited string of args, eg {POODLL:type="mod_ogte",function="embed_table",args="arg1|arg2|arg3"} + //if the args string contains "cloudpoodlltoken" it will be replaced with the actual cloud poodll token. + if(isset($filterprops['renderer']) && isset($filterprops['function']) && strpos($filterprops['function'],'embed_')===0){ + if(!isset($token)){$token=false;} + $somerenderer = $PAGE->get_renderer($filterprops['renderer']); + $args=[]; + if(isset($filterprops['args'])){ + $args_string =str_replace('cloudpoodlltoken',$token,$filterprops['args']); + $args_array = explode('|',$args_string); + } + $renderedcontent=call_user_func_array([$somerenderer, $filterprops['function']], $args_array); + $genericotemplate = str_replace('@@renderedcontent@@',$renderedcontent, $genericotemplate); + } + //If template requires a MOODLEPAGEID lets give them one //this is legacy really. Now we have @@URLPARAM we could do it that way $moodlepageid = optional_param('id', 0, PARAM_INT); diff --git a/presets/renderedcontent.txt b/presets/renderedcontent.txt new file mode 100644 index 0000000..cabba12 --- /dev/null +++ b/presets/renderedcontent.txt @@ -0,0 +1 @@ +{"name":"Rendered Content","key":"renderedcontent","version":"1.0.1","instructions":"This will fetch and display from a Moodle renderer given the renderer/component name, function name and pipe delimited set of arguments to the function.","showatto":"0","showplayers":"0","requirecss":"","requirejs":"","shim":"","defaults":"renderer=\"\",function=\"\",args=\"\"","amd":"1","body":"\n@@renderedcontent@@","bodyend":"","script":"","style":"","dataset":"","datasetvars":"","alternate":"","alternateend":""} \ No newline at end of file diff --git a/version.php b/version.php index cdd640d..806dceb 100644 --- a/version.php +++ b/version.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2022122200; // The current plugin version (Date: YYYYMMDDXX) +$plugin->version = 2024012400; // The current plugin version (Date: YYYYMMDDXX) $plugin->requires = 2011070100; // Requires this Moodle version $plugin->component = 'filter_generico'; // Full name of the plugin (used for diagnostics) $plugin->maturity = MATURITY_STABLE; -$plugin->release = 'Version 1.4.18(Build 2022122200)'; +$plugin->release = 'Version 1.4.19(Build 2024012400)';