WSN Links
Featuresspacer Showcasespacer Reviewsspacer Demosspacer Purchasespacer Manualspacer Support

Register | Forgot Password
Plugins
Plugins
By Paul

Plugins allow you to override WSN Links 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)
checkincompletes (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 Links 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 checkincompletes() function, added in 5.0, allows you to trigger an incomplete prompt when the submitted data isn't valid. For example, I use this on the WSN suppport forums to make sure the version field is filled with a valid number:
function checkincompletes($object)
{
global $incomplete, $incompletemessage;
// $incomplete should be set as true when it's incomplete. $incompletemessage is an array containing a list of prompts for the user.

if ($object->objecttype == 'link')
{
$pattern = "/(WSN (Links|Gallery|KB|Forum|Classifieds|Guest|FormEmail)?)?( )?[0-9]+\.[0-9]+\.[0-9]+( (Alpha|Beta|RC) [0-9]+)?/i";
$check = preg_match($pattern, $object->sversion);
if (!$check)
{
$incomplete = true;
$incompletemessage[] = "A valid version number would be, for example, 5.0.1. ".$object->sversion." is not valid.";
}
}
return true;
}


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.

Rating:


0/5 based on 0 votes. The median rating is 0.

Submitted: 05/19/07 (Edited 08/09/08)

Description: Changing the functionality of WSN Links with PHP plugin files.

Views: 429 views. Averaging 1 per day.
In the most recent 30 day period, there've been 31 views.

Previous Article | Next Article

Home    |    Features    |    Showcase    |    Reviews    |    Demos    |    Purchase    |    Manual    |    Support