@@ -3,12 +3,12 @@ |
||
3 | 3 | use Ajax\common\BaseEnum; |
4 | 4 | abstract class Transition extends BaseEnum { |
5 | 5 | const SCALE="scale", |
6 | - FADE="fade",FADE_UP="fadeUp",FADE_DOWN="fadeDown",FADE_LEFT="fadeLeft",FADE_RIGHT="fadeRight", |
|
7 | - HORIZONTAL_FLIP="horizontalFlip",VERTICAL_FLIP="verticalFlip", |
|
6 | + FADE="fade", FADE_UP="fadeUp", FADE_DOWN="fadeDown", FADE_LEFT="fadeLeft", FADE_RIGHT="fadeRight", |
|
7 | + HORIZONTAL_FLIP="horizontalFlip", VERTICAL_FLIP="verticalFlip", |
|
8 | 8 | DROP="drop", |
9 | - FLY_LEFT="flyLeft",FLY_RIGHT="flyRight",FLY_UP="flyUp",FLY_DOWN="flyDown", |
|
10 | - SWING_LEFT="swingLeft",SWING_RIGHT="swingRight",SWING_UP="swingUp",SWING_DOWN="swingDown", |
|
11 | - BROWSE="browse",BROWSE_RIGHT="browseRight", |
|
12 | - SLIDE_LEFT="slideLeft",SLIDE_RIGHT="slideRight",SLIDE_UP="slideUp",SLIDE_DOWN="slideDown", |
|
13 | - JIGGLE="jiggle",FLASH="flash",SHAKE="shake",PULSE="pulse",TADA="tada",BOUNCE="bounce"; |
|
9 | + FLY_LEFT="flyLeft", FLY_RIGHT="flyRight", FLY_UP="flyUp", FLY_DOWN="flyDown", |
|
10 | + SWING_LEFT="swingLeft", SWING_RIGHT="swingRight", SWING_UP="swingUp", SWING_DOWN="swingDown", |
|
11 | + BROWSE="browse", BROWSE_RIGHT="browseRight", |
|
12 | + SLIDE_LEFT="slideLeft", SLIDE_RIGHT="slideRight", SLIDE_UP="slideUp", SLIDE_DOWN="slideDown", |
|
13 | + JIGGLE="jiggle", FLASH="flash", SHAKE="shake", PULSE="pulse", TADA="tada", BOUNCE="bounce"; |
|
14 | 14 | } |
15 | 15 | \ No newline at end of file |
@@ -1,39 +1,39 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace Ajax\php\ci; |
3 | 3 | |
4 | -class JsUtils extends \Ajax\JsUtils{ |
|
4 | +class JsUtils extends \Ajax\JsUtils { |
|
5 | 5 | protected $ci; |
6 | - protected $_my_controller_paths= array(); |
|
7 | - protected $_my_controllers= array(); |
|
6 | + protected $_my_controller_paths=array(); |
|
7 | + protected $_my_controllers=array(); |
|
8 | 8 | |
9 | - public function __construct($params=array(),$injected=NULL){ |
|
10 | - parent::__construct($params,$injected); |
|
11 | - $this->_my_controller_paths = array(APPPATH); |
|
9 | + public function __construct($params=array(), $injected=NULL) { |
|
10 | + parent::__construct($params, $injected); |
|
11 | + $this->_my_controller_paths=array(APPPATH); |
|
12 | 12 | } |
13 | - public function getUrl($url){ |
|
13 | + public function getUrl($url) { |
|
14 | 14 | return site_url($url); |
15 | 15 | } |
16 | 16 | |
17 | - public function getCi(){ |
|
18 | - if(isset($this->ci)===false){ |
|
19 | - $this->ci =& get_instance(); |
|
17 | + public function getCi() { |
|
18 | + if (isset($this->ci)===false) { |
|
19 | + $this->ci=& get_instance(); |
|
20 | 20 | $this->ci->load->helper('url'); |
21 | 21 | } |
22 | 22 | return $this->ci; |
23 | 23 | } |
24 | 24 | |
25 | - public function addViewElement($identifier,$content,&$view){ |
|
26 | - if(\array_key_exists("q", $view)===false){ |
|
25 | + public function addViewElement($identifier, $content, &$view) { |
|
26 | + if (\array_key_exists("q", $view)===false) { |
|
27 | 27 | $view["q"]=array(); |
28 | 28 | } |
29 | 29 | $view["q"][$identifier]=$content; |
30 | 30 | } |
31 | 31 | |
32 | - public function createScriptVariable(&$view,$view_var, $output){ |
|
32 | + public function createScriptVariable(&$view, $view_var, $output) { |
|
33 | 33 | $view[$view_var]=$output; |
34 | 34 | } |
35 | 35 | |
36 | - public function forward($initialControllerInstance,$controllerName,$actionName,$params=NULL){ |
|
36 | + public function forward($initialControllerInstance, $controllerName, $actionName, $params=NULL) { |
|
37 | 37 | $ci=$this->getCi(); |
38 | 38 | $controllerName=strtolower($controllerName); |
39 | 39 | $this->controller($controllerName); |
@@ -44,64 +44,64 @@ discard block |
||
44 | 44 | return $result; |
45 | 45 | } |
46 | 46 | |
47 | - public function renderContent($initialControllerInstance,$viewName, $params=NULL) { |
|
47 | + public function renderContent($initialControllerInstance, $viewName, $params=NULL) { |
|
48 | 48 | return $initialControllerInstance->load->view($viewName, $params, true); |
49 | 49 | } |
50 | 50 | |
51 | - public function fromDispatcher($dispatcher){ |
|
51 | + public function fromDispatcher($dispatcher) { |
|
52 | 52 | return array_values($dispatcher->uri->segment_array()); |
53 | 53 | } |
54 | 54 | |
55 | - public function controller($controller, $name = '', $db_conn = FALSE){ |
|
56 | - if (\is_array($controller)){ |
|
57 | - foreach ($controller as $babe){ |
|
55 | + public function controller($controller, $name='', $db_conn=FALSE) { |
|
56 | + if (\is_array($controller)) { |
|
57 | + foreach ($controller as $babe) { |
|
58 | 58 | $this->controller($babe); |
59 | 59 | } |
60 | 60 | return; |
61 | 61 | } |
62 | - if ($controller == ''){ |
|
62 | + if ($controller=='') { |
|
63 | 63 | return; |
64 | 64 | } |
65 | - $path = ''; |
|
65 | + $path=''; |
|
66 | 66 | // Is the controller in a sub-folder? If so, parse out the filename and path. |
67 | - if (($last_slash = strrpos($controller, '/')) !== FALSE){ |
|
67 | + if (($last_slash=strrpos($controller, '/'))!==FALSE) { |
|
68 | 68 | // The path is in front of the last slash |
69 | - $path = substr($controller, 0, $last_slash + 1); |
|
69 | + $path=substr($controller, 0, $last_slash+1); |
|
70 | 70 | // And the controller name behind it |
71 | - $controller = substr($controller, $last_slash + 1); |
|
71 | + $controller=substr($controller, $last_slash+1); |
|
72 | 72 | } |
73 | 73 | |
74 | - if ($name == ''){ |
|
75 | - $name = $controller; |
|
74 | + if ($name=='') { |
|
75 | + $name=$controller; |
|
76 | 76 | } |
77 | 77 | |
78 | - if (in_array($name, $this->_my_controllers, TRUE)){ |
|
78 | + if (in_array($name, $this->_my_controllers, TRUE)) { |
|
79 | 79 | return; |
80 | 80 | } |
81 | 81 | |
82 | - $CI =$this->getCi(); |
|
83 | - if (isset($CI->$name)){ |
|
82 | + $CI=$this->getCi(); |
|
83 | + if (isset($CI->$name)) { |
|
84 | 84 | show_error('The controller name you are loading is the name of a resource that is already being used: '.$name); |
85 | 85 | } |
86 | - $controller = strtolower($controller); |
|
87 | - foreach ($this->_my_controller_paths as $mod_path){ |
|
88 | - if ( ! file_exists($mod_path.'controllers/'.$path.$controller.'.php')){ |
|
86 | + $controller=strtolower($controller); |
|
87 | + foreach ($this->_my_controller_paths as $mod_path) { |
|
88 | + if (!file_exists($mod_path.'controllers/'.$path.$controller.'.php')) { |
|
89 | 89 | continue; |
90 | 90 | } |
91 | - if ($db_conn !== FALSE && ! class_exists('CI_DB')){ |
|
92 | - if ($db_conn === TRUE){ |
|
93 | - $db_conn = ''; |
|
91 | + if ($db_conn!==FALSE && !class_exists('CI_DB')) { |
|
92 | + if ($db_conn===TRUE) { |
|
93 | + $db_conn=''; |
|
94 | 94 | } |
95 | 95 | $CI->load->database($db_conn, FALSE, TRUE); |
96 | 96 | } |
97 | - if ( ! class_exists('CI_Controller')){ |
|
97 | + if (!class_exists('CI_Controller')) { |
|
98 | 98 | load_class('Controller', 'core'); |
99 | 99 | } |
100 | 100 | require_once($mod_path.'controllers/'.$path.$controller.'.php'); |
101 | - $controller = ucfirst($controller); |
|
102 | - $CI->$name = new $controller(); |
|
101 | + $controller=ucfirst($controller); |
|
102 | + $CI->$name=new $controller(); |
|
103 | 103 | |
104 | - $this->_my_controllers[] = $name; |
|
104 | + $this->_my_controllers[]=$name; |
|
105 | 105 | return; |
106 | 106 | } |
107 | 107 | show_error('Unable to locate the controller you have specified: '.$controller); |
@@ -12,10 +12,10 @@ |
||
12 | 12 | parent::__construct($identifier, $instance, $captions); |
13 | 13 | } |
14 | 14 | |
15 | - public function getValue($index){ |
|
15 | + public function getValue($index) { |
|
16 | 16 | $result=parent::getValue($index); |
17 | - if($result instanceof HtmlFormField){ |
|
18 | - $lbl=new HtmlSemDoubleElement("lbl-".$this->widgetIdentifier."-".$index,"label","",$this->getCaption($index)); |
|
17 | + if ($result instanceof HtmlFormField) { |
|
18 | + $lbl=new HtmlSemDoubleElement("lbl-".$this->widgetIdentifier."-".$index, "label", "", $this->getCaption($index)); |
|
19 | 19 | $lbl->setProperty("for", $result->getDataField()->getIdentifier()); |
20 | 20 | $this->captions[$index]=$lbl; |
21 | 21 | } |
@@ -18,49 +18,49 @@ discard block |
||
18 | 18 | class DataElement extends Widget { |
19 | 19 | |
20 | 20 | public function __construct($identifier, $modelInstance=NULL) { |
21 | - parent::__construct($identifier, null,$modelInstance); |
|
22 | - $this->_init(new DeInstanceViewer($identifier), "table", new HtmlTable($identifier, 0,2), false); |
|
21 | + parent::__construct($identifier, null, $modelInstance); |
|
22 | + $this->_init(new DeInstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 2), false); |
|
23 | 23 | $this->content["table"]->setDefinition(); |
24 | 24 | } |
25 | 25 | |
26 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
27 | - if(!$this->_generated){ |
|
26 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
27 | + if (!$this->_generated) { |
|
28 | 28 | $this->_instanceViewer->setInstance($this->_modelInstance); |
29 | 29 | |
30 | 30 | $table=$this->content["table"]; |
31 | 31 | $this->_generateContent($table); |
32 | 32 | |
33 | - if(isset($this->_toolbar)){ |
|
33 | + if (isset($this->_toolbar)) { |
|
34 | 34 | $this->_setToolbarPosition($table); |
35 | 35 | } |
36 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
36 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
37 | 37 | $this->_compileForm(); |
38 | 38 | $this->_generated=true; |
39 | 39 | } |
40 | - return parent::compile($js,$view); |
|
40 | + return parent::compile($js, $view); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | 44 | * @param HtmlTable $table |
45 | 45 | */ |
46 | - protected function _generateContent($table){ |
|
47 | - $values= $this->_instanceViewer->getValues(); |
|
46 | + protected function _generateContent($table) { |
|
47 | + $values=$this->_instanceViewer->getValues(); |
|
48 | 48 | $captions=$this->_instanceViewer->getCaptions(); |
49 | 49 | $count=$this->_instanceViewer->count(); |
50 | - for($i=0;$i<$count;$i++){ |
|
51 | - $table->addRow([$captions[$i],$values[$i]]); |
|
50 | + for ($i=0; $i<$count; $i++) { |
|
51 | + $table->addRow([$captions[$i], $values[$i]]); |
|
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | - protected function _getFieldName($index){ |
|
55 | + protected function _getFieldName($index) { |
|
56 | 56 | return $this->_instanceViewer->getFieldName($index); |
57 | 57 | } |
58 | 58 | |
59 | - protected function _getFieldCaption($index){ |
|
59 | + protected function _getFieldCaption($index) { |
|
60 | 60 | return null; |
61 | 61 | } |
62 | 62 | |
63 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
63 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
64 | 64 | return $this->identifier."-{$prefix}-".$name; |
65 | 65 | } |
66 | 66 | |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | return $this; |
93 | 93 | } |
94 | 94 | |
95 | - public function asForm(){ |
|
95 | + public function asForm() { |
|
96 | 96 | return $this->getForm(); |
97 | 97 | } |
98 | 98 | } |
99 | 99 | \ No newline at end of file |
@@ -15,6 +15,7 @@ |
||
15 | 15 | * {@inheritdoc} |
16 | 16 | * |
17 | 17 | * @see \Ajax\semantic\widgets\dataform\DataForm::__construct() |
18 | + * @param string $identifier |
|
18 | 19 | */ |
19 | 20 | public function __construct($identifier,$modelInstance=null,$fieldsOrder,$fieldsDefinition,$fields=[],$captions=[],$separators=[]) { |
20 | 21 | if(!isset($modelInstance)){ |
@@ -16,17 +16,17 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @see \Ajax\semantic\widgets\dataform\DataForm::__construct() |
18 | 18 | */ |
19 | - public function __construct($identifier,$modelInstance=null,$fieldsOrder,$fieldsDefinition,$fields=[],$captions=[],$separators=[]) { |
|
20 | - if(!isset($modelInstance)){ |
|
19 | + public function __construct($identifier, $modelInstance=null, $fieldsOrder, $fieldsDefinition, $fields=[], $captions=[], $separators=[]) { |
|
20 | + if (!isset($modelInstance)) { |
|
21 | 21 | $modelInstance=$this->getDefaultModelInstance(); |
22 | 22 | } |
23 | - parent::__construct($identifier,$modelInstance); |
|
24 | - $this->_initForm($fieldsOrder, $fieldsDefinition,$fields,$captions,$separators); |
|
23 | + parent::__construct($identifier, $modelInstance); |
|
24 | + $this->_initForm($fieldsOrder, $fieldsDefinition, $fields, $captions, $separators); |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | abstract protected function getDefaultModelInstance(); |
28 | 28 | |
29 | - protected function _initForm($fieldsOrder,$fieldsDefinition,$fields=[],$captions=[],$separators=[]){ |
|
29 | + protected function _initForm($fieldsOrder, $fieldsDefinition, $fields=[], $captions=[], $separators=[]) { |
|
30 | 30 | $this->_fieldsOrder=$fieldsOrder; |
31 | 31 | $this->setFields($fields); |
32 | 32 | $this->setSeparators($separators); |
@@ -34,26 +34,26 @@ discard block |
||
34 | 34 | $this->setCaptions($captions); |
35 | 35 | } |
36 | 36 | |
37 | - protected function _getIndex($fieldName){ |
|
37 | + protected function _getIndex($fieldName) { |
|
38 | 38 | $index=$fieldName; |
39 | - if(\is_string($fieldName)){ |
|
39 | + if (\is_string($fieldName)) { |
|
40 | 40 | $index=\array_search($fieldName, $this->_fieldsOrder); |
41 | 41 | } |
42 | 42 | return $index; |
43 | 43 | } |
44 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
44 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
45 | 45 | $index=$this->_getIndex($index); |
46 | - return parent::_fieldAs($elementCallback, $index,$attributes,$prefix); |
|
46 | + return parent::_fieldAs($elementCallback, $index, $attributes, $prefix); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | - public function removeField($fieldName){ |
|
50 | + public function removeField($fieldName) { |
|
51 | 51 | parent::removeField($fieldName); |
52 | - \array_splice($this->_fieldsOrder,$this->_getIndex($fieldName),1); |
|
52 | + \array_splice($this->_fieldsOrder, $this->_getIndex($fieldName), 1); |
|
53 | 53 | return $this; |
54 | 54 | } |
55 | 55 | |
56 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
57 | - return parent::compile($js,$view); |
|
56 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
57 | + return parent::compile($js, $view); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | \ No newline at end of file |
@@ -47,15 +47,17 @@ |
||
47 | 47 | |
48 | 48 | |
49 | 49 | public function addSeparatorAfter($fieldNum){ |
50 | - if(\array_search($fieldNum, $this->separators)===false) |
|
51 | - $this->separators[]=$fieldNum; |
|
50 | + if(\array_search($fieldNum, $this->separators)===false) { |
|
51 | + $this->separators[]=$fieldNum; |
|
52 | + } |
|
52 | 53 | return $this; |
53 | 54 | } |
54 | 55 | |
55 | 56 | public function addHeaderDividerBefore($fieldNum,$header){ |
56 | 57 | $this->headers[$fieldNum]=$header; |
57 | - if($fieldNum>0) |
|
58 | - $this->addSeparatorAfter($fieldNum-1); |
|
58 | + if($fieldNum>0) { |
|
59 | + $this->addSeparatorAfter($fieldNum-1); |
|
60 | + } |
|
59 | 61 | return $this; |
60 | 62 | } |
61 | 63 |
@@ -11,58 +11,58 @@ discard block |
||
11 | 11 | protected $headers; |
12 | 12 | protected $wrappers; |
13 | 13 | |
14 | - public function __construct($identifier,$instance=NULL, $captions=NULL) { |
|
15 | - parent::__construct($identifier,$instance=NULL, $captions=NULL); |
|
14 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
15 | + parent::__construct($identifier, $instance=NULL, $captions=NULL); |
|
16 | 16 | $this->separators=[-1]; |
17 | 17 | $this->headers=[]; |
18 | 18 | $this->wrappers=[]; |
19 | - $this->defaultValueFunction=function($name,$value,$index){ |
|
19 | + $this->defaultValueFunction=function($name, $value, $index) { |
|
20 | 20 | $caption=$this->getCaption($index); |
21 | - $input=new HtmlFormInput($this->widgetIdentifier."-".$name,$caption,"text",$value); |
|
21 | + $input=new HtmlFormInput($this->widgetIdentifier."-".$name, $caption, "text", $value); |
|
22 | 22 | $input->setName($name); |
23 | 23 | return $input; |
24 | 24 | }; |
25 | 25 | } |
26 | 26 | |
27 | - protected function _beforeAddProperty($index,&$field){ |
|
28 | - if(JString::endswith($field, "\n")===true){ |
|
27 | + protected function _beforeAddProperty($index, &$field) { |
|
28 | + if (JString::endswith($field, "\n")===true) { |
|
29 | 29 | $this->addSeparatorAfter($index); |
30 | 30 | } |
31 | - if($index>1 && JString::startswith($field, "\n")===true){ |
|
31 | + if ($index>1 && JString::startswith($field, "\n")===true) { |
|
32 | 32 | $this->addSeparatorAfter($index-1); |
33 | 33 | } |
34 | 34 | $field=\str_replace("\n", "", $field); |
35 | - if(($header=$this->hasHeader($field))!==false){ |
|
35 | + if (($header=$this->hasHeader($field))!==false) { |
|
36 | 36 | $this->addHeaderDividerBefore($index, $header); |
37 | 37 | } |
38 | 38 | } |
39 | 39 | |
40 | - protected function hasHeader(&$field){ |
|
41 | - $matches=[];$result=false; |
|
42 | - if(\preg_match('/\{(.*?)\}/s', $field, $matches)===1){ |
|
40 | + protected function hasHeader(&$field) { |
|
41 | + $matches=[]; $result=false; |
|
42 | + if (\preg_match('/\{(.*?)\}/s', $field, $matches)===1) { |
|
43 | 43 | $result=$matches[1]; |
44 | - $field=\str_replace("{".$result."}","", $field); |
|
44 | + $field=\str_replace("{".$result."}", "", $field); |
|
45 | 45 | } |
46 | 46 | return $result; |
47 | 47 | } |
48 | 48 | |
49 | 49 | |
50 | 50 | |
51 | - public function addSeparatorAfter($fieldNum){ |
|
52 | - if(\array_search($fieldNum, $this->separators)===false) |
|
51 | + public function addSeparatorAfter($fieldNum) { |
|
52 | + if (\array_search($fieldNum, $this->separators)===false) |
|
53 | 53 | $this->separators[]=$fieldNum; |
54 | 54 | return $this; |
55 | 55 | } |
56 | 56 | |
57 | - public function addHeaderDividerBefore($fieldNum,$header){ |
|
57 | + public function addHeaderDividerBefore($fieldNum, $header) { |
|
58 | 58 | $this->headers[$fieldNum]=$header; |
59 | - if($fieldNum>0) |
|
59 | + if ($fieldNum>0) |
|
60 | 60 | $this->addSeparatorAfter($fieldNum-1); |
61 | 61 | return $this; |
62 | 62 | } |
63 | 63 | |
64 | - public function addWrapper($fieldNum,$contentBefore,$contentAfter=null){ |
|
65 | - $this->wrappers[$fieldNum]=[$contentBefore,$contentAfter]; |
|
64 | + public function addWrapper($fieldNum, $contentBefore, $contentAfter=null) { |
|
65 | + $this->wrappers[$fieldNum]=[$contentBefore, $contentAfter]; |
|
66 | 66 | return $this; |
67 | 67 | } |
68 | 68 | |
@@ -70,15 +70,15 @@ discard block |
||
70 | 70 | return $this->separators; |
71 | 71 | } |
72 | 72 | |
73 | - public function removeSeparator($index){ |
|
74 | - \array_splice($this->separators,$index,1); |
|
73 | + public function removeSeparator($index) { |
|
74 | + \array_splice($this->separators, $index, 1); |
|
75 | 75 | } |
76 | 76 | |
77 | - public function removeField($index){ |
|
77 | + public function removeField($index) { |
|
78 | 78 | parent::removeField($index); |
79 | 79 | $pos=\array_search($index, $this->separators); |
80 | - if($pos!==false){ |
|
81 | - for($i=$pos+1;$i<\sizeof($this->separators);$i++){ |
|
80 | + if ($pos!==false) { |
|
81 | + for ($i=$pos+1; $i<\sizeof($this->separators); $i++) { |
|
82 | 82 | $this->separators[$i]--; |
83 | 83 | } |
84 | 84 | \array_splice($this->separators, $pos, 1); |
@@ -14,34 +14,34 @@ discard block |
||
14 | 14 | use FieldTrait; |
15 | 15 | protected $_container; |
16 | 16 | protected $_validation; |
17 | - public function __construct($identifier, $field,$label=NULL) { |
|
18 | - parent::__construct($identifier, "div","field"); |
|
17 | + public function __construct($identifier, $field, $label=NULL) { |
|
18 | + parent::__construct($identifier, "div", "field"); |
|
19 | 19 | $this->content=array(); |
20 | - $this->_states=[State::ERROR,State::DISABLED]; |
|
21 | - if(isset($label) && $label!=="") |
|
20 | + $this->_states=[State::ERROR, State::DISABLED]; |
|
21 | + if (isset($label) && $label!=="") |
|
22 | 22 | $this->setLabel($label); |
23 | 23 | $this->setField($field); |
24 | 24 | $this->_validation=NULL; |
25 | 25 | } |
26 | 26 | |
27 | - public function addPointingLabel($label,$pointing=Direction::NONE){ |
|
28 | - $labelO=new HtmlLabel("",$label); |
|
27 | + public function addPointingLabel($label, $pointing=Direction::NONE) { |
|
28 | + $labelO=new HtmlLabel("", $label); |
|
29 | 29 | $labelO->setPointing($pointing); |
30 | - $this->addContent($labelO,$pointing==="below" || $pointing==="right"); |
|
30 | + $this->addContent($labelO, $pointing==="below" || $pointing==="right"); |
|
31 | 31 | return $labelO; |
32 | 32 | } |
33 | 33 | |
34 | - public function setLabel($label){ |
|
34 | + public function setLabel($label) { |
|
35 | 35 | $labelO=$label; |
36 | - if(\is_string($label)){ |
|
37 | - $labelO=new HtmlSemDoubleElement("","label",""); |
|
36 | + if (\is_string($label)) { |
|
37 | + $labelO=new HtmlSemDoubleElement("", "label", ""); |
|
38 | 38 | $labelO->setContent($label); |
39 | - $labelO->setProperty("for", \str_replace("field-", "",$this->identifier)); |
|
39 | + $labelO->setProperty("for", \str_replace("field-", "", $this->identifier)); |
|
40 | 40 | } |
41 | 41 | $this->content["label"]=$labelO; |
42 | 42 | } |
43 | 43 | |
44 | - public function setField($field){ |
|
44 | + public function setField($field) { |
|
45 | 45 | $this->content["field"]=$field; |
46 | 46 | } |
47 | 47 | |
@@ -49,8 +49,8 @@ discard block |
||
49 | 49 | * Returns the label or null |
50 | 50 | * @return mixed |
51 | 51 | */ |
52 | - public function getLabel(){ |
|
53 | - if(\array_key_exists("label", $this->content)) |
|
52 | + public function getLabel() { |
|
53 | + if (\array_key_exists("label", $this->content)) |
|
54 | 54 | return $this->content["label"]; |
55 | 55 | } |
56 | 56 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | * Return the field |
59 | 59 | * @return mixed |
60 | 60 | */ |
61 | - public function getField(){ |
|
61 | + public function getField() { |
|
62 | 62 | return $this->content["field"]; |
63 | 63 | } |
64 | 64 | |
@@ -66,14 +66,14 @@ discard block |
||
66 | 66 | * Return the field with data |
67 | 67 | * @return mixed |
68 | 68 | */ |
69 | - public function getDataField(){ |
|
69 | + public function getDataField() { |
|
70 | 70 | return $this->content["field"]; |
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
74 | 74 | * puts the label before or behind |
75 | 75 | */ |
76 | - public function swapLabel(){ |
|
76 | + public function swapLabel() { |
|
77 | 77 | $label=$this->getLabel(); |
78 | 78 | unset($this->content["label"]); |
79 | 79 | $this->content["label"]=$label; |
@@ -84,31 +84,31 @@ discard block |
||
84 | 84 | * @param int $width |
85 | 85 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
86 | 86 | */ |
87 | - public function setWidth($width){ |
|
88 | - if(\is_int($width)){ |
|
87 | + public function setWidth($width) { |
|
88 | + if (\is_int($width)) { |
|
89 | 89 | $width=Wide::getConstants()["W".$width]; |
90 | 90 | } |
91 | 91 | $this->addToPropertyCtrl("class", $width, Wide::getConstants()); |
92 | - if(isset($this->_container)){ |
|
92 | + if (isset($this->_container)) { |
|
93 | 93 | $this->_container->setEqualWidth(false); |
94 | 94 | } |
95 | - return $this->addToPropertyCtrl("class", "wide",array("wide")); |
|
95 | + return $this->addToPropertyCtrl("class", "wide", array("wide")); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | /** |
99 | 99 | * Field displays an error state |
100 | 100 | * @return \Ajax\semantic\html\collections\form\HtmlFormField |
101 | 101 | */ |
102 | - public function setError(){ |
|
102 | + public function setError() { |
|
103 | 103 | return $this->addToProperty("class", "error"); |
104 | 104 | } |
105 | 105 | |
106 | - public function setInline(){ |
|
106 | + public function setInline() { |
|
107 | 107 | return $this->addToProperty("class", "inline"); |
108 | 108 | } |
109 | 109 | |
110 | - public function jsState($state){ |
|
111 | - return $this->jsDoJquery("addClass",$state); |
|
110 | + public function jsState($state) { |
|
111 | + return $this->jsDoJquery("addClass", $state); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | public function setContainer($_container) { |
@@ -116,39 +116,39 @@ discard block |
||
116 | 116 | return $this; |
117 | 117 | } |
118 | 118 | |
119 | - public function setReadonly(){ |
|
119 | + public function setReadonly() { |
|
120 | 120 | $this->getField()->setProperty("readonly", ""); |
121 | 121 | } |
122 | 122 | |
123 | - public function addRule($type,$prompt=NULL,$value=NULL){ |
|
123 | + public function addRule($type, $prompt=NULL, $value=NULL) { |
|
124 | 124 | $field=$this->getDataField(); |
125 | - if(isset($field)){ |
|
126 | - if(!isset($this->_validation)){ |
|
125 | + if (isset($field)) { |
|
126 | + if (!isset($this->_validation)) { |
|
127 | 127 | $this->_validation=new FieldValidation($field->getIdentifier()); |
128 | 128 | } |
129 | - if($type==="empty"){ |
|
130 | - $this->addToProperty("class","required"); |
|
129 | + if ($type==="empty") { |
|
130 | + $this->addToProperty("class", "required"); |
|
131 | 131 | } |
132 | - $this->_validation->addRule($type,$prompt,$value); |
|
132 | + $this->_validation->addRule($type, $prompt, $value); |
|
133 | 133 | } |
134 | 134 | return $this; |
135 | 135 | } |
136 | 136 | |
137 | - public function addRules(array $rules){ |
|
138 | - foreach ($rules as $rule){ |
|
137 | + public function addRules(array $rules) { |
|
138 | + foreach ($rules as $rule) { |
|
139 | 139 | $this->addRule($rule); |
140 | 140 | } |
141 | 141 | return $this; |
142 | 142 | } |
143 | 143 | |
144 | - public function setRules(array $rules){ |
|
144 | + public function setRules(array $rules) { |
|
145 | 145 | $this->_validation=null; |
146 | 146 | return $this->addRules($rules); |
147 | 147 | } |
148 | 148 | |
149 | - public function addIcon($icon,$direction=Direction::LEFT){ |
|
149 | + public function addIcon($icon, $direction=Direction::LEFT) { |
|
150 | 150 | $field=$this->getField(); |
151 | - return $field->addIcon($icon,$direction); |
|
151 | + return $field->addIcon($icon, $direction); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | public function getValidation() { |
@@ -18,8 +18,9 @@ discard block |
||
18 | 18 | parent::__construct($identifier, "div","field"); |
19 | 19 | $this->content=array(); |
20 | 20 | $this->_states=[State::ERROR,State::DISABLED]; |
21 | - if(isset($label) && $label!=="") |
|
22 | - $this->setLabel($label); |
|
21 | + if(isset($label) && $label!=="") { |
|
22 | + $this->setLabel($label); |
|
23 | + } |
|
23 | 24 | $this->setField($field); |
24 | 25 | $this->_validation=NULL; |
25 | 26 | } |
@@ -50,8 +51,9 @@ discard block |
||
50 | 51 | * @return mixed |
51 | 52 | */ |
52 | 53 | public function getLabel(){ |
53 | - if(\array_key_exists("label", $this->content)) |
|
54 | - return $this->content["label"]; |
|
54 | + if(\array_key_exists("label", $this->content)) { |
|
55 | + return $this->content["label"]; |
|
56 | + } |
|
55 | 57 | } |
56 | 58 | |
57 | 59 | /** |
@@ -62,8 +62,7 @@ discard block |
||
62 | 62 | $rules=$attributes["rules"]; |
63 | 63 | if(\is_array($rules)){ |
64 | 64 | $element->addRules($rules); |
65 | - } |
|
66 | - else{ |
|
65 | + } else{ |
|
67 | 66 | $element->addRule($rules); |
68 | 67 | } |
69 | 68 | unset($attributes["rules"]); |
@@ -123,8 +122,9 @@ discard block |
||
123 | 122 | public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
124 | 123 | return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
125 | 124 | $header=new HtmlHeader($id,$niveau,$value); |
126 | - if(isset($icon)) |
|
127 | - $header->asIcon($icon, $value); |
|
125 | + if(isset($icon)) { |
|
126 | + $header->asIcon($icon, $value); |
|
127 | + } |
|
128 | 128 | return $header; |
129 | 129 | }, $index,$attributes,"header"); |
130 | 130 | } |
@@ -132,7 +132,9 @@ discard block |
||
132 | 132 | |
133 | 133 | public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
134 | 134 | $this->setValueFunction($index,function($img) use($size,$circular){ |
135 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
135 | + $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular) { |
|
136 | + $image->setCircular(); |
|
137 | + } |
|
136 | 138 | return $image; |
137 | 139 | }); |
138 | 140 | return $this; |
@@ -221,14 +223,14 @@ discard block |
||
221 | 223 | $i=0; |
222 | 224 | if(JArray::isAssociative($types)){ |
223 | 225 | foreach ($types as $type=>$attributes){ |
224 | - if(\is_int($type)) |
|
225 | - $this->fieldAs($i++,$attributes,[]); |
|
226 | - else{ |
|
226 | + if(\is_int($type)) { |
|
227 | + $this->fieldAs($i++,$attributes,[]); |
|
228 | + } else{ |
|
227 | 229 | $type=preg_replace('/\d/', '', $type ); |
228 | 230 | $this->fieldAs($i++,$type,$attributes); |
229 | 231 | } |
230 | 232 | } |
231 | - }else{ |
|
233 | + } else{ |
|
232 | 234 | foreach ($types as $type){ |
233 | 235 | $this->fieldAs($i++,$type); |
234 | 236 | } |
@@ -240,7 +242,7 @@ discard block |
||
240 | 242 | if(\method_exists($this, $method)){ |
241 | 243 | if(!\is_array($attributes)){ |
242 | 244 | $attributes=[$index]; |
243 | - }else{ |
|
245 | + } else{ |
|
244 | 246 | \array_unshift($attributes, $index); |
245 | 247 | } |
246 | 248 | \call_user_func_array([$this,$method], $attributes); |
@@ -30,9 +30,17 @@ discard block |
||
30 | 30 | trait FieldAsTrait{ |
31 | 31 | |
32 | 32 | abstract protected function _getFieldIdentifier($prefix,$name=""); |
33 | + |
|
34 | + /** |
|
35 | + * @param \Closure $callback |
|
36 | + */ |
|
33 | 37 | abstract public function setValueFunction($index,$callback); |
34 | 38 | abstract protected function _getFieldName($index); |
35 | 39 | abstract protected function _getFieldCaption($index); |
40 | + |
|
41 | + /** |
|
42 | + * @param string $event |
|
43 | + */ |
|
36 | 44 | abstract protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
37 | 45 | |
38 | 46 | /** |
@@ -243,6 +251,9 @@ discard block |
||
243 | 251 | } |
244 | 252 | } |
245 | 253 | |
254 | + /** |
|
255 | + * @param integer $index |
|
256 | + */ |
|
246 | 257 | public function fieldAs($index,$type,$attributes=NULL){ |
247 | 258 | $method="fieldAs".\ucfirst($type); |
248 | 259 | if(\method_exists($this, $method)){ |
@@ -27,23 +27,23 @@ discard block |
||
27 | 27 | * @property boolean $_edition |
28 | 28 | * @property mixed _modelInstance |
29 | 29 | */ |
30 | -trait FieldAsTrait{ |
|
30 | +trait FieldAsTrait { |
|
31 | 31 | |
32 | - abstract protected function _getFieldIdentifier($prefix,$name=""); |
|
33 | - abstract public function setValueFunction($index,$callback); |
|
32 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
33 | + abstract public function setValueFunction($index, $callback); |
|
34 | 34 | abstract protected function _getFieldName($index); |
35 | 35 | abstract protected function _getFieldCaption($index); |
36 | - abstract protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
|
36 | + abstract protected function _buttonAsSubmit(BaseHtml&$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @param HtmlFormField $element |
40 | 40 | * @param array $attributes |
41 | 41 | */ |
42 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
43 | - if(isset($attributes["jsCallback"])){ |
|
42 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
43 | + if (isset($attributes["jsCallback"])) { |
|
44 | 44 | $callback=$attributes["jsCallback"]; |
45 | - if(\is_callable($callback)){ |
|
46 | - $callback($element,$this->_modelInstance,$index); |
|
45 | + if (\is_callable($callback)) { |
|
46 | + $callback($element, $this->_modelInstance, $index); |
|
47 | 47 | unset($attributes["jsCallback"]); |
48 | 48 | } |
49 | 49 | } |
@@ -53,43 +53,43 @@ discard block |
||
53 | 53 | $element->fromArray($attributes); |
54 | 54 | } |
55 | 55 | |
56 | - private function _getLabelField($caption,$icon=NULL){ |
|
57 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
56 | + private function _getLabelField($caption, $icon=NULL) { |
|
57 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
58 | 58 | return $label; |
59 | 59 | } |
60 | 60 | |
61 | 61 | |
62 | - protected function _addRules($element,&$attributes){ |
|
63 | - if(isset($attributes["rules"])){ |
|
62 | + protected function _addRules($element, &$attributes) { |
|
63 | + if (isset($attributes["rules"])) { |
|
64 | 64 | $rules=$attributes["rules"]; |
65 | - if(\is_array($rules)){ |
|
65 | + if (\is_array($rules)) { |
|
66 | 66 | $element->addRules($rules); |
67 | 67 | } |
68 | - else{ |
|
68 | + else { |
|
69 | 69 | $element->addRule($rules); |
70 | 70 | } |
71 | 71 | unset($attributes["rules"]); |
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
75 | - protected function _prepareFormFields(&$field,$name,&$attributes){ |
|
75 | + protected function _prepareFormFields(&$field, $name, &$attributes) { |
|
76 | 76 | $field->setName($name); |
77 | 77 | $this->_addRules($field, $attributes); |
78 | 78 | return $field; |
79 | 79 | } |
80 | 80 | |
81 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
82 | - $this->setValueFunction($index,function($value,$instance,$index) use (&$attributes,$elementCallback,$prefix){ |
|
81 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
82 | + $this->setValueFunction($index, function($value, $instance, $index) use (&$attributes, $elementCallback, $prefix){ |
|
83 | 83 | $caption=$this->_getFieldCaption($index); |
84 | 84 | $name=$this->_getFieldName($index); |
85 | - $id=$this->_getFieldIdentifier($prefix,$name); |
|
86 | - if(isset($attributes["name"])){ |
|
85 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
86 | + if (isset($attributes["name"])) { |
|
87 | 87 | $name=$attributes["name"]; |
88 | 88 | unset($attributes["name"]); |
89 | 89 | } |
90 | - $element=$elementCallback($id,$name,$value,$caption); |
|
91 | - if(\is_array($attributes)){ |
|
92 | - $this->_applyAttributes($element, $attributes,$index); |
|
90 | + $element=$elementCallback($id, $name, $value, $caption); |
|
91 | + if (\is_array($attributes)) { |
|
92 | + $this->_applyAttributes($element, $attributes, $index); |
|
93 | 93 | } |
94 | 94 | $element->setDisabled(!$this->_edition); |
95 | 95 | return $element; |
@@ -98,175 +98,175 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | |
101 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
102 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
103 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
101 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
102 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
103 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
104 | 104 | return $pb; |
105 | 105 | }); |
106 | 106 | return $this; |
107 | 107 | } |
108 | 108 | |
109 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
110 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
111 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
109 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
110 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
111 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
112 | 112 | return $rating; |
113 | 113 | }); |
114 | 114 | return $this; |
115 | 115 | } |
116 | 116 | |
117 | - public function fieldAsLabel($index,$icon=NULL){ |
|
118 | - $this->setValueFunction($index,function($caption) use($icon){ |
|
119 | - $lbl=$this->_getLabelField($caption,$icon); |
|
117 | + public function fieldAsLabel($index, $icon=NULL) { |
|
118 | + $this->setValueFunction($index, function($caption) use($icon){ |
|
119 | + $lbl=$this->_getLabelField($caption, $icon); |
|
120 | 120 | return $lbl; |
121 | 121 | }); |
122 | 122 | return $this; |
123 | 123 | } |
124 | 124 | |
125 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
126 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
127 | - $header=new HtmlHeader($id,$niveau,$value); |
|
128 | - if(isset($icon)) |
|
125 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
126 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
127 | + $header=new HtmlHeader($id, $niveau, $value); |
|
128 | + if (isset($icon)) |
|
129 | 129 | $header->asIcon($icon, $value); |
130 | 130 | return $header; |
131 | - }, $index,$attributes,"header"); |
|
131 | + }, $index, $attributes, "header"); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
135 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
136 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
137 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
135 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
136 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
137 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
138 | 138 | return $image; |
139 | 139 | }); |
140 | 140 | return $this; |
141 | 141 | } |
142 | 142 | |
143 | - public function fieldAsFlag($index){ |
|
144 | - $this->setValueFunction($index,function($flag){ |
|
145 | - $flag=new HtmlFlag($this->_getFieldIdentifier("flag"),$flag); |
|
143 | + public function fieldAsFlag($index) { |
|
144 | + $this->setValueFunction($index, function($flag) { |
|
145 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
146 | 146 | return $flag; |
147 | 147 | }); |
148 | 148 | return $this; |
149 | 149 | } |
150 | 150 | |
151 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
152 | - return $this->_fieldAs(function($id,$name,$value){ |
|
153 | - $img=new HtmlImage($id,$value); |
|
151 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
152 | + return $this->_fieldAs(function($id, $name, $value) { |
|
153 | + $img=new HtmlImage($id, $value); |
|
154 | 154 | $img->asAvatar(); |
155 | 155 | return $img; |
156 | - }, $index,$attributes,"avatar"); |
|
156 | + }, $index, $attributes, "avatar"); |
|
157 | 157 | } |
158 | 158 | |
159 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
160 | - return $this->_fieldAs(function($id,$name,$value) use($attributes){ |
|
161 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
159 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
160 | + return $this->_fieldAs(function($id, $name, $value) use($attributes){ |
|
161 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
162 | 162 | return $this->_prepareFormFields($input, $name, $attributes); |
163 | - }, $index,$attributes,"radio"); |
|
163 | + }, $index, $attributes, "radio"); |
|
164 | 164 | } |
165 | 165 | |
166 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
167 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
168 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
169 | - }, $index,$attributes,"radios"); |
|
166 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
167 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
168 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
169 | + }, $index, $attributes, "radios"); |
|
170 | 170 | } |
171 | 171 | |
172 | - public function fieldAsInput($index,$attributes=NULL){ |
|
173 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
174 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
172 | + public function fieldAsInput($index, $attributes=NULL) { |
|
173 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
174 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
175 | 175 | return $this->_prepareFormFields($input, $name, $attributes); |
176 | - }, $index,$attributes,"input"); |
|
176 | + }, $index, $attributes, "input"); |
|
177 | 177 | } |
178 | 178 | |
179 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
180 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
181 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
179 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
180 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
181 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
182 | 182 | return $this->_prepareFormFields($textarea, $name, $attributes); |
183 | - }, $index,$attributes,"textarea"); |
|
183 | + }, $index, $attributes, "textarea"); |
|
184 | 184 | } |
185 | 185 | |
186 | - public function fieldAsHidden($index,$attributes=NULL){ |
|
187 | - if(!\is_array($attributes)){ |
|
186 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
187 | + if (!\is_array($attributes)) { |
|
188 | 188 | $attributes=[]; |
189 | 189 | } |
190 | 190 | $attributes["imputType"]="hidden"; |
191 | - return $this->fieldAsInput($index,$attributes); |
|
191 | + return $this->fieldAsInput($index, $attributes); |
|
192 | 192 | } |
193 | 193 | |
194 | - public function fieldAsCheckbox($index,$attributes=NULL){ |
|
195 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($attributes){ |
|
196 | - $input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier()); |
|
194 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
195 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($attributes){ |
|
196 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
197 | 197 | $input->setChecked(JString::isBooleanTrue($value)); |
198 | 198 | return $this->_prepareFormFields($input, $name, $attributes); |
199 | - }, $index,$attributes,"ck"); |
|
199 | + }, $index, $attributes, "ck"); |
|
200 | 200 | } |
201 | 201 | |
202 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
203 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple,$attributes){ |
|
204 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value); |
|
205 | - $dd->asSelect($name,$multiple); |
|
202 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
203 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple, $attributes){ |
|
204 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value); |
|
205 | + $dd->asSelect($name, $multiple); |
|
206 | 206 | return $this->_prepareFormFields($dd, $name, $attributes); |
207 | - }, $index,$attributes,"dd"); |
|
207 | + }, $index, $attributes, "dd"); |
|
208 | 208 | } |
209 | 209 | |
210 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
211 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
212 | - $mess= new HtmlMessage("message-".$id,$caption); |
|
210 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
211 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
212 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
213 | 213 | $mess->addHeader($value); |
214 | 214 | return $mess; |
215 | - }, $index,$attributes,"message"); |
|
215 | + }, $index, $attributes, "message"); |
|
216 | 216 | } |
217 | 217 | |
218 | - public function fieldAsLink($index,$attributes=NULL){ |
|
219 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
220 | - $lnk= new HtmlLink("message-".$id,"#",$caption); |
|
218 | + public function fieldAsLink($index, $attributes=NULL) { |
|
219 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
220 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
221 | 221 | return $lnk; |
222 | - }, $index,$attributes,"link"); |
|
222 | + }, $index, $attributes, "link"); |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | /**Change fields type |
226 | 226 | * @param array $types an array or associative array $type=>$attributes |
227 | 227 | */ |
228 | - public function fieldsAs(array $types){ |
|
228 | + public function fieldsAs(array $types) { |
|
229 | 229 | $i=0; |
230 | - if(JArray::isAssociative($types)){ |
|
231 | - foreach ($types as $type=>$attributes){ |
|
232 | - if(\is_int($type)) |
|
233 | - $this->fieldAs($i++,$attributes,[]); |
|
234 | - else{ |
|
235 | - $type=preg_replace('/\d/', '', $type ); |
|
236 | - $this->fieldAs($i++,$type,$attributes); |
|
230 | + if (JArray::isAssociative($types)) { |
|
231 | + foreach ($types as $type=>$attributes) { |
|
232 | + if (\is_int($type)) |
|
233 | + $this->fieldAs($i++, $attributes, []); |
|
234 | + else { |
|
235 | + $type=preg_replace('/\d/', '', $type); |
|
236 | + $this->fieldAs($i++, $type, $attributes); |
|
237 | 237 | } |
238 | 238 | } |
239 | - }else{ |
|
240 | - foreach ($types as $type){ |
|
241 | - $this->fieldAs($i++,$type); |
|
239 | + } else { |
|
240 | + foreach ($types as $type) { |
|
241 | + $this->fieldAs($i++, $type); |
|
242 | 242 | } |
243 | 243 | } |
244 | 244 | } |
245 | 245 | |
246 | - public function fieldAs($index,$type,$attributes=NULL){ |
|
246 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
247 | 247 | $method="fieldAs".\ucfirst($type); |
248 | - if(\method_exists($this, $method)){ |
|
249 | - if(!\is_array($attributes)){ |
|
248 | + if (\method_exists($this, $method)) { |
|
249 | + if (!\is_array($attributes)) { |
|
250 | 250 | $attributes=[$index]; |
251 | - }else{ |
|
251 | + } else { |
|
252 | 252 | \array_unshift($attributes, $index); |
253 | 253 | } |
254 | - \call_user_func_array([$this,$method], $attributes); |
|
254 | + \call_user_func_array([$this, $method], $attributes); |
|
255 | 255 | } |
256 | 256 | } |
257 | 257 | |
258 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
259 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
260 | - $button=new HtmlButton($id,$caption,$cssStyle); |
|
261 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]); |
|
258 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
259 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
260 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
261 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
|
262 | 262 | return $button; |
263 | - }, $index,$attributes,"submit"); |
|
263 | + }, $index, $attributes, "submit"); |
|
264 | 264 | } |
265 | 265 | |
266 | - public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){ |
|
267 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
268 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
266 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
267 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
268 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
269 | 269 | return $button; |
270 | - }, $index,$attributes,"button"); |
|
270 | + }, $index, $attributes, "button"); |
|
271 | 271 | } |
272 | 272 | } |
273 | 273 | \ No newline at end of file |
@@ -10,50 +10,50 @@ |
||
10 | 10 | * @param string $identifier |
11 | 11 | * @param object $modelInstance |
12 | 12 | */ |
13 | - public function __construct($identifier,$modelInstance=null,$fieldsOrder=[],$fieldsDefinition=[],$fields=[],$captions=[],$separators=[]) { |
|
14 | - parent::__construct($identifier,$modelInstance,$fieldsOrder,$fieldsDefinition,$fields,$captions,$separators); |
|
13 | + public function __construct($identifier, $modelInstance=null, $fieldsOrder=[], $fieldsDefinition=[], $fields=[], $captions=[], $separators=[]) { |
|
14 | + parent::__construct($identifier, $modelInstance, $fieldsOrder, $fieldsDefinition, $fields, $captions, $separators); |
|
15 | 15 | } |
16 | 16 | |
17 | - protected function getDefaultModelInstance(){ |
|
17 | + protected function getDefaultModelInstance() { |
|
18 | 18 | return new UserModel(); |
19 | 19 | } |
20 | 20 | |
21 | - public static function regular($identifier,$modelInstance=null){ |
|
22 | - return new FormLogin($identifier,$modelInstance, |
|
23 | - ["message","login","password","remember","forget","submit","error"], |
|
24 | - ["message"=>[["icon"=>"sign in"]],"input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"checkbox","link","submit"=>["green fluid"],"message2"=>[["error"=>true]]], |
|
25 | - ["Connection","login","password","remember","forget","submit","error"], |
|
26 | - ["Please enter login and password to connect","Login","Password","Remember me.","Forgot your password?","Connection"], |
|
27 | - [0,2,4,5,6]); |
|
21 | + public static function regular($identifier, $modelInstance=null) { |
|
22 | + return new FormLogin($identifier, $modelInstance, |
|
23 | + ["message", "login", "password", "remember", "forget", "submit", "error"], |
|
24 | + ["message"=>[["icon"=>"sign in"]], "input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "checkbox", "link", "submit"=>["green fluid"], "message2"=>[["error"=>true]]], |
|
25 | + ["Connection", "login", "password", "remember", "forget", "submit", "error"], |
|
26 | + ["Please enter login and password to connect", "Login", "Password", "Remember me.", "Forgot your password?", "Connection"], |
|
27 | + [0, 2, 4, 5, 6]); |
|
28 | 28 | } |
29 | 29 | |
30 | - public static function smallInline($identifier,$modelInstance=null){ |
|
31 | - $result=new FormLogin($identifier,$modelInstance, |
|
32 | - ["login","password","submit"], |
|
33 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
34 | - ["login","password","submit"], |
|
35 | - ["","","Connection"], |
|
30 | + public static function smallInline($identifier, $modelInstance=null) { |
|
31 | + $result=new FormLogin($identifier, $modelInstance, |
|
32 | + ["login", "password", "submit"], |
|
33 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
34 | + ["login", "password", "submit"], |
|
35 | + ["", "", "Connection"], |
|
36 | 36 | [2]); |
37 | 37 | $result->addDividerBefore(0, "Connection"); |
38 | 38 | return $result; |
39 | 39 | } |
40 | 40 | |
41 | - public static function small($identifier,$modelInstance=null){ |
|
42 | - $result=new FormLogin($identifier,$modelInstance, |
|
43 | - ["login","password","submit"], |
|
44 | - ["input0"=>[["rules"=>"empty"]],"input1"=>[["inputType"=>"password","rules"=>"empty"]],"submit"=>["green basic"]], |
|
45 | - ["login","password","submit"], |
|
46 | - ["Login","Password","Connection"], |
|
47 | - [1,2]); |
|
41 | + public static function small($identifier, $modelInstance=null) { |
|
42 | + $result=new FormLogin($identifier, $modelInstance, |
|
43 | + ["login", "password", "submit"], |
|
44 | + ["input0"=>[["rules"=>"empty"]], "input1"=>[["inputType"=>"password", "rules"=>"empty"]], "submit"=>["green basic"]], |
|
45 | + ["login", "password", "submit"], |
|
46 | + ["Login", "Password", "Connection"], |
|
47 | + [1, 2]); |
|
48 | 48 | $result->addDividerBefore(0, "Connection"); |
49 | 49 | return $result; |
50 | 50 | } |
51 | 51 | |
52 | - public static function attachedSegment($identifier,$modelInstance=null){ |
|
53 | - $result=self::regular($identifier,$modelInstance); |
|
54 | - $result->fieldAsMessage("message",["icon"=>"sign in","attached"=>true]); |
|
55 | - $result->addWrapper("message",null,"<div class='ui attached segment'>"); |
|
56 | - $result->addWrapper("error", null,"</div>"); |
|
52 | + public static function attachedSegment($identifier, $modelInstance=null) { |
|
53 | + $result=self::regular($identifier, $modelInstance); |
|
54 | + $result->fieldAsMessage("message", ["icon"=>"sign in", "attached"=>true]); |
|
55 | + $result->addWrapper("message", null, "<div class='ui attached segment'>"); |
|
56 | + $result->addWrapper("error", null, "</div>"); |
|
57 | 57 | return $result; |
58 | 58 | } |
59 | 59 | } |
60 | 60 | \ No newline at end of file |