Diagram of a standard request
This page shows how a standard request to Piwik is handled, how is the Model View Controller used, when is called the API, etc.
This diagram show what happens for a request to piwik, for example an ajax request with the URL http://piwik.org/demo/index.php?module=Referers&action=getKeywords&idSite=1&period=day&date=yesterday&viewDataTable=cloud
|
|
Explanations
When hitting this URL the following things will happen:
- index.php the index.php calls to the FrontController. After initialization, the Front Controller will dispatch the request to the appropriate Controller. This controller is always located in a plugin specified by the module parameter. In our case this controller is the Home Controller
- Home_Controller the Controller Home is loaded, and the method getKeywords() is executed (specified by the action parameter). This method getKeywords() will:
- load a ViewDataTable object via the factory() method. The factory will look at the viewDataTable parameter in the HTTP request and load the appropriate ViewDataTable object ; in our case it will load the ViewDataTable_Cloud.
- init() the ViewDataTable_Cloud object, by giving it some useful parameters ; for example, the API method to call to request the data
- call the renderView() method on the ViewDataTable object
- ViewDataTable_Cloud the renderView() method on the ViewDataTable will call the main() and then render() the view. The main() will load data from the API and get a DataTable object. It will convert this DataTable in a simple PHP array and give this array to the Visualization_Cloud object (which is a simple class to render a tag cloud given an array of (keyword,value)
- Visualization_Cloud the Visualization_Cloud will go through the array( keywordA => value, keywordB => value, ... ) and render the tag cloud as HTML using the appropriate template (cloud.tpl) - the templating system used is Smarty.
- cloud.tpl / smarty The HTML generated is then given back to the ViewDataTable, then the Controller, the FrontController, and finally to the user.
- After the browser receives the HTML, all the javascript code (if any) will be executed (for example all the Jquery code).
|
See also
See the other documentation available.