23
Dashamir Hoxha Dashamir Hoxha [email protected] Elda Nallbani Elda Nallbani [email protected] Institute for Informatics and Applied Mathematics INIMA http://www.inima.al  The phpWebApp Framework http://phpwebapp.sourceforge.net/  The SEE-GRID Resources Web Application http://see-grid.inima.al/gridrc/ phpWebApp and SEE-GRID Resoures phpWebApp and SEE-GRID Resoures 

phpWebApp presentation

Embed Size (px)

Citation preview

Page 1: phpWebApp presentation

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 SEE­GRID Resources Web Application http://see­grid.inima.al/gridrc/

phpWebApp and SEE­GRID ResouresphpWebApp and SEE­GRID Resoures  

Page 2: phpWebApp presentation
Page 3: phpWebApp presentation
Page 4: phpWebApp presentation

SEE­GRID Resources Web AppSEE­GRID 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.

Page 5: phpWebApp presentation

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.

Page 6: phpWebApp presentation

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.

Page 7: phpWebApp presentation

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.

Page 8: phpWebApp presentation

Features of phpWebAppFeatures of phpWebApp

Separates layout from logic (template system)

Supports modularity.

Thinks of a web application like a state machine.

Supports an event­based programming model.

Supports web components and web objects.

Supports code re­usability.

Page 9: phpWebApp presentation

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.

Page 10: phpWebApp presentation

phpWebApp ComponentsphpWebApp Components

Templates

Template variables

State Variables

Transitions

Events

Database

WebBox­es

WebClass­es and WebObjects

Page 11: phpWebApp presentation

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>

Page 12: phpWebApp presentation

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>

Page 13: phpWebApp presentation

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.

Page 14: phpWebApp presentation

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 webbox­es (which are considered as a state machine).

Stored inside the web­page itself.

Example: 

  $user_id = 

  WebApp::getSVar('user_list­>selected_user');

Page 15: phpWebApp presentation

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)

Page 16: phpWebApp presentation

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.

Page 17: phpWebApp presentation

phpWebApp: WebBox­esphpWebApp: WebBox­es

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 self­contained and independent, and can be included easily in other pages or in other applications.<webbox id="box_id">

   <!­­ content of WebBox ­­>

  </webbox>

Page 18: phpWebApp presentation

phpWebApp: WebBox­esphpWebApp: WebBox­es

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.

Page 19: phpWebApp presentation

phpWebApp: WebClass­esphpWebApp: WebClass­es

An attempt to use the concept of 'Class' for the templates of the framework.

Several WebObject­s 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 tab­like menu

Page 20: phpWebApp presentation

The Structure of a Web PageThe Structure of a Web Page

Page 21: phpWebApp presentation

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/'.

Page 22: phpWebApp presentation

Future WorkFuture Work

Improvement of the docs of the framework.

Improvements to the framework itself.

Tools for working with the framework:✗ Emacs mode, Quanta plug­in, etc.

Building reusable WebBox­es and WebClass­es; they can be even organized in higher­level frameworks for apps of a certain kind.

Code generation and reverse enginnering from UML models.

Page 23: phpWebApp presentation

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 SEE­GRID Resources Web Application http://see­grid.inima.al/gridrc/

phpWebApp and SEE­GRID ResouresphpWebApp and SEE­GRID Resoures