klenwell information services : WikkaBaseActionClass

Wiki source for WikkaBaseActionClass


Show raw source

=====Base Action Class=====
ProjectWikka
source: [[https://gist.github.com/klenwell/5564387#file-action-class-php | https://gist.github.com/klenwell/5564387]]

The Klenwell Wikka Action Class (WAC) provides some common useful methods for actions using the action class pattern. It serves as a base class for specific action classes.

It offers mail, database, and data persistence methods. See the [[https://gist.github.com/klenwell/5564387#file-action-class-php | source code]] for the full API.

====Implementation====
%%(php)
require_once 'libs/action.class.php';

class SampleAction extends WikkaAction {

var $version = '1.0';

# parameter defaults
var $some_parameter = 'hello world';

# internal
# add internal variables

function action_set_up() {
if ( $this->has_param('some_parameter') ) {
$this->some_parameter = $this->get_param('some_parameter');
}
}

function main() {
$this->action_set_up();
return $this->some_parameter;
}

function output($content) {
print $content;
}
}

# Main Routine
try {
$Action = new SampleAction($this, $vars);
$content = $Action->main();
$Action->output($content);
}
catch(Exception $e) {
printf('<em class="error">%s</em>', $e->getMessage());
}
%%

====Examples====
Classes using the Klenwell wikka action class:
~- [[WikkaActivitySummaryAction | Activity Summary]]

====Additional Info====
[[WikkaActionDatastoreTest | Data Persistence]]