| | 2 | |
|---|
| | 3 | |
|---|
| | 4 | /** Set the display object method for a given module. |
|---|
| | 5 | * @param $module A string containing the module name - eg "file" |
|---|
| | 6 | * @param $function The name of your function matching the prototype $name($object_id, $object_type) where $object_type is the description of the object eg "file::file". |
|---|
| | 7 | */ |
|---|
| | 8 | function display_set_display_function($module, $function) |
|---|
| | 9 | { |
|---|
| | 10 | global $CFG; |
|---|
| | 11 | |
|---|
| | 12 | if (!isset($CFG->displayobjectfunctions)) |
|---|
| | 13 | $CFG->displayobjectfunctions = array(); |
|---|
| | 14 | |
|---|
| | 15 | $CFG->displayobjectfunctions[$module] = $function; |
|---|
| | 16 | } |
|---|
| | 17 | |
|---|
| | 18 | /** Call a function's display object code and returns its html |
|---|
| | 19 | * @param $module The module name eg 'file' |
|---|
| | 20 | * @param $object_id The id of the object |
|---|
| | 21 | * @param $object_type The type of the object - eg 'file::file' - largely ignored. |
|---|
| | 22 | */ |
|---|
| | 23 | function display_run_displayobject($module, $object_id, $object_type) |
|---|
| | 24 | { |
|---|
| | 25 | global $CFG; |
|---|
| | 26 | |
|---|
| | 27 | $result = ""; |
|---|
| | 28 | if (isset($CFG->displayobjectfunctions[$module])) |
|---|
| | 29 | { |
|---|
| | 30 | $function = $CFG->displayobjectfunctions[$module]; |
|---|
| | 31 | if (is_callable($function)) |
|---|
| | 32 | { |
|---|
| | 33 | $result = $function($object_id, $object_type); |
|---|
| | 34 | } |
|---|
| | 35 | } |
|---|
| | 36 | |
|---|
| | 37 | return $result; |
|---|
| | 38 | } |
|---|