Plugins
By Paul
By Paul
Plugins allow you to override WSN Knowledge Base functions with customized versions. The following functions can be replaced by plugins:
beforeaddition (includes/commonfuncs.php - dummy, see explanation below)
afteraddition (includes/commonfuncs.php - dummy, see explanation below)
afterpayment (includes/commonfuncs.php - dummy, see explanation below)
aftersetup (includes/commonfuncs.php - dummy, see explanation below)
securityimagevalue (includes/commonfuncs.php - returns characters for security image)
realip (includes/commonfuncs.php - determines the visitor's IP address)
catselector (includes/commonfuncs.php - gives category selector dropdown)
redirect (includes/commonfuncs.php - redirects from one page to another)
markrequired (includes/addeditfuncs.php - marks required fields in red outline)
reciprocates (includes/addeditfuncs.php - determines whether a link is considered reciprocated)
typeselector (includes/addeditfuncs.php - gives link type selector options)
makehtaccess (includes/admincommonfuncs.php - writes the .htaccess for URL rewriting)
googlemap (includes/googlemapfunc.php - generates google or sitemaps.org sitemap)
latextohtml (includes/templatefunctions.php - processes latex codes)
protecttext (includes/templatefunctions.php - disguises email addresses)
addtag (includes/tagfunctions.php - adds a new tag)
showfeeds (includes/objectfunctions.php - shows RSS feed data associated with item)
pluralize (includes/pluralize.php - attempts to pluralize/singularize words appopriately)
geofromaddr (includes/commonfuncs.php - finds latitude and longitude for an address)
geofromip (includes/commonfuncs.php - finds latitude and longitude from an IP)
If you'd like another function to become pluggable, just ask and your wish will almost certainly be granted.
Just place a PHP file in the plugins directory, containing your new version of the functions, to have the functions in it used. Start by copying the original function, then change it to your specs.
The most useful pluggable function will probably be beforeaddition. Use it to perform any desired changes to any sort of object just before it gets added to the database. For example:
Note how the objecttype property of $object allows you to determine what sort of object you're dealing with. Don't hesitate to ask support if you need help understanding how the WSN Knowledge Base objects work.
The afteraddition() function is the same as beforeddition() except it executes after the item has been added to the database (though it hasn't necessarily been validated).
The function afterpayment() is similar, but it allows you to do whatever you want after the sucessful processing of a sponsorship payment. See the dummy in commonfuncs.php for a short list of useful inputs.
The aftersetup() function lets you run code after a successful new installation completes. This may help simplify the task of a large-scale deployment where alterations need to be performed or default data needs to be inserted after installation.
Note that if you want to create new functions or do processing which may benefit from things having been initialized already you may find the modifications directory more useful, and for login-related matters see member system integration.
beforeaddition (includes/commonfuncs.php - dummy, see explanation below)
afteraddition (includes/commonfuncs.php - dummy, see explanation below)
afterpayment (includes/commonfuncs.php - dummy, see explanation below)
aftersetup (includes/commonfuncs.php - dummy, see explanation below)
securityimagevalue (includes/commonfuncs.php - returns characters for security image)
realip (includes/commonfuncs.php - determines the visitor's IP address)
catselector (includes/commonfuncs.php - gives category selector dropdown)
redirect (includes/commonfuncs.php - redirects from one page to another)
markrequired (includes/addeditfuncs.php - marks required fields in red outline)
reciprocates (includes/addeditfuncs.php - determines whether a link is considered reciprocated)
typeselector (includes/addeditfuncs.php - gives link type selector options)
makehtaccess (includes/admincommonfuncs.php - writes the .htaccess for URL rewriting)
googlemap (includes/googlemapfunc.php - generates google or sitemaps.org sitemap)
latextohtml (includes/templatefunctions.php - processes latex codes)
protecttext (includes/templatefunctions.php - disguises email addresses)
addtag (includes/tagfunctions.php - adds a new tag)
showfeeds (includes/objectfunctions.php - shows RSS feed data associated with item)
pluralize (includes/pluralize.php - attempts to pluralize/singularize words appopriately)
geofromaddr (includes/commonfuncs.php - finds latitude and longitude for an address)
geofromip (includes/commonfuncs.php - finds latitude and longitude from an IP)
If you'd like another function to become pluggable, just ask and your wish will almost certainly be granted.
Just place a PHP file in the plugins directory, containing your new version of the functions, to have the functions in it used. Start by copying the original function, then change it to your specs.
The most useful pluggable function will probably be beforeaddition. Use it to perform any desired changes to any sort of object just before it gets added to the database. For example:
<?php
function beforeaddition(&$object)
{
if ($object->objecttype == 'link') $object->title = ucwords($object->title); // capitalize first letter of each word in link titles
}
Note how the objecttype property of $object allows you to determine what sort of object you're dealing with. Don't hesitate to ask support if you need help understanding how the WSN Knowledge Base objects work.
The afteraddition() function is the same as beforeddition() except it executes after the item has been added to the database (though it hasn't necessarily been validated).
The function afterpayment() is similar, but it allows you to do whatever you want after the sucessful processing of a sponsorship payment. See the dummy in commonfuncs.php for a short list of useful inputs.
The aftersetup() function lets you run code after a successful new installation completes. This may help simplify the task of a large-scale deployment where alterations need to be performed or default data needs to be inserted after installation.
Note that if you want to create new functions or do processing which may benefit from things having been initialized already you may find the modifications directory more useful, and for login-related matters see member system integration.
Rate this article:
Submitted: 05/19/07 (Edited 09/30/07)
Description: Changing the functionality of WSN Links with PHP plugin files.
Views:
228 views. Averaging 1 per day.
In the most recent 30 day period, there've been 3 views.

Print
E-Mail