| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | // hiervon werden die Plugins abgeleitet |
|---|
| 4 | class JlogPlugin { |
|---|
| 5 | |
|---|
| 6 | /* Hooks */ |
|---|
| 7 | function hook_body ($t) { return $t; } // string body |
|---|
| 8 | function hook_commentForm ($t) { return $t; } // string with comment form output + array with form data |
|---|
| 9 | function hook_adminContent ($t) { return $t; } // string content |
|---|
| 10 | function hook_newComment ($t) { return $t; } // array form data |
|---|
| 11 | function hook_updateComment ($t) { return $t; } // array form data |
|---|
| 12 | function hook_deleteComment ($t) { return $t; } // string comment id |
|---|
| 13 | function hook_showComment ($t) { return $t; } // string comment output |
|---|
| 14 | function hook_onUpdate ($t) { return $t; } // array with all rss feeds and sub |
|---|
| 15 | function hook_doEntry ($t) { return $t; } // string with entry + array with data from database + string count comments + string section |
|---|
| 16 | function hook_doTeaser ($t) { return $t; } // string with entry + array with data from database + string count comments + string pre + string post |
|---|
| 17 | function hook_bbcode ($t) { return $t; } // bbcode object |
|---|
| 18 | function hook_bbcomments ($t) { return $t; } // bbcomments object |
|---|
| 19 | function hook_adminForm ($t) { return $t; } // admin formular |
|---|
| 20 | function hook_insertEntry ($t) { return $t; } // int id + array with form data |
|---|
| 21 | function hook_updateEntry ($t) { return $t; } // int id + array with form data |
|---|
| 22 | function hook_permalink ($t) { return $t; } // string permalink + string date + string url + string section |
|---|
| 23 | function hook_xmlrpcPermalink ($t) { return $t; } // string url |
|---|
| 24 | function hook_countComments ($t) { return $t; } // array with id and count |
|---|
| 25 | function hook_adminMail ($t) { return $t; } // array with mail + array blogentry |
|---|
| 26 | function hook_commentorMail ($t) { return $t; } // array with mail + array blogentry |
|---|
| 27 | function hook_commentAdminList($t) { return $t; } // string with actual tr + array with comment data |
|---|
| 28 | function hook_previewComment ($t) { return $t; } // same as newComment |
|---|
| 29 | function hook_dispatchLogin ($t) { return $t; } // |
|---|
| 30 | function hook_loginForm ($t) { return $t; } // |
|---|
| 31 | function hook_adminMenu ($t) { return $t; } // string with the admin menu html |
|---|
| 32 | function hook_adminList ($t) { return $t; } // |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | class JlogPluginManager { |
|---|
| 36 | var $plugins = array(); |
|---|
| 37 | |
|---|
| 38 | function JlogPluginManager($plugindirectory) { |
|---|
| 39 | $handle = ""; |
|---|
| 40 | $file = ""; |
|---|
| 41 | $this->get = strip($_GET); |
|---|
| 42 | |
|---|
| 43 | if(is_dir($plugindirectory)) { |
|---|
| 44 | $handle = opendir($plugindirectory); |
|---|
| 45 | while( false !== ( $file = readdir ($handle) ) ) { |
|---|
| 46 | if(substr($file, -10) === '.jplug.php') { |
|---|
| 47 | include_once $plugindirectory.$file; |
|---|
| 48 | $this->register( substr($file, 0, -10) ); |
|---|
| 49 | } |
|---|
| 50 | } |
|---|
| 51 | closedir($handle); |
|---|
| 52 | |
|---|
| 53 | } |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | function register($plugin) { |
|---|
| 57 | $this->plugins[] = new $plugin; |
|---|
| 58 | } |
|---|
| 59 | |
|---|
| 60 | // Aufruf $JLogPluginManagerInstanz->callHook('eins', $param1[, $param2, ...]); |
|---|
| 61 | // $param1 = Pflicht-Parameter, alle anderen optional |
|---|
| 62 | function callHook($hook) { |
|---|
| 63 | $hook = 'hook_' . $hook; |
|---|
| 64 | |
|---|
| 65 | $parameters = func_get_args(); |
|---|
| 66 | array_shift($parameters); // $hook entfernen |
|---|
| 67 | if (!isset($parameters[0])) |
|---|
| 68 | die('fatal error - no parameters'); |
|---|
| 69 | |
|---|
| 70 | $hookresult = $parameters[0]; |
|---|
| 71 | |
|---|
| 72 | foreach ($this->plugins as $plugin) { |
|---|
| 73 | $parameters[0] = $hookresult; |
|---|
| 74 | if($hook == 'hook_adminTitle' OR $hook == 'hook_adminContent') { |
|---|
| 75 | if(strtolower($this->get['jplug']) === strtolower(get_class($plugin))) |
|---|
| 76 | $hookresult = call_user_func_array(array($plugin, $hook), $parameters); |
|---|
| 77 | } |
|---|
| 78 | else $hookresult = call_user_func_array(array($plugin, $hook), $parameters); |
|---|
| 79 | } |
|---|
| 80 | return $hookresult; |
|---|
| 81 | } |
|---|
| 82 | } |
|---|
| 83 | ?> |
|---|