| 1 |
<?php |
| 2 |
|
| 3 |
class Red_Action |
| 4 |
{ |
| 5 |
function Red_Action ($values) |
| 6 |
{ |
| 7 |
if (is_array ($values)) |
| 8 |
{ |
| 9 |
foreach ($values AS $key => $value) |
| 10 |
$this->$key = $value; |
| 11 |
} |
| 12 |
} |
| 13 |
|
| 14 |
function can_change_code () { return false;} |
| 15 |
|
| 16 |
function config () { } |
| 17 |
|
| 18 |
static function create ($name, $code) |
| 19 |
{ |
| 20 |
$avail = self::available (); |
| 21 |
if (isset ($avail[$name])) |
| 22 |
{ |
| 23 |
if (!class_exists (strtolower ($avail[$name][1]))) |
| 24 |
include (dirname (__FILE__).'/../actions/'.$avail[$name][0]); |
| 25 |
|
| 26 |
$obj = new $avail[$name][1] (array ('action_code' => $code)); |
| 27 |
$obj->type = $name; |
| 28 |
return $obj; |
| 29 |
} |
| 30 |
|
| 31 |
return false; |
| 32 |
} |
| 33 |
|
| 34 |
static function available () |
| 35 |
{ |
| 36 |
return array |
| 37 |
( |
| 38 |
'url' => array ('url.php', 'Url_Action'), |
| 39 |
'error' => array ('error.php', 'Error_Action'), |
| 40 |
'nothing' => array ('nothing.php', 'Nothing_Action'), |
| 41 |
'random' => array ('random.php', 'Random_Action'), |
| 42 |
'pass' => array ('pass.php', 'Pass_Action'), |
| 43 |
); |
| 44 |
} |
| 45 |
|
| 46 |
function type () |
| 47 |
{ |
| 48 |
return $this->type; |
| 49 |
} |
| 50 |
|
| 51 |
function process_before ($code, $target) { return true; } |
| 52 |
function process_after ($code, $target) { return true; } |
| 53 |
function can_perform_action () { return true; } |
| 54 |
function action_codes () { return array ();} |
| 55 |
|
| 56 |
function display_actions () |
| 57 |
{ |
| 58 |
foreach ($this->action_codes () AS $key => $code) |
| 59 |
echo '<option value="'.$key.'"'.(($key == $this->action_code) ? ' selected="selected"' : '').'>'.sprintf ('%s - %s', $key, $code).'</option>'; |
| 60 |
} |
| 61 |
|
| 62 |
} |
| 63 |
?> |