@@ -21,7 +21,7 @@ |
||
21 | 21 | |
22 | 22 | public function required_arguments() |
23 | 23 | { |
24 | - return array('name','data'); |
|
24 | + return array('name', 'data'); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function get_template_path() |
@@ -6,7 +6,7 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | // Prevent direct file access |
9 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
9 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
10 | 10 | |
11 | 11 | // Load module functions |
12 | 12 | require_once 'functions.php'; |
13 | 13 | \ No newline at end of file |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * @param array $props |
21 | 21 | * @return AbstractComponent |
22 | 22 | */ |
23 | - public static function create( $type, array $props ) |
|
23 | + public static function create($type, array $props) |
|
24 | 24 | { |
25 | 25 | try { |
26 | 26 | $component = self::create_registered_component($type, $props); |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | * @param string $class_name |
42 | 42 | * @throws \RuntimeException |
43 | 43 | */ |
44 | - public static function register( $type, $class_name ) |
|
44 | + public static function register($type, $class_name) |
|
45 | 45 | { |
46 | - if( !in_array($type, self::$registered_components) ) |
|
46 | + if (!in_array($type, self::$registered_components)) |
|
47 | 47 | { |
48 | 48 | self::$registered_components[$type] = $class_name; |
49 | 49 | } |
@@ -56,15 +56,15 @@ discard block |
||
56 | 56 | * @param type $props |
57 | 57 | * @throws \RuntimeException |
58 | 58 | */ |
59 | - private static function create_core_component( $type, $props ) |
|
59 | + private static function create_core_component($type, $props) |
|
60 | 60 | { |
61 | 61 | $file_name = __DIR__."/components/$type/controller.php"; |
62 | 62 | $class_name = 'Amarkal\\UI\\Component_'.$type; |
63 | 63 | |
64 | 64 | // Load one of the core components |
65 | - if(!class_exists($class_name)) |
|
65 | + if (!class_exists($class_name)) |
|
66 | 66 | { |
67 | - if( file_exists( $file_name ) ) |
|
67 | + if (file_exists($file_name)) |
|
68 | 68 | { |
69 | 69 | require_once $file_name; |
70 | 70 | } |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * @param type $props |
84 | 84 | * @throws \RuntimeException |
85 | 85 | */ |
86 | - private static function create_registered_component( $type, $props ) |
|
86 | + private static function create_registered_component($type, $props) |
|
87 | 87 | { |
88 | - if(in_array($type, self::$registered_components)) |
|
88 | + if (in_array($type, self::$registered_components)) |
|
89 | 89 | { |
90 | 90 | $class_name = self::$registered_components[$type]; |
91 | 91 | return new $class_name($props); |
@@ -25,9 +25,9 @@ discard block |
||
25 | 25 | * @param array $model |
26 | 26 | * @param string $template_path |
27 | 27 | */ |
28 | - public function __construct( array $model = array(), $template_path = null ) |
|
28 | + public function __construct(array $model = array(), $template_path = null) |
|
29 | 29 | { |
30 | - $this->set_model( $model ); |
|
30 | + $this->set_model($model); |
|
31 | 31 | $this->template = $template_path; |
32 | 32 | } |
33 | 33 | |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @return mixed the argument's value. |
40 | 40 | */ |
41 | - public function __get( $name ) |
|
41 | + public function __get($name) |
|
42 | 42 | { |
43 | - if( isset( $this->model[$name] ) ) |
|
43 | + if (isset($this->model[$name])) |
|
44 | 44 | { |
45 | 45 | return $this->model[$name]; |
46 | 46 | } |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @return mixed the settings' argument value. |
56 | 56 | */ |
57 | - public function __set( $name, $value ) |
|
57 | + public function __set($name, $value) |
|
58 | 58 | { |
59 | 59 | $this->model[$name] = $value; |
60 | 60 | } |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | * |
75 | 75 | * @return array |
76 | 76 | */ |
77 | - public function set_model( $model ) |
|
77 | + public function set_model($model) |
|
78 | 78 | { |
79 | 79 | $this->model = $model; |
80 | 80 | } |
@@ -95,22 +95,22 @@ discard block |
||
95 | 95 | * @return string The rendered template. |
96 | 96 | * @throws TemplateNotFoundException Thrown if the template file cannot be found. |
97 | 97 | */ |
98 | - public function render( $echo = false ) |
|
98 | + public function render($echo = false) |
|
99 | 99 | { |
100 | 100 | $rendered_html = ''; |
101 | 101 | |
102 | - if( file_exists( $this->get_template_path() ) ) |
|
102 | + if (file_exists($this->get_template_path())) |
|
103 | 103 | { |
104 | 104 | ob_start(); |
105 | - include( $this->get_template_path() ); |
|
105 | + include($this->get_template_path()); |
|
106 | 106 | $rendered_html = ob_get_clean(); |
107 | 107 | } |
108 | 108 | else |
109 | 109 | { |
110 | - throw new \RuntimeException( "Error: cannot render HTML, template file not found at " . $this->get_template_path() ); |
|
110 | + throw new \RuntimeException("Error: cannot render HTML, template file not found at ".$this->get_template_path()); |
|
111 | 111 | } |
112 | 112 | |
113 | - if( !$echo ) |
|
113 | + if (!$echo) |
|
114 | 114 | { |
115 | 115 | return $rendered_html; |
116 | 116 | } |
@@ -6,13 +6,13 @@ |
||
6 | 6 | */ |
7 | 7 | |
8 | 8 | // Prevent direct file access |
9 | -defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
|
9 | +defined('ABSPATH') or die('No script kiddies please!'); |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Load module functions. If this amarkal module has not been loaded, |
13 | 13 | * functions.php will not return false. |
14 | 14 | */ |
15 | -if(false !== (require_once 'functions.php')) |
|
15 | +if (false !== (require_once 'functions.php')) |
|
16 | 16 | { |
17 | 17 | // Load required classes if not using composer |
18 | 18 | require_once 'AbstractComponent.php'; |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | 'required' => false, |
28 | 28 | 'readonly' => false, |
29 | 29 | 'default' => null, |
30 | - 'filter' => array( $this, 'filter' ), |
|
31 | - 'validation' => array( $this, 'validation' ) |
|
30 | + 'filter' => array($this, 'filter'), |
|
31 | + 'validation' => array($this, 'validation') |
|
32 | 32 | ); |
33 | 33 | } |
34 | 34 | |
@@ -37,19 +37,19 @@ discard block |
||
37 | 37 | return floatval($v); |
38 | 38 | } |
39 | 39 | |
40 | - public function validation($v,&$e) |
|
40 | + public function validation($v, &$e) |
|
41 | 41 | { |
42 | 42 | $max = $this->max; |
43 | 43 | $min = $this->min; |
44 | 44 | |
45 | - if(null !== $max && $v > $max) |
|
45 | + if (null !== $max && $v > $max) |
|
46 | 46 | { |
47 | - $e = sprintf( __("Value must be less than %d",'amarkal'), $max); |
|
47 | + $e = sprintf(__("Value must be less than %d", 'amarkal'), $max); |
|
48 | 48 | } |
49 | 49 | |
50 | - if(null !== $min && $v < $min) |
|
50 | + if (null !== $min && $v < $min) |
|
51 | 51 | { |
52 | - $e = sprintf( __("Value must be greater than %d",'amarkal'), $min); |
|
52 | + $e = sprintf(__("Value must be greater than %d", 'amarkal'), $min); |
|
53 | 53 | } |
54 | 54 | |
55 | 55 | return $e ? false : true; |
@@ -25,13 +25,13 @@ |
||
25 | 25 | 'min' => null, |
26 | 26 | 'max' => null, |
27 | 27 | 'step' => 1, |
28 | - 'filter' => array( $this, 'filter' ) |
|
28 | + 'filter' => array($this, 'filter') |
|
29 | 29 | ); |
30 | 30 | } |
31 | 31 | |
32 | 32 | public function required_arguments() |
33 | 33 | { |
34 | - return array('name','min','max'); |
|
34 | + return array('name', 'min', 'max'); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | public function get_template_path() |
@@ -29,7 +29,7 @@ |
||
29 | 29 | |
30 | 30 | public function required_arguments() |
31 | 31 | { |
32 | - return array('request_url','label_start'); |
|
32 | + return array('request_url', 'label_start'); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function get_template_path() |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | * |
39 | 39 | * @param array $model |
40 | 40 | */ |
41 | - public function __construct( array $model = array() ) |
|
41 | + public function __construct(array $model = array()) |
|
42 | 42 | { |
43 | 43 | parent::__construct($model); |
44 | 44 | |
@@ -79,24 +79,24 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return array |
81 | 81 | */ |
82 | - public function set_model( $model ) |
|
82 | + public function set_model($model) |
|
83 | 83 | { |
84 | 84 | // Check that the required arguments are provided. |
85 | - foreach( $this->required_arguments() as $key ) |
|
85 | + foreach ($this->required_arguments() as $key) |
|
86 | 86 | { |
87 | - if ( !isset($model[$key]) ) |
|
87 | + if (!isset($model[$key])) |
|
88 | 88 | { |
89 | 89 | throw new \RuntimeException('The required argument "'.$key.'" was not provided for '.get_called_class()); |
90 | 90 | } |
91 | 91 | } |
92 | 92 | |
93 | 93 | // Assign the name of the component as the id if no id was specified |
94 | - if( !isset($model['id']) && isset($model['name']) ) |
|
94 | + if (!isset($model['id']) && isset($model['name'])) |
|
95 | 95 | { |
96 | 96 | $model['id'] = $model['name']; |
97 | 97 | } |
98 | 98 | |
99 | - $this->model = array_merge( $this->default_model(), $model ); |
|
99 | + $this->model = array_merge($this->default_model(), $model); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -115,9 +115,9 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @param string $class |
117 | 117 | */ |
118 | - public function add_html_class( $class ) |
|
118 | + public function add_html_class($class) |
|
119 | 119 | { |
120 | - if( !in_array($class, $this->html_classes) ) |
|
120 | + if (!in_array($class, $this->html_classes)) |
|
121 | 121 | { |
122 | 122 | $this->html_classes[] = $class; |
123 | 123 | } |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | * |
130 | 130 | * @param string $class |
131 | 131 | */ |
132 | - public function remove_html_class( $class ) |
|
132 | + public function remove_html_class($class) |
|
133 | 133 | { |
134 | 134 | $i = 0; |
135 | - foreach( $this->html_classes as $c ) |
|
135 | + foreach ($this->html_classes as $c) |
|
136 | 136 | { |
137 | - if( $c === $class ) |
|
137 | + if ($c === $class) |
|
138 | 138 | { |
139 | - array_splice($this->html_classes,$i,1); |
|
139 | + array_splice($this->html_classes, $i, 1); |
|
140 | 140 | break; |
141 | 141 | } |
142 | 142 | $i++; |
@@ -148,10 +148,10 @@ discard block |
||
148 | 148 | * |
149 | 149 | * @param type $validity |
150 | 150 | */ |
151 | - Public function set_validity( $validity ) |
|
151 | + Public function set_validity($validity) |
|
152 | 152 | { |
153 | 153 | $this->validity = $validity; |
154 | - if($validity === $this::INVALID) |
|
154 | + if ($validity === $this::INVALID) |
|
155 | 155 | { |
156 | 156 | $this->add_html_class('amarkal-ui-component-error'); |
157 | 157 | } |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * |
175 | 175 | * {@inheritdoc} |
176 | 176 | */ |
177 | - public function render( $echo = false ) |
|
177 | + public function render($echo = false) |
|
178 | 178 | { |
179 | 179 | $this->enqueue_scripts(); |
180 | 180 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | include dirname(__FILE__).'/AbstractComponent.phtml'; |
183 | 183 | $html = ob_get_clean(); |
184 | 184 | |
185 | - if( !$echo ) |
|
185 | + if (!$echo) |
|
186 | 186 | { |
187 | 187 | return $html; |
188 | 188 | } |