PluginProbe
Redirection / 4.2
Redirection v4.2
5.10.0 5.9.0 5.8.1 5.8.0 3.7.2 3.7.3 4.0 4.0.1 4.1 4.1.1 4.2 4.2.1 4.2.2 4.2.3 4.3 4.3.1 4.3.2 4.3.3 4.4 4.4.1 4.4.2 4.5 4.5.1 4.6.2 4.7.1 All 130 releases
redirection / models / action.php

action.php in Redirection 4.2, at models/action.php

59 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 abstract class Red_Action {
4 protected $code;
5 protected $type;
6
7 function __construct( $values ) {
8 if ( is_array( $values ) ) {
9 foreach ( $values as $key => $value ) {
10 $this->$key = $value;
11 }
12 }
13 }
14
15 static function create( $name, $code ) {
16 $avail = self::available();
17
18 if ( isset( $avail[ $name ] ) ) {
19 if ( ! class_exists( strtolower( $avail[ $name ][1] ) ) ) {
20 include_once dirname( __FILE__ ) . '/../actions/' . $avail[ $name ][0];
21 }
22
23 $obj = new $avail[ $name ][1]( array( 'code' => $code ) );
24 $obj->type = $name;
25 return $obj;
26 }
27
28 return false;
29 }
30
31 static function available() {
32 return array(
33 'url' => array( 'url.php', 'Url_Action' ),
34 'error' => array( 'error.php', 'Error_Action' ),
35 'nothing' => array( 'nothing.php', 'Nothing_Action' ),
36 'random' => array( 'random.php', 'Random_Action' ),
37 'pass' => array( 'pass.php', 'Pass_Action' ),
38 );
39 }
40
41 public function process_before( $code, $target ) {
42 return $target;
43 }
44
45 public function process_after( $code, $target ) {
46 return true;
47 }
48
49 public function get_code() {
50 return $this->code;
51 }
52
53 public function get_type() {
54 return $this->type;
55 }
56
57 abstract public function needs_target();
58 }
59