includes/plugins.php
author Dan
Fri, 07 Mar 2008 01:27:28 -0500
changeset 493 d8296f89ebb5
parent 464 8063eace5b67
child 507 586fd7d3202d
permissions -rw-r--r--
Fixed the TinyMCE save bug.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     1
<?php
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     2
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     3
/*
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     4
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
411
d1a95497b68f Rebrand as 1.1.2; made upgrade framework functional
Dan
parents: 403
diff changeset
     5
 * Version 1.1.2 (Caoineag alpha 2)
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     6
 * Copyright (C) 2006-2007 Dan Fuhry
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     7
 *
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     8
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     9
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    10
 *
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    11
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    12
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    13
 */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    14
 
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    15
/**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    16
 * Class used to handle and process plugin requests and loading. Singleton.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    17
 * @package Enano
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    18
 * @author Dan Fuhry <dan@enanocms.org>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    19
 * @copyright (C) 2006-2008 Enano Project
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    20
 * @license GNU General Public License <http://enanocms.org/Special:GNU_General_Public_License>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    21
 */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    22
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    23
class pluginLoader {
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    24
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    25
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    26
   * The list of hooks registered.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    27
   * @var array
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    28
   * @access private
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    29
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    30
  
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    31
  var $hook_list;
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    32
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    33
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    34
   * The list of plugins that should be loaded. Used only by common.php.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    35
   * @var array
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    36
   * @access private
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    37
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    38
  
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    39
  var $load_list;
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    40
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    41
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    42
   * The list of plugins that are loaded currently. This is only used by the loaded() method which in turn is
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    43
   * used by template files with the <!-- IFPLUGIN --> special tag.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    44
   * @var array
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    45
   * @access private
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    46
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    47
  
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    48
  var $loaded_plugins;
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    49
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    50
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    51
   * The list of plugins that are always loaded because they're part of the Enano core. This cannot be modified
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    52
   * by any external code because user plugins are loaded after the load_list is calculated. Can be useful in
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    53
   * alternative administration panel frameworks that need the list of system plugins.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    54
   * @var array
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    55
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    56
  
403
2c9745b5c09d Started on a Special:RecentChanges page, more to come.
Dan
parents: 387
diff changeset
    57
  var $system_plugins = Array('SpecialUserFuncs.php','SpecialUserPrefs.php','SpecialPageFuncs.php','SpecialAdmin.php','SpecialCSS.php','SpecialUpdownload.php','SpecialSearch.php','PrivateMessages.php','SpecialGroups.php', 'SpecialRecentChanges.php');
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    58
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    59
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    60
   * Name kept for compatibility. Effectively a constructor. Calculates the list of plugins that should be loaded
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    61
   * and puts that list in the $load_list property. Plugin developers have absolutely no use for this whatsoever.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    62
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
    63
  
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    64
  function loadAll() 
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    65
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    66
    $dir = ENANO_ROOT.'/plugins/';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    67
    
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    68
    $this->load_list = Array();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    69
    
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    70
    $plugins = Array();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    71
    
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    72
    // Open a known directory, and proceed to read its contents
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    73
    
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    74
    if (is_dir($dir))
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    75
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    76
      if ($dh = opendir($dir))
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    77
      {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    78
        while (($file = readdir($dh)) !== false)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    79
        {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    80
          if(preg_match('#^(.*?)\.php$#is', $file))
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    81
          {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    82
            if(getConfig('plugin_'.$file) == '1' || in_array($file, $this->system_plugins))
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    83
            {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    84
              $this->load_list[] = $dir . $file;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    85
              $plugid = substr($file, 0, strlen($file)-4);
378
c1c7fa6b329f Got Enano to load even if there are no plugins; added caching for decrypted session keys to significantly improve performance (in theory at least)
Dan
parents: 322
diff changeset
    86
              $f = @file_get_contents($dir . $file);
c1c7fa6b329f Got Enano to load even if there are no plugins; added caching for decrypted session keys to significantly improve performance (in theory at least)
Dan
parents: 322
diff changeset
    87
              if ( empty($f) )
c1c7fa6b329f Got Enano to load even if there are no plugins; added caching for decrypted session keys to significantly improve performance (in theory at least)
Dan
parents: 322
diff changeset
    88
                continue;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    89
              $f = explode("\n", $f);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    90
              $f = array_slice($f, 2, 7);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    91
              $f[0] = substr($f[0], 13);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    92
              $f[1] = substr($f[1], 12);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    93
              $f[2] = substr($f[2], 13);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    94
              $f[3] = substr($f[3], 8 );
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    95
              $f[4] = substr($f[4], 9 );
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    96
              $f[5] = substr($f[5], 12);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    97
              $plugins[$plugid] = Array();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    98
              $plugins[$plugid]['name'] = $f[0];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    99
              $plugins[$plugid]['uri']  = $f[1];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   100
              $plugins[$plugid]['desc'] = $f[2];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   101
              $plugins[$plugid]['auth'] = $f[3];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   102
              $plugins[$plugid]['vers'] = $f[4];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   103
              $plugins[$plugid]['aweb'] = $f[5];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   104
            }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   105
          }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   106
        }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   107
        closedir($dh);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   108
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   109
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   110
    $this->loaded_plugins = $plugins;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   111
    //die('<pre>'.htmlspecialchars(print_r($plugins, true)).'</pre>');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   112
  }
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   113
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   114
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   115
   * Name kept for compatibility. This method is used to add a new hook into the code somewhere. Plugins are encouraged
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   116
   * to set hooks and hook into other plugins in a fail-safe way, this encourages reuse of code. Returns an array, whose
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   117
   * values should be eval'ed.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   118
   * @example <code>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   119
   $code = $plugins->setHook('my_hook_name');
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   120
   foreach ( $code as $cmd )
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   121
   {
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   122
     eval($cmd);
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   123
   }
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   124
   </code>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   125
   * @param string The name of the hook.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   126
   * @param array Deprecated.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   127
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   128
  
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   129
  function setHook($name, $opts = Array()) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   130
    if(isset($this->hook_list[$name]) && is_array($this->hook_list[$name]))
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   131
    {
379
82b991bee797 Minor and hopefully non-breaking change to plugin loader to possibly double performance at hook points
Dan
parents: 378
diff changeset
   132
      return array(implode("\n", $this->hook_list[$name]));
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   133
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   134
    else
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   135
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   136
      return Array();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   137
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   138
  }
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   139
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   140
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   141
   * Attaches to a hook effectively scheduling some code to be run at that point. You should try to keep hooks clean by
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   142
   * making a function that has variables that need to be modified passed by reference.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   143
   * @example Simple example: <code>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   144
   $plugins->attachHook('render_wikiformat_pre', '$text = str_replace("Goodbye, Mr. Chips", "Hello, Mr. Carrots", $text);');
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   145
   </code>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   146
   * @example More complicated example: <code>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   147
   $plugins->attachHook('render_wikiformat_pre', 'myplugin_parser_ext($text);');
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   148
   
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   149
   // Notice that $text is passed by reference.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   150
   function myplugin_parser_ext(&$text)
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   151
   {
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   152
     $text = str_replace("Goodbye, Mr. Chips", "Hello, Mr. Carrots", $text);
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   153
   }
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   154
   </code>
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   155
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   156
  
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   157
  function attachHook($name, $code) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   158
    if(!isset($this->hook_list[$name]))
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   159
    {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   160
      $this->hook_list[$name] = Array();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   161
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   162
    $this->hook_list[$name][] = $code;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   163
  }
464
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   164
  
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   165
  /**
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   166
   * Tell whether a plugin is loaded or not.
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   167
   * @param string The filename of the plugin
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   168
   * @return bool
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   169
   */
8063eace5b67 Documented includes/plugins.php to try and help plugin developers a little.
Dan
parents: 411
diff changeset
   170
  
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   171
  function loaded($plugid)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   172
  {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   173
    return isset( $this->loaded_plugins[$plugid] );
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   174
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   175
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   176
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   177
?>