Friday, 30 September 2011 14:35

iLance Pseudo-MVC Structure Featured

Written by
Rate this item
(2 votes)

iLance Pseudo-MVC Structure

iLance is a “Many Entry Point” application or platform. There are a number of files that take care of the ‘controller’ logic in the root directory, i.e. buying.php, main.php, etc. The logic in these is files is not delivered via a “class method” structure, where each piece of functionality is separated nicely into a method of the controlling class. The situation specific logic is perform via if statements in each of the files.

The “Model” like processing is perform via several class objects which are by default contained in the /functions/api directory with the file name class.class_name.inc.php where class_name exactly matches the class name as it appears in the file. i.e.

<?
class class_name {

 

?>

The model/data objects are usually made part of the global $ilance variable in the form of

$ilance->model = construct_object('api.class_name');

The ‘.’ notation contained there in is a file path starting in the functions directory. We keep all of our custom classes in the ‘functions/custom/’ folder and hence we invoke them as:

$myobject = construct_object('custom.myobject_class');

Note, that the file name has the same naming convention class.myobject_class.inc.php.

Finally the “view” portion of the content delivery is handled by a series of lines that are delivery at the end of each if statement logic block.

The first line loads the “template” file into the $ilance→template object. The template file holds the structured html and has a series of place holders for the variables that the script has been processing in the form of {variable}, note: there is no ‘$’.

Next, for variables that are part of an array and are represented in the template file that way, i.e. {array[key]} the parse_hash method is used. Next, the <if condition="<!-- condition -- >"><else/></if> blocks are processed and parsed. These are iLance specific structures that allow in-template processing logic to take place.

The last processing is to call the pprint method which takes a list of all of the variables the script just processed (the ones that need to be shown). The inner workings then replace those vars in the template with match names.

That is the iLance MVC structure in a nut shell.

Read 12946 times Last modified on Tuesday, 15 January 2013 18:37
Cameron

Cameron is a PHP Application Developer and consultant and spends much of his time furthering the business goals of his company Magnetic Merchandising Inc. which he started in 2005.

Cameron has provided technical deployment and consultation for many entities since starting MMI. Much of that work has been in complex hosted auction platforms, professional Joomla! deployments and extension development and sales.

As such, Cameron has acquired a deep technical skill-set, a sensitivity to client needs, and the ability to produce anything those clients can visualize.

Everyday, he actively seeks out and becomes familiar technologies that will give MMI clients maximum return for their web development and general e-presence dollar.

magneticmerchandising.com