@@ -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() |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | class Component_select |
| 9 | 9 | extends AbstractComponent |
| 10 | 10 | implements ValueComponentInterface, |
| 11 | - DisableableComponentInterface |
|
| 11 | + DisableableComponentInterface |
|
| 12 | 12 | { |
| 13 | 13 | public $component_type = 'select'; |
| 14 | 14 | |
@@ -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); |
@@ -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'; |
@@ -8,7 +8,7 @@ |
||
| 8 | 8 | class Component_checkbox |
| 9 | 9 | extends AbstractComponent |
| 10 | 10 | implements ValueComponentInterface, |
| 11 | - DisableableComponentInterface |
|
| 11 | + DisableableComponentInterface |
|
| 12 | 12 | { |
| 13 | 13 | public $name_template = '{{name}}[]'; |
| 14 | 14 | |
@@ -8,9 +8,9 @@ |
||
| 8 | 8 | class Component_composite |
| 9 | 9 | extends AbstractComponent |
| 10 | 10 | implements ValueComponentInterface, |
| 11 | - DisableableComponentInterface, |
|
| 12 | - FilterableComponentInterface, |
|
| 13 | - ValidatableComponentInterface |
|
| 11 | + DisableableComponentInterface, |
|
| 12 | + FilterableComponentInterface, |
|
| 13 | + ValidatableComponentInterface |
|
| 14 | 14 | { |
| 15 | 15 | /** |
| 16 | 16 | * The list of child components. |
@@ -25,16 +25,16 @@ discard block |
||
| 25 | 25 | * The __set magic method is overridden here to apply value & name changes to |
| 26 | 26 | * child components. |
| 27 | 27 | */ |
| 28 | - public function __set( $name, $value ) |
|
| 28 | + public function __set($name, $value) |
|
| 29 | 29 | { |
| 30 | 30 | parent::__set($name, $value); |
| 31 | 31 | |
| 32 | - if( 'value' === $name ) |
|
| 32 | + if ('value' === $name) |
|
| 33 | 33 | { |
| 34 | 34 | $this->set_value($value); |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - if( 'name' === $name ) |
|
| 37 | + if ('name' === $name) |
|
| 38 | 38 | { |
| 39 | 39 | $this->set_name($value); |
| 40 | 40 | } |
@@ -46,9 +46,9 @@ discard block |
||
| 46 | 46 | * @param array $value |
| 47 | 47 | * @return void |
| 48 | 48 | */ |
| 49 | - public function set_value( array $value ) |
|
| 49 | + public function set_value(array $value) |
|
| 50 | 50 | { |
| 51 | - foreach($value as $n => $v) |
|
| 51 | + foreach ($value as $n => $v) |
|
| 52 | 52 | { |
| 53 | 53 | $component = $this->get_component($n); |
| 54 | 54 | $component->value = $v; |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | * @param string $name |
| 62 | 62 | * @return void |
| 63 | 63 | */ |
| 64 | - public function set_name( $name ) |
|
| 64 | + public function set_name($name) |
|
| 65 | 65 | { |
| 66 | - foreach($this->components as $c) |
|
| 66 | + foreach ($this->components as $c) |
|
| 67 | 67 | { |
| 68 | 68 | $c->name_template = str_replace('{{parent_name}}', $this->get_name(), $c->composite_name_template); |
| 69 | 69 | } |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | public function required_arguments() |
| 94 | 94 | { |
| 95 | - return array('name','components','template'); |
|
| 95 | + return array('name', 'components', 'template'); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function get_name() |
| 128 | 128 | { |
| 129 | - if('' !== $this->parent_name) |
|
| 129 | + if ('' !== $this->parent_name) |
|
| 130 | 130 | { |
| 131 | 131 | return "{$this->parent_name}[{$this->name}]"; |
| 132 | 132 | } |
@@ -135,9 +135,9 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | public function filter($v) |
| 137 | 137 | { |
| 138 | - foreach($this->components as $component) |
|
| 138 | + foreach ($this->components as $component) |
|
| 139 | 139 | { |
| 140 | - if($component instanceof FilterableComponentInterface && |
|
| 140 | + if ($component instanceof FilterableComponentInterface && |
|
| 141 | 141 | \is_callable($component->filter)) |
| 142 | 142 | { |
| 143 | 143 | $n = $component->name; |
@@ -148,15 +148,15 @@ discard block |
||
| 148 | 148 | return $v; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - public function validation($v,&$e) |
|
| 151 | + public function validation($v, &$e) |
|
| 152 | 152 | { |
| 153 | - foreach($this->components as $component) |
|
| 153 | + foreach ($this->components as $component) |
|
| 154 | 154 | { |
| 155 | - if($component instanceof ValidatableComponentInterface && |
|
| 155 | + if ($component instanceof ValidatableComponentInterface && |
|
| 156 | 156 | \is_callable($component->validation)) |
| 157 | 157 | { |
| 158 | 158 | $n = $component->name; |
| 159 | - if(!$component->validation($v[$n],$e)) |
|
| 159 | + if (!$component->validation($v[$n], $e)) |
|
| 160 | 160 | { |
| 161 | 161 | return false; |
| 162 | 162 | } |
@@ -172,9 +172,9 @@ discard block |
||
| 172 | 172 | * @return UI\AbstractComponent |
| 173 | 173 | * @throws \RuntimeException If there's no child component corresponding to the given name |
| 174 | 174 | */ |
| 175 | - public function get_component( $name ) |
|
| 175 | + public function get_component($name) |
|
| 176 | 176 | { |
| 177 | - if(!array_key_exists($name, $this->components)) |
|
| 177 | + if (!array_key_exists($name, $this->components)) |
|
| 178 | 178 | { |
| 179 | 179 | throw new \RuntimeException("Composite sub-component not found with name $name"); |
| 180 | 180 | } |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | protected function on_created() |
| 188 | 188 | { |
| 189 | - foreach( $this->model['components'] as $args ) |
|
| 189 | + foreach ($this->model['components'] as $args) |
|
| 190 | 190 | { |
| 191 | 191 | $this->components[$args['name']] = $this->create_component($args); |
| 192 | 192 | } |
@@ -197,16 +197,16 @@ discard block |
||
| 197 | 197 | * @param type $args |
| 198 | 198 | * @return type |
| 199 | 199 | */ |
| 200 | - private function create_component( $args ) |
|
| 200 | + private function create_component($args) |
|
| 201 | 201 | { |
| 202 | 202 | $type = $args['type']; |
| 203 | 203 | |
| 204 | - if('composite' === $type) |
|
| 204 | + if ('composite' === $type) |
|
| 205 | 205 | { |
| 206 | 206 | $args['parent_name'] = $this->get_name(); |
| 207 | 207 | } |
| 208 | 208 | |
| 209 | - $c = \Amarkal\UI\ComponentFactory::create( $type, $args ); |
|
| 209 | + $c = \Amarkal\UI\ComponentFactory::create($type, $args); |
|
| 210 | 210 | |
| 211 | 211 | // Apply the composite name template |
| 212 | 212 | $c->name_template = str_replace('{{parent_name}}', $this->get_name(), $c->composite_name_template); |
@@ -8,9 +8,9 @@ |
||
| 8 | 8 | class Component_textarea |
| 9 | 9 | extends AbstractComponent |
| 10 | 10 | implements ValueComponentInterface, |
| 11 | - DisableableComponentInterface, |
|
| 12 | - FilterableComponentInterface, |
|
| 13 | - ValidatableComponentInterface |
|
| 11 | + DisableableComponentInterface, |
|
| 12 | + FilterableComponentInterface, |
|
| 13 | + ValidatableComponentInterface |
|
| 14 | 14 | { |
| 15 | 15 | public $component_type = 'textarea'; |
| 16 | 16 | |
@@ -8,9 +8,9 @@ |
||
| 8 | 8 | class Component_number |
| 9 | 9 | extends AbstractComponent |
| 10 | 10 | implements ValueComponentInterface, |
| 11 | - DisableableComponentInterface, |
|
| 12 | - FilterableComponentInterface, |
|
| 13 | - ValidatableComponentInterface |
|
| 11 | + DisableableComponentInterface, |
|
| 12 | + FilterableComponentInterface, |
|
| 13 | + ValidatableComponentInterface |
|
| 14 | 14 | { |
| 15 | 15 | public $component_type = 'number'; |
| 16 | 16 | |
@@ -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; |
@@ -8,9 +8,9 @@ |
||
| 8 | 8 | class Component_text |
| 9 | 9 | extends AbstractComponent |
| 10 | 10 | implements ValueComponentInterface, |
| 11 | - DisableableComponentInterface, |
|
| 12 | - FilterableComponentInterface, |
|
| 13 | - ValidatableComponentInterface |
|
| 11 | + DisableableComponentInterface, |
|
| 12 | + FilterableComponentInterface, |
|
| 13 | + ValidatableComponentInterface |
|
| 14 | 14 | { |
| 15 | 15 | public $component_type = 'text'; |
| 16 | 16 | |