Skip to content

Commit

Permalink
added a try/catch to rendered content processing
Browse files Browse the repository at this point in the history
  • Loading branch information
justinhunt committed Jan 25, 2024
1 parent 7445159 commit 4df72f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Change List
=========
Version 1.4.20(Build 202401xxxx)
- Added a try/catch to renderedcontent filter processing

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

Expand Down
24 changes: 15 additions & 9 deletions filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,21 @@ function filter_generico_callback(array $link) {
//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);
try {
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);
} catch (Exception $e) {
$genericotemplate = str_replace('@@renderedcontent@@', 'Failed to render!!', $genericotemplate);
}
}

//If template requires a MOODLEPAGEID lets give them one
Expand Down

0 comments on commit 4df72f4

Please sign in to comment.