Introduction
Installation
Getting started
Package Definition Reference
Connecting to Database
Common DB Operations
Filter
Handling Multiple Databases
How-Tos
Deployment
Credit
Feedback
Changelog

Zephyr API

Forum

<<-getting started->>

all the packages in zephyr resides on "packages" folder. so if you want to develop a new package, just give it a name and create a folder in this folder as "packagename". let me explaint it a bit more. here is the folder structure

- zephyr
  | - packages
  |   | + packagename

after creating you package, you can create your package definition which is just a small xml file decribes your package. zephyr depend on this package definition to find which template it would run as a home page and which other files are bound to this packages, specially javascript, css and custom php functions. we will discuss about managing packages later. for now, just see a sample package definition.

<?xml version="1.0" encoding="iso-8859-1"?>
<package>
     <name>zephyr</name>
     <version>1.00</version>
     <root_action>home</root_action>
</package>

well, i am not going to cover them in detail, just FYI, the "<root_action>" is the first action that will be executed when someone requested a package. this is something similar to your package "homepage".

you will get a complete definition under "package definition reference" section

<<-the classic "hello world" application->>

this is a small ajax application which says "hello world" in any desired <div> in the current page. frst create a golder name "hello_world" under packages folder.

- zephyr
  | - packages
  |   | - hello_world

now start creating the package definition. here is the sample file.

<?xml version="1.0" encoding="iso-8859-1"?>
<package>
     <name>hello_worldr</name>
     <version>1.00</version>
     <root_action>home</root_action>
</package>

now create two seperate folde in your "hello_world". one of them is "actions" which contains all the action necessary for your package, second is "views" which contains the viewes [or templates to render]. lets see the folder structure for your first application.

- zephyr
  | - packages
  |   | - hello_world
  |   |   | + actions
  |   |   | + views

now we will create our first action "home" which will be executed as a default action. this action will return the template "hello.tpl" to our controller. zephyrcontroller will then render this template file and display output.

<?
//home.class.php class home implements action { public $params; public function execute() { return array("view_file"=hello"); } public function get_view() { } } ?>

now we have to create two template file. one is "hello.tpl" as package homepage and another is a "messages.tpl" for rendering the message and return to your action. lets see the "hello.tpl"...


<h2 align='center'>Welcome to zephyr</h1>
<div id='results'> This is your primary content </div><br />
<input type='button' value="Click me" onclick='load_action_smartly("display_message","Hello world","results");'/>

this file has one <div> object in which our message "hello world" will be loaded dynamically. look at the button, it calls a builtin function "load_action_smartly()". when someone clicked on this button, the action "display_message" will be invoked with one additional parameter message, here it is "Hello World". the third parameter is the name of <div> object in which the result of "display_message" action will be shown dynamically. lets create the action "display_message".

<?
//display_message.class.php class display_message implements action { /** * this variable stores incoming data as a serialized object * * @var string * @access public * @since 1.0 */ public $params ; public function execute() { $data = array("message"=>$this->params); return array("view_file"=>"messages", "command"=>"void", "data"=>$data); } //this method is removed from action.interface.php in beta1 //if you use zephyr prior to beta 1, you have to include this method. In beta 1, it is not needed. public function get_view() { } } ?>

well this is a typical action handler. here out incoming data "hello world" has been passed as "$params". we capture it and pass to "messages.tpl" via this line.

$data = array("message"=>$this->params);
return array("view_file"=>"messages", "command"=>"void", "data"=>$data);

so the "messages.tpl" will be invoked automatically with smarty variable {$message} as we defined in data array. lets have a look at "messages.tpl".

{$message}

lets look at the directory structure finally.

- zephyr
  | - packages
  |   | - hello_world
  |   |   | - actions
  |   |   |   | display_message.class.php
  |   |   |   | home.class.php
  |   |   | - views
  |   |   |   | hello.tpl
  |   |   |   | message.tpl

now run your application with following url

http://localhost/zephyr/index.php?package=hello_world

here are the screenshots