diff --git a/CHANGES.txt b/CHANGES.txt index 23aec634..ccc41808 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,8 @@ Change List ========= +Version 3.1.72(Build 2024012400) +- Added a template and code to support it, that allows you to call a renderer function from a template + Version 3.1.71(2023101300) - removed debugger statement - removed deprecated calback call which php8.2 complained about diff --git a/filter.php b/filter.php index 717a2fd1..50d2ed19 100644 --- a/filter.php +++ b/filter.php @@ -426,10 +426,18 @@ function filter_poodll_process(array $link, $ext = false) { } //If this is a renderer call, lets do it - if(isset($filterprops['component']) && isset($filterprops['function']) && isset($filterprops['cmid'])){ + //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['component']); - $renderedcontent=call_user_func_array([$somerenderer, $filterprops['function']], [$filterprops['cmid'],$token]); + $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); $poodlltemplate = str_replace('@@renderedcontent@@',$renderedcontent, $poodlltemplate); } diff --git a/presets/renderedcontent.txt b/presets/renderedcontent.txt new file mode 100644 index 00000000..cabba121 --- /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 04498d95..40ea9f90 100644 --- a/version.php +++ b/version.php @@ -25,9 +25,9 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2023101300; +$plugin->version = 2024012400; $plugin->requires = 2016052300;//moodle 3.1.0 $plugin->component = 'filter_poodll'; $plugin->maturity = MATURITY_STABLE; -$plugin->release = '3.1.71(Build 2023101300)'; +$plugin->release = '3.1.72(Build 2024012400)';