| 1 |
<?php |
| 2 |
|
| 3 |
class Red_Action { |
| 4 |
function __construct( $values ) { |
| 5 |
if ( is_array( $values ) ) { |
| 6 |
foreach ( $values as $key => $value ) { |
| 7 |
$this->$key = $value; |
| 8 |
} |
| 9 |
} |
| 10 |
} |
| 11 |
|
| 12 |
static function create( $name, $code ) { |
| 13 |
$avail = self::available(); |
| 14 |
|
| 15 |
if ( isset( $avail[ $name ] ) ) { |
| 16 |
if ( ! class_exists( strtolower( $avail[ $name ][1] ) ) ) { |
| 17 |
include_once dirname( __FILE__ ).'/../actions/'.$avail[ $name ][0]; |
| 18 |
} |
| 19 |
|
| 20 |
$obj = new $avail[ $name ][1]( array( 'action_code' => $code ) ); |
| 21 |
$obj->type = $name; |
| 22 |
return $obj; |
| 23 |
} |
| 24 |
|
| 25 |
return false; |
| 26 |
} |
| 27 |
|
| 28 |
static function available() { |
| 29 |
return array( |
| 30 |
'url' => array( 'url.php', 'Url_Action' ), |
| 31 |
'error' => array( 'error.php', 'Error_Action' ), |
| 32 |
'nothing' => array( 'nothing.php', 'Nothing_Action' ), |
| 33 |
'random' => array( 'random.php', 'Random_Action' ), |
| 34 |
'pass' => array( 'pass.php', 'Pass_Action' ), |
| 35 |
); |
| 36 |
} |
| 37 |
|
| 38 |
public function process_before( $code, $target ) { |
| 39 |
return $target; |
| 40 |
} |
| 41 |
|
| 42 |
public function process_after( $code, $target ) { |
| 43 |
return true; |
| 44 |
} |
| 45 |
} |
| 46 |
|