Upload
dashamir-hoxha
View
423
Download
2
Embed Size (px)
Citation preview
Dashamir HoxhaDashamir Hoxha [email protected] NallbaniElda Nallbani [email protected]
Institute for Informatics and Applied Mathematics INIMA
http://www.inima.al
The phpWebApp Framework http://phpwebapp.sourceforge.net/
The SEEGRID Resources Web Application http://seegrid.inima.al/gridrc/
phpWebApp and SEEGRID ResouresphpWebApp and SEEGRID Resoures
SEEGRID Resources Web AppSEEGRID Resources Web App
Displays resources for each country and cluster.
Displays also summary tables (reports).
Admins can also edit/modify the data.
Modification of data is password protected.
Each country/cluster has an admin password.
The admins can also change their password, and country admins can set the cluster passwords.
Why Not Use Plain PHPWhy Not Use Plain PHP
Mixing HTML, CSS, JS, PHP, SQL codes✗ Editing becomes difficult (code colorization, etc.)✗ The maintenance of the application becomes difficult.✗ Makes difficult the team work.✗ Increases the complexity of web applications.
There are no persistent variables.
Lack of modularity.
Choosing a FrameworkChoosing a Framework
Possible Tools:✗ Any template system or web application framework
(look at http://sourceforge.net/search/?type=soft)✗ ColdFusion, Smarty, etc.
Why phpWebApp?✗ It is free (GNU GPL).✗ Better than the others (more flexible, powerful, etc.).✗ We know it better than the others.
What is the phpWebApp FrameworkWhat is the phpWebApp Framework
A Web Application Framework
Built with PHP and used for PHP apps
Easy interface to DB
Can be used for eContent, eGovernment, eCommerce, etc.
Features of phpWebAppFeatures of phpWebApp
Separates layout from logic (template system)
Supports modularity.
Thinks of a web application like a state machine.
Supports an eventbased programming model.
Supports web components and web objects.
Supports code reusability.
Features of phpWebAppFeatures of phpWebApp
Simplifies the interaction of the application with the database and makes it database independent.
Facilitates an iterative and incremental development approach for web applications.
Supports i18n and l10n (translation to other languages) using standard GNU gettext tools.
Has good debugging features.
phpWebApp ComponentsphpWebApp Components
Templates
Template variables
State Variables
Transitions
Events
Database
WebBoxes
WebClasses and WebObjects
phpWebApp: TemplatesphpWebApp: Templates
XHTML files with some additional tags and variables: <include>, <if>, <repeat>, <recordset>, <var>, <!# comments >, <webbox>, etc.<include src="{{./}}edit/cluster_edit.html" />
<if condition="!{{admin}}">
<a class="button" href="javascript:edit()">
Edit</a>
</if>
phpWebApp: TemplatesphpWebApp: Templates
<table> <repeat rs="clusters">
<tr><td>{{cluster_name}}</td></tr>
</repeat>
</table>
<recordset id="country">
<query>
SELECT country_name FROM countries
WHERE country_id = '{{country>id}}'
</query>
</recordset>
phpWebApp: Template VariablesphpWebApp: Template Variables
Slots in template files, denoted like this: {{var_name}}
Get their value in the php code, like this: WebApp::addVar(var_name, var_value);
The framework gets its value from a state variable, from a global php variable or from a php constant that has the same name as the template variable.
phpWebApp: State VariablesphpWebApp: State Variables
Persistent variables (don't loose their value from one page to another); similar to session variables.
Keep the state of the application and its webboxes (which are considered as a state machine).
Stored inside the webpage itself.
Example:
$user_id =
WebApp::getSVar('user_list>selected_user');
phpWebApp: Transitions and EventsphpWebApp: Transitions and Events
A transition is the move of the application from one state to another.
It is done by the function: GoTo('page.html')
An event is usually sent as well.
An event can be sent like this as well:SendEvent('targetBox', 'eventName', 'arg1=val1;arg2=val2');
It is handled by the php function: targetBox::on_eventName($event_args)
phpWebApp: DatabasephpWebApp: Database
Facilitates the connection and interaction of web applications with relational databases.
Is easy and convenient, but also flexible.
Is database independent.
Some of the classes are: Connection, Recordset, EditableRS, PagedRS, etc.
phpWebApp: WebBoxesphpWebApp: WebBoxes
A WebBox is a tpl which has its own php code.
It can also have its own JS, CSS, DB code, etc.
It can be selfcontained and independent, and can be included easily in other pages or in other applications.<webbox id="box_id">
<! content of WebBox >
</webbox>
phpWebApp: WebBoxesphpWebApp: WebBoxes
The other files are: box_id.php, box_id.js, etc.
box_id.php is like this:
<?php class box_id extends WebObject
{ . . . }
?>
It can have functions: onParse(), onRender()
These override the functions of WebObject.
phpWebApp: WebClassesphpWebApp: WebClasses
An attempt to use the concept of 'Class' for the templates of the framework.
Several WebObjects of the same class can be used in the same page.<WebObject class=”listbox” name=”books” rs=”books” />
Some predefined webclasses are:✗ listbox: a list of values from a recordset✗ datebox: select the date from a calendar✗ tabs: horizontal tablike menu
The Structure of a Web PageThe Structure of a Web Page
Conventions of Web ApplicationsConventions of Web Applications
Web Apps should follow some conventions:
Files index.php, webapp.php, browse.php, etc. are the same for all the applications.
The configuration of the application is placed in the folder 'config/' (const.Options.php, const.Paths.php, const.Debug.php, etc.)
Templates (webboxes etc.) are usually placed in the folder 'templates/'.
Future WorkFuture Work
Improvement of the docs of the framework.
Improvements to the framework itself.
Tools for working with the framework:✗ Emacs mode, Quanta plugin, etc.
Building reusable WebBoxes and WebClasses; they can be even organized in higherlevel frameworks for apps of a certain kind.
Code generation and reverse enginnering from UML models.
Dashamir HoxhaDashamir Hoxha [email protected] NallbaniElda Nallbani [email protected]
Institute for Informatics and Applied Mathematics INIMA
http://www.inima.al
The phpWebApp Framework http://phpwebapp.sourceforge.net/
The SEEGRID Resources Web Application http://seegrid.inima.al/gridrc/
phpWebApp and SEEGRID ResouresphpWebApp and SEEGRID Resoures