b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (Version 1.9) [ class tree: plugins ] [ index: plugins ] [ all elements ]

Source for file _plugin.class.php

Documentation is available at _plugin.class.php

  1. <?php
  2. /**
  3.  * This file implements the abstract {@link Plugin} class.
  4.  *
  5.  * This file is part of the evoCore framework - {@link http://evocore.net/}
  6.  * See also {@link http://sourceforge.net/projects/evocms/}.
  7.  *
  8.  * @copyright (c)2003-2006 by Francois PLANQUE - {@link http://fplanque.net/}
  9.  *  Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
  10.  *
  11.  *  {@internal License choice
  12.  *  - If you have received this file as part of a package, please find the license.txt file in
  13.  *    the same folder or the closest folder above for complete license terms.
  14.  *  - If you have received this file individually (e-g: from http://cvs.sourceforge.net/viewcvs.py/evocms/)
  15.  *    then you must choose one of the following licenses before using the file:
  16.  *    - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
  17.  *    - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
  18.  *  }}}
  19.  *
  20.  *  {@internal Open Source relicensing agreement:
  21.  *  Daniel HAHLER grants Francois PLANQUE the right to license
  22.  *  Daniel HAHLER's contributions to this file and the b2evolution project
  23.  *  under any OSI approved OSS license (http://www.opensource.org/licenses/).
  24.  *  }}}
  25.  *
  26.  * @package plugins
  27.  *
  28.  * @todo Add links to pages on manual.b2evolution.net, once they are "clean"/tiny
  29.  *
  30.  *  {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  31.  * @author fplanque: Francois PLANQUE - {@link http://fplanque.net/}
  32.  * @author blueyed: Daniel HAHLER
  33.  *
  34.  * @version $Id: _plugin.class.php,v 1.82.2.28 2007/02/17 21:12:44 blueyed Exp $
  35.  */
  36. if!defined('EVO_MAIN_INIT') ) die'Please, do not access this page directly.' );
  37.  
  38.  
  39. /**
  40.  * Plugin Class
  41.  *
  42.  * Real plugins should be derived from this class.
  43.  *
  44.  * @abstract
  45.  * @package plugins
  46.  */
  47. class Plugin
  48. {
  49.     /**#@+
  50.      * Variables below MUST be overriden by plugin implementations,
  51.      * either in the subclass declaration or in the subclass constructor.
  52.      */
  53.  
  54.     /**
  55.      * Default plugin name as it will appear in lists.
  56.      *
  57.      * To make it available for translations set it in the constructor by
  58.      * using the {@link Plugin::T_()} function.
  59.      *
  60.      * This should be no longer than 50 characters.
  61.      *
  62.      * @var string 
  63.      */
  64.     var $name = '';
  65.  
  66.     /**
  67.      * Globally unique code for this plugin functionality. 32 chars. MUST BE SET.
  68.      *
  69.      * A common code MIGHT be shared between different plugins providing the same functionnality.
  70.      * This allows to replace a given renderer with another one and keep the associations with posts.
  71.      * Example: replacing a GIF smiley renderer with an SWF smiley renderer...
  72.      *
  73.      * @var string 
  74.      */
  75.     var $code = '';
  76.  
  77.     /**
  78.      * Default priority.
  79.      *
  80.      * Priority determines in which order the plugins get called.
  81.      * Range: 1 to 100 (the lower the number, the earlier it gets called)
  82.      *
  83.      * @var int 
  84.      */
  85.     var $priority = 50;
  86.  
  87.     /**
  88.      * Plugin version number (max 42 chars, so obscure CVS Revision keywords get handled).
  89.      *
  90.      * This must be compatible to PHP's {@link version_compare()},
  91.      * e.g. '1', '2', '1.1', '2.1b' and '10-1-1a' are fine.
  92.      *
  93.      * This can be used by other plugins when requiring your plugin
  94.      * through {@link Plugin::GetDependencies()}.
  95.      *
  96.      * By increasing it you can request a call of {@link GetDbLayout()} upon instantiating.
  97.      * If there are DB layout changes to be made, the plugin gets changed to status "needs_config".
  98.      *
  99.      * @var string 
  100.      */
  101.     var $version = '0';
  102.  
  103.     /**
  104.      * Plugin author.
  105.      *
  106.      * This is for user info only.
  107.      *
  108.      * @var string 
  109.      */
  110.     var $author = 'Unknown author';
  111.  
  112.     /**
  113.      * URL for more info about the plugin, author and new versions.
  114.      *
  115.      * This is for user info only.
  116.      *
  117.      * If empty, it defaults to 'http://manual.b2evolution.net/Plugins/[plugin_classname]',
  118.      * where '[plugin_classname]' is the plugin's PHP class name.
  119.      *
  120.      * @var string 
  121.      */
  122.     var $help_url = '';
  123.  
  124.     /**
  125.      * Plugin short description.
  126.      *
  127.      * This should be no longer than a line and is limited to 255 chars.
  128.      *
  129.      * @var string 
  130.      */
  131.     var $short_desc;
  132.  
  133.     /**#@-*/
  134.  
  135.  
  136.     /**#@+
  137.      * Variables below MAY be overriden.
  138.      */
  139.  
  140.     /**
  141.      * Plugin long description.
  142.      *
  143.      * This should be no longer than a line.
  144.      *
  145.      * @var string 
  146.      */
  147.     var $long_desc;
  148.  
  149.  
  150.     /**
  151.      * If this is a rendering plugin, when should rendering apply?
  152.      *
  153.      * This is the default value for the plugin and can be overriden in the Plugins
  154.      * administration for plugins that provide rendering events.
  155.      *
  156.      * {@internal The actual value for the plugin gets stored in T_plugins.plug_apply_rendering.}}
  157.      *
  158.      * Possible values:
  159.      * - 'stealth': gets always used, but not displayed as option
  160.      * - 'always': gets always used, and displayed as disabled checkbox
  161.      * - 'opt-out': enabled by default
  162.      * - 'opt-in': disabled by default
  163.      * - 'lazy': checkbox gets displayed, but is disabled
  164.      * - 'never': cannot get used as a renderer
  165.      *
  166.      * @todo blueyed>> IMHO we would need another value, which is the same as "lazy", but does not display a checkbox, which is useful for Plugins that add themselves as renderers on Item update
  167.      *
  168.      * @var string 
  169.      */
  170.     var $apply_rendering = 'never'// By default, this may not be a rendering plugin
  171.  
  172.  
  173.     /**
  174.      * Number of allowed installs.
  175.      *
  176.      * When installing the plugin it gets checked if the plugin is already installed this
  177.      * many times. If so, the installation gets aborted.
  178.      */
  179.     var $number_of_installs;
  180.  
  181.  
  182.     /**
  183.      * Main group of the plugin.
  184.      *
  185.      * @var string 
  186.      */
  187.     var $group;
  188.  
  189.  
  190.     /**
  191.      * Sub-Group of the plugin.
  192.      *
  193.      * @var string 
  194.      */
  195.     var $sub_group;
  196.  
  197.  
  198.     /**
  199.      * Name of the ping service (if this is a ping plugin, see {@link Plugin::ItemSendPing()})
  200.      * @var string 
  201.      */
  202.     var $ping_service_name;
  203.  
  204.     /**
  205.      * Note about the ping service, used in the list of ping services in the blog settings
  206.      * (if this is a ping plugin, see {@link Plugin::ItemSendPing()})
  207.      * @var string 
  208.      */
  209.     var $ping_service_note;
  210.  
  211.     /**#@-*/
  212.  
  213.  
  214.     /**#@+
  215.      * Variables below MUST NOT be overriden or changed by you!
  216.      * @access private
  217.      */
  218.  
  219.     /**
  220.      * Name of the current class. (AUTOMATIC)
  221.      *
  222.      * Will be set automatically (from filename) when registering plugin.
  223.      *
  224.      * @var string 
  225.      */
  226.     var $classname;
  227.  
  228.     /**
  229.      * Internal (DB) ID. (AUTOMATIC)
  230.      *
  231.      * ID < 1 means 'NOT installed'
  232.      *
  233.      * @var int 
  234.      */
  235.     var $ID 0;
  236.  
  237.  
  238.     /**
  239.      * If the plugin provides settings, this will become the object to access them.
  240.      *
  241.      * This gets instantianted on Plugin registration for PHP4 and through
  242.      * overloading in PHP5+, which means on first access.
  243.      *
  244.      * @see GetDefaultSettings()
  245.      * @var NULL|PluginSettings
  246.      */
  247.     var $Settings;
  248.  
  249.  
  250.     /**
  251.      * If the plugin provides user settings, this will become the object to access them.
  252.      *
  253.      * This gets instantianted on Plugin registration for PHP4 and through
  254.      * overloading in PHP5+, which means on first access.
  255.      *
  256.      * NOTE: its methods use {@link $current_User::ID} by default, but you may call it
  257.      *       if there's no {@link $current_User} instantiated (yet).
  258.      *
  259.      * @see GetDefaultUserSettings()
  260.      * @var NULL|PluginUserSettings
  261.      */
  262.     var $UserSettings;
  263.  
  264.  
  265.     /**
  266.      * The status of the plugin.
  267.      *
  268.      * Use {@link set_status()} to change it, if you need to.
  269.      *
  270.      * @var string Either 'enabled', 'disabled', 'needs_config' or 'broken'.
  271.      */
  272.     var $status;
  273.  
  274.     /**
  275.      * The "mother" object, where this Plugin got instantiated from.
  276.      *
  277.      * This is needed, if you have to call a method on it (e.g. {@link Plugins::set_apply_rendering()}.
  278.      *
  279.      * @var Plugins|Plugins_admin
  280.      */
  281.     var $Plugins;
  282.  
  283.     /**
  284.      * The translations keyed by locale. They get loaded through include() of _global.php.
  285.      * @see Plugin::T_()
  286.      * @var array 
  287.      */
  288.     var $_trans array();
  289.  
  290.     /**
  291.      * The translation charsets keyed by locale. They get loaded through include() of _global.php.
  292.      * @see Plugin::T_()
  293.      * @var array 
  294.      */
  295.     var $_trans_charsets array();
  296.  
  297.     /**
  298.      * @var boolean Has the global /locales/_global.php file (where translation for
  299.      *  all languages can be put into) been loaded?
  300.      */
  301.     var $_trans_loaded_global false;
  302.  
  303.     /**#@-*/
  304.  
  305.  
  306.     /**
  307.      * Constructor.
  308.      *
  309.      * You should not use a constructor with your plugin, but the
  310.      * {@link Plugin::PluginInit()} method instead!
  311.      */
  312.     function Plugin()
  313.     {
  314.     }
  315.  
  316.  
  317.     /**
  318.      * Init the Plugin after it has been registered/instantiated.
  319.      *
  320.      * Should set name and description in a localizable fashion.
  321.      *
  322.      * This gets called on every instantiated plugin, also if it's just for
  323.      * discovering the list of available plugins in the backoffice.
  324.      *
  325.      * Use this to validate Settings/requirements and/or cache them into class properties.
  326.      *
  327.      * @param array Associative array of parameters.
  328.      *               'is_installed': true, if the plugin is installed; false if not (probably it got discovered then)
  329.      *               'db_row': an array with the columns of the plugin DB entry (in T_plugins).
  330.      *                         This is empty, if the plugin is not installed!
  331.      *                         E.g., 'plug_version' might be interesting to compare again "$this->version".
  332.      * @return boolean If this method returns false, the Plugin gets unregistered (for the current request only).
  333.      */
  334.     function PluginInit$params )
  335.     {
  336.         // NOTE: the code below is just to handle stuff that has been deprecated since
  337.         //       b2evolution 1.9. You don't have to include this, if you override this method.
  338.  
  339.         ifis_null($this->short_desc) )
  340.         // may have been set in plugin's constructor (which is deprecated since 1.9)
  341.             $this->short_desc = T_('No desc available');
  342.         }
  343.         ifis_null($this->long_desc) )
  344.         // may have been set in plugin's constructor (which is deprecated since 1.9)
  345.             $this->long_desc = T_('No description available');
  346.         }
  347.  
  348.         ifmethod_exists$this'AppendPluginRegister' && $params['is_installed')
  349.         // Wrapper for deprecated AppendPluginRegister method (deprecated since 1.9)
  350.             $this->debug_log('Plugin has deprecated AppendPluginRegister method. Use PluginInit instead.'array('deprecated'));
  351.  
  352.             return $this->AppendPluginRegister($params);
  353.         }
  354.  
  355.         return true;
  356.     }
  357.  
  358.  
  359.     // Plugin information (settings, DB layout, ..): {{{
  360.  
  361.     /**
  362.      * Define here default settings that are then available in the backoffice.
  363.      *
  364.      * You can access them in the plugin through the member object
  365.      * {@link Plugin::Settings}, e.g.:
  366.      * <code>$this->Settings->get( 'my_param' );</code>
  367.      *
  368.      * You probably don't need to set or change values (other than the
  369.      * defaultvalues), but if you know what you're doing, see
  370.      * {@link PluginSettings}, where {@link Plugin::Settings} gets derived from.
  371.      *
  372.      * NOTE: this method gets called by b2evo when instantiating the plugin
  373.      *       settings and when the settings get displayed for editing in the backoffice.
  374.      *       In the second case, $params['for_editing'] will be true.
  375.      *
  376.      * @param array Associative array of parameters (since 1.9).
  377.      *     'for_editing': true, if the settings get queried for editing;
  378.      *                    false, if they get queried for instantiating {@link Plugin::Settings}.
  379.      * @return array 
  380.      *  The array to be returned should define the names of the settings as keys (max length is 30 chars)
  381.      *  and assign an array with the following keys to them (only 'label' is required):
  382.      *
  383.      *    <ul><li>
  384.      *    'label': Name/Title of the param, gets displayed as label for the input field, or
  385.      *               as "legend" tag with types "array" and "fieldset".
  386.      *    </li><li>
  387.      *    'defaultvalue': Default value for the setting, defaults to '' (empty string)
  388.      *    </li><li>
  389.      *    'type', which can be:
  390.      *      <ul><li>
  391.      *      'text' (default): a simple string
  392.      *      </li><li>
  393.      *      'html_input' : like text, but allows html
  394.      *      </li><li>
  395.      *      'password': like text, but hidden during input
  396.      *      </li><li>
  397.      *      'checkbox': either 0 or 1
  398.      *      </li><li>
  399.      *      'integer': a number (no float, can have leading "+" or "-")
  400.      *                   (like 'text' for input, but gets validated when submitting)
  401.      *      </li><li>
  402.      *      'float': a floating number (can have leading "+" or "-", e.g. "+1", "-0.05")
  403.      *                   (like 'text' for input, but gets validated when submitting)
  404.      *      </li><li>
  405.      *      'textarea': several lines of input. The following can be set for this type:
  406.      *        <ul><li>
  407.      *        'rows': number of rows
  408.      *        </li><li>
  409.      *        'cols': number of columns
  410.      *        </li></ul>
  411.      *      'html_textarea': like textarea, but allows html
  412.      *      </li><li>
  413.      *      'select': a drop down field; you must set 'options' for it:
  414.      *        <ul><li>
  415.      *        'options': an array of options ('value' => 'description'), see {@link Form::select_input_array()}.
  416.      *        </li></ul>
  417.      *      </li><li>
  418.      *      'select_group': a drop down field, providing all existing groups (Group ID is the value or "" if "allow_none" is true)
  419.      *      </li><li>
  420.      *      'select_user': a drop down field, providing all existing groups (User ID is the value or "" if "allow_none" is true)
  421.      *      </li><li>
  422.      *      'array': a subset of settings. The value gets automagically (un)serialized through get() and set().
  423.      *        The following keys apply to this type:
  424.      *        <ul><li>
  425.      *        'entries': an array with the sub-settings (which can be everything from the top-level, except:
  426.      *                     "valid_pattern", "valid_range"). Note: currently there's no type forcing or checking
  427.      *                     for sub-entries involved (e.g., if you have an entry of type "integer", you could get
  428.      *                     a non-numeric string there).
  429.      *        </li><li>
  430.      *        'max_count': maximum count of sets (optional, default is no restriction)
  431.      *        </li><li>
  432.      *        'min_count': minimum count of sets (optional, default is no restriction)
  433.      *        </li></ul>
  434.      *      </li></ul>
  435.      *    </li><li>
  436.      *    'note' (gets displayed as a note to the param field),
  437.      *    </li><li>
  438.      *    'size': Size of the HTML input field (applies to types 'text', 'password' and 'integer'; defaults to 15)
  439.      *    </li><li>
  440.      *    'maxlength': maxlength attribute for the input field (See 'size' above; defaults to no limit)
  441.      *    </li><li>
  442.      *    'disabled': if true, it adds a 'disabled="disabled"' html attribute to the element and the value cannot be changed
  443.      *    </li><li>
  444.      *    'no_edit': if true, the setting is not editable. This is useful for internal settings.
  445.      *    </li><li>
  446.      *    'allow_none': set this to true to have "None" in the options list for types
  447.      *                    'select_group' and 'select_user'.
  448.      *    </li><li>
  449.      *    'valid_pattern': A regular expression pattern that the value must match.
  450.      *                       This is either just a regexp pattern as string or an array
  451.      *                       with the keys 'pattern' and 'error' to define a custom error message.
  452.      *    </li><li>
  453.      *    'valid_range': An array with keys 'min', 'max' and (optionally) 'error' to define
  454.      *                     a custom error message. At least "min" or "max" must be given.
  455.      *    </li><li>
  456.      *    'help': can be:
  457.      *           <ul><li>
  458.      *           '#anchor': anchor that gets appended to {@link $help_url}
  459.      *           </li><li>
  460.      *           true: the settings name/key gets transformed to an html ID and gets used as anchor to {@link $help_url}.
  461.      *           </li><li>
  462.      *           'http://example.com/uri': a full URL (starting with http:// or https://)
  463.      *           </li></ul>
  464.      *    </li><li>
  465.      *    'layout': Use this to visually group your settings.
  466.      *                Either 'begin_fieldset', 'end_fieldset' or 'separator'. You can use 'label' for 'begin_fieldset'.
  467.      *    </li><li>
  468.      *    'id', 'onchange', 'onclick', 'onfocus', 'onkeyup', 'onkeydown', 'onreset', 'onselect': get passed
  469.      *            through as attributes to the form/input element.
  470.      *    </li></ul>
  471.      *    </li></ul>
  472.      *
  473.      *
  474.      *  e.g.:
  475.      *  <code>
  476.      *  return array(
  477.      *    'my_param' => array(
  478.      *      'label' => $this->T_('My Param'),
  479.      *      'defaultvalue' => '10',
  480.      *      'note' => $this->T_('Quite cool, eh?'),
  481.      *      'valid_pattern' => array( 'pattern' => '[1-9]\d+', $this->T_('The value must be >= 10.') ),
  482.      *    ),
  483.      *    'another_param' => array( // this one has no 'note'
  484.      *      'label' => $this->T_('My checkbox'),
  485.      *      'defaultvalue' => '1',
  486.      *      'type' => 'checkbox',
  487.      *    ),
  488.      *    array( 'layout' => 'separator' ),
  489.      *    'my_select' => array(
  490.      *      'label' => $this->T_('Selector'),
  491.      *      'defaultvalue' => 'one',
  492.      *      'type' => 'select',
  493.      *      'options' => array( 'sun' => $this->T_('Sunday'), 'mon' => $this->T_('Monday') ),
  494.      *    ) );
  495.      *  </code>
  496.      *
  497.      */
  498.     function GetDefaultSettings$params )
  499.     {
  500.         return array();
  501.     }
  502.  
  503.  
  504.     /**
  505.      * Define here default user settings that are then available in the backoffice.
  506.      *
  507.      * You can access them in the plugin through the member object
  508.      * {@link $UserSettings}, e.g.:
  509.      * <code>$this->UserSettings->get( 'my_param' );</code>
  510.      *
  511.      * This method behaves exactly like {@link Plugin::GetDefaultSettings()},
  512.      * except that it defines settings specific for users.
  513.      *
  514.      *
  515.      * @see Plugin::GetDefaultSettings()
  516.      * @param array Associative array of parameters.
  517.      *     'for_editing': true, if the settings get queried for editing;
  518.      *                    false, if they get queried for instantiating {@link Plugin::UserSettings}.
  519.      * @return array See {@link Plugin::GetDefaultSettings()}.
  520.      *                NOTE: type 'array' does not work (for editing)!
  521.      */
  522.     function GetDefaultUserSettings$params )
  523.     {
  524.     }
  525.  
  526.  
  527.     /**
  528.      * Get the list of dependencies that the plugin has.
  529.      *
  530.      * This gets checked on install or uninstall of a plugin.
  531.      *
  532.      * There are two <b>classes</b> of dependencies:
  533.      *  - 'recommends': This is just a recommendation. If it cannot get fulfilled
  534.      *                  there will just be a note added on install.
  535.      *  - 'requires': A plugin cannot be installed if the dependencies cannot get
  536.      *                fulfilled. Also, a plugin cannot get uninstalled, if another
  537.      *                plugin depends on it.
  538.      *
  539.      * Each <b>class</b> of dependency can have the following types:
  540.      *  - 'events_by_one': A list of eventlists that have to be provided by a single plugin,
  541.      *                     e.g., <code>array( array('CaptchaPayload', 'CaptchaValidated') )</code>
  542.      *                     to look for a plugin that provides both events.
  543.      *  - 'plugins':
  544.      *    A list of plugins, either just the plugin's classname or an array with
  545.      *    classname and minimum version of the plugin (see {@link Plugin::version}).
  546.      *    E.g.: <code>array( 'test_plugin', '1' )</code> to require at least version "1"
  547.      *          of the test plugin.
  548.      *  - 'app_min': Minimum application (b2evo) version, e.g. "1.9".
  549.      *               This way you can make sure that the hooks you need are implemented
  550.      *               in the core.
  551.      *               (Available since b2evo 1.8.3. To make it work before 1.8.2 use
  552.      *               "api_min" and check for array(1, 2) (API version of 1.9)).
  553.      *  - 'api_min': You can require a specific minimum version of the Plugins API here.
  554.      *               If it's just a number, only the major version is checked against.
  555.      *               To check also for the minor version, you have to give an array:
  556.      *               array( major, minor ).
  557.      *               Obsolete since 1.9! Used API versions: 1.1 (b2evo 1.8.1) and 1.2 (b2evo 1.9).
  558.      *
  559.      * @see test_plugin::GetDependencies()
  560.      * @return array 
  561.      */
  562.     function GetDependencies()
  563.     {
  564.         return array()// no dependencies by default, of course
  565.     }
  566.  
  567.  
  568.     /**
  569.      * This method should return your DB schema, consisting of a list of CREATE TABLE
  570.      * queries.
  571.      *
  572.      * The DB gets changed accordingly on installing or enabling your Plugin.
  573.      *
  574.      * If you want to change your DB layout in a new version of your Plugin, simply
  575.      * adjust the queries here and increase {@link Plugin::version}, because this will
  576.      * request to check the current DB layout against the one you require.
  577.      *
  578.      * For restrictions see {@link db_delta()}.
  579.      */
  580.     function GetDbLayout()
  581.     {
  582.         return array();
  583.     }
  584.  
  585.  
  586.     /**
  587.      * This method gets asked when plugins get installed and allows you to return a list
  588.      * of extra events, which your plugin triggers itself (e.g. through
  589.      * {@link $Plugins->trigger_event()}).
  590.      *
  591.      * NOTE: PLEASE use a distinct prefix for the event name, e.g. "$this->classname".
  592.      *
  593.      * NOTE: The length of event names is limited to 40 chars.
  594.      *
  595.      * NOTE: Please comment the params and the return value here with the list
  596.      *       that you return. Only informal as comment, but makes it easier for
  597.      *       others.
  598.      *
  599.      * @see test_plugin::GetExtraEvents()
  600.      * @return NULL|array"event_name" => "description"
  601.      */
  602.     function GetExtraEvents()
  603.     {
  604.     }
  605.  
  606.  
  607.     /**
  608.      * Override this method to define methods/functions that you want to make accessible
  609.      * through /htsrv/call_plugin.php, which allows you to call those methods by HTTP request.
  610.      *
  611.      * This is useful for things like AJAX or displaying an <iframe> element, where the content
  612.      * should get provided by the plugin itself.
  613.      *
  614.      * E.g., the image captcha plugin uses this method to serve a generated image.
  615.      *
  616.      * NOTE: the Plugin's method must be prefixed with "htsrv_", but in this list (and the URL) it
  617.      *       is not. E.g., to have a method "disp_image" that should be callable through this method
  618.      *       return <code>array('disp_image')</code> here and implement it as
  619.      *       <code>function htsrv_disp_image( $params )</code> in your plugin.
  620.      *       This is used to distinguish those methods from others, but keep URLs nice.
  621.      *
  622.      * @see get_htsrv_url()
  623.      * @return array 
  624.      */
  625.     function GetHtsrvMethods()
  626.     {
  627.         return array();
  628.     }
  629.  
  630.  
  631.     /**
  632.      * This method gets asked for a list of cronjobs that the plugin
  633.      * provides.
  634.      * If a user installs a cron job out of this list, the
  635.      * {@link Plugin::ExecCronJob()} of the plugin gets called.
  636.      *
  637.      * @return array Array of arrays with keys "name", "ctrl" and "params".
  638.      *                "name" gets used for display. "ctrl" (string) and
  639.      *                "params" (array) get passed to the
  640.      *                {@link Plugin::ExecCronJob()} method when the cronjob
  641.      *                gets executed.
  642.      */
  643.     function GetCronJobs$params )
  644.     {
  645.         return array();
  646.     }
  647.  
  648.  
  649.     /**
  650.      * Execute/handle a cron job, which has been scheduled by the admin out
  651.      * of the list that the Plugin provides (see {@link GetCronJobs()}).
  652.      *
  653.      * @param array Associative array of parameters
  654.      *    - 'ctrl': The "ctrl" name as defined in {@link GetCronJobs()}
  655.      *    - 'params': The "params" value as defined in {@link GetCronJobs()},
  656.      *                plus "ctsk_ID" which holds the cron task ID.
  657.      * @return array with keys "code" (integer, 1 is ok), "message" (gets logged)
  658.      */
  659.     function ExecCronJob$params )
  660.     {
  661.     }
  662.  
  663.     // }}}
  664.  
  665.  
  666.     /*
  667.      * Event handlers. These are meant to be implemented by your plugin. {{{
  668.      */
  669.  
  670.     // Admin/backoffice events (without events specific to Items or Comments): {{{
  671.  
  672.     /**
  673.      * Event handler: Gets invoked in /admin/_header.php for every backoffice page after
  674.      *                the menu structure is build. You could use the {@link $AdminUI} object
  675.      *                to modify it.
  676.      *
  677.      * This is the hook to register menu entries. See {@link register_menu_entry()}.
  678.      */
  679.     function AdminAfterMenuInit()
  680.     {
  681.         // Example:
  682.         $this->register_menu_entry$this->T_('My Tab') );
  683.     }
  684.  
  685.  
  686.     /**
  687.      * Event handler: Called when ending the admin html head section.
  688.      *
  689.      * @param array Associative array of parameters
  690.      * @return boolean did we do something?
  691.      */
  692.     function AdminEndHtmlHead$params )
  693.     {
  694.         return false;        // Do nothing by default.
  695.     }
  696.  
  697.  
  698.     /**
  699.      * Event handler: Called right after displaying the admin page footer.
  700.      *
  701.      * @param array Associative array of parameters
  702.      * @return boolean did we do something?
  703.      */
  704.     function AdminAfterPageFooter$params )
  705.     {
  706.         return false;        // Do nothing by default.
  707.     }
  708.  
  709.  
  710.     /**
  711.      * Event handler: Called when displaying editor buttons.
  712.      *
  713.      * This method, if implemented, should output the buttons
  714.      * (probably as html INPUT elements) and return true, if
  715.      * button(s) have been displayed.
  716.      *
  717.      * You should provide an unique html ID with your button.
  718.      *
  719.      * @param array Associative array of parameters.
  720.      *    - 'target_type': either 'Comment' or 'Item'.
  721.      *    - 'edit_layout': "simple", "expert", etc. (users, hackers, plugins, etc. may create their own layouts in addition to these)
  722.      *                     NOTE: Please respect the "simple" mode, which should display only the most simple things!
  723.      * @return boolean did we display a button?
  724.      */
  725.     function AdminDisplayEditorButton$params )
  726.     {
  727.         if$params['edit_layout'== 'simple' )
  728.         // Do nothing in simple mode
  729.             return false;
  730.         }
  731.  
  732.         return false;        // Do nothing by default.
  733.     }
  734.  
  735.  
  736.     /**
  737.      * Event handler: Called when displaying editor toolbars.
  738.      *
  739.      * @param array Associative array of parameters
  740.      *    - 'target_type': either 'Comment' or 'Item'.
  741.      *    - 'edit_layout': "simple", "expert", etc. (users, hackers, plugins, etc. may create their own layouts in addition to these)
  742.      *                     NOTE: Please respect the "simple" mode, which should display only the most simple things!
  743.      * @return boolean did we display a toolbar?
  744.      */
  745.     function AdminDisplayToolbar$params )
  746.     {
  747.         return false;        // Do nothing by default.
  748.     }
  749.  
  750.  
  751.     /**
  752.      * Event handler: Called when handling actions for the "Tools" menu.
  753.      *
  754.      * Use {@link msg()} to add messages for the user.
  755.      */
  756.     function AdminToolAction()
  757.     {
  758.     }
  759.  
  760.  
  761.     /**
  762.      * Event handler: Called when displaying the block in the "Tools" menu.
  763.      *
  764.      * @return boolean did we display something?
  765.      */
  766.     function AdminToolPayload()
  767.     {
  768.         return false;        // Do nothing by default.
  769.     }
  770.  
  771.  
  772.     /**
  773.      * Event handler: Method that gets invoked when our tab is selected.
  774.      *
  775.      * You should catch (your own) params (using {@link param()}) here and do actions
  776.      * (but no output!).
  777.      *
  778.      * Use {@link msg()} to add messages for the user.
  779.      */
  780.     function AdminTabAction()
  781.     {
  782.     }
  783.  
  784.  
  785.     /**
  786.      * Event handler: Gets invoked when our tab is selected and should get displayed.
  787.      *
  788.      * Do your output here.
  789.      *
  790.      * @return boolean did we display something?
  791.      */
  792.     function AdminTabPayload()
  793.     {
  794.         return false;        // Do nothing by default.
  795.     }
  796.  
  797.  
  798.     /**
  799.      * Event handler: Gets invoked before the main payload in the backoffice.
  800.      */
  801.     function AdminBeginPayload()
  802.     {
  803.     }
  804.  
  805.     // }}}
  806.  
  807.  
  808.     // Skin/Blog events: {{{
  809.  
  810.     /**
  811.      * Event handler: Called before a blog gets displayed (in _blog_main.inc.php).
  812.      */
  813.     function BeforeBlogDisplay$params )
  814.     {
  815.     }
  816.  
  817.  
  818.     /**
  819.      * Event handler: Called at the beginning of the skin's HTML HEAD section.
  820.      *
  821.      * Use this to add any HTML HEAD lines (like CSS styles or links to resource
  822.      * files (CSS, JavaScript, ..)).
  823.      */
  824.     function SkinBeginHtmlHead$params )
  825.     {
  826.     }
  827.  
  828.  
  829.     /**
  830.      * Event handler: Gets asked about a list of skin names that the plugin handles.
  831.      *
  832.      * If one of the skins returned gets called through the "skin=X" URL param, the
  833.      * {@link Plugin::DisplaySkin()} method of your plugin gets called.
  834.      *
  835.      * @return array 
  836.      */
  837.     function GetProvidedSkins()
  838.     {
  839.         return array();
  840.     }
  841.  
  842.  
  843.     /**
  844.      * Event handler: Display a skin. Use {@link Plugin::GetProvidedSkins()} to return
  845.      * a list of names that you register.
  846.      *
  847.      * @param array Associative array of parameters
  848.      *    - 'skin': name of skin to be displayed (from the list of {@link Plugin::GetProvidedSkins()}).
  849.      *              If your Plugin only registers one skin, you can ignore it.
  850.      */
  851.     function DisplaySkin$params )
  852.     {
  853.     }
  854.  
  855.     // }}}
  856.  
  857.  
  858.     // (Un)Install / (De)Activate events: {{{
  859.  
  860.     /**
  861.      * Event handler: Called before the plugin is going to be installed.
  862.      *
  863.      * This is the hook to create any DB tables or the like.
  864.      *
  865.      * If you just want to add a note, use {@link Plugin::msg()} (and return true).
  866.      *
  867.      * @return true|stringTrue, if the plugin can be enabled/activated,
  868.      *                      a string with an error/note otherwise.
  869.      */
  870.     function BeforeInstall()
  871.     {
  872.         return true;  // default is to allow Installation
  873.     }
  874.  
  875.  
  876.     /**
  877.      * Event handler: Called after the plugin has been installed.
  878.      */
  879.     function AfterInstall()
  880.     {
  881.     }
  882.  
  883.  
  884.     /**
  885.      * Event handler: Called before the plugin is going to be un-installed.
  886.      *
  887.      * This is the hook to remove any files or the like - tables with canonical names
  888.      * (see {@link Plugin::get_sql_table()}, are handled internally.
  889.      *
  890.      * See {@link BeforeUninstallPayload()} for the corresponding payload handler, which you
  891.      * can request to invoke by returning NULL here.
  892.      *
  893.      * Note: this method gets called again, if the uninstallation has to be confirmed,
  894.      *       either because you've requested a call to {@link BeforeUninstallPayload()}
  895.      *       or there are tables to be dropped (what the admin user has to confirm).
  896.      *
  897.      * @param array Associative array of parameters.
  898.      *               'unattended': true if Uninstall is unattended (e.g., the /install action "deletedb" uses it).
  899.      *                             This should cleanup everything without confirmation!
  900.      * @return boolean|NULL
  901.      *          true when it's ok to uninstall,
  902.      *          false on failure (the plugin won't get uninstalled then).
  903.      *                You should add the reason for it through {@link Plugin::msg()}.
  904.      *          NULL requests to execute the {@link BeforeUninstallPayload()} method.
  905.      */
  906.     function BeforeUninstall$params )
  907.     {
  908.         return true;
  909.     }
  910.  
  911.  
  912.     /**
  913.      * Event handler: Gets invoked to display the payload before uninstalling the plugin.
  914.      *
  915.      * You have to request a call to this during the plugin uninstall procedure by
  916.      * returning NULL in {@link BeforeUninstall()}.
  917.      *
  918.      * @param array Associative array of parameters.
  919.      *               'Form': The {@link Form} that asks the user for confirmation (by reference).
  920.      *                       If your plugin uses canonical table names (see {@link Plugin::get_sql_table()}),
  921.      *                       there will be already a list of those tables included in it.
  922.      *                       Do not end the form, just add own inputs or hidden keys to it.
  923.      */
  924.     function BeforeUninstallPayload$params )
  925.     {
  926.     }
  927.  
  928.  
  929.     /**
  930.      * Event handler: Called when the admin tries to enable the plugin, changes
  931.      * its configuration/settings and after installation.
  932.      *
  933.      * Use this, if your plugin needs configuration before it can be used.
  934.      *
  935.      * @return true|stringTrue, if the plugin can be enabled/activated,
  936.      *                      a string with an error/note otherwise.
  937.      */
  938.     function BeforeEnable()
  939.     {
  940.         return true;  // default is to allow Activation
  941.     }
  942.  
  943.  
  944.     /**
  945.      * Event handler: Your plugin gets notified here, just before it gets
  946.      * disabled.
  947.      *
  948.      * You cannot prevent this, but only clean up stuff, if you have to.
  949.      */
  950.     function BeforeDisable()
  951.     {
  952.     }
  953.  
  954.  
  955.     /*
  956.      * NOTE: function AppendPluginRegister( & $params ) is deprecated since 1.9.
  957.      * Use Plugin::PluginInit() instead.
  958.      */
  959.  
  960.  
  961.     /**
  962.      * Event handler: Called when we detect a version change (in {@link Plugins::register()}).
  963.      *
  964.      * Use this for your upgrade needs.
  965.      *
  966.      * @param array Associative array of parameters.
  967.      *               'old_version': The old version of your plugin as stored in DB.
  968.      *               'db_row': an array with the columns of the plugin DB entry (in T_plugins).
  969.      *                         The key 'plug_version' is the same as the 'old_version' key.
  970.      * @return boolean If this method returns false, the Plugin's status gets changed to "needs_config" and
  971.      *                  it gets unregistered for the current request.
  972.      */
  973.     function PluginVersionChanged$params )
  974.     {
  975.         return true;
  976.     }
  977.  
  978.     // }}}
  979.  
  980.  
  981.     // Item events: {{{
  982.  
  983.     /**
  984.      * Event handler: Called when rendering item/post contents as HTML.
  985.      *
  986.      * Note: You have to change $params['data'] (which gets passed by reference).
  987.      *
  988.      * @param array Associative array of parameters
  989.      *    - 'data': the data (by reference). You probably want to modify this.
  990.      *    - 'format': see {@link format_to_output()}. Only 'htmlbody' and 'entityencoded' will arrive here.
  991.      *    - 'Item': the {@link Item} object which gets rendered.
  992.      * @return boolean Have we changed something?
  993.      */
  994.     function RenderItemAsHtml$params )
  995.     {
  996.         /*
  997.         $content = & $params['data'];
  998.         $content = 'PREFIX__'.$content.'__SUFFIX'; // just an example
  999.         return true;
  1000.         */
  1001.     }
  1002.  
  1003.  
  1004.     /**
  1005.      * Event handler: Called when rendering item/post contents as XML.
  1006.      *
  1007.      * Should this plugin apply to XML?
  1008.      * It should actually only apply when:
  1009.      * - it generates some content that is visible without HTML tags
  1010.      * - it removes some dirty markup when generating the tags (which will get stripped afterwards)
  1011.      * Note: htmlentityencoded is not considered as XML here.
  1012.      *
  1013.      * Note: You have to change $params['data'] (which gets passed by reference).
  1014.      *
  1015.      * @param array Associative array of parameters
  1016.      *    - 'data': the data (by reference). You probably want to modify this.
  1017.      *    - 'format': see {@link format_to_output()}. Only 'xml' will arrive here.
  1018.      *    - 'Item': the {@link Item} object which gets rendered.
  1019.      * @return boolean Have we changed something?
  1020.      */
  1021.     function RenderItemAsXml$params )
  1022.     {
  1023.         return false;        // Do nothing by default.
  1024.     }
  1025.  
  1026.  
  1027.     /**
  1028.      * Event handler: Called when rendering item/post contents other than XML or HTML.
  1029.      *
  1030.      * Note: return value is ignored. You have to change $params['data'].
  1031.      *
  1032.      * @param array Associative array of parameters
  1033.      *    - 'data': the data (by reference). You probably want to modify this.
  1034.      *    - 'format': see {@link format_to_output()}. Only 'text' will arrive here.
  1035.      *    - 'Item': the {@link Item} object which gets rendered.
  1036.      * @return boolean Have we changed something?
  1037.      */
  1038.     function RenderItemAsText()
  1039.     {
  1040.         return false;        // Do nothing by default.
  1041.     }
  1042.  
  1043.  
  1044.     /**
  1045.      * Event handler: Called when displaying an item/post's content as HTML.
  1046.      *
  1047.      * This is different from {@link RenderItemAsHtml()}, because it gets called
  1048.      * on every display (while rendering gets cached).
  1049.      *
  1050.      * @param array Associative array of parameters
  1051.      *    - 'data': the data (by reference). You probably want to modify this.
  1052.      *    - 'format': see {@link format_to_output()}.
  1053.      *    - 'Item': The {@link Item} that gets displayed (by reference).
  1054.      *    - 'preview': Is this only a preview?
  1055.      *    - 'dispmore': Does this include the "more" text (if available), which means "full post"?
  1056.      * @return boolean Have we changed something?
  1057.      */
  1058.     function DisplayItemAsHtml$params )
  1059.     {
  1060.         return false;        // Do nothing by default.
  1061.     }
  1062.  
  1063.  
  1064.     /**
  1065.      * Event handler: Called when displaying an item/post's content as XML.
  1066.      *
  1067.      * This is different from {@link RenderItemAsXml()}, because it gets called
  1068.      * on every display (while rendering gets cached).
  1069.      *
  1070.      * @param array Associative array of parameters
  1071.      *    - 'data': the data (by reference). You probably want to modify this.
  1072.      *    - 'format': see {@link format_to_output()}.
  1073.      *    - 'Item': The {@link Item} that gets displayed (by reference).
  1074.      *    - 'preview': Is this only a preview?
  1075.      *    - 'dispmore': Does this include the "more" text (if available), which means "full post"?
  1076.      * @return boolean Have we changed something?
  1077.      */
  1078.     function DisplayItemAsXml$params )
  1079.     {
  1080.         return false;        // Do nothing by default.
  1081.     }
  1082.  
  1083.  
  1084.     /**
  1085.      * Event handler: Called when displaying an item/post's content as text.
  1086.      *
  1087.      * This is different from {@link RenderItemAsText()}, because it gets called
  1088.      * on every display (while rendering gets cached).
  1089.      *
  1090.      * @param array Associative array of parameters
  1091.      *    - 'data': the data (by reference). You probably want to modify this.
  1092.      *    - 'format': see {@link format_to_output()}. Only 'text' will arrive here.
  1093.      *    - 'Item': The {@link Item} that gets displayed (by reference).
  1094.      *    - 'preview': Is this only a preview?
  1095.      *    - 'dispmore': Does this include the "more" text (if available), which means "full post"?
  1096.      * @return boolean Have we changed something?
  1097.      */
  1098.     function DisplayItemAsText$params )
  1099.     {
  1100.         return false;        // Do nothing by default.
  1101.     }
  1102.  
  1103.  
  1104.     /**
  1105.      * Event handler: called at the beginning of {@link Item::dbupdate() updating}
  1106.      * an item/post in the database}.
  1107.      *
  1108.      * Use this to manipulate the {@link Item}, e.g. adding a renderer code
  1109.      * through {@link Item::add_renderer()}.
  1110.      *
  1111.      * @param array Associative array of parameters
  1112.      *    - 'Item': the related Item (by reference)
  1113.      */
  1114.     function PrependItemUpdateTransact$params )
  1115.     {
  1116.     }
  1117.  
  1118.  
  1119.     /**
  1120.      * Event handler: called at the end of {@link Item::dbupdate() updating}
  1121.      * an item/post in the database}, which means that it has been changed.
  1122.      *
  1123.      * @param array Associative array of parameters
  1124.      *    - 'Item': the related Item (by reference)
  1125.      *    - 'dbchanges': array with DB changes; a copy of {@link Item::dbchanges()},
  1126.      *                   before they got applied (since 1.9)
  1127.      */
  1128.     function AfterItemUpdate$params )
  1129.     {
  1130.     }
  1131.  
  1132.  
  1133.     /**
  1134.      * Event handler: called at the beginning of {@link Item::dbinsert() inserting}
  1135.      * an item/post in the database}.
  1136.      *
  1137.      * Use this to manipulate the {@link Item}, e.g. adding a renderer code
  1138.      * through {@link Item::add_renderer()}.
  1139.      *
  1140.      * @param array Associative array of parameters
  1141.      *    - 'Item': the related Item (by reference)
  1142.      */
  1143.     function PrependItemInsertTransact$params )
  1144.     {
  1145.     }
  1146.  
  1147.  
  1148.     /**
  1149.      * Event handler: called at the end of {@link Item::dbinsert() inserting}
  1150.      * a item/post into the database}, which means it has been created.
  1151.      *
  1152.      * @param array Associative array of parameters
  1153.      *    - 'Item': the related Item (by reference)
  1154.      *    - 'dbchanges': array with DB changes; a copy of {@link Item::dbchanges()},
  1155.      *                   before they got applied (since 1.9)
  1156.      */
  1157.     function AfterItemInsert$params )
  1158.     {
  1159.     }
  1160.  
  1161.  
  1162.     /**
  1163.      * Event handler: called at the end of {@link Item::dbdelete() deleting}
  1164.      * an item/post from the database}.
  1165.      *
  1166.      * @param array Associative array of parameters
  1167.      *    - 'Item': the related Item (by reference)
  1168.      */
  1169.     function AfterItemDelete$params )
  1170.     {
  1171.     }
  1172.  
  1173.  
  1174.     /**
  1175.      * Event handler: called when instantiating an Item for preview.
  1176.      *
  1177.      * @param array Associative array of parameters
  1178.      *    - 'Item': the related Item (by reference)
  1179.      */
  1180.     function AppendItemPreviewTransact$params )
  1181.     {
  1182.     }
  1183.  
  1184.  
  1185.     /**
  1186.      * Event handler: Called when the view counter of an item got increased.
  1187.      *
  1188.      * @param array Associative array of parameters
  1189.      *    - 'Item': the Item object (by reference)
  1190.      */
  1191.     function ItemViewsIncreased$params )
  1192.     {
  1193.     }
  1194.  
  1195.  
  1196.     /**
  1197.      * Event handler: Called at the end of the "Edit item" form.
  1198.      *
  1199.      * @param array Associative array of parameters
  1200.      *    - 'Form': the {@link Form} object (by reference)
  1201.      *    - 'Item': the Item which gets edited (by reference)
  1202.      *    - 'edit_layout': "simple", "expert", etc. (users, hackers, plugins, etc. may create their own layouts in addition to these)
  1203.      *                     NOTE: Please respect the "simple" mode, which should display only the most simple things!
  1204.      * @return boolean did we display something?
  1205.      */
  1206.     function AdminDisplayItemFormFieldset$params )
  1207.     {
  1208.         return false;        // Do nothing by default.
  1209.     }
  1210.  
  1211.  
  1212.     /**
  1213.      * Event handler: Called before a new item gets created (in the backoffice).
  1214.      *
  1215.      * You could {@link Plugin::msg() add a message} of
  1216.      * category "error" here, to prevent the comment from being inserted.
  1217.      *
  1218.      * @param array Associative array of parameters
  1219.      *               'Item': the Item which gets created (by reference)
  1220.      */
  1221.     function AdminBeforeItemEditCreate$params )
  1222.     {
  1223.     }
  1224.  
  1225.  
  1226.     /**
  1227.      * Event handler: Called before an existing item gets updated (in the backoffice).
  1228.      *
  1229.      * You could {@link Plugin::msg() add a message} of
  1230.      * category "error" here, to prevent the comment from being inserted.
  1231.      *
  1232.      * @param array Associative array of parameters
  1233.      *               'Item': the Item which gets updated (by reference)
  1234.      */
  1235.     function AdminBeforeItemEditUpdate$params )
  1236.     {
  1237.     }
  1238.  
  1239.  
  1240.     /**
  1241.      * Event handler: the plugin gets asked if an item can receive feedback/comments.
  1242.      *
  1243.      * @param array Associative array of parameters
  1244.      *               'Item': the Item
  1245.      * @return boolean|string
  1246.      *    true, if the Item can receive feedback
  1247.      *    false/string, if the Item cannot receive feedback. If you return a string
  1248.      *                  this gets displayed as an error/explanation.
  1249.      *    NULL, if you do not want to say "yes" or "no".
  1250.      */
  1251.     function ItemCanComment$params )
  1252.     {
  1253.     }
  1254.  
  1255.  
  1256.     /**
  1257.      * Event handler: send a ping about a new item.
  1258.      *
  1259.      * @param array Associative array of parameters
  1260.      *         'Item': the Item (by reference)
  1261.      *         'xmlrpcresp': Set this to the {@link xmlrpcresp} object, if the plugin
  1262.      *                       uses XMLRPC.
  1263.      *         'display': Should results get displayed? (normally you should not need
  1264.      *                    to care about this, especially if you can set 'xmlrpcresp')
  1265.      * @return boolean Was the ping successful?
  1266.      */
  1267.     function ItemSendPing$params )
  1268.     {
  1269.     }
  1270.  
  1271.  
  1272.     /**
  1273.      * Event handler: called to display the URL that accepts trackbacks for
  1274.      *                an item.
  1275.      *
  1276.      * @param array Associative array of parameters
  1277.      *    - 'Item': the {@link Item} object (by reference)
  1278.      *    - 'template': the template to display the URL (%url%)
  1279.      */
  1280.     function DisplayTrackbackAddr$params )
  1281.     {
  1282.     }
  1283.  
  1284.  
  1285.     /**
  1286.      * Event handler: Does your Plugin want to apply as a renderer for the item?
  1287.      *
  1288.      * NOTE: this is especially useful for lazy Plugins, which would look
  1289.      *       at the content and decide, if they apply.
  1290.      *
  1291.      * @return boolean|NULLIf true, the Plugin gets added as a renderer, false
  1292.      *          removes it as a renderer (if existing) and NULL does not change the
  1293.      *          renderer setting regarding your Plugin.
  1294.      */
  1295.     function ItemApplyAsRenderer$params )
  1296.     {
  1297.     }
  1298.  
  1299.     // }}}
  1300.  
  1301.  
  1302.     // Feedback (Comment/Trackback) events: {{{
  1303.  
  1304.     /**
  1305.      * Event handler: Called when displaying editor toolbars.
  1306.      *
  1307.      * @param array Associative array of parameters
  1308.      * @return boolean did we display a toolbar?
  1309.      */
  1310.     function DisplayCommentToolbar$params )
  1311.     {
  1312.         return false;        // Do nothing by default.
  1313.     }
  1314.  
  1315.  
  1316.     /**
  1317.      * Event handler: Called at the end of the frontend comment form.
  1318.      *
  1319.      * You might want to use this to inject antispam payload to use in
  1320.      * in {@link GetSpamKarmaForComment()} or modify the Comment according
  1321.      * to it in {@link BeforeCommentFormInsert()}.
  1322.      *
  1323.      * @see Plugin::BeforeCommentFormInsert(), Plugin::AfterCommentFormInsert()
  1324.      * @param array Associative array of parameters
  1325.      *    - 'Form': the comment form generating object
  1326.      *    - 'Item': the Item for which the comment is meant
  1327.      */
  1328.     function DisplayCommentFormFieldset$params )
  1329.     {
  1330.     }
  1331.  
  1332.  
  1333.     /**
  1334.      * Event handler: Called in the submit button section of the
  1335.      * frontend comment form.
  1336.      *
  1337.      * @param array Associative array of parameters
  1338.      *    - 'Form': the comment form generating object
  1339.      *    - 'Item': the Item for which the comment is meant
  1340.      */
  1341.     function DisplayCommentFormButton$params )
  1342.     {
  1343.     }
  1344.  
  1345.  
  1346.     /**
  1347.      * Event handler: Called before a comment gets inserted through the public comment
  1348.      *                form.
  1349.      *
  1350.      * Use this, to validate a comment: you could {@link Plugin::msg() add a message} of
  1351.      * category "error" here, to prevent the comment from being inserted.
  1352.      *
  1353.      * @see Plugin::DisplayCommentFormFieldset()
  1354.      * @param array Associative array of parameters
  1355.      *    - 'Comment': the Comment (by reference)
  1356.      *    - 'original_comment': this is the unstripped and unformated posted comment, use with care! (by reference)
  1357.      *    - 'is_preview': is this a request for previewing the comment? (boolean)
  1358.      */
  1359.     function BeforeCommentFormInsert$params )
  1360.     {
  1361.     }
  1362.  
  1363.  
  1364.     /**
  1365.      * Event handler: Called when a comment form has been processed and the comment
  1366.      *                got inserted into DB.
  1367.      *
  1368.      * @param array Associative array of parameters
  1369.      *    - 'Comment': the Comment (by reference)
  1370.      *    - 'original_comment': this is the unstripped and unformated posted comment, use with care!
  1371.      */
  1372.     function AfterCommentFormInsert$params )
  1373.     {
  1374.     }
  1375.  
  1376.  
  1377.     /**
  1378.      * Event handler: Called to ask the plugin for the spam karma of a comment.
  1379.      *
  1380.      * This gets called just before the comment gets stored.
  1381.      *
  1382.      * @param array Associative array of parameters
  1383.      *    - 'Comment': the {@link Comment} object (by reference)
  1384.      *    - The following values are interesting if you want to provide skipping of a test:
  1385.      *      - 'cur_karma': current karma value (cur_karma_abs/cur_karma_divider or NULL)
  1386.      *      - 'cur_karma_abs': current karma absolute value or NULL (if no Plugin returned karma before)
  1387.      *      - 'cur_karma_divider': current divider (sum of weights)
  1388.      *      - 'cur_count_plugins': number of Plugins that have already been asked
  1389.      * @return integer|NULLSpam probability (-100 - 100).
  1390.      *                 -100 means "absolutely no spam", 100 means "absolutely spam".
  1391.      *                 Only if you return a numeric value, it gets considered (e.g., "", NULL or false get ignored).
  1392.      */
  1393.     function GetSpamKarmaForComment$params )
  1394.     {
  1395.         return;
  1396.     }
  1397.  
  1398.  
  1399.     /**
  1400.      * Event handler: called at the end of {@link Comment::dbupdate() updating}
  1401.      * a comment in the database}, which means that it has changed.
  1402.      *
  1403.      * @param array Associative array of parameters
  1404.      *    - 'Comment': the related Comment (by reference)
  1405.      *    - 'dbchanges': array with DB changes; a copy of {@link Comment::dbchanges()},
  1406.      *                   before they got applied (since 1.9)
  1407.      */
  1408.     function AfterCommentUpdate$params )
  1409.     {
  1410.     }
  1411.  
  1412.  
  1413.     /**
  1414.      * Event handler: called at the end of {@link Comment::dbinsert() inserting}
  1415.      * a comment into the database}, which means it has been created.
  1416.      *
  1417.      * @param array Associative array of parameters
  1418.      *    - 'Comment': the related Comment (by reference)
  1419.      *    - 'dbchanges': array with DB changes; a copy of {@link Comment::dbchanges()},
  1420.      *                   before they got applied (since 1.9)
  1421.      */
  1422.     function AfterCommentInsert$params )
  1423.     {
  1424.     }
  1425.  
  1426.  
  1427.     /**
  1428.      * Event handler: called at the end of {@link Comment::dbdelete() deleting}
  1429.      * a comment from the database}.
  1430.      *
  1431.      * @param array Associative array of parameters
  1432.      *    - 'Comment': the related Comment (by reference)
  1433.      */
  1434.     function AfterCommentDelete$params )
  1435.     {
  1436.     }
  1437.  
  1438.  
  1439.     /**
  1440.      * Event handler: called before a trackback gets recorded.
  1441.      *
  1442.      * Use this, to validate a trackback: you could {@link Plugin::msg() add a message} of
  1443.      * category "error" here, to prevent the trackback from being accepted.
  1444.      *
  1445.      * @param array Associative array of parameters
  1446.      *    - 'Comment': the trackback (which is a {@link Comment} object with "trackback" type) (by reference)
  1447.      *         The trackback-params get mapped like this:
  1448.      *         - "blog_name" => "author"
  1449.      *         - "url" => "author_url"
  1450.      *         - "title"/"excerpt" => "comment"
  1451.      *
  1452.      */
  1453.     function BeforeTrackbackInsert$params )
  1454.     {
  1455.     }
  1456.  
  1457.  
  1458.     /**
  1459.      * Event handler: called to filter the comment's author name (blog name for trackbacks)
  1460.      *
  1461.      * @param array Associative array of parameters
  1462.      *    - 'data': the name of the author/blog (by reference)
  1463.      *    - 'makelink': true, if the "data" contains a link
  1464.      *    - 'Comment': the {@link Comment} object
  1465.      */
  1466.     function FilterCommentAuthor$params )
  1467.     {
  1468.     }
  1469.  
  1470.  
  1471.  
  1472.     /**
  1473.      * Event handler: called to filter the comment's author URL
  1474.      *
  1475.      * @param array Associative array of parameters
  1476.      *    - 'data': the URL of the author/blog (by reference)
  1477.      *    - 'makelink': true, if the "data" contains a link
  1478.      *    - 'Comment': the {@link Comment} object
  1479.      */
  1480.     function FilterCommentAuthorUrl$params )
  1481.     {
  1482.     }
  1483.  
  1484.  
  1485.     /**
  1486.      * Event handler: called to filter the comment's content
  1487.      *
  1488.      * @param array Associative array of parameters
  1489.      *    - 'data': the name of the author/blog (by reference)
  1490.      *    - 'Comment': the {@link Comment} object
  1491.      */
  1492.     function FilterCommentContent$params )
  1493.     {
  1494.     }
  1495.  
  1496.     // }}}
  1497.  
  1498.  
  1499.     // Message form events: {{{
  1500.  
  1501.     /**
  1502.      * Event handler: Called at the end of the frontend message form, which
  1503.      * allows to send an email to a user/commentator.
  1504.      *
  1505.      * You might want to use this to inject antispam payload to use in
  1506.      * in {@link MessageFormSent()}.
  1507.      *
  1508.      * @param array Associative array of parameters
  1509.      *    - 'Form': the comment form generating object
  1510.      *    - 'recipient_ID': ID of the user (if any)
  1511.      *    - 'item_ID': ID of the item where the user clicked the msgform icon (if any)
  1512.      *    - 'comment_ID': ID of the comment where the user clicked the msgform icon (if any)
  1513.      */
  1514.     function DisplayMessageFormFieldset$params )
  1515.     {
  1516.     }
  1517.  
  1518.  
  1519.     /**
  1520.      * Event handler: Called in the submit button section of the
  1521.      * frontend message form.
  1522.      *
  1523.      * @param array Associative array of parameters
  1524.      *    - 'Form': the comment form generating object
  1525.      *    - 'recipient_ID': ID of the user (if any)
  1526.      *    - 'item_ID': ID of the item where the user clicked the msgform icon (if any)
  1527.      *    - 'comment_ID': ID of the comment where the user clicked the msgform icon (if any)
  1528.      */
  1529.     function DisplayMessageFormButton$params )
  1530.     {
  1531.     }
  1532.  
  1533.  
  1534.     /**
  1535.      * Event handler: Called when a message form has been submitted.
  1536.      *
  1537.      * Add messages of category "error" to prevent the message from being sent.
  1538.      *
  1539.      * You can also alter the "message" or "message_footer" that gets sent here.
  1540.      *
  1541.      * @param array Associative array of parameters
  1542.      *    - 'recipient_ID': ID of the user (if any)
  1543.      *    - 'item_ID': ID of the item where the user clicked the msgform icon (if any)
  1544.      *    - 'comment_ID': ID of the comment where the user clicked the msgform icon (if any)
  1545.      *    - 'message': The message to be sent (by reference)
  1546.      *    - 'message_footer': The footer of the message (by reference)
  1547.      */
  1548.     function MessageFormSent$params )
  1549.     {
  1550.     }
  1551.  
  1552.  
  1553.     /**
  1554.      * Event handler: Called after a message has been sent through the public email form.
  1555.      *
  1556.      * This is meant to cleanup generated data.
  1557.      */
  1558.     function MessageFormSentCleanup()
  1559.     {
  1560.     }
  1561.  
  1562.     // }}}
  1563.  
  1564.  
  1565.     // Caching events: {{{
  1566.  
  1567.     /**
  1568.      * Event handler: called to cache object data.
  1569.      *
  1570.      * @param array Associative array of parameters
  1571.      *    - 'action': 'delete', 'set', 'get'
  1572.      *    - 'key': The key to refer to 'data'
  1573.      *    - 'data': The actual data. This must be set by the plugin.
  1574.      * @return boolean True if action was successful, false otherwise.
  1575.      */
  1576.     function CacheObjects$params )
  1577.     {
  1578.     }
  1579.  
  1580.  
  1581.     /**
  1582.      * Event handler: called to cache page content (get cached content or request caching).
  1583.      *
  1584.      * This method must build a unique key for the requested page (including cookie/session info) and
  1585.      * start an output buffer, to get the content to cache.
  1586.      *
  1587.      * Note, that there are special occassions when this event does not get called, because we want
  1588.      * really fresh content always:
  1589.      *  - we're generating static pages
  1590.      *  - there gets a "dynamic object", such as "Messages" or "core.preview_Comment" transported in the session
  1591.      *
  1592.      * @see Plugin::CacheIsCollectingContent()
  1593.      * @param array Associative array of parameters
  1594.      *    - 'data': this must get set to the page content on cache hit
  1595.      * @return boolean True if we handled the request (either returned caching data or started buffering),
  1596.      *                  false if we do not want to cache this page.
  1597.      */
  1598.     function CachePageContent$params )
  1599.     {
  1600.     }
  1601.  
  1602.  
  1603.     /**
  1604.      * Event handler: gets asked for if we are generating cached content.
  1605.      *
  1606.      * This is useful to not generate a list of online users or the like.
  1607.      *
  1608.      * @see Plugin::CachePageContent()
  1609.      * @return boolean 
  1610.      */
  1611.     function CacheIsCollectingContent()
  1612.     {
  1613.     }
  1614.  
  1615.     // }}}
  1616.  
  1617.  
  1618.     // PluginSettings {{{
  1619.     /**
  1620.      * Event handler: Called before displaying or setting a plugin's setting in the backoffice.
  1621.      *
  1622.      * @see GetDefaultSettings()
  1623.      * @param array Associative array of parameters
  1624.      *    - 'name': name of the setting
  1625.      *    - 'value': value of the setting (by reference)
  1626.      *    - 'meta': meta data of the setting (as given in {@link GetDefaultSettings()})
  1627.      * @return string|NULLReturn a string with an error to prevent the setting from being set
  1628.      *                      and/or a message added to the settings field.
  1629.      */
  1630.     function PluginSettingsValidateSet$params )
  1631.     {
  1632.     }
  1633.  
  1634.  
  1635.     /**
  1636.      * Event handler: Called as action just before updating the {@link Plugin::Settings plugin's settings}.
  1637.      *
  1638.      * The "regular" settings from {@link GetDefaultSettings()} have been set into
  1639.      * {@link Plugin::Settings}, but get saved into DB after this method has been called.
  1640.      *
  1641.      * Use this to catch custom input fields from {@link PluginSettingsEditDisplayAfter()} or
  1642.      * add notes/errors through {@link Plugin::msg()}.
  1643.      *
  1644.      * If you want to modify plugin events (see {@link Plugin::enable_event()} and
  1645.      * {@link Plugin::disable_event()}), you should use {@link Plugin::BeforeEnable()}, because Plugin
  1646.      * events get saved (according to the edit settings screen) after this event.
  1647.      *
  1648.      * @return false|NULLReturn false to prevent the settings from being updated to DB.
  1649.      */
  1650.     function PluginSettingsUpdateAction()
  1651.     {
  1652.     }
  1653.  
  1654.  
  1655.     /**
  1656.      * Event handler: Called as action before displaying the "Edit plugin" form,
  1657.      * which includes the display of the {@link Plugin::Settings plugin's settings}.
  1658.      *
  1659.      * You may want to use this to check existing settings or display notes about
  1660.      * something.
  1661.      */
  1662.     function PluginSettingsEditAction()
  1663.     {
  1664.     }
  1665.  
  1666.  
  1667.     /**
  1668.      * Event handler: Called after the form to edit the {@link Plugin::Settings} has been
  1669.      * displayed.
  1670.      *
  1671.      * Use this to add custom input fields (and catch them in {@link PluginSettingsUpdateAction()})
  1672.      * or display custom output (e.g. a test link).
  1673.      *
  1674.      * @param array Associative array of parameters
  1675.      *    - 'Form': the {@link Form}, where an fieldset has been opened already (by reference)
  1676.      */
  1677.     function PluginSettingsEditDisplayAfter$params )
  1678.     {
  1679.     }
  1680.  
  1681.     // }}}
  1682.  
  1683.  
  1684.     // PluginUserSettings {{{
  1685.     /**
  1686.      * Event handler: Called before displaying or setting a plugin's user setting in the backoffice.
  1687.      *
  1688.      * @see GetDefaultUserSettings()
  1689.      * @param array Associative array of parameters
  1690.      *    - 'name': name of the setting
  1691.      *    - 'value': value of the setting (by reference)
  1692.      *    - 'meta': meta data of the setting (as given in {@link GetDefaultUserSettings()})
  1693.      *    - 'User': the {@link User} for which the setting is
  1694.      * @return string|NULLReturn a string with an error to prevent the setting from being set
  1695.      *                      and/or a message added to the settings field.
  1696.      */
  1697.     function PluginUserSettingsValidateSet$params )
  1698.     {
  1699.     }
  1700.  
  1701.  
  1702.     /**
  1703.      * Event handler: Called as action just before updating the {@link Plugin::UserSettings plugin's user settings}.
  1704.      *
  1705.      * The "regular" settings from {@link GetDefaultUserSettings()} have been set into
  1706.      * {@link Plugin::UserSettings}, but get saved into DB after this method has been called.
  1707.      *
  1708.      * Use this to catch custom input fields from {@link PluginUserSettingsEditDisplayAfter()} or
  1709.      * add notes/errors through {@link Plugin::msg()}.
  1710.      *
  1711.      * @param array Associative array of parameters
  1712.      *    - 'User': the {@link User} for which the settings get updated
  1713.      *
  1714.      * @return false|NULLReturn false to prevent the settings from being updated to DB.
  1715.      */
  1716.     function PluginUserSettingsUpdateAction$params )
  1717.     {
  1718.     }
  1719.  
  1720.  
  1721.     /**
  1722.      * Event handler: Called as action before displaying the "Edit user" form,
  1723.      * which includes the display of the {@link Plugin::UserSettings plugin's user settings}.
  1724.      *
  1725.      * You may want to use this to check existing settings or display notes about
  1726.      * something.
  1727.      *
  1728.      * @param array Associative array of parameters
  1729.      *    - 'User': the {@link User} for which the settings are being displayed/edited
  1730.      */
  1731.     function PluginUserSettingsEditAction$params )
  1732.     {
  1733.     }
  1734.  
  1735.  
  1736.     /**
  1737.      * Event handler: Called after the form to edit the {@link Plugin::UserSettings} has been
  1738.      * displayed.
  1739.      *
  1740.      * Use this to add custom input fields (and catch them in {@link PluginUserSettingsUpdateAction()})
  1741.      * or display custom output (e.g. a test link).
  1742.      *
  1743.      * @param array Associative array of parameters
  1744.      *    - 'Form': the {@link Form}, where an fieldset has been opened already (by reference)
  1745.      */
  1746.     function PluginUserSettingsEditDisplayAfter$params )
  1747.     {
  1748.     }
  1749.  
  1750.     // }}}
  1751.  
  1752.  
  1753.     // User related events, including registration and login (procedure): {{{
  1754.  
  1755.     /**
  1756.      * Event handler: Called at the end of the login procedure, if the
  1757.      *                user is anonymous ({@link $current_User current User} NOT set).
  1758.      *
  1759.      * Use this for example to read some cookie and define further handling of
  1760.      * this visitor or force them to login, by {@link Plugin::msg() adding a message}
  1761.      * of class "login_error", which will trigger the login screen.
  1762.      */
  1763.     function AfterLoginAnonymousUser$params )
  1764.     {
  1765.     }
  1766.  
  1767.  
  1768.     /**
  1769.      * Event handler: Called at the end of the login procedure, if the
  1770.      *                {@link $current_User current User} is set and the
  1771.      *                user is therefor registered.
  1772.      *
  1773.      * Use this for example to re-act on specific {@link Plugin::UserSettings user settings},
  1774.      * e.g., call {@link Plugin::forget_events()} to de-activate the plugin for
  1775.      * the current request.
  1776.      *
  1777.      * You can also {@link Plugin::msg() add a message} of class "login_error"
  1778.      * to prevent the user from accessing the site and triggering
  1779.      * the login screen.
  1780.      */
  1781.     function AfterLoginRegisteredUser$params )
  1782.     {
  1783.     }
  1784.  
  1785.  
  1786.     /**
  1787.      * Event handler: Called when a new user has registered, at the end of the
  1788.      *                DB transaction that created this user.
  1789.      *
  1790.      * If you want to modify the about-to-be-created user (if the transaction gets
  1791.      * committed), you'll have to call {@link User::dbupdate()} on it, because he
  1792.      * got already inserted (but the transaction is not yet committed).
  1793.      *
  1794.      * Note: if you want to re-act on a new user,
  1795.      * use {@link Plugin::AfterUserRegistration()} instead!
  1796.      *
  1797.      * @param array Associative array of parameters
  1798.      *    - 'User': the {@link User user object} (as reference).
  1799.      * @return boolean false if the whole transaction should get rolled back (the user does not get created).
  1800.      */
  1801.     function AppendUserRegistrTransact$params )
  1802.     {
  1803.         return true;
  1804.     }
  1805.  
  1806.  
  1807.     /**
  1808.      * Event handler: Called when a new user has registered and got created.
  1809.      *
  1810.      * Note: if you want to modify a new user,
  1811.      * use {@link Plugin::AppendUserRegistrTransact()} instead!
  1812.      *
  1813.      * @param array Associative array of parameters
  1814.      *    - 'User': the {@link User user object} (as reference).
  1815.      */
  1816.     function AfterUserRegistration$params )
  1817.     {
  1818.     }
  1819.  
  1820.  
  1821.     /**
  1822.      * Event handler: Called at the end of the "Register as new user" form.
  1823.      *
  1824.      * You might want to use this to inject antispam payload to use
  1825.      * in {@link Plugin::RegisterFormSent()}.
  1826.      *
  1827.      * @param array Associative array of parameters
  1828.      *    - 'Form': the comment form generating object (by reference)
  1829.      */
  1830.     function DisplayRegisterFormFieldset$params )
  1831.     {
  1832.     }
  1833.  
  1834.  
  1835.     /**
  1836.      * Event handler: Called when a "Register as new user" form has been submitted.
  1837.      *
  1838.      * You can cancel the registration process by {@link Plugin::msg() adding a message}
  1839.      * of type "error".
  1840.      */
  1841.     function RegisterFormSent$params )
  1842.     {
  1843.     }
  1844.  
  1845.  
  1846.     /**
  1847.      * Event handler: Called at the end of the "Login" form.
  1848.      *
  1849.      * You might want to use this to inject payload to use
  1850.      * in {@link LoginAttempt()}.
  1851.      *
  1852.      * @param array Associative array of parameters
  1853.      *    - 'Form': the comment form generating object (by reference)
  1854.      */
  1855.     function DisplayLoginFormFieldset$params )
  1856.     {
  1857.     }
  1858.  
  1859.  
  1860.     /**
  1861.      * Event handler: called when a user attemps to login.
  1862.      *
  1863.      * You can prevent the user from logging in by {@link Plugin::msg() adding a message}
  1864.      * of type "login_error".
  1865.      *
  1866.      * Otherwise, this hook is meant to authenticate a user against some
  1867.      * external database (e.g. LDAP) and generate a new user.
  1868.      *
  1869.      * To check, if a user already exists in b2evo with that login/password, you might
  1870.      * want to use <code>user_pass_ok( $login, $pass_md5, true )</code>.
  1871.      *
  1872.      * @see Plugin::AlternateAuthentication()
  1873.      * @see Plugin::Logout()
  1874.      * @param array Associative array of parameters
  1875.      *    - 'login': user's login
  1876.      *    - 'pass': user's password
  1877.      *    - 'pass_md5': user's md5 password
  1878.      */
  1879.     function LoginAttempt$params )
  1880.     {
  1881.     }
  1882.  
  1883.  
  1884.     /**
  1885.      * Event handler: called when a user logs out.
  1886.      *
  1887.      * This is meant to cleanup data, e.g. if you use the
  1888.      * {@link Plugin::AlternateAuthentication()} hook.
  1889.      *
  1890.      * @see Plugin::AlternateAuthentication()
  1891.      * @see Plugin::Logout()
  1892.      * @param array Associative array of parameters
  1893.      *    - 'User': the user object
  1894.      */
  1895.     function Logout$params )
  1896.     {
  1897.     }
  1898.  
  1899.  
  1900.     /**
  1901.      * Event handler: Called at the end of the "Validate user account" form, which gets
  1902.      *                invoked if newusers_mustvalidate is enabled and the user has not
  1903.      *                been validated yet.
  1904.      *
  1905.      * The corresponding action event is {@link Plugin::ValidateAccountFormSent()}.
  1906.      *
  1907.      * @param array Associative array of parameters
  1908.      *    - 'Form': the comment form generating object (by reference)
  1909.      */
  1910.     function DisplayValidateAccountFormFieldset$params )
  1911.     {
  1912.     }
  1913.  
  1914.  
  1915.     /**
  1916.      * Event handler: Called when a "Validate user account" form has been submitted.
  1917.      *
  1918.      * You can cancel the registration process by {@link Plugin::msg() adding a message}
  1919.      * of type "error".
  1920.      */
  1921.     function ValidateAccountFormSent$params )
  1922.     {
  1923.     }
  1924.  
  1925.  
  1926.     /**
  1927.      * Event handler: called at the end of the login process, if the user did not try to
  1928.      *                login (by sending "login" and "pwd"), the session has no user attached
  1929.      *                or only "login" is given.
  1930.      *
  1931.      * This hook is meant to automagically login/authenticate an user by his/her IP address,
  1932.      * special cookie, etc..
  1933.      *
  1934.      * If you can authenticate the user, you'll have to attach him to the {@link $Session},
  1935.      * either through {@link Session::set_user_ID()} or {@link Session::set_User()}.
  1936.      *
  1937.      * @see Plugin::LoginAttempt()
  1938.      * @see Plugin::Logout()
  1939.      * @return boolean True, if the user has been authentificated (set in $Session)
  1940.      */
  1941.     function AlternateAuthentication$params )
  1942.     {
  1943.     }
  1944.  
  1945.  
  1946.     /**
  1947.      * Event handler: called at the end of {@link User::dbupdate() updating}
  1948.      * an user account in the database}, which means that it has been changed.
  1949.      *
  1950.      * @since 1.8.1
  1951.      * @param array Associative array of parameters
  1952.      *    - 'User': the related User (by reference)
  1953.      */
  1954.     function AfterUserUpdate$params )
  1955.     {
  1956.     }
  1957.  
  1958.  
  1959.     /**
  1960.      * Event handler: called at the end of {@link User::dbinsert() inserting}
  1961.      * an user account into the database}, which means it has been created.
  1962.      *
  1963.      * @since 1.8.1
  1964.      * @param array Associative array of parameters
  1965.      *    - 'User': the related User (by reference)
  1966.      */
  1967.     function AfterUserInsert$params )
  1968.     {
  1969.     }
  1970.  
  1971.  
  1972.     /**
  1973.      * Event handler: called at the end of {@link User::dbdelete() deleting}
  1974.      * an user from the database}.
  1975.      *
  1976.      * @since 1.8.1
  1977.      * @param array Associative array of parameters
  1978.      *    - 'User': the related User (by reference)
  1979.      */
  1980.     function AfterUserDelete$params )
  1981.     {
  1982.     }
  1983.  
  1984.     // }}}
  1985.  
  1986.  
  1987.     // General events: {{{
  1988.  
  1989.     /**
  1990.      * Event handler: general event to inject payload for a captcha test.
  1991.      *
  1992.      * This does not get called by b2evolution itself, but provides an interface
  1993.      * to other plugins. E.g., the {@link dnsbl_antispam_plugin DNS blacklist plugin}
  1994.      * uses this event optionally to whitelist a user.
  1995.      *
  1996.      * @param array Associative array of parameters
  1997.      *    - 'Form': the {@link form} where payload should get added (by reference, OPTIONALLY!)
  1998.      *      If it's not given as param, you have to create an own form, if you need one.
  1999.      *    - 'form_use_fieldset': if a "Form" param is given and we use it, should we add
  2000.      *                           an own fieldset? (boolean, default "true", OPTIONALLY!)
  2001.      *    - 'key': A key that is associated to the caller of the event (string, OPTIONALLY!)
  2002.      * @return boolean True, if you have provided payload for a captcha test
  2003.      */
  2004.     function CaptchaPayload$params )
  2005.     {
  2006.     }
  2007.  
  2008.  
  2009.     /**
  2010.      * Event handler: general event to validate a captcha which payload was added
  2011.      * through {@link CaptchaPayload()}.
  2012.      *
  2013.      * This does not get called by b2evolution itself, but provides an interface
  2014.      * to other plugins. E.g., the {@link dnsbl_antispam_plugin DNS blacklist plugin}
  2015.      * uses this event optionally to whitelist a user.
  2016.      *
  2017.      * NOTE: if the action is verified/completed in total, you HAVE to call
  2018.      *       {@link CaptchaValidatedCleanup()}, so that the plugin can cleanup its data
  2019.      *       and is not vulnerable against multiple usage of the same captcha!
  2020.      *
  2021.      * @param array Associative array of parameters
  2022.      *    - 'validate_error': you can optionally set this, if you want to give a reason
  2023.      *      of the failure. This is optionally and meant to be used by other plugins
  2024.      *      that trigger this event.
  2025.      * @return boolean true if the catcha could be validated
  2026.      */
  2027.     function CaptchaValidated$params )
  2028.     {
  2029.     }
  2030.  
  2031.  
  2032.     /**
  2033.      * Event handler: general event to be called after an action has been taken, which
  2034.      * involved {@link CaptchaPayload()} and {@link CaptchaValidated()}.
  2035.      *
  2036.      * This is meant to cleanup generated data for the Captcha test.
  2037.      *
  2038.      * This does not get called by b2evolution itself, but provides an interface
  2039.      * to other plugins. E.g., the {@link dnsbl_antispam_plugin DNS blacklist plugin}
  2040.      * uses this event optionally to whitelist a user.
  2041.      */
  2042.     function CaptchaValidatedCleanup$params )
  2043.     {
  2044.     }
  2045.  
  2046.     // }}}
  2047.  
  2048.  
  2049.     /**
  2050.      * Event handler: Called when an IP address gets displayed, typically in a protected
  2051.      * area or for a privileged user, e.g. in the backoffice statistics menu.
  2052.      *
  2053.      * @param array Associative array of parameters
  2054.      *    - 'data': the data (by reference). You probably want to modify this.
  2055.      *    - 'format': see {@link format_to_output()}.
  2056.      * @return boolean Have we changed something?
  2057.      */
  2058.     function FilterIpAddress$params )
  2059.     {
  2060.         return false;        // Do nothing by default.
  2061.     }
  2062.  
  2063.  
  2064.     /**
  2065.      * Event handler: Called after initializing plugins, DB, Settings, Hit, .. but
  2066.      * quite early.
  2067.      *
  2068.      * This is meant to be a good point for Antispam plugins to cancel the request.
  2069.      *
  2070.      * @see dnsbl_antispam_plugin
  2071.      */
  2072.     function SessionLoaded()
  2073.     {
  2074.     }
  2075.  
  2076.     /*
  2077.      * Event handlers }}}
  2078.      */
  2079.  
  2080.  
  2081.     /*
  2082.      * Helper methods. You should not change/derive those in your plugin, but use them only. {{{
  2083.      */
  2084.  
  2085.     /**
  2086.      * Get a string, unqiue for the plugin, usable in HTML form elements.
  2087.      *
  2088.      * @param string Optional text to append (gets prefixed with "_").
  2089.      * @return string 
  2090.      */
  2091.     function get_class_id$append '' )
  2092.     {
  2093.         return $this->classname.'_id'.$this->ID.$append '_'.$append '' );
  2094.     }
  2095.  
  2096.  
  2097.     /**
  2098.      * Translate a given string, in the Plugin's context.
  2099.      *
  2100.      * This means, that the translation is obtained from the Plugin's "locales" folder.
  2101.      * @link http://manual.b2evolution.net/Localization#Plugins
  2102.      *
  2103.      *  It uses the global/regular {@link T_()} function as fallback.
  2104.      *
  2105.      *  {@internal This is mainly a copy of {@link T_()}, for the $use_l10n==2 case.  
  2106.      *
  2107.      * @param string The string (english), that should be translated
  2108.      * @param string Requested locale ({@link $current_locale} gets used by default)
  2109.      * @return string 
  2110.      */
  2111.     function T_$string$req_locale '' )
  2112.     {
  2113.         global $current_locale$locales$Debuglog$plugins_path$evo_charset;
  2114.  
  2115.         $trans $this->_trans;
  2116.  
  2117.         ifempty($req_locale) )
  2118.         // By default we use the current locale
  2119.             ifempty$current_locale ) )
  2120.             // don't translate if we have no locale
  2121.                 return $string;
  2122.             }
  2123.  
  2124.             $req_locale $current_locale;
  2125.         }
  2126.  
  2127.         ifisset$locales[$req_locale]['messages') )
  2128.         {
  2129.             $this->debug_log'No messages file dirname for locale. $locales["'
  2130.                                             .$req_locale.'"] is '.var_export@$locales[$req_locale]true )'locale' );
  2131.             $locales[$req_locale]['messages'false;
  2132.         }
  2133.  
  2134.         $messages $locales[$req_locale]['messages'];
  2135.  
  2136.         // replace special characters to msgid-equivalents
  2137.         $search str_replacearray("\n""\r""\t")array('\n''''\t')$string );
  2138.  
  2139.         // echo "Translating ", $search, " to $messages<br />";
  2140.  
  2141.         ifisset($trans$messages ) )
  2142.         // Translations for current locale have not yet been loaded:
  2143.  
  2144.             ifisset($this->classfile_path) )
  2145.             // ->T_() called through the plugin's constructor, which is deprecated!
  2146.                 $this->debug_log'T_() method called through plugin constructor!' );
  2147.                 return $string;
  2148.             }
  2149.  
  2150.             $locales_dir dirname($this->classfile_path).'/';
  2151.             if$locales_dir == $plugins_path )
  2152.             {
  2153.                 $locales_dir .= $this->classname.'/';
  2154.             }
  2155.             $locales_dir .= 'locales/';
  2156.  
  2157.             // First load the global messages file, if existing:
  2158.             if$this->_trans_loaded_global )
  2159.             {
  2160.                 $this->_trans_loaded_global true;
  2161.  
  2162.                 $file_path $locales_dir.'_global.php';
  2163.                 iffile_exists($file_path) )
  2164.                 {
  2165.                     ifis_readable($file_path) )
  2166.                     {
  2167.                         // echo 'LOADING GLOBAL '.$file_path;
  2168.                         include $file_path;
  2169.                     }
  2170.                     else
  2171.                     {
  2172.                         $this->debug_log'Global messages file '.$file_path.' is not readable!''locale' );
  2173.                     }
  2174.                 }
  2175.             }
  2176.  
  2177.             // Then load locale specific files:
  2178.             $file_path $locales_dir.$messages.'/_global.php';
  2179.  
  2180.             iffile_exists($file_path) )
  2181.             {
  2182.                 ifis_readable($file_path) )
  2183.                 {
  2184.                     // echo 'LOADING '.$file_path;
  2185.                     include $file_path;
  2186.                 }
  2187.                 else
  2188.                 {
  2189.                     $this->debug_log'Messages file '.$file_path.' for locale '.$req_locale.' is not readable!''locale' );
  2190.                 }
  2191.             }
  2192.  
  2193.             ifisset($trans$messages ) )
  2194.             // Still not loaded... file doesn't exist, memorize that no translations are available
  2195.                 // echo 'file not found!';
  2196.                 $trans$messages array();
  2197.  
  2198.                 /*
  2199.                 May be an english locale without translation.
  2200.                 TODO: when refactoring locales, assign a key for 'original english'.
  2201.                 $Debuglog->add( 'No messages found for locale ['.$req_locale.'],
  2202.                                                 message file [/locales/'.$messages.'/_global.php]', 'locale' );*/
  2203.             }
  2204.  
  2205.             // Remember the charset:
  2206.             ifisset($trans[$messages]['']) )
  2207.             {
  2208.                 if( ($pos strpos($trans[$messages]['']'Content-Type:')) !== false )
  2209.                 {
  2210.                     ifpreg_match('~^Content-Type:.*charset=([\w\d-]+)~'substr($trans[$messages]['']$pos)$match) )
  2211.                     {
  2212.                         $this->_trans_charsets[$messages$match[1];
  2213.                         $this->debug_log'Charset of messages for '.$messages.' is '.$match[1);
  2214.                     }
  2215.                 }
  2216.             }
  2217.             ifisset($this->_trans_charsets[$messages]) )
  2218.             // not provided, use the one of the main locale files:
  2219.                 $this->_trans_charsets[$messages$locales[$req_locale]['charset'];
  2220.             }
  2221.         }
  2222.  
  2223.         ifisset$trans$messages ]$search ) )
  2224.         // If the string has been translated:
  2225.             $r $trans$messages ]$search ];
  2226.         }
  2227.         else
  2228.         // Fallback to global T_() function:
  2229.             return T_$string$req_locale );
  2230.         }
  2231.  
  2232.         ifempty($evo_charset) ) // this extra check is needed, because $evo_charset may not yet be determined.. :/
  2233.         {
  2234.             $r convert_charset$r$evo_charset$this->_trans_charsets[$messages);
  2235.         }
  2236.  
  2237.         return $r;
  2238.     }
  2239.  
  2240.  
  2241.     /**
  2242.      * Get the absolute URL to the plugin's directory (where the plugins classfile is).
  2243.      * Trailing slash included.
  2244.      *
  2245.      * This is either below {@link $plugins_url}, if no Blog is set or we're in the
  2246.      * backoffice, or the "plugins" directory below the Blog's URL root otherwise.
  2247.      *
  2248.      * @param string Get absolute URL? (or cut off $ReqHost at the beginning)
  2249.      * @return string 
  2250.      */
  2251.     function get_plugin_url$abs false )
  2252.     {
  2253.         global $ReqHost$Blog$plugins_url$plugins_path$plugins_subdir;
  2254.  
  2255.         ifisset($Blog&& is_admin_page() )
  2256.         {
  2257.             $base $Blog->get('baseurl').$plugins_subdir;
  2258.         }
  2259.         else
  2260.         {
  2261.             $base $plugins_url;
  2262.         }
  2263.  
  2264.         ifstrpos$base$ReqHost !== )
  2265.         // the base url does not begin with the requested host:
  2266.  
  2267.             // Fix "http:" to "https:":
  2268.             ifstrpos$ReqHost'https:' === && strpos$base'http:' === )
  2269.             {
  2270.                 $base_fixed 'https:'.substr$base);
  2271.  
  2272.                 ifstrpos$base_fixed$ReqHost === )
  2273.                 {
  2274.                     $base $base_fixed;
  2275.                 }
  2276.             }
  2277.         }
  2278.  
  2279.         if$abs && strpos$base$ReqHost === )
  2280.         // cut off $ReqHost if the resulting URL starts with it:
  2281.             $base substr($basestrlen($ReqHost));
  2282.         }
  2283.  
  2284.         // Append sub-path below $plugins_path, if any:
  2285.         $sub_path preg_replace':^'.preg_quote($plugins_path':').':'''dirname($this->classfile_path).'/' );
  2286.  
  2287.         return $base.$sub_path;
  2288.     }
  2289.  
  2290.  
  2291.     /**
  2292.      * Log a debug message.
  2293.      *
  2294.      * This gets added to {@link $Debuglog the global Debuglog} with
  2295.      * the category '[plugin_classname]_[plugin_ID]'.
  2296.      *
  2297.      * NOTE: if debugging is not enabled (see {@link $debug}), {@link $Debuglog}
  2298.      * is of class {@link Log_noop}, which means it does not accept nor display
  2299.      * messages.
  2300.      *
  2301.      * @param string Message to log.
  2302.      * @param array Optional list of additional categories.
  2303.      */
  2304.     function debug_log$msg$add_cats array() )
  2305.     {
  2306.         global $Debuglog;
  2307.  
  2308.         ifis_array($add_cats) )
  2309.         {
  2310.             $add_cats array($add_cats);
  2311.         }
  2312.  
  2313.         ifisset($this->ID$this->classname) )
  2314.         // plugin not yet instantiated. This happens, if the (deprecated) constructor of a plugin gets used.
  2315.             $add_cats[get_class($this).'_?';
  2316.         }
  2317.         else
  2318.         {
  2319.             $add_cats[$this->classname.'_'.$this->ID;
  2320.         }
  2321.         $Debuglog->add$msg$add_cats );
  2322.     }
  2323.  
  2324.  
  2325.     /**
  2326.      * Get the URL to call a plugin method through http. This links to the /htsrv/call_plugin.php
  2327.      * file.
  2328.      *
  2329.      * It uses the Blog's baseurl and changes "http" to "https", if needed, so that this URL can
  2330.      * be used in AJAX callbacks (which requires it to be on the same domain/protocol).
  2331.      *
  2332.      * @todo we might want to provide whitelisting of methods through {@link $Session} here and check for it in the htsrv handler.
  2333.      *
  2334.      * @param string Method to call. This must be listed in {@link GetHtsrvMethods()}.
  2335.      * @param array Array of optional parameters passed to the method.
  2336.      * @param string Glue for additional GET params used internally.
  2337.      * @param string Get absolute URL? (or cut off $ReqHost at the beginning)
  2338.      * @return string The URL
  2339.      */
  2340.     function get_htsrv_url$method$params array()$glue '&amp;'$abs false )
  2341.     {
  2342.         global $htsrv_url$htsrv_url_sensitive;
  2343.         global $ReqHost$Blog;
  2344.  
  2345.         $base substr($ReqHost06== 'https:' $htsrv_url_sensitive $htsrv_url;
  2346.  
  2347.         if$abs && strpos$base$ReqHost === )
  2348.         // cut off $ReqHost if the resulting URL starts with it:
  2349.             $base substr($basestrlen($ReqHost));
  2350.         }
  2351.  
  2352.         $r $base.'call_plugin.php?plugin_ID='.$this->ID.$glue.'method='.$method;
  2353.         if!empty$params ) )
  2354.         {
  2355.             $r .= $glue.'params='.rawurlencode(serialize$params ));
  2356.         }
  2357.  
  2358.         return $r;
  2359.     }
  2360.  
  2361.  
  2362.     /**
  2363.      * A simple wrapper around the {@link $Messages} object with a default
  2364.      * catgory of 'note'.
  2365.      *
  2366.      * @param string Message
  2367.      * @param string|arraycategory ('note', 'error', 'success'; default: 'note')
  2368.      */
  2369.     function msg$msg$category 'note' )
  2370.     {
  2371.         global $Messages;
  2372.         $Messages->add$msg$category );
  2373.     }
  2374.  
  2375.  
  2376.     /**
  2377.      * Register a tab (sub-menu) for the backoffice Tools menus.
  2378.      *
  2379.      * @param string Text for the tab.
  2380.      * @param string|arrayPath to add the menu entry into.
  2381.      *         See {@link AdminUI::add_menu_entries()}. Default: 'tools' for the Tools menu.
  2382.      * @param array Optional params. See {@link AdminUI::add_menu_entries()}.
  2383.      */
  2384.     function register_menu_entry$text$path 'tools'$menu_entry_props array() )
  2385.     {
  2386.         global $AdminUI;
  2387.  
  2388.         $menu_entry_props['text'$text;
  2389.  
  2390.         $AdminUI->add_menu_entries$patharray'plug_ID_'.$this->ID => $menu_entry_props ) );
  2391.     }
  2392.  
  2393.  
  2394.     /**
  2395.      * Check if the requested list of events is provided by any or one plugin.
  2396.      *
  2397.      * @param array|stringA single event or a list thereof
  2398.      * @param boolean Make sure there's at least one plugin that provides them all?
  2399.      *                 This is useful for event pairs like "CaptchaPayload" and "CaptchaValidated", which
  2400.      *                 should be served by the same plugin.
  2401.      * @return boolean 
  2402.      */
  2403.     function are_events_available$events$by_one_plugin false )
  2404.     {
  2405.         global $Plugins;
  2406.  
  2407.         return $Plugins->are_events_available$events$by_one_plugin );
  2408.     }
  2409.  
  2410.  
  2411.     /**
  2412.      * Set param value.
  2413.      *
  2414.      * @deprecated since 1.9 - no use.
  2415.      * @param string Name of parameter
  2416.      * @param mixed Value of parameter
  2417.      */
  2418.     function set_param$parname$parvalue )
  2419.     {
  2420.         // Set value:
  2421.         $this->$parname $parvalue;
  2422.     }
  2423.  
  2424.  
  2425.     /**
  2426.      * Set the status of the plugin.
  2427.      *
  2428.      * @param string 'enabled', 'disabled' or 'needs_config'
  2429.      * @return boolean 
  2430.      */
  2431.     function set_status$status )
  2432.     {
  2433.         global $Plugins;
  2434.  
  2435.         ifin_array$statusarray'enabled''disabled''needs_config' ) ) )
  2436.         {
  2437.             return false;
  2438.         }
  2439.  
  2440.         $Plugins->set_Plugin_status$this$status );
  2441.     }
  2442.  
  2443.  
  2444.     /**
  2445.      * Get canonical name for database tables a plugin uses, by adding an unique
  2446.      * prefix for your plugin instance.
  2447.      *
  2448.      * You should use this when refering to your SQL table names.
  2449.      *
  2450.      * E.g., for the "test_plugin" with ID 7 and the default {@link $tableprefix} of "evo_" it
  2451.      * would generate: "evo_plugin_test_7_log" for a requested name "log".
  2452.      *
  2453.      * @param string Your name, which gets returned with the unique prefix.
  2454.      * @return string 
  2455.      */
  2456.     function get_sql_table$name )
  2457.     {
  2458.         global $tableprefix;
  2459.  
  2460.         // NOTE: table name length seems limited to 64 chars (MySQL 5) - classname is limited to 40 (in T_plugins)
  2461.         return $tableprefix.'plugin_'.preg_replace'#_plugin$#'''$this->classname ).'_'.$this->ID.'_'.$name;
  2462.     }
  2463.  
  2464.  
  2465.     /**
  2466.      * Stop propagation of the event to next plugins (with lower priority)
  2467.      * in events that get triggered for a batch of Plugins.
  2468.      *
  2469.      * @see Plugins::trigger_event()
  2470.      * @see Plugins::stop_propagation()
  2471.      */
  2472.     function stop_propagation()
  2473.     {
  2474.         global $Plugins;
  2475.         $Plugins->stop_propagation();
  2476.     }
  2477.  
  2478.  
  2479.     /**
  2480.      * Set a data value for the session.
  2481.      *
  2482.      * NOTE: the session data is limited to about 64kb, so do not use it for huge data!
  2483.      *       Please consider using an own database table (see {@link Plugin::GetDbLayout()}).
  2484.      *
  2485.      * @param string Name of the data's key (gets prefixed with 'plugIDX_' internally).
  2486.      * @param mixed The value
  2487.      * @param integer Time in seconds for data to expire (0 to disable).
  2488.      * @param boolean Should the data get saved immediately?
  2489.      */
  2490.     function session_set$name$value$timeout$save_immediately false )
  2491.     {
  2492.         global $Session;
  2493.  
  2494.         $r $Session->set'plugID'.$this->ID.'_'.$name$value$timeout );
  2495.         if$save_immediately )
  2496.         {
  2497.             $Session->dbsave();
  2498.         }
  2499.         return $r;
  2500.     }
  2501.  
  2502.  
  2503.     /**
  2504.      * Get a data value for the session, using a unique prefix to the Plugin.
  2505.      * This checks for the data to be expired and unsets it then.
  2506.      *
  2507.      * @param string Name of the data's key (gets prefixed with 'plugIDX_' internally).
  2508.      * @return mixed|NULLThe value, if set; otherwise NULL
  2509.      */
  2510.     function session_get$name )
  2511.     {
  2512.         global $Session;
  2513.  
  2514.         return $Session->get'plugID'.$this->ID.'_'.$name );
  2515.     }
  2516.  
  2517.  
  2518.     /**
  2519.      * Delete a value from the session data, using a unique prefix to the Plugin.
  2520.      *
  2521.      * @param string Name of the data's key (gets prefixed with 'plugIDX_' internally).
  2522.      */
  2523.     function session_delete$name )
  2524.     {
  2525.         global $Session;
  2526.  
  2527.         return $Session->delete'plugID'.$this->ID.'_'.$name );
  2528.     }
  2529.  
  2530.  
  2531.     /**
  2532.      * Call this to unregister all your events for the current request.
  2533.      */
  2534.     function forget_events()
  2535.     {
  2536.         global $Plugins;
  2537.         $Plugins->forget_events$this->ID );
  2538.     }
  2539.  
  2540.  
  2541.     /**
  2542.      * Disable an event.
  2543.      *
  2544.      * This removes it from the events table.
  2545.      *
  2546.      * @return boolean True, if status has changed; false if it was disabled already
  2547.      */
  2548.     function disable_event$event )
  2549.     {
  2550.         return $this->Plugins->set_event_status$this->ID$event);
  2551.     }
  2552.  
  2553.  
  2554.     /**
  2555.      * Enable an event.
  2556.      *
  2557.      * This adds it to the events table.
  2558.      *
  2559.      * @return boolean True, if status has changed; false if it was enabled already
  2560.      */
  2561.     function enable_event$event )
  2562.     {
  2563.         return $this->Plugins->set_event_status$this->ID$event);
  2564.     }
  2565.  
  2566.     /*
  2567.      * Helper methods }}}
  2568.      */
  2569.  
  2570.  
  2571.     /*
  2572.      * Interface methods. You should not override those! {{{
  2573.      *
  2574.      * These are used to access certain plugin internals.
  2575.      */
  2576.  
  2577.     /**
  2578.      * Template function: display plugin code
  2579.      * @deprecated since 1.9
  2580.      */
  2581.     function code()
  2582.     {
  2583.         echo $this->code;
  2584.     }
  2585.  
  2586.  
  2587.     /**
  2588.      * Template function: Get displayable plugin name.
  2589.      *
  2590.      * @deprecated since 1.9
  2591.      * @param string Output format, see {@link format_to_output()}
  2592.      * @param boolean shall we display?
  2593.      * @return string displayable plugin name.
  2594.      */
  2595.     function name$format 'htmlbody'$disp true )
  2596.     {
  2597.         if$disp )
  2598.         {
  2599.             echo format_to_output$this->name$format );
  2600.         }
  2601.         else
  2602.         {
  2603.             return format_to_output$this->name$format );
  2604.         }
  2605.     }
  2606.  
  2607.  
  2608.     /**
  2609.      * Template function: display short description for plug in
  2610.      *
  2611.      * @deprecated since 1.9
  2612.      * @param string Output format, see {@link format_to_output()}
  2613.      * @param boolean shall we display?
  2614.      * @return string displayable short desc
  2615.      */
  2616.     function short_desc$format 'htmlbody'$disp true )
  2617.     {
  2618.         if$disp )
  2619.         {
  2620.             echo format_to_output$this->short_desc$format );
  2621.         }
  2622.         else
  2623.         {
  2624.             return format_to_output$this->short_desc$format );
  2625.         }
  2626.     }
  2627.  
  2628.  
  2629.     /**
  2630.      * Template function: display long description for plug in
  2631.      *
  2632.      * @deprecated since 1.9
  2633.      * @param string Output format, see {@link format_to_output()}
  2634.      * @param boolean shall we display?
  2635.      * @return string displayable long desc
  2636.      */
  2637.     function long_desc$format 'htmlbody'$disp true )
  2638.     {
  2639.         if$disp )
  2640.         {
  2641.             echo format_to_output$this->long_desc$format );
  2642.         }
  2643.         else
  2644.         {
  2645.             return format_to_output$this->long_desc$format );
  2646.         }
  2647.     }
  2648.  
  2649.  
  2650.     /**
  2651.      * Get a link to a help page (with icon).
  2652.      *
  2653.      * @param string Target; one of the following:
  2654.      *          - anchor to {@link $help_url} ("#anchor")
  2655.      *          - absolute link to some URL, e.g. "http://example.com/example.php"
  2656.      *          - '$help_url' or empty for {@link $help_url}, then also the "www" icon gets used
  2657.      *          - '$readme' to link to the plugin's README.html file (if available)
  2658.      * @return string The html A tag, linking to the help (or empty in case of $readme, if there is none).
  2659.      */
  2660.     function get_help_link$target '' )
  2661.     {
  2662.         static $target_counter 0;
  2663.         $title '';
  2664.         $icon 'help';
  2665.         $word '';
  2666.         $link_attribs array'target' => '_blank''id'=>'anchor_help_plugin_'.$this->ID.'_'.$target_counter++ );
  2667.  
  2668.         if$target == '$help_url' || empty($target) )
  2669.         {
  2670.             $url $this->get_help_url();
  2671.             $title T_('Homepage of the plugin');
  2672.             $icon 'www';
  2673.         }
  2674.         elseif$target == '$readme' )
  2675.         // README
  2676.             if$this->get_help_file() )
  2677.             {
  2678.                 return '';
  2679.             }
  2680.  
  2681.             global $admin_url;
  2682.  
  2683.             $link_attribs['use_js_popup'true;
  2684.             $link_attribs['use_js_size''500, 400';
  2685.             $title T_('Local documentation of the plugin');
  2686.             $url url_add_param$admin_url'ctrl=plugins&amp;action=disp_help_plain&amp;plugin_ID='.$this->ID );
  2687.             $icon 'help';
  2688.         }
  2689.         elseifsubstr($target01== '#' )
  2690.         // anchor
  2691.             $help_url empty$this->help_url $this->help_url 'http://manual.b2evolution.net/Plugins/'.$this->classname;
  2692.             $url $help_url.$target;
  2693.         }
  2694.         elseifpreg_match'~^https?://~'$target ) )
  2695.         // absolute URL (strict match to allow other formats later if needed)
  2696.             $url $target;
  2697.         }
  2698.         else
  2699.         {
  2700.             debug_die'Invalid get_help_link() target: '.$target );
  2701.         }
  2702.  
  2703.         return action_icon$title$icon$url$word41$link_attribs );
  2704.     }
  2705.  
  2706.  
  2707.     /**
  2708.      * Get the plugin's external help/website URL.
  2709.      *
  2710.      * @return string 
  2711.      */
  2712.     function get_help_url()
  2713.     {
  2714.         ifempty$this->help_url ) )
  2715.         {
  2716.             return 'http://manual.b2evolution.net/Plugins/'.$this->classname;
  2717.         }
  2718.         else
  2719.         {
  2720.             return $this->help_url;
  2721.         }
  2722.     }
  2723.  
  2724.  
  2725.     /**
  2726.      * @deprecated Backwards compatibility wrapper (for 1.8)
  2727.      */
  2728.     function get_README_link()
  2729.     {
  2730.         return $this->get_help_link('$readme');
  2731.     }
  2732.  
  2733.  
  2734.     /**
  2735.      * Get the help file for a Plugin ID. README.LOCALE.html will take
  2736.      * precedence above the general (english) README.html.
  2737.      *
  2738.      * @todo Handle encoding of files (to $io_charset)
  2739.      *
  2740.      * @return false|string
  2741.      */
  2742.     function get_help_file()
  2743.     {
  2744.         global $default_locale$plugins_path$current_User;
  2745.  
  2746.         if$current_User->check_perm'options''view'false ) )
  2747.         // README gets displayed through plugins controller, which requires these perms
  2748.             // TODO: Catch "disp_help" and "disp_help_plain" messages in plugins.php before general perms check!?
  2749.             return false;
  2750.         }
  2751.  
  2752.         // Get the language. We use $default_locale because it does not have to be activated ($current_locale)
  2753.         $lang substr$default_locale0);
  2754.  
  2755.         $help_dir dirname($this->classfile_path).'/';
  2756.         if$help_dir == $plugins_path )
  2757.         {
  2758.             $help_dir .= $this->classname.'/';
  2759.         }
  2760.  
  2761.         // Try help for the user's locale:
  2762.         $help_file $help_dir.'README.'.$lang.'.html';
  2763.  
  2764.         iffile_exists($help_file) )
  2765.         // Fallback: README.html
  2766.             $help_file $help_dir.'README.html';
  2767.  
  2768.             iffile_exists($help_file) )
  2769.             {
  2770.                 return false;
  2771.             }
  2772.         }
  2773.  
  2774.         return $help_file;
  2775.     }
  2776.  
  2777.  
  2778.     /**
  2779.      * Get a link to edit the Plugin's settings (if the user has permission).
  2780.      *
  2781.      * @return false|string
  2782.      */
  2783.     function get_edit_settings_link()
  2784.     {
  2785.         global $current_User$admin_url;
  2786.  
  2787.         if$current_User->check_perm'options''view'false ) )
  2788.         {
  2789.             return false;
  2790.         }
  2791.  
  2792.         return action_iconT_('Edit plugin settings!')'edit'$admin_url.'?ctrl=plugins&amp;action=edit_settings&amp;plugin_ID='.$this->ID );
  2793.     }
  2794.  
  2795.  
  2796.     /**
  2797.      * PHP5 overloading of get method to lazy-load (User)Settings.
  2798.      */
  2799.     function __get$nm )
  2800.     {
  2801.         switch$nm )
  2802.         {
  2803.             case 'Settings':
  2804.                 $this->Plugins->instantiate_Settings$this'Settings' );
  2805.                 return isset($this->Settings$this->Settings NULL;
  2806.  
  2807.             case 'UserSettings':
  2808.                 $this->Plugins->instantiate_Settings$this'UserSettings' );
  2809.                 return isset($this->UserSettings$this->UserSettings NULL;
  2810.         }
  2811.     }
  2812.  
  2813.     /*
  2814.      * Interface methods }}}
  2815.      */
  2816.  
  2817. }
  2818.  
  2819.  
  2820. /*
  2821.  * $Log: _plugin.class.php,v $
  2822.  * Revision 1.82.2.28  2007/02/17 21:12:44  blueyed
  2823.  * MFH: Removed magic in Plugin::get_htsrv_url() which used the blog url and assumed that "htsrv" was available in there
  2824.  *
  2825.  * Revision 1.82.2.27  2006/12/28 23:18:54  fplanque
  2826.  * added plugin event for displaying comment form toolbars
  2827.  * used by smilies plugin
  2828.  *
  2829.  * Revision 1.82.2.26  2006/11/17 22:36:41  blueyed
  2830.  * MFH: dbchanges param for AfterItemUpdate, AfterItemInsert, AfterCommentUpdate and AfterCommentInsert
  2831.  *
  2832.  * Revision 1.82.2.25  2006/11/06 23:21:28  blueyed
  2833.  * Won't get fixed for 1.9 also - too much hassle.. :/
  2834.  *
  2835.  * Revision 1.82.2.24  2006/11/04 19:55:05  fplanque
  2836.  * Reinjected old Log blocks. Removing them from CVS was a bad idea -- especially since Daniel has decided branch 1.9 was his HEAD...
  2837.  *
  2838.  * Revision 1.82  2006/07/31 20:11:28  blueyed
  2839.  * Karma: check for "numeric" instead of "integer" return values.
  2840.  *
  2841.  * Revision 1.81  2006/07/31 16:38:23  blueyed
  2842.  * doc
  2843.  *
  2844.  * Revision 1.80  2006/07/31 15:41:37  yabs
  2845.  * Modified 'allow_html' to html_input/html_textarea
  2846.  *
  2847.  * Revision 1.79  2006/07/31 06:58:47  yabs
  2848.  * Added info line to GetDefaultSettings() for : allow_html
  2849.  *
  2850.  * Revision 1.78  2006/07/26 20:48:33  blueyed
  2851.  * Added Plugin event "Logout"
  2852.  *
  2853.  * Revision 1.77  2006/07/23 20:18:31  fplanque
  2854.  * cleanup
  2855.  *
  2856.  * Revision 1.76  2006/07/17 01:19:25  blueyed
  2857.  * Added events: AfterUserInsert, AfterUserUpdate, AfterUserDelete
  2858.  *
  2859.  * Revision 1.75  2006/07/15 19:53:33  blueyed
  2860.  * Re-added get_README_link() for backwards compatibility.
  2861.  *
  2862.  * Revision 1.74  2006/07/10 22:53:38  blueyed
  2863.  * Grouping of plugins added, based on a patch from balupton
  2864.  *
  2865.  * Revision 1.73  2006/07/10 21:05:40  blueyed
  2866.  * Enhanced Plugin::T_():
  2867.  * Now also uses a global _global.php file, which may hold all translations in one file.
  2868.  *
  2869.  * Revision 1.72  2006/07/10 20:19:30  blueyed
  2870.  * Fixed PluginInit behaviour. It now gets called on both installed and non-installed Plugins, but with the "is_installed" param appropriately set.
  2871.  *
  2872.  * Revision 1.71  2006/07/10 18:53:04  blueyed
  2873.  * Fixed method def; added doc
  2874.  *
  2875.  * Revision 1.70  2006/07/07 21:26:04  blueyed
  2876.  * Should have tested it.. ;/
  2877.  *
  2878.  * Revision 1.69  2006/07/07 21:21:16  blueyed
  2879.  * Handle deprecated stuff.
  2880.  *
  2881.  * Revision 1.68  2006/07/06 21:38:45  blueyed
  2882.  * Deprecated plugin constructor. Renamed AppendPluginRegister() to PluginInit().
  2883.  *
  2884.  * Revision 1.67  2006/07/04 17:32:30  fplanque
  2885.  * no message
  2886.  *
  2887.  * Revision 1.66  2006/06/30 22:58:13  blueyed
  2888.  * Abstracted charset conversation, not much tested.
  2889.  *
  2890.  * Revision 1.65  2006/06/25 23:43:34  blueyed
  2891.  * doc
  2892.  *
  2893.  * Revision 1.64  2006/06/19 20:59:14  blueyed
  2894.  * minor
  2895.  *
  2896.  * Revision 1.63  2006/06/10 19:16:17  blueyed
  2897.  * DisplayTrackbackAddr event
  2898.  *
  2899.  * Revision 1.62  2006/06/06 20:35:50  blueyed
  2900.  * Plugins can define extra events that they trigger themselves.
  2901.  *
  2902.  * Revision 1.61  2006/06/05 23:15:00  blueyed
  2903.  * cleaned up plugin help links
  2904.  *
  2905.  * Revision 1.60  2006/06/05 18:02:59  blueyed
  2906.  * doc
  2907.  *
  2908.  * Revision 1.59  2006/06/05 17:44:38  blueyed
  2909.  * doc
  2910.  *
  2911.  * Revision 1.58  2006/06/05 15:48:52  blueyed
  2912.  * Fix
  2913.  *
  2914.  * Revision 1.57  2006/06/05 15:38:29  blueyed
  2915.  * Fix
  2916.  *
  2917.  * Revision 1.56  2006/06/05 15:00:29  blueyed
  2918.  * Fix get_plugin_url to use https if ReqHost uses https.
  2919.  *
  2920.  * Revision 1.55  2006/06/05 14:34:31  blueyed
  2921.  * Added get_plugin_url()
  2922.  *
  2923.  * Revision 1.54  2006/06/05 14:26:42  blueyed
  2924.  * doc
  2925.  *
  2926.  * Revision 1.53  2006/05/30 23:08:59  blueyed
  2927.  * doc
  2928.  *
  2929.  * Revision 1.52  2006/05/30 19:39:55  fplanque
  2930.  * plugin cleanup
  2931.  *
  2932.  * Revision 1.51  2006/05/24 20:43:19  blueyed
  2933.  * Pass "Item" as param to Render* event methods.
  2934.  *
  2935.  * Revision 1.50  2006/05/22 20:35:37  blueyed
  2936.  * Passthrough some attribute of plugin settings, allowing to use JS handlers. Also fixed submitting of disabled form elements.
  2937.  *
  2938.  * Revision 1.49  2006/05/20 01:56:07  blueyed
  2939.  * ItemCanComment hook; "disable anonymous feedback" through basic antispam plugin
  2940.  *
  2941.  * Revision 1.48  2006/05/17 23:35:42  blueyed
  2942.  * cleanup
  2943.  *
  2944.  * Revision 1.47  2006/05/15 22:26:48  blueyed
  2945.  * Event hooks for skin plugins.
  2946.  *
  2947.  * Revision 1.46  2006/05/13 15:46:40  blueyed
  2948.  * doc fix
  2949.  *
  2950.  * Revision 1.45  2006/05/12 21:53:38  blueyed
  2951.  * Fixes, cleanup, translation for plugins
  2952.  *
  2953.  * Revision 1.44  2006/05/05 19:36:23  blueyed
  2954.  * New events
  2955.  *
  2956.  * Revision 1.43  2006/05/04 10:18:41  blueyed
  2957.  * Added Session property to skip page content caching event.
  2958.  *
  2959.  * Revision 1.42  2006/05/02 23:35:22  blueyed
  2960.  * Extended karma collecting event(s)
  2961.  *
  2962.  * Revision 1.41  2006/05/02 04:36:25  blueyed
  2963.  * Spam karma changed (-100..100 instead of abs/max); Spam weight for plugins; publish/delete threshold
  2964.  *
  2965.  * Revision 1.40  2006/05/02 01:47:58  blueyed
  2966.  * Normalization
  2967.  *
  2968.  * Revision 1.39  2006/05/02 01:27:55  blueyed
  2969.  * Moved nofollow handling to basic antispam plugin; added Filter events to Comment class
  2970.  *
  2971.  * Revision 1.38  2006/05/01 04:25:05  blueyed
  2972.  * Normalization
  2973.  *
  2974.  * Revision 1.37  2006/04/29 01:04:23  blueyed
  2975.  * *** empty log message ***
  2976.  *
  2977.  * Revision 1.36  2006/04/27 20:07:19  blueyed
  2978.  * Renamed Plugin::get_htsrv_methods() to GetHtsrvMethods() (normalization)
  2979.  *
  2980.  * Revision 1.35  2006/04/27 19:44:33  blueyed
  2981.  * A plugin can disable events (e.g. after install)
  2982.  *
  2983.  * Revision 1.34  2006/04/27 19:11:12  blueyed
  2984.  * Cleanup; handle broken plugins more decent
  2985.  *
  2986.  * Revision 1.33  2006/04/22 02:36:38  blueyed
  2987.  * Validate users on registration through email link (+cleanup around it)
  2988.  *
  2989.  * Revision 1.32  2006/04/20 22:24:08  blueyed
  2990.  * plugin hooks cleanup
  2991.  *
  2992.  * Revision 1.31  2006/04/19 20:14:03  fplanque
  2993.  * do not restrict to :// (does not catch subdomains, not even www.)
  2994.  *
  2995.  * Revision 1.29  2006/04/19 18:14:12  blueyed
  2996.  * Added "no_edit" param to GetDefault(User)Settings
  2997.  *
  2998.  * Revision 1.28  2006/04/18 21:09:20  blueyed
  2999.  * Added hooks to manipulate Items before insert/update/preview; fixes; cleanup
  3000.  *
  3001.  * Revision 1.27  2006/04/18 17:06:14  blueyed
  3002.  * Added "disabled" to plugin (user) settings (Thanks to balupton)
  3003.  *
  3004.  * Revision 1.26  2006/04/13 01:36:27  blueyed
  3005.  * Added interface method to edit Plugin settings (gets already used by YouTube Plugin)
  3006.  *
  3007.  * Revision 1.25  2006/04/13 01:23:19  blueyed
  3008.  * Moved help related functions back to Plugin class
  3009.  *
  3010.  * Revision 1.24  2006/04/11 22:09:08  blueyed
  3011.  * Fixed validation of negative integers (and also allowed "+" at the beginning)
  3012.  *
  3013.  * Revision 1.23  2006/04/05 19:16:35  blueyed
  3014.  * Refactored/cleaned up help link handling: defaults to online-manual-pages now.
  3015.  *
  3016.  * Revision 1.22  2006/04/04 22:56:12  blueyed
  3017.  * Simplified/refactored uninstalling/registering of a plugin (especially the hooking process)
  3018.  *
  3019.  * Revision 1.21  2006/03/28 22:24:46  blueyed
  3020.  * Fixed logical spam karma issues
  3021.  *
  3022.  * Revision 1.20  2006/03/21 23:17:17  blueyed
  3023.  * doc/cleanup
  3024.  *
  3025.  * Revision 1.19  2006/03/19 22:38:29  blueyed
  3026.  * added get_class_id()
  3027.  *
  3028.  * Revision 1.18  2006/03/19 19:02:51  blueyed
  3029.  * New events for captcha plugins
  3030.  *
  3031.  * Revision 1.17  2006/03/18 19:39:19  blueyed
  3032.  * Fixes for pluginsettings; added "valid_range"
  3033.  *
  3034.  * Revision 1.16  2006/03/15 23:30:20  blueyed
  3035.  * Use plugin classname in SQL table name.
  3036.  *
  3037.  * Revision 1.15  2006/03/15 21:04:36  blueyed
  3038.  * Call Plugin::BeforeEnable also on configuration changes and disable the plugin, if it does not say "ok"
  3039.  *
  3040.  * Revision 1.14  2006/03/12 23:09:01  fplanque
  3041.  * doc cleanup
  3042.  *
  3043.  * Revision 1.13  2006/03/11 15:49:48  blueyed
  3044.  * Allow a plugin to not update his settings at all.
  3045.  *
  3046.  * Revision 1.12  2006/03/11 01:59:00  blueyed
  3047.  * Added Plugin::forget_events()
  3048.  *
  3049.  * Revision 1.11  2006/03/06 22:42:20  blueyed
  3050.  * doc fixes
  3051.  *
  3052.  * Revision 1.10  2006/03/06 22:07:32  blueyed
  3053.  * doc, organized events into subsections
  3054.  *
  3055.  * Revision 1.9  2006/03/06 20:03:40  fplanque
  3056.  * comments
  3057.  *
  3058.  * Revision 1.8  2006/03/03 20:10:21  blueyed
  3059.  * doc
  3060.  *
  3061.  * Revision 1.7  2006/03/02 22:18:24  blueyed
  3062.  * New events
  3063.  *
  3064.  * Revision 1.6  2006/03/02 19:57:52  blueyed
  3065.  * Added DisplayIpAddress() and fixed/finished DisplayItemAllFormats()
  3066.  *
  3067.  * Revision 1.5  2006/03/01 01:07:43  blueyed
  3068.  * Plugin(s) polishing
  3069.  *
  3070.  * Revision 1.4  2006/02/27 16:57:12  blueyed
  3071.  * PluginUserSettings - allows a plugin to store user related settings
  3072.  *
  3073.  * Revision 1.3  2006/02/24 22:22:57  blueyed
  3074.  * Fix URL for internal help.
  3075.  *
  3076.  * Revision 1.2  2006/02/24 22:08:59  blueyed
  3077.  * Plugin enhancements
  3078.  *
  3079.  * Revision 1.1  2006/02/23 21:12:18  fplanque
  3080.  * File reorganization to MVC (Model View Controller) architecture.
  3081.  * See index.hml files in folders.
  3082.  * (Sorry for all the remaining bugs induced by the reorg... :/)
  3083.  *
  3084.  * Revision 1.33  2006/02/15 04:07:16  blueyed
  3085.  * minor merge
  3086.  *
  3087.  * Revision 1.32  2006/02/09 22:05:43  blueyed
  3088.  * doc fixes
  3089.  *
  3090.  * Revision 1.31  2006/02/07 11:14:21  blueyed
  3091.  * Help for Plugins improved.
  3092.  *
  3093.  * Revision 1.25  2006/01/28 21:11:16  blueyed
  3094.  * Added helpers for Session data handling.
  3095.  *
  3096.  * Revision 1.23  2006/01/28 16:59:47  blueyed
  3097.  * Removed remove_events_for_this_request() as the problem would be anyway to handle the event where it got called from.
  3098.  *
  3099.  * Revision 1.21  2006/01/26 23:47:27  blueyed
  3100.  * Added password settings type.
  3101.  *
  3102.  * Revision 1.20  2006/01/26 23:08:36  blueyed
  3103.  * Plugins enhanced.
  3104.  *
  3105.  * Revision 1.19  2006/01/23 01:12:15  blueyed
  3106.  * Added get_table_prefix() and remove_events_for_this_request(),
  3107.  *
  3108.  * Revision 1.18  2006/01/06 18:58:08  blueyed
  3109.  * Renamed Plugin::apply_when to $apply_rendering; added T_plugins.plug_apply_rendering and use it to find Plugins which should apply for rendering in Plugins::validate_list().
  3110.  *
  3111.  * Revision 1.17  2006/01/06 00:27:06  blueyed
  3112.  * Small enhancements to new Plugin system
  3113.  *
  3114.  * Revision 1.16  2006/01/05 23:57:17  blueyed
  3115.  * Enhancements to msg() and debug_log()
  3116.  *
  3117.  * Revision 1.15  2006/01/04 15:03:52  fplanque
  3118.  * enhanced list sorting capabilities
  3119.  *
  3120.  * Revision 1.14  2005/12/23 19:06:35  blueyed
  3121.  * Advanced enabling/disabling of plugin events.
  3122.  *
  3123.  * Revision 1.13  2005/12/22 23:13:40  blueyed
  3124.  * Plugins' API changed and handling optimized
  3125.  *
  3126.  * Revision 1.12  2005/12/12 19:21:23  fplanque
  3127.  * big merge; lots of small mods; hope I didn't make to many mistakes :]
  3128.  *
  3129.  * Revision 1.11  2005/11/25 00:28:04  blueyed
  3130.  * doc
  3131.  *
  3132.  * Revision 1.10  2005/09/06 17:13:55  fplanque
  3133.  * stop processing early if referer spam has been detected
  3134.  *
  3135.  * Revision 1.9  2005/06/22 14:46:31  blueyed
  3136.  * help_link(): "renderer" => "plugin"
  3137.  *
  3138.  * Revision 1.8  2005/04/28 20:44:20  fplanque
  3139.  * normalizing, doc
  3140.  *
  3141.  * Revision 1.7  2005/03/14 20:22:20  fplanque
  3142.  * refactoring, some cacheing optimization
  3143.  *
  3144.  * Revision 1.5  2005/03/02 18:30:56  fplanque
  3145.  * tedious merging... :/
  3146.  *
  3147.  * Revision 1.4  2005/02/28 09:06:33  blueyed
  3148.  * removed constants for DB config (allows to override it from _config_TEST.php), introduced EVO_CONFIG_LOADED
  3149.  *
  3150.  * Revision 1.3  2005/02/22 03:00:57  blueyed
  3151.  * fixed Render() again
  3152.  *
  3153.  * Revision 1.2  2005/02/20 22:34:40  blueyed
  3154.  * doc, help_link(), don't pass $param as reference
  3155.  *
  3156.  * Revision 1.1  2004/10/13 22:46:32  fplanque
  3157.  * renamed [b2]evocore/*
  3158.  *
  3159.  * Revision 1.9  2004/10/12 16:12:18  fplanque
  3160.  * Edited code documentation.
  3161.  *
  3162.  */
  3163. ?>

Documentation generated on Tue, 18 Dec 2007 22:50:07 +0100 by phpDocumentor 1.4.0