Smutty


Smutty.Smutty_Controller

Class Smutty_Controller

Smutty_Object
|
+--Smutty_Controller

public class Smutty_Controller
extends Smutty_Object

this is the base class for all smutty controllers. it defines a lot of required functionality and helper methods for classes that inherit from it.

/


Method Summary
nothing

action(String name)

executes an action on the current controller

protected nothing

actionBefore(Smutty_Data data, Smutty_Session session)

this function is called before an action.

nothing

addError(String message)

adds an error to this controller

static nothing

addErrors(array errors)

adds errors to the current controller

String

get(String name)

returns the value of a template var

nothing

push(String name, String value)

this function pushes a value onto the named array, if the array doesn't exist then it's created.

protected nothing

redirect(array params, array args)

redirects the user to the given url.

protected nothing

redirectJs(array params)

this function takes the same arguments as the normal redirect function, but prints out javascript code to do the redirect itself.

protected nothing

redirectUrl(String url)

redirects the user to the application url specified.

nothing

set(String name, mixed value)

sets a variable for use by the template

nothing

smuttyView(String viewFile)

show the view file using the smutty template class

protected nothing

view(String viewFile)

show the specified file with the standard user template class.

Method Detail

action

public nothing action(String name)

executes an action on the current controller

Parameters:
name - name of action
Go to code

actionBefore

protected nothing actionBefore(Smutty_Data data, Smutty_Session session)

this function is called before an action. it has no implementation here but can be over-rided by sub-classes if they want to use it.

Parameters:
data - the data object
session - the session object
Go to code

addError

public nothing addError(String message)

adds an error to this controller

Parameters:
message - error message
Go to code

addErrors

public static nothing addErrors(array errors)

adds errors to the current controller

Parameters:
errors - array of errors
Go to code

get

public String get(String name)

returns the value of a template var

Parameters:
name - var name
Returns:
value
Go to code

push

public nothing push(String name, String value)

this function pushes a value onto the named array, if the array doesn't exist then it's created.

Parameters:
name - name of array
value - value to add
Go to code

redirect

protected nothing redirect(array params, array args)

redirects the user to the given url. the parameter array should be a hash of name value pairs. the names being anything set up for the route.

Parameters:
params - array of parameters
args - query string args
Go to code

redirectJs

protected nothing redirectJs(array params)

this function takes the same arguments as the normal redirect function, but prints out javascript code to do the redirect itself. this can be useful when doing ajax callbacks with forms.

it would be nice if i could think of a way to merge these two methods and have it "know" which one to do, but that seems a bit impossible i think?

Parameters:
params - params for the redirect
Go to code

redirectUrl

protected nothing redirectUrl(String url)

redirects the user to the application url specified. the url must be absolute from the base of the app.

Parameters:
url - the url to redirect to
Go to code

set

public nothing set(String name, mixed value)

sets a variable for use by the template

Parameters:
name - name of the variable to set
value - the value to set
Go to code

smuttyView

public nothing smuttyView(String viewFile)

show the view file using the smutty template class

Parameters:
viewFile - the file to view
Go to code

view

protected nothing view(String viewFile)

show the specified file with the standard user template class. if the view file is not specifed then it is assumed to be located as "views/controller/action.tpl"

Parameters:
viewFile - the file to view
Go to code

Smutty