-
Sep 19, 2008, 12:42 amThis is what I have for now:
*** DOC ***
When redirecting, make sure to end your link with a '/' otherwise the redirect message may be amalgamated with other parameters.
CODING STYLE
Whenever possible use "null objects" (eg array())
CSS
utils.css
- Color message boxes
- CSS Reset
- Layout: integrates in existing page
- Column layouts: 10%, 20%, 25%, 30%, 33%, 40%, 50%, 60%, 66%, 70%, 75%, 80%, 90%, 100%
- Column layouts: float left, float right
Missing: typography support...
BASE FUNCTIONS
import($path)
redirect($url, $redirect_message)
addjs($js)
include_here(__FILE__, 'filename')
LOGGERS
FirePHPLogger
TmpLogger
EchoLogger
NullLogger
ROUTER
- url/controller/action
- url/controller/action/arg1/...
- url/context/controller/action
- url/context/controller/action/arg1/...
Avoid or substitute Gcontext by specifying in config.php in $altroutes
VARIABLES LIFECYCLE AND VISIBILITY
In controller, all $this->varname is then exposed to view as $varname
CONTROLLERS
- throw GoodException to pop out of controller and keep processing
VIEWS
$page_parameters
- 'action' is used to ask framework to modify view action
- 'action' = 'redirect': use redirect() instead
- 'action' = 'notify': call notifyView() == ???
- 'action' = 'api' if page-type is api - will not pollute communication with extra output
$options
- 'controller' to get view from another controller
- 'view' to display different view page
- 'header' to display alternate header
existing header pages:
header.html.php (default)
admin_header.html.php (default for admin pages)
partial_header.html.php include style sheets and javascript and message, if any
- 'body' to display alternate page body
alternate body: empty.html.php
- ' footer' to display alternate footer
existing footer pages:
footer.html.php (default)
admin_footer.html.php (default for admin pages)
partial_footer.html.php send minimal footer
VIEW HELPERS
label_for, input_tag,
form_tag, submit_tag,
etc.
AJAX
You can export methods directly from your controllers.
In the controller file, create your a static method.
After your class definition, call
ajaxExport(ClassName, methodName)
for instance:
class UserController extends ApplicationController
{
static function checkUsernameAvailable($username)
{
return ($username != 'chris');
}
}
ajaxExport(UserController, checkUsernameAvailable)
In the view file, add this javascript code:
CLassName$methodName(parameters, callback)
We need a callback because we cannot test the result of our call directly: it is being performed asynchronously, therefore the result will be returned later (to the callback function!).
for instance:
function check_availability()
{
UserController$checkUsernameAvailable('john', check_availability_cb);
return false;
}
function check_availability_cb(avail)
{
alert(avail ? 'Available' : 'Not available');
}
CONTEXTS
By default, models, views, controllers and helpers are expected to exist in contexts located under app/
However, you can create objects of any of these types in the main context. Simply name them in config.php
CLASSPATH
The Classpath is a list of root directories under which your classes can be defined.
By design, controllers and views are not in the classpath. This is to prevent their direct invocation.
Models and controllers, however, depend on the classpath.
There are two main paths in the classpath: models/ and helpers/
Every time you invoke a context, its models/ and helpers/ directories are added to the classpath.
NAMESPACES
Namespaces exist both at the application root (main context) and in the contexts.
Models are automatically available in the classpath, therefore they do not need to be imported in the controllers.
Helpers, however, have to be "namespaced" and as such they need to be imported.
An example:
You are the owner of a Las Vegas casino called 'The Lucky House'.
You create a context called 'casino' and decide to add a model called 'Roulette' and a helper 'Croupier'
Your directory structure will look like this:
app/casino/models/roulette.php
app/casino/helpers/com/theluckyhouse/casino/croupier.php
The namespace shown here is arbitrary. You could decide, for instance, to simplify it to:
app/casino/helpers/casino/croupier.php
In your controller, found in controller_casino.php, you can use Roulette directly because models are in the classpath by default:
$roulette = new Roulette();
To use a 'Croupier' helper, however, you need to import it first:
import('com.theluckyhouse.casino.croupier');
$croupier = new Croupier();
Tip: let's say that the Croupier helper offers a method for rendering a roulette table. You may want to make the $croupier instance available to your view. It is as easy as actually making it an instance variable. Your code will then look like:
$this->croupier = new Croupier();
ARGUMENTS
When in a controller, you can retrieve all the current URL information through:
$this->_args
In a view, you have access to:
$controller
$action
$args
Note: whenever possible, you should limit access to $args to the header and footer elements.
ADMIN CP & PREFERENCES
The framework comes with its own admin control panel that you can customize to support any kind of settings.
Using the 'please' utility it is possible to create new settings that the control panel will automatically know how to handle.
USERS ACCOUNTS & SESSION MANAGEMENT
You can register new accounts. Registration can be open or require an invitation. Of course, a mechanism for requesting invitations is also provided.
Members can log in and their session is automatically maintained in the database.
ACTIVE RECORDS
All model classes inherit from an active model. Currently two default active models are available:
- ActiveRecord for easy access to many database engines (MySQL, Sybase, ODBC...)
- ActiveWSRecord provides the same level of encapsulation for web services.
Both implement the ApplicationModel interface. Any model you use should eventually implement this interface,
ActiveRecord:
Relationships: belongsTo and hasMany
ActiveWSRecord:
This class offers convenience methods for accessing Restful web services.
Requests can be performed using GET or POST.
Results can be parsed using JSON or XML.
THE LIBRARY
The library is kept as small as possible. The idea is not to re-invent the wheel. You can find dozens of PHP scripts that will fit perfectly your needs and that is why, rather than forcing you to memorize a whole library, the framework will try to 'stay out of your way.'
DEBUGGING
Select one of several debugging mechanisms: local, to the file system, to the screen, or to Firebug if you are using Firefox.
System Components (lib/)
AdoDB: databases abstraction
jQuery, AJAX, inflectors, validators, session management...
Helpers (helpers/com/voilaweb/core/)
Login management, files management, dates handling, pagination, undo...
PLEASE
'please' is an interactive console shell that speeds up the manipulation of entities.
Here are a list of commands it understands:
create
model Create a new model class
controller Create a new controller class
view Create a new view directory and a default index page
all Create a model, a controller and a view
helper Create a helper
setting Create a new setting
delete
setting Delete a setting
set
setting Set a setting's value
show
setting Show a setting's value
settings Show all settings
Tip: You can hit [Return] or [Enter] before entering all the parameters to get more information on a command's syntax.
Use '.' to exit the console.
You are not logged in or *gasp* you have not registered yet.
Log in or Register now
