Base Action Class
ProjectWikkasource: wikka/libs/action.class.php
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 source code for the full API.
Implementation
require_once 'libs/action.class.php';
class SampleAction extends WikkaAction {
var $version = '1.0';
# parameter defaults
var $some_parameter = 'hello world'; # hours
# 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());
}
class SampleAction extends WikkaAction {
var $version = '1.0';
# parameter defaults
var $some_parameter = 'hello world'; # hours
# 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());
}
[There are no comments on this page]