Extent the module functionality to allow callback to append content onto course conte...
authorcindy li <cli@ocad.ca>
Wed, 8 Dec 2010 15:25:23 +0000 (15:25 -0000)
committercindy li <cli@ocad.ca>
Wed, 8 Dec 2010 15:25:23 +0000 (15:25 -0000)
mods/hello_world/ModuleCallbacks.class.php [new file with mode: 0644]
mods/hello_world/module.php

diff --git a/mods/hello_world/ModuleCallbacks.class.php b/mods/hello_world/ModuleCallbacks.class.php
new file mode 100644 (file)
index 0000000..5e1437d
--- /dev/null
@@ -0,0 +1,27 @@
+<?php
+
+/**
+ * This class contains the callback functions that are called in the core scripts to manipulate content etc. 
+ *
+ * Note:
+ * 1. CHANGE the class name and ensure its uniqueness by prefixing with the module name
+ * 2. DO NOT change the script name. Leave as "ModuleCallbacks.class.php"
+ * 3. DO NOT change the names of the methods.
+ * 4. REGISTER the unique class name in module.php
+ *
+ * @access     public
+ */
+if (!defined('AT_INCLUDE_PATH')) exit;
+
+class HelloWorldCallbacks {
+       /*
+        * To append output onto course content page 
+        * @param: None
+        * @return: a string, plain or html, to be appended to course content page
+        */ 
+       public static function appendContent() {
+               return "Output from hello world module!";
+       }
+}
+
+?>
\ No newline at end of file
index 189205a..63f4add 100644 (file)
@@ -86,6 +86,14 @@ $this->_content_tools[] = array("id"=>"helloworld_tool",
                                 "text"=>_AT('hello_world'), 
                                 "js"=>AT_BASE_HREF."mods/hello_world/content_tool_action.js");
 
+/*******
+ * Register the entry of the callback class. Make sure the class name is properly namespaced, 
+ * for instance, prefixed with the module name, to enforce its uniqueness.
+ * This class must be defined in "ModuleCallbacks.class.php".
+ * This class contains the static methods to append content to "view content" page.
+ */
+$this->_callbacks['hello_world'] = 'HelloWorldCallbacks';
+
 function hello_world_get_group_url($group_id) {
        return 'mods/hello_world/index.php';
 }