Features

The iScripts framework provides a number of features like PageContext, PostAction, Debugger, Logger, Db layer, Url router, etc. The framework uses Smarty template engine. The framework helps to use SEO friendly url. It has options to set layout and disable layout.

The layouts of the projects is a tpl file should be at the location view/layout of the corresponding module in the project directory. The tpl files for a controller should be in the view/script directory inside the folder with same name as controller file name.

The framework provides options to implement multiple languages. The language files should be in the resource folder in project directory. The default language is English. The framework has bootstrap, fusion charts, fckeditors, Php mailer, etc embedded in it.

PageContext

Page Context provides a set of static functions through which many of the properties of the project which is owned by the framework can be accessed/modified. The outermost layer of the page ( page header ) is owned by the framework. The developer can add HTML only within the body tag. If the developer wants to add/modify anything in the header areas or add a js file or stylesheet or add a js code snippet to the page, it can be done using page context.

A Js file can be added to a page using addScript function. The function can be called in the controller of the page. The JS file should be kept in the js folder in project directory. The file name is passed as a parameter to the function.

Eg :

 PageContext::addScript("test.js");  

A stylesheet (.css file) can be added to a page using addStyle function. The function can be called in the controller of the page. The stylesheet should be kept in the styles folder in project directory. The file name is passed as a parameter to the function.

Eg :

 PageContext:: addStyle ("test. css ");   

To include an external library to a page/project the library folder should be created inside lib folder in project directory. The library folder name should be in lowercase. The library can be included using includePath function.

To pass a PHP constant value to the JS addJsVar function can be used.

Eg :

     PageContext::addJsVar(JS_IMAGE_URL, IMAGE_URL).    

The variable JS_IMAGE_URL will be available everywhere in the js for that page.

PostActions

Post actions are pagelets which can be loaded independently or attached with another page. Post actions offers flexibility of breaking the logic of a single page into multiple logical units.

Eg : In a simple page with a menu on top, the menu will be repeated in every page with its own logical flows. In this case, we can write the menu as a pagepost action, and include it in all the pages which needs menu.

This is done using addPostAction, registerPostAction, renderPostAction functions of PageContext.

Url Router

Url router component controls the overall url routing in the project. The router class provides three static functions (connect, redirect, alias) with which the entire set of urls required for the project can be defined in pageroutes.php in config folder in project directory. This helps to implement a single point of control for all url’s in the application.

Example:

 
      Router::connect(“user”,”/user/dashboard’);
      Router::redirect(“user/login”,”login”);
      Router::alias(":username", "(.*)");
      Router::connect(“:username”,”/user/profile/$1”);
        

In this example :username is a variable which can take any value as defined in the regular expression.

Url router component helps to easily implement SEO friendly URL’s.

Example: To load static pages with url as page“SITE_URL/STATIC_PAGE_ALIAS”

 
      Router::alias(":username", "(.*)");
      Router::alias(“:staticpages”,”about|contact|feedback”);
      Router::connect(“:staticpages”,”/content/static/$1”);
      Router::connect(“:username”,”/user/profile/$1”);    
        

File Handler

File handler consist of all the lower level file handling logics required in the application. Using file handler, a file upload can be done from any source ( local file path/url/file object).

The file handler maintains a central files table. Uploaded files will be stored in files folder in project directory and all the file information will be stored in files table. The file_id ( primary key of the files table) will be returned.

The Filehandler class contains handleUpload, handleUrl, handleLocalFile, handleFile, etc functions. The functions are called using an object of the Filehandler class.

Db Layer

Db Layer consist of all the lower level database handling logics required in the application. Using Db Layer, basic Db operations can be done easily.

The Db class contains addFields, updateFields, selectRow, selectRecord, execute, fetchAll etc functions. The functions are called using an object of the Db class. The Db class helps to execute queries easily. The connection to the database is setup when the the object of the Db class is created. The database details are defined in the settings.php in config folder in project directory.

Eg:

 
      $objDb = new Db();
      $objDb->selectQuery($query);
      $objDb->selectResult($table,$field,$where);
       

Control Panel

Framework provides a basic control panel to turn some of the basic features on/off. Debugger, Logger, Cache, Error reporting, etc can be controlled from here.

The path to control panel is “[SITE_URL]/fw”. There is a basic http authentication, to avoid users other than developers from accessing this page. Username : admin ; password : admin

Logger

Logger will help the developer in debugging. Using the logger class, data (objects/variables/arrays) can be logged from anywhere in the application. When Logger is turned ON, the logged data along with line number will be logged into the log file and also will be printed on to the debug console.Logger can be turned ON/OFF from the control panel.

Example :

 
      Logger::info($data); $data can be a variable/array/object
        

Debugger

Debugger is a tool implemented to greatly reduce the effort required in debugging. Debugger can be activated/deactivated from the control panel. When debugger is turned ON, the framework will add a debug console in the tail of every page. The debug console will output, the DB queries executed, Logs, Session data, Cache, Constants, Page Headers, Request Object, etc in separate tabs for that page.

Session Layer

Session Layer is used to handle all the session related operations in the application. Session Layer is implemented using LibSession class.

The LibSession class contains set, get, delete and destroy functions. The functions are called using an object of the LibSession class.

Javascript Vars

Javascript Vars are used to make assignment of data in php variables to JavaScript variables easily. This is done using addJsVar function of PageContext.

Eg :

 
      PageContext::addJsVar("title", "Hello");
        

Meta Tag Detection

The iScripts framework provides the feature to change the meta data of the project. It provides the feature to give different meta data for each page in the project.

This can be done by either setting the values of $metaTitle, $metaDes, $metaKey variables of PageContext in the controller of the page, or by definind the table ‘fw_metadata’ in the database of the project. The table should have the fields ‘url’, ‘keyword’, ‘title’ and ‘description’.

Cache Management

The iScripts framework provides the feature for cache management. We can enable or disable cache support by defining the constant CACHE_ENABLED in the setting.php file. Cache support can be enable by defining the constant as true and can be disabled by defining the constant as false. The constants defined fir cache support are CACHE_ENABLED, CACHE_TYPE, CACHE_SERVER, CACHE_PORT.

 
          define('CACHE_ENABLED', false);
          define('CACHE_TYPE', 'memcache');
          define('CACHE_SERVER', '192.168.0.11')
          define('CACHE_PORT', 11211);
        

Next CMS Introduction