PluginProbe
Redirection / 2.7.1
Redirection v2.7.1
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 2.7.1, at models/action.php

71 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 function can_change_code() {
13 return false;
14 }
15
16 function config() {
17 }
18
19 static function create( $name, $code ) {
20 $avail = self::available();
21
22 if ( isset( $avail[ $name ] ) ) {
23 if ( ! class_exists( strtolower( $avail[ $name ][1] ) ) ) {
24 include dirname( __FILE__ ).'/../actions/'.$avail[ $name ][0];
25 }
26
27 $obj = new $avail[ $name ][1]( array( 'action_code' => $code ) );
28 $obj->type = $name;
29 return $obj;
30 }
31
32 return false;
33 }
34
35 static function available() {
36 return array(
37 'url' => array( 'url.php', 'Url_Action' ),
38 'error' => array( 'error.php', 'Error_Action' ),
39 'nothing' => array( 'nothing.php', 'Nothing_Action' ),
40 'random' => array( 'random.php', 'Random_Action' ),
41 'pass' => array( 'pass.php', 'Pass_Action' ),
42 );
43 }
44
45 function type() {
46 return $this->type;
47 }
48
49 function process_before( $code, $target ) {
50 return true;
51 }
52
53 function process_after( $code, $target ) {
54 return true;
55 }
56
57 function can_perform_action () {
58 return true;
59 }
60
61 function action_codes () {
62 return array();
63 }
64
65 function display_actions() {
66 foreach ( $this->action_codes() as $key => $code ) {
67 echo '<option value="'.$key.'"'.( ( $key === intval( $this->action_code ) ) ? ' selected="selected"' : '' ).'>'.sprintf( '%s - %s', $key, $code ).'</option>';
68 }
69 }
70 }
71