Jlog PHP Cross Reference Blogging Systems

Source: /scripts/jlogPlugins.class.php - 86 lines - 3408 bytes - Summary - Text - Print

   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  
  25    /* Parameters functions */
  26  /*
  27      function saveConfigData($name, $t) {
  28      echo  get_class($this);
  29          return false;
  30      }
  31  
  32      function loadConfigData($name, $t) {
  33          return false;
  34      }
  35  */
  36  }
  37  
  38  class JlogPluginManager {
  39      var $plugins = array();
  40  
  41      function JlogPluginManager($plugindirectory) {
  42          $handle = "";
  43          $file = "";
  44          $this->get = strip($_GET);
  45  
  46          if(is_dir($plugindirectory)) {
  47              $handle = opendir($plugindirectory);
  48              while( false !== ( $file = readdir ($handle) ) ) {
  49                  if(substr($file, -10) === '.jplug.php') {
  50                      include_once $plugindirectory.$file;
  51                      $this->register( substr($file, 0, -10) );
  52                  }
  53              }
  54              closedir($handle);
  55  
  56          }
  57      }
  58  
  59      function register($plugin) {
  60          $this->plugins[] = new $plugin;
  61      }
  62  
  63      // Aufruf $JLogPluginManagerInstanz->callHook('eins', $param1[, $param2, ...]);
  64      // $param1 = Pflicht-Parameter, alle anderen optional
  65      function callHook($hook) {
  66          $hook = 'hook_' . $hook;
  67  
  68          $parameters = func_get_args();
  69          array_shift($parameters); // $hook entfernen
  70          if (!isset($parameters[0]))
  71              die('fatal error - no parameters');
  72  
  73          $hookresult = $parameters[0];
  74  
  75          foreach ($this->plugins as $plugin) {
  76              $parameters[0] = $hookresult;
  77              if($hook == 'hook_adminTitle' OR $hook == 'hook_adminContent') {
  78                  if(strtolower($this->get['jplug']) === strtolower(get_class($plugin)))
  79                      $hookresult = call_user_func_array(array($plugin, $hook), $parameters);
  80              }
  81              else $hookresult = call_user_func_array(array($plugin, $hook), $parameters);
  82          }
  83          return $hookresult;
  84      }
  85  }
  86  ?>

title

Description

title

Description

title

Description

title

title

Body