YesNoOk
  1. Welcome!
    EosAlpha BBS is a fork of the popular Simple Machines Forum software. We aim at creating a new forum software, adding several new features and a modern and fresh design on top of the existing SMF code base.

    This software is currently in an early stage of development and this forum acts primarily as a testing platform for the ongoing development.

    Feel free to look around to get an idea about how it feels and looks.
avatar

New hooks (Read 1949 times)

Started by Nightwish, September 12, 2011, 18:14:40
0 Members and 1 Guest are viewing this.
Share this topic:
New hooks
New #1
Posted by Nightwish September 12, 2011, 18:14:40
This is just an internal memo for documenting a few new hooks I'm adding. For performance reasons, all these hooks are currently considered advanced hooks. They are never executed unless a special option in the admin area is enabled.

   1. integrate_parse_bbc_after

   Function prototype:
Code: (php)
function foo(&$message, &$parse_tags, &$smileys)
{
    // code
}
This hook executes in parse_bbc() after all standard codes and smileys have been parsed. It can be used to support mods like the footnotes modification that work on an already fully parsed message. Content parsed by this hook is still cacheable.


   2. integrate_parse_bbc_stage2

   Function prototype:
Code: (php)
function foo(&$message, &$parse_tags, &$smileys)
{
    // code
}
This hook can be used to implement BBCODE tags that should not (or cannot be) cacheable. On example would be a tag to hide or show post content based on the viewer's permissions (a typical hide tag modification). Two-staged bbcode parsing is currently experimental and there are no tags that are actually using it, but it may become a requirement because of the cache implementation.

   3. integrate_loadmembercontext

   Function prototype:
Code: (php)
function foo(&$memberContext, &$profile)
{
    // code
}
Hooks into loadMemberContext() and can be used to extend the memberContext[$userid] array with custom data fields. The $profile array contains the data loaded by loadMemberData(), so this hook is only useful when combined with integrate_loadmemberdata.

   4. integrate_loadmemberdata

   Function prototype:
Code: (php)
function foo(&$set, &$columns, &$tables)
{
    // code
}
Hooks into loadMemberData() and can be used to extend the SQL query that fetches member data from the database.

   5. display_messagerequest

   Function prototype:
Code: (php)
function foo(&$sql_what, &$sql_from_tables, &$sql_from_joins, &$sql_array)
{
    // code
}
Hooks into Display.php and allows to modify the SQL query that fetches all posts to display in a topic page. The parameters contain the list of fields to include in the query, a list of tables to fetch from (typically smf_messages left joined by a number of other tables) and the array that holds the replacement variables for the request.


   Hooks for supporting template hooks (to be implemented later)

With template hooks, it should become possible to modify the template output without actually altering the template files. Such hooks will allow to add or change content for the topic-, messageindex-, profile- and other views.


   1. display_postbit

   Function prototype:
Code: (php)
function foo(&$message)
{
    // code
}
This hook executes in prepareDisplayContext() and allows to modify the content of a post before it is passed to the template.


   1. display_general

   Function prototype:
Code: (php)
function foo()
{
    global $context;
    // code
}
Generic hook that executes once in Display.php and can be used to extend $context[] with additional information before it is passed to the template.

      Posted: March 17, 2012, 15:11:20
Maintenance hooks

   1. sys_daily_maint and sys_weekly_maint
   Function prototype:
Code: (php)
function foo()
{
    // code
}
These hooks execute in daily and weekly maintenance tasks. No parameters are passed to the hook functions. Plugin authors can use them to perform maintenance tasks on a regular base, one example would be the pruning of a plugin-private table.

      Posted: April 14, 2012, 10:13:13
Testpost
Every program has at least one bug and can be shortened by at least one instruction -- from which, by induction, one can deduce that every program can be reduced to a single instruction that doesn't work.
My SMF-based forum fork
4 Like It 
Last Edit: April 23, 2012, 05:12:55 by Velvet