@@ -3,25 +3,25 @@ discard block |
||
| 3 | 3 | namespace Ajax\service; |
| 4 | 4 | |
| 5 | 5 | class JReflection { |
| 6 | - public static function shortClassName($object){ |
|
| 7 | - $classNameWithNamespace = get_class($object); |
|
| 6 | + public static function shortClassName($object) { |
|
| 7 | + $classNameWithNamespace=get_class($object); |
|
| 8 | 8 | return substr($classNameWithNamespace, strrpos($classNameWithNamespace, '\\')+1); |
| 9 | 9 | } |
| 10 | 10 | |
| 11 | - public static function jsonObject($classname){ |
|
| 11 | + public static function jsonObject($classname) { |
|
| 12 | 12 | $object=new $classname(); |
| 13 | - $class = new \ReflectionClass($classname); |
|
| 13 | + $class=new \ReflectionClass($classname); |
|
| 14 | 14 | $methods=$class->getMethods(\ReflectionMethod::IS_PUBLIC); |
| 15 | - foreach ($methods as $method){ |
|
| 15 | + foreach ($methods as $method) { |
|
| 16 | 16 | $name=$method->getName(); |
| 17 | - if(JString::startswith($name, "set")){ |
|
| 17 | + if (JString::startswith($name, "set")) { |
|
| 18 | 18 | $property=\lcfirst(JString::replaceAtFirst($name, "set", "")); |
| 19 | 19 | $value="__".$property."__"; |
| 20 | - try{ |
|
| 21 | - if($class->getProperty($property)!==null){ |
|
| 22 | - \call_user_func_array([$object,$name],[$value]); |
|
| 20 | + try { |
|
| 21 | + if ($class->getProperty($property)!==null) { |
|
| 22 | + \call_user_func_array([$object, $name], [$value]); |
|
| 23 | 23 | } |
| 24 | - }catch(\Exception $e){ |
|
| 24 | + }catch (\Exception $e) { |
|
| 25 | 25 | //Nothing to do |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | return $object; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - public static function callMethod($object,$callback,array $values){ |
|
| 33 | - return \call_user_func_array([$object,$callback],$values); |
|
| 32 | + public static function callMethod($object, $callback, array $values) { |
|
| 33 | + return \call_user_func_array([$object, $callback], $values); |
|
| 34 | 34 | } |
| 35 | 35 | } |
| 36 | 36 | \ No newline at end of file |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @return \Ajax\semantic\html\HtmlIcon |
| 69 | 69 | */ |
| 70 | 70 | public function setFlipped($sens="horizontally") { |
| 71 | - return $this->addToProperty("class", "flipped " . $sens); |
|
| 71 | + return $this->addToProperty("class", "flipped ".$sens); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * @return \Ajax\semantic\html\HtmlIcon |
| 78 | 78 | */ |
| 79 | 79 | public function setRotated($sens="clockwise") { |
| 80 | - return $this->addToProperty("class", "rotated " . $sens); |
|
| 80 | + return $this->addToProperty("class", "rotated ".$sens); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | /** |
@@ -86,12 +86,12 @@ discard block |
||
| 86 | 86 | * @param string target |
| 87 | 87 | * @return HtmlIcon |
| 88 | 88 | */ |
| 89 | - public function asLink($href=NULL,$target=NULL) { |
|
| 89 | + public function asLink($href=NULL, $target=NULL) { |
|
| 90 | 90 | if (isset($href)) { |
| 91 | 91 | $_target=""; |
| 92 | - if(isset($target)) |
|
| 92 | + if (isset($target)) |
|
| 93 | 93 | $_target="target='{$target}'"; |
| 94 | - $this->wrap("<a href='" . $href . "' {$_target}>", "</a>"); |
|
| 94 | + $this->wrap("<a href='".$href."' {$_target}>", "</a>"); |
|
| 95 | 95 | } |
| 96 | 96 | return $this->addToProperty("class", "link"); |
| 97 | 97 | } |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function setBordered($inverted=false) { |
| 109 | 109 | $invertedStr=""; |
| 110 | - if ($inverted !== false) |
|
| 110 | + if ($inverted!==false) |
|
| 111 | 111 | $invertedStr=" inverted"; |
| 112 | - return $this->addToProperty("class", "bordered" . $invertedStr); |
|
| 112 | + return $this->addToProperty("class", "bordered".$invertedStr); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -121,11 +121,11 @@ discard block |
||
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | public function addLabel($label, $before=false, $icon=NULL) { |
| 124 | - if($before) |
|
| 124 | + if ($before) |
|
| 125 | 125 | $this->wrap($label); |
| 126 | 126 | else |
| 127 | 127 | $this->wrap("", $label); |
| 128 | - if(isset($icon)) |
|
| 128 | + if (isset($icon)) |
|
| 129 | 129 | $this->addToIcon($icon); |
| 130 | 130 | return $this; |
| 131 | 131 | } |
@@ -89,8 +89,9 @@ discard block |
||
| 89 | 89 | public function asLink($href=NULL,$target=NULL) { |
| 90 | 90 | if (isset($href)) { |
| 91 | 91 | $_target=""; |
| 92 | - if(isset($target)) |
|
| 93 | - $_target="target='{$target}'"; |
|
| 92 | + if(isset($target)) { |
|
| 93 | + $_target="target='{$target}'"; |
|
| 94 | + } |
|
| 94 | 95 | $this->wrap("<a href='" . $href . "' {$_target}>", "</a>"); |
| 95 | 96 | } |
| 96 | 97 | return $this->addToProperty("class", "link"); |
@@ -107,8 +108,9 @@ discard block |
||
| 107 | 108 | */ |
| 108 | 109 | public function setBordered($inverted=false) { |
| 109 | 110 | $invertedStr=""; |
| 110 | - if ($inverted !== false) |
|
| 111 | - $invertedStr=" inverted"; |
|
| 111 | + if ($inverted !== false) { |
|
| 112 | + $invertedStr=" inverted"; |
|
| 113 | + } |
|
| 112 | 114 | return $this->addToProperty("class", "bordered" . $invertedStr); |
| 113 | 115 | } |
| 114 | 116 | |
@@ -121,12 +123,14 @@ discard block |
||
| 121 | 123 | } |
| 122 | 124 | |
| 123 | 125 | public function addLabel($label, $before=false, $icon=NULL) { |
| 124 | - if($before) |
|
| 125 | - $this->wrap($label); |
|
| 126 | - else |
|
| 127 | - $this->wrap("", $label); |
|
| 128 | - if(isset($icon)) |
|
| 129 | - $this->addToIcon($icon); |
|
| 126 | + if($before) { |
|
| 127 | + $this->wrap($label); |
|
| 128 | + } else { |
|
| 129 | + $this->wrap("", $label); |
|
| 130 | + } |
|
| 131 | + if(isset($icon)) { |
|
| 132 | + $this->addToIcon($icon); |
|
| 133 | + } |
|
| 130 | 134 | return $this; |
| 131 | 135 | } |
| 132 | 136 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | public function setFocusable($value=true) { |
| 59 | - if ($value === true) |
|
| 59 | + if ($value===true) |
|
| 60 | 60 | $this->setProperty("tabindex", "0"); |
| 61 | 61 | else { |
| 62 | 62 | $this->removeProperty("tabindex"); |
@@ -66,14 +66,14 @@ discard block |
||
| 66 | 66 | |
| 67 | 67 | public function setAnimated($content, $animation="") { |
| 68 | 68 | $this->setTagName("div"); |
| 69 | - $this->addToProperty("class", "animated " . $animation); |
|
| 70 | - $visible=new HtmlSemDoubleElement("visible-" . $this->identifier, "div"); |
|
| 69 | + $this->addToProperty("class", "animated ".$animation); |
|
| 70 | + $visible=new HtmlSemDoubleElement("visible-".$this->identifier, "div"); |
|
| 71 | 71 | $visible->setClass("visible content"); |
| 72 | 72 | $visible->setContent($this->content); |
| 73 | - $hidden=new HtmlSemDoubleElement("hidden-" . $this->identifier, "div"); |
|
| 73 | + $hidden=new HtmlSemDoubleElement("hidden-".$this->identifier, "div"); |
|
| 74 | 74 | $hidden->setClass("hidden content"); |
| 75 | 75 | $hidden->setContent($content); |
| 76 | - $this->content=array ($visible,$hidden ); |
|
| 76 | + $this->content=array($visible, $hidden); |
|
| 77 | 77 | return $hidden; |
| 78 | 78 | } |
| 79 | 79 | |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | public function asIcon($icon) { |
| 86 | 86 | $iconO=$icon; |
| 87 | 87 | if (\is_string($icon)) { |
| 88 | - $iconO=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
| 88 | + $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
|
| 89 | 89 | } |
| 90 | 90 | $this->addToProperty("class", "icon"); |
| 91 | 91 | $this->content=$iconO; |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | public function addLabel($label, $before=false, $icon=NULL) { |
| 108 | 108 | $this->tagName="div"; |
| 109 | 109 | $this->addToProperty("class", "labeled"); |
| 110 | - $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
|
| 110 | + $this->content=new HtmlButton("button-".$this->identifier, $this->content); |
|
| 111 | 111 | $this->content->setTagName("div"); |
| 112 | - $label=new HtmlLabel("label-" . $this->identifier, $label, $icon,"a"); |
|
| 112 | + $label=new HtmlLabel("label-".$this->identifier, $label, $icon, "a"); |
|
| 113 | 113 | $label->setBasic(); |
| 114 | 114 | $this->addContent($label, $before); |
| 115 | 115 | return $label; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | */ |
| 122 | 122 | public function fromArray($array) { |
| 123 | 123 | $array=parent::fromArray($array); |
| 124 | - foreach ( $array as $key => $value ) { |
|
| 124 | + foreach ($array as $key => $value) { |
|
| 125 | 125 | $this->setProperty($key, $value); |
| 126 | 126 | } |
| 127 | 127 | return $array; |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | * @return HtmlButton |
| 185 | 185 | */ |
| 186 | 186 | public static function social($identifier, $social, $value=NULL) { |
| 187 | - if ($value === NULL) |
|
| 187 | + if ($value===NULL) |
|
| 188 | 188 | $value=\ucfirst($social); |
| 189 | 189 | $return=new HtmlButton($identifier, $value); |
| 190 | 190 | $return->addIcon($social); |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | * {@inheritDoc} |
| 222 | 222 | * @see HtmlSemDoubleElement::asLink() |
| 223 | 223 | */ |
| 224 | - public function asLink($href=NULL,$target=NULL) { |
|
| 225 | - $lnk=new HtmlLink("lnk-".$this->identifier,$href,$this->content,$target); |
|
| 224 | + public function asLink($href=NULL, $target=NULL) { |
|
| 225 | + $lnk=new HtmlLink("lnk-".$this->identifier, $href, $this->content, $target); |
|
| 226 | 226 | $this->content=$lnk; |
| 227 | 227 | return $this; |
| 228 | 228 | } |
@@ -56,9 +56,9 @@ discard block |
||
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | public function setFocusable($value=true) { |
| 59 | - if ($value === true) |
|
| 60 | - $this->setProperty("tabindex", "0"); |
|
| 61 | - else { |
|
| 59 | + if ($value === true) { |
|
| 60 | + $this->setProperty("tabindex", "0"); |
|
| 61 | + } else { |
|
| 62 | 62 | $this->removeProperty("tabindex"); |
| 63 | 63 | } |
| 64 | 64 | return $this; |
@@ -184,8 +184,9 @@ discard block |
||
| 184 | 184 | * @return HtmlButton |
| 185 | 185 | */ |
| 186 | 186 | public static function social($identifier, $social, $value=NULL) { |
| 187 | - if ($value === NULL) |
|
| 188 | - $value=\ucfirst($social); |
|
| 187 | + if ($value === NULL) { |
|
| 188 | + $value=\ucfirst($social); |
|
| 189 | + } |
|
| 189 | 190 | $return=new HtmlButton($identifier, $value); |
| 190 | 191 | $return->addIcon($social); |
| 191 | 192 | return $return->addToPropertyCtrl("class", $social, Social::getConstants()); |
@@ -22,7 +22,7 @@ discard block |
||
| 22 | 22 | use BaseTrait; |
| 23 | 23 | protected $_popup=NULL; |
| 24 | 24 | protected $_dimmer=NULL; |
| 25 | - protected $_params=array (); |
|
| 25 | + protected $_params=array(); |
|
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | public function __construct($identifier, $tagName="p", $baseClass="ui", $content=NULL) { |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | * @return HtmlDimmer |
| 79 | 79 | */ |
| 80 | 80 | public function addDimmer($params=array(), $content=NULL) { |
| 81 | - $dimmer=new HtmlDimmer("dimmer-" . $this->identifier, $content); |
|
| 81 | + $dimmer=new HtmlDimmer("dimmer-".$this->identifier, $content); |
|
| 82 | 82 | $dimmer->setParams($params); |
| 83 | 83 | $dimmer->setContainer($this); |
| 84 | 84 | $this->addContent($dimmer); |
@@ -94,12 +94,12 @@ discard block |
||
| 94 | 94 | */ |
| 95 | 95 | public function addLabel($label, $before=false, $icon=NULL) { |
| 96 | 96 | $labelO=$label; |
| 97 | - if (\is_object($label) === false) { |
|
| 98 | - $labelO=new HtmlLabel("label-" . $this->identifier, $label); |
|
| 97 | + if (\is_object($label)===false) { |
|
| 98 | + $labelO=new HtmlLabel("label-".$this->identifier, $label); |
|
| 99 | 99 | if (isset($icon)) |
| 100 | 100 | $labelO->addIcon($icon); |
| 101 | 101 | } else { |
| 102 | - $labelO->addToPropertyCtrl("class", "label", array ("label" )); |
|
| 102 | + $labelO->addToPropertyCtrl("class", "label", array("label")); |
|
| 103 | 103 | } |
| 104 | 104 | $this->addContent($labelO, $before); |
| 105 | 105 | return $labelO; |
@@ -113,9 +113,9 @@ discard block |
||
| 113 | 113 | * @param string $icon |
| 114 | 114 | * @return HtmlSemDoubleElement |
| 115 | 115 | */ |
| 116 | - public function attachLabel($label,$side=Side::TOP,$direction=Direction::NONE,$icon=NULL){ |
|
| 117 | - $label=$this->addLabel($label,true,$icon); |
|
| 118 | - $label->setAttached($side,$direction); |
|
| 116 | + public function attachLabel($label, $side=Side::TOP, $direction=Direction::NONE, $icon=NULL) { |
|
| 117 | + $label=$this->addLabel($label, true, $icon); |
|
| 118 | + $label->setAttached($side, $direction); |
|
| 119 | 119 | return $this; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | * Transforms the element into a link |
| 124 | 124 | * @return HtmlSemDoubleElement |
| 125 | 125 | */ |
| 126 | - public function asLink($href=NULL,$target=NULL) { |
|
| 126 | + public function asLink($href=NULL, $target=NULL) { |
|
| 127 | 127 | if (isset($href)) |
| 128 | 128 | $this->setProperty("href", $href); |
| 129 | - if(isset($target)) |
|
| 129 | + if (isset($target)) |
|
| 130 | 130 | $this->setProperty("target", $target); |
| 131 | 131 | return $this->setTagName("a"); |
| 132 | 132 | } |
@@ -138,9 +138,9 @@ discard block |
||
| 138 | 138 | */ |
| 139 | 139 | public function jsShowDimmer($show=true) { |
| 140 | 140 | $status="hide"; |
| 141 | - if ($show === true) |
|
| 141 | + if ($show===true) |
|
| 142 | 142 | $status="show"; |
| 143 | - return '$("#.' . $this->identifier . ').dimmer("' . $status . '");'; |
|
| 143 | + return '$("#.'.$this->identifier.').dimmer("'.$status.'");'; |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | /** |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | * @see HtmlDoubleElement::run() |
| 159 | 159 | */ |
| 160 | 160 | public function run(JsUtils $js) { |
| 161 | - $this->_bsComponent=$js->semantic()->generic("#" . $this->identifier); |
|
| 161 | + $this->_bsComponent=$js->semantic()->generic("#".$this->identifier); |
|
| 162 | 162 | parent::run($js); |
| 163 | 163 | $this->addEventsOnRun($js); |
| 164 | 164 | if (isset($this->_popup)) { |
@@ -40,8 +40,9 @@ discard block |
||
| 40 | 40 | * @param string $popupEvent |
| 41 | 41 | */ |
| 42 | 42 | public function setPopupAttributes($variation=NULL, $popupEvent=NULL) { |
| 43 | - if (isset($this->_popup)) |
|
| 44 | - $this->_popup->setAttributes($variation, $popupEvent); |
|
| 43 | + if (isset($this->_popup)) { |
|
| 44 | + $this->_popup->setAttributes($variation, $popupEvent); |
|
| 45 | + } |
|
| 45 | 46 | } |
| 46 | 47 | |
| 47 | 48 | /** |
@@ -96,8 +97,9 @@ discard block |
||
| 96 | 97 | $labelO=$label; |
| 97 | 98 | if (\is_object($label) === false) { |
| 98 | 99 | $labelO=new HtmlLabel("label-" . $this->identifier, $label); |
| 99 | - if (isset($icon)) |
|
| 100 | - $labelO->addIcon($icon); |
|
| 100 | + if (isset($icon)) { |
|
| 101 | + $labelO->addIcon($icon); |
|
| 102 | + } |
|
| 101 | 103 | } else { |
| 102 | 104 | $labelO->addToPropertyCtrl("class", "label", array ("label" )); |
| 103 | 105 | } |
@@ -124,10 +126,12 @@ discard block |
||
| 124 | 126 | * @return HtmlSemDoubleElement |
| 125 | 127 | */ |
| 126 | 128 | public function asLink($href=NULL,$target=NULL) { |
| 127 | - if (isset($href)) |
|
| 128 | - $this->setProperty("href", $href); |
|
| 129 | - if(isset($target)) |
|
| 130 | - $this->setProperty("target", $target); |
|
| 129 | + if (isset($href)) { |
|
| 130 | + $this->setProperty("href", $href); |
|
| 131 | + } |
|
| 132 | + if(isset($target)) { |
|
| 133 | + $this->setProperty("target", $target); |
|
| 134 | + } |
|
| 131 | 135 | return $this->setTagName("a"); |
| 132 | 136 | } |
| 133 | 137 | |
@@ -138,8 +142,9 @@ discard block |
||
| 138 | 142 | */ |
| 139 | 143 | public function jsShowDimmer($show=true) { |
| 140 | 144 | $status="hide"; |
| 141 | - if ($show === true) |
|
| 142 | - $status="show"; |
|
| 145 | + if ($show === true) { |
|
| 146 | + $status="show"; |
|
| 147 | + } |
|
| 143 | 148 | return '$("#.' . $this->identifier . ').dimmer("' . $status . '");'; |
| 144 | 149 | } |
| 145 | 150 | |
@@ -148,8 +153,9 @@ discard block |
||
| 148 | 153 | * @see BaseHtml::compile() |
| 149 | 154 | */ |
| 150 | 155 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 151 | - if (isset($this->_popup)) |
|
| 152 | - $this->_popup->compile($js); |
|
| 156 | + if (isset($this->_popup)) { |
|
| 157 | + $this->_popup->compile($js); |
|
| 158 | + } |
|
| 153 | 159 | return parent::compile($js, $view); |
| 154 | 160 | } |
| 155 | 161 | |
@@ -17,19 +17,19 @@ discard block |
||
| 17 | 17 | class HtmlCard extends HtmlSemDoubleElement { |
| 18 | 18 | |
| 19 | 19 | public function __construct($identifier) { |
| 20 | - parent::__construct($identifier, "div", "ui card", array ()); |
|
| 20 | + parent::__construct($identifier, "div", "ui card", array()); |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | private function createContent($content, $baseClass="content") { |
| 24 | 24 | $count=\sizeof($this->content); |
| 25 | - $result=new HtmlCardContent("content-" . $count . "-" . $this->identifier, $content); |
|
| 25 | + $result=new HtmlCardContent("content-".$count."-".$this->identifier, $content); |
|
| 26 | 26 | $result->setClass($baseClass); |
| 27 | 27 | return $result; |
| 28 | 28 | } |
| 29 | 29 | |
| 30 | 30 | private function addElementInContent($key, $element) { |
| 31 | - if (\array_key_exists($key, $this->content) === false) { |
|
| 32 | - $this->content[$key]=array (); |
|
| 31 | + if (\array_key_exists($key, $this->content)===false) { |
|
| 32 | + $this->content[$key]=array(); |
|
| 33 | 33 | } |
| 34 | 34 | $this->content[$key][]=$element; |
| 35 | 35 | return $element; |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | |
| 47 | 47 | public function addHeader($header, $niveau=4, $type="page") { |
| 48 | 48 | if (!$header instanceof HtmlHeader) { |
| 49 | - $header=new HtmlHeader("header-" . $this->identifier, $niveau, $header, $type); |
|
| 49 | + $header=new HtmlHeader("header-".$this->identifier, $niveau, $header, $type); |
|
| 50 | 50 | } |
| 51 | 51 | $this->content["header"]=$this->createContent($header); |
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function addImage($image, $title="") { |
| 55 | 55 | if (!$image instanceof HtmlImage) { |
| 56 | - $image=new HtmlImage("image-" . $this->identifier, $image, $title); |
|
| 56 | + $image=new HtmlImage("image-".$this->identifier, $image, $title); |
|
| 57 | 57 | } |
| 58 | 58 | $image->setClass("image"); |
| 59 | 59 | return $this->addElementInContent("content", $image); |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | public function addReveal($visibleContent, $hiddenContent=NULL, $type=RevealType::FADE, $attributeType=NULL) { |
| 63 | 63 | $reveal=$visibleContent; |
| 64 | 64 | if (!$visibleContent instanceof HtmlReveal) { |
| 65 | - $reveal=new HtmlReveal("reveral-" . $this->identifier, $visibleContent, $hiddenContent, $type, $attributeType); |
|
| 65 | + $reveal=new HtmlReveal("reveral-".$this->identifier, $visibleContent, $hiddenContent, $type, $attributeType); |
|
| 66 | 66 | } |
| 67 | 67 | return $this->addElementInContent("content", $reveal); |
| 68 | 68 | } |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | * @param boolean $asIcons |
| 92 | 92 | * @return \Ajax\semantic\html\elements\HtmlButtonGroups |
| 93 | 93 | */ |
| 94 | - public function addButtons($elements=array(), $asIcons=false){ |
|
| 95 | - $buttons=new HtmlButtonGroups("buttons-".$this->identifier,$elements,$asIcons); |
|
| 94 | + public function addButtons($elements=array(), $asIcons=false) { |
|
| 95 | + $buttons=new HtmlButtonGroups("buttons-".$this->identifier, $elements, $asIcons); |
|
| 96 | 96 | $this->addElementInContent("content", $buttons); |
| 97 | 97 | return $buttons; |
| 98 | 98 | } |
@@ -101,12 +101,12 @@ discard block |
||
| 101 | 101 | |
| 102 | 102 | public function addCardHeaderContent($header, $metas=array(), $description=NULL) { |
| 103 | 103 | $count=\sizeof($this->content); |
| 104 | - return $this->addElementInContent("content", new HtmlCardHeaderContent("content-" . $count . "-" . $this->identifier, $header, $metas, $description)); |
|
| 104 | + return $this->addElementInContent("content", new HtmlCardHeaderContent("content-".$count."-".$this->identifier, $header, $metas, $description)); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | public function addCardContent($content=array()) { |
| 108 | 108 | $count=\sizeof($this->content); |
| 109 | - return $this->addElementInContent("content", new HtmlCardContent("content-" . $count . "-" . $this->identifier, $content)); |
|
| 109 | + return $this->addElementInContent("content", new HtmlCardContent("content-".$count."-".$this->identifier, $content)); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | 112 | public function getCardContent($index=NULL) { |
@@ -132,13 +132,13 @@ discard block |
||
| 132 | 132 | * @see HtmlSemDoubleElement::compile() |
| 133 | 133 | */ |
| 134 | 134 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 135 | - $this->content=JArray::sortAssociative($this->content, [ "header","image","content","extra-content" ]); |
|
| 135 | + $this->content=JArray::sortAssociative($this->content, ["header", "image", "content", "extra-content"]); |
|
| 136 | 136 | return parent::compile($js, $view); |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - public function asLink($href="",$target=NULL) { |
|
| 139 | + public function asLink($href="", $target=NULL) { |
|
| 140 | 140 | $this->addToProperty("class", "link"); |
| 141 | - if ($href !== "") { |
|
| 141 | + if ($href!=="") { |
|
| 142 | 142 | $this->setProperty("href", $href); |
| 143 | 143 | if (isset($target)) |
| 144 | 144 | $this->setProperty("target", $target); |
@@ -37,8 +37,9 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | private function getPart($part, $index=NULL) { |
| 39 | 39 | if (\array_key_exists($part, $this->content)) { |
| 40 | - if (isset($index)) |
|
| 41 | - return $this->content[$part][$index]; |
|
| 40 | + if (isset($index)) { |
|
| 41 | + return $this->content[$part][$index]; |
|
| 42 | + } |
|
| 42 | 43 | return $this->content[$part]; |
| 43 | 44 | } |
| 44 | 45 | return NULL; |
@@ -140,8 +141,9 @@ discard block |
||
| 140 | 141 | $this->addToProperty("class", "link"); |
| 141 | 142 | if ($href !== "") { |
| 142 | 143 | $this->setProperty("href", $href); |
| 143 | - if (isset($target)) |
|
| 144 | - $this->setProperty("target", $target); |
|
| 144 | + if (isset($target)) { |
|
| 145 | + $this->setProperty("target", $target); |
|
| 146 | + } |
|
| 145 | 147 | } |
| 146 | 148 | return $this; |
| 147 | 149 | } |
@@ -26,23 +26,23 @@ discard block |
||
| 26 | 26 | * @property boolean $_edition |
| 27 | 27 | * @property mixed _modelInstance |
| 28 | 28 | */ |
| 29 | -trait FieldAsTrait{ |
|
| 29 | +trait FieldAsTrait { |
|
| 30 | 30 | |
| 31 | - abstract protected function _getFieldIdentifier($prefix,$name=""); |
|
| 32 | - abstract public function setValueFunction($index,$callback); |
|
| 31 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
| 32 | + abstract public function setValueFunction($index, $callback); |
|
| 33 | 33 | abstract protected function _getFieldName($index); |
| 34 | 34 | abstract protected function _getFieldCaption($index); |
| 35 | - abstract protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL); |
|
| 35 | + abstract protected function _buttonAsSubmit(HtmlButton&$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
| 36 | 36 | |
| 37 | 37 | /** |
| 38 | 38 | * @param HtmlFormField $element |
| 39 | 39 | * @param array $attributes |
| 40 | 40 | */ |
| 41 | - protected function _applyAttributes($element,&$attributes,$index){ |
|
| 42 | - if(isset($attributes["jsCallback"])){ |
|
| 41 | + protected function _applyAttributes($element, &$attributes, $index) { |
|
| 42 | + if (isset($attributes["jsCallback"])) { |
|
| 43 | 43 | $callback=$attributes["jsCallback"]; |
| 44 | - if(\is_callable($callback)){ |
|
| 45 | - $callback($element,$this->_modelInstance,$index); |
|
| 44 | + if (\is_callable($callback)) { |
|
| 45 | + $callback($element, $this->_modelInstance, $index); |
|
| 46 | 46 | unset($attributes["jsCallback"]); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -52,43 +52,43 @@ discard block |
||
| 52 | 52 | $element->fromArray($attributes); |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - private function _getLabelField($caption,$icon=NULL){ |
|
| 56 | - $label=new HtmlLabel($this->_getFieldIdentifier("lbl"),$caption,$icon); |
|
| 55 | + private function _getLabelField($caption, $icon=NULL) { |
|
| 56 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
| 57 | 57 | return $label; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | |
| 61 | - protected function _addRules($element,&$attributes){ |
|
| 62 | - if(isset($attributes["rules"])){ |
|
| 61 | + protected function _addRules($element, &$attributes) { |
|
| 62 | + if (isset($attributes["rules"])) { |
|
| 63 | 63 | $rules=$attributes["rules"]; |
| 64 | - if(\is_array($rules)){ |
|
| 64 | + if (\is_array($rules)) { |
|
| 65 | 65 | $element->addRules($rules); |
| 66 | 66 | } |
| 67 | - else{ |
|
| 67 | + else { |
|
| 68 | 68 | $element->addRule($rules); |
| 69 | 69 | } |
| 70 | 70 | unset($attributes["rules"]); |
| 71 | 71 | } |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - protected function _prepareFormFields(&$field,$name,&$attributes){ |
|
| 74 | + protected function _prepareFormFields(&$field, $name, &$attributes) { |
|
| 75 | 75 | $field->setName($name); |
| 76 | 76 | $this->_addRules($field, $attributes); |
| 77 | 77 | return $field; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - protected function _fieldAs($elementCallback,&$index,$attributes=NULL,$prefix=null){ |
|
| 81 | - $this->setValueFunction($index,function($value,$instance,$index) use (&$attributes,$elementCallback,$prefix){ |
|
| 80 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
| 81 | + $this->setValueFunction($index, function($value, $instance, $index) use (&$attributes, $elementCallback, $prefix){ |
|
| 82 | 82 | $caption=$this->_getFieldCaption($index); |
| 83 | 83 | $name=$this->_getFieldName($index); |
| 84 | - $id=$this->_getFieldIdentifier($prefix,$name); |
|
| 85 | - if(isset($attributes["name"])){ |
|
| 84 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
| 85 | + if (isset($attributes["name"])) { |
|
| 86 | 86 | $name=$attributes["name"]; |
| 87 | 87 | unset($attributes["name"]); |
| 88 | 88 | } |
| 89 | - $element=$elementCallback($id,$name,$value,$caption); |
|
| 90 | - if(\is_array($attributes)){ |
|
| 91 | - $this->_applyAttributes($element, $attributes,$index); |
|
| 89 | + $element=$elementCallback($id, $name, $value, $caption); |
|
| 90 | + if (\is_array($attributes)) { |
|
| 91 | + $this->_applyAttributes($element, $attributes, $index); |
|
| 92 | 92 | } |
| 93 | 93 | $element->setDisabled(!$this->_edition); |
| 94 | 94 | return $element; |
@@ -97,177 +97,177 @@ discard block |
||
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | |
| 100 | - public function fieldAsProgress($index,$label=NULL, $attributes=array()){ |
|
| 101 | - $this->setValueFunction($index,function($value) use($label,$attributes){ |
|
| 102 | - $pb=new HtmlProgress($this->_getFieldIdentifier("pb"),$value,$label,$attributes); |
|
| 100 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
| 101 | + $this->setValueFunction($index, function($value) use($label, $attributes){ |
|
| 102 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
| 103 | 103 | return $pb; |
| 104 | 104 | }); |
| 105 | 105 | return $this; |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | - public function fieldAsRating($index,$max=5, $icon=""){ |
|
| 109 | - $this->setValueFunction($index,function($value) use($max,$icon){ |
|
| 110 | - $rating=new HtmlRating($this->_getFieldIdentifier("rat"),$value,$max,$icon); |
|
| 108 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
| 109 | + $this->setValueFunction($index, function($value) use($max, $icon){ |
|
| 110 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
| 111 | 111 | return $rating; |
| 112 | 112 | }); |
| 113 | 113 | return $this; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - public function fieldAsLabel($index,$icon=NULL){ |
|
| 117 | - $this->setValueFunction($index,function($caption) use($icon){ |
|
| 118 | - $lbl=$this->_getLabelField($caption,$icon); |
|
| 116 | + public function fieldAsLabel($index, $icon=NULL) { |
|
| 117 | + $this->setValueFunction($index, function($caption) use($icon){ |
|
| 118 | + $lbl=$this->_getLabelField($caption, $icon); |
|
| 119 | 119 | return $lbl; |
| 120 | 120 | }); |
| 121 | 121 | return $this; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - public function fieldAsHeader($index,$niveau=1,$icon=NULL,$attributes=NULL){ |
|
| 125 | - return $this->_fieldAs(function($id,$name,$value) use($niveau,$icon){ |
|
| 126 | - $header=new HtmlHeader($id,$niveau,$value); |
|
| 127 | - if(isset($icon)) |
|
| 124 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
| 125 | + return $this->_fieldAs(function($id, $name, $value) use($niveau, $icon){ |
|
| 126 | + $header=new HtmlHeader($id, $niveau, $value); |
|
| 127 | + if (isset($icon)) |
|
| 128 | 128 | $header->asIcon($icon, $value); |
| 129 | 129 | return $header; |
| 130 | - }, $index,$attributes,"header"); |
|
| 130 | + }, $index, $attributes, "header"); |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | |
| 134 | - public function fieldAsImage($index,$size=Size::MINI,$circular=false){ |
|
| 135 | - $this->setValueFunction($index,function($img) use($size,$circular){ |
|
| 136 | - $image=new HtmlImage($this->_getFieldIdentifier("image"),$img);$image->setSize($size);if($circular)$image->setCircular(); |
|
| 134 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
| 135 | + $this->setValueFunction($index, function($img) use($size, $circular){ |
|
| 136 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); $image->setSize($size); if ($circular)$image->setCircular(); |
|
| 137 | 137 | return $image; |
| 138 | 138 | }); |
| 139 | 139 | return $this; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public function fieldAsFlag($index){ |
|
| 143 | - $this->setValueFunction($index,function($flag){ |
|
| 144 | - $flag=new HtmlFlag($this->_getFieldIdentifier("flag"),$flag); |
|
| 142 | + public function fieldAsFlag($index) { |
|
| 143 | + $this->setValueFunction($index, function($flag) { |
|
| 144 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
| 145 | 145 | return $flag; |
| 146 | 146 | }); |
| 147 | 147 | return $this; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - public function fieldAsAvatar($index,$attributes=NULL){ |
|
| 151 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 152 | - $img=new HtmlImage($id,$value); |
|
| 150 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
| 151 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 152 | + $img=new HtmlImage($id, $value); |
|
| 153 | 153 | $img->asAvatar(); |
| 154 | 154 | return $img; |
| 155 | - }, $index,$attributes,"avatar"); |
|
| 155 | + }, $index, $attributes, "avatar"); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | - public function fieldAsRadio($index,$attributes=NULL){ |
|
| 159 | - return $this->_fieldAs(function($id,$name,$value){ |
|
| 160 | - $input= new HtmlRadio($id,$name,$value,$value); |
|
| 158 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
| 159 | + return $this->_fieldAs(function($id, $name, $value) { |
|
| 160 | + $input=new HtmlRadio($id, $name, $value, $value); |
|
| 161 | 161 | return $input; |
| 162 | - }, $index,$attributes,"radio"); |
|
| 162 | + }, $index, $attributes, "radio"); |
|
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - public function fieldAsRadios($index,$elements=[],$attributes=NULL){ |
|
| 166 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($elements){ |
|
| 167 | - return HtmlFormFields::radios($name,$elements,$caption,$value); |
|
| 168 | - }, $index,$attributes,"radios"); |
|
| 165 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
| 166 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements){ |
|
| 167 | + return HtmlFormFields::radios($name, $elements, $caption, $value); |
|
| 168 | + }, $index, $attributes, "radios"); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - public function fieldAsInput($index,$attributes=NULL){ |
|
| 172 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($attributes){ |
|
| 173 | - $input= new HtmlFormInput($id,$caption,"text",$value); |
|
| 171 | + public function fieldAsInput($index, $attributes=NULL) { |
|
| 172 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes){ |
|
| 173 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
| 174 | 174 | return $this->_prepareFormFields($input, $name, $attributes); |
| 175 | - }, $index,$attributes,"input"); |
|
| 175 | + }, $index, $attributes, "input"); |
|
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - public function fieldAsTextarea($index,$attributes=NULL){ |
|
| 179 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 180 | - $textarea=new HtmlFormTextarea($id,$caption,$value); |
|
| 178 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
| 179 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 180 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
| 181 | 181 | $textarea->setName($name); |
| 182 | 182 | return $textarea; |
| 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){ |
|
| 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) { |
|
| 196 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
| 197 | 197 | $input->setChecked(JString::isBooleanTrue($value)); |
| 198 | 198 | $input->setName($name); |
| 199 | 199 | return $input; |
| 200 | - }, $index,$attributes,"ck"); |
|
| 200 | + }, $index, $attributes, "ck"); |
|
| 201 | 201 | } |
| 202 | 202 | |
| 203 | - public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){ |
|
| 204 | - return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple){ |
|
| 205 | - $dd=new HtmlFormDropdown($id,$elements,$caption,$value); |
|
| 206 | - $dd->asSelect($name,$multiple); |
|
| 203 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
| 204 | + return $this->_fieldAs(function($id, $name, $value, $caption) use($elements, $multiple){ |
|
| 205 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value); |
|
| 206 | + $dd->asSelect($name, $multiple); |
|
| 207 | 207 | return $dd; |
| 208 | - }, $index,$attributes,"dd"); |
|
| 208 | + }, $index, $attributes, "dd"); |
|
| 209 | 209 | } |
| 210 | 210 | |
| 211 | - public function fieldAsMessage($index,$attributes=NULL){ |
|
| 212 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 213 | - $mess= new HtmlMessage("message-".$id,$caption); |
|
| 211 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
| 212 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 213 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
| 214 | 214 | $mess->addHeader($value); |
| 215 | 215 | return $mess; |
| 216 | - }, $index,$attributes,"message"); |
|
| 216 | + }, $index, $attributes, "message"); |
|
| 217 | 217 | } |
| 218 | 218 | |
| 219 | - public function fieldAsLink($index,$attributes=NULL){ |
|
| 220 | - return $this->_fieldAs(function($id,$name,$value,$caption){ |
|
| 221 | - $lnk= new HtmlLink("message-".$id,"#",$caption); |
|
| 219 | + public function fieldAsLink($index, $attributes=NULL) { |
|
| 220 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
| 221 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
| 222 | 222 | return $lnk; |
| 223 | - }, $index,$attributes,"link"); |
|
| 223 | + }, $index, $attributes, "link"); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | /**Change fields type |
| 227 | 227 | * @param array $types an array or associative array $type=>$attributes |
| 228 | 228 | */ |
| 229 | - public function fieldsAs(array $types){ |
|
| 229 | + public function fieldsAs(array $types) { |
|
| 230 | 230 | $i=0; |
| 231 | - if(JArray::isAssociative($types)){ |
|
| 232 | - foreach ($types as $type=>$attributes){ |
|
| 233 | - if(\is_int($type)) |
|
| 234 | - $this->fieldAs($i++,$attributes,[]); |
|
| 235 | - else{ |
|
| 236 | - $type=preg_replace('/\d/', '', $type ); |
|
| 237 | - $this->fieldAs($i++,$type,$attributes); |
|
| 231 | + if (JArray::isAssociative($types)) { |
|
| 232 | + foreach ($types as $type=>$attributes) { |
|
| 233 | + if (\is_int($type)) |
|
| 234 | + $this->fieldAs($i++, $attributes, []); |
|
| 235 | + else { |
|
| 236 | + $type=preg_replace('/\d/', '', $type); |
|
| 237 | + $this->fieldAs($i++, $type, $attributes); |
|
| 238 | 238 | } |
| 239 | 239 | } |
| 240 | - }else{ |
|
| 241 | - foreach ($types as $type){ |
|
| 242 | - $this->fieldAs($i++,$type); |
|
| 240 | + } else { |
|
| 241 | + foreach ($types as $type) { |
|
| 242 | + $this->fieldAs($i++, $type); |
|
| 243 | 243 | } |
| 244 | 244 | } |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | - public function fieldAs($index,$type,$attributes=NULL){ |
|
| 247 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
| 248 | 248 | $method="fieldAs".\ucfirst($type); |
| 249 | - if(\method_exists($this, $method)){ |
|
| 250 | - if(!\is_array($attributes)){ |
|
| 249 | + if (\method_exists($this, $method)) { |
|
| 250 | + if (!\is_array($attributes)) { |
|
| 251 | 251 | $attributes=[$index]; |
| 252 | - }else{ |
|
| 252 | + } else { |
|
| 253 | 253 | \array_unshift($attributes, $index); |
| 254 | 254 | } |
| 255 | - \call_user_func_array([$this,$method], $attributes); |
|
| 255 | + \call_user_func_array([$this, $method], $attributes); |
|
| 256 | 256 | } |
| 257 | 257 | } |
| 258 | 258 | |
| 259 | - public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){ |
|
| 260 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){ |
|
| 261 | - $button=new HtmlButton($id,$caption,$cssStyle); |
|
| 262 | - $this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]); |
|
| 259 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
| 260 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes){ |
|
| 261 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
| 262 | + $this->_buttonAsSubmit($button, "click", $url, $responseElement, @$attributes["ajax"]); |
|
| 263 | 263 | return $button; |
| 264 | - }, $index,$attributes,"submit"); |
|
| 264 | + }, $index, $attributes, "submit"); |
|
| 265 | 265 | } |
| 266 | 266 | |
| 267 | - public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){ |
|
| 268 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
| 269 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 267 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 268 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
| 269 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 270 | 270 | return $button; |
| 271 | - }, $index,$attributes,"button"); |
|
| 271 | + }, $index, $attributes, "button"); |
|
| 272 | 272 | } |
| 273 | 273 | } |
| 274 | 274 | \ No newline at end of file |
@@ -19,80 +19,80 @@ discard block |
||
| 19 | 19 | class DataForm extends Widget { |
| 20 | 20 | |
| 21 | 21 | public function __construct($identifier, $modelInstance=NULL) { |
| 22 | - parent::__construct($identifier, null,$modelInstance); |
|
| 22 | + parent::__construct($identifier, null, $modelInstance); |
|
| 23 | 23 | $this->_form=new HtmlForm($identifier); |
| 24 | 24 | $this->_init(new FormInstanceViewer($identifier), "form", $this->_form, true); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - protected function _getFieldIdentifier($prefix,$name=""){ |
|
| 27 | + protected function _getFieldIdentifier($prefix, $name="") { |
|
| 28 | 28 | return $this->identifier."-{$name}-".$this->_instanceViewer->getIdentifier(); |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 32 | - if(!$this->_generated){ |
|
| 31 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 32 | + if (!$this->_generated) { |
|
| 33 | 33 | $this->_instanceViewer->setInstance($this->_modelInstance); |
| 34 | 34 | |
| 35 | 35 | $form=$this->content["form"]; |
| 36 | 36 | $this->_generateContent($form); |
| 37 | 37 | |
| 38 | - if(isset($this->_toolbar)){ |
|
| 38 | + if (isset($this->_toolbar)) { |
|
| 39 | 39 | $this->_setToolbarPosition($form); |
| 40 | 40 | } |
| 41 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"form",PositionInTable::AFTERTABLE]); |
|
| 41 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "form", PositionInTable::AFTERTABLE]); |
|
| 42 | 42 | $this->_generated=true; |
| 43 | 43 | } |
| 44 | - return parent::compile($js,$view); |
|
| 44 | + return parent::compile($js, $view); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * @param HtmlForm $form |
| 49 | 49 | */ |
| 50 | - protected function _generateContent($form){ |
|
| 51 | - $values= $this->_instanceViewer->getValues(); |
|
| 50 | + protected function _generateContent($form) { |
|
| 51 | + $values=$this->_instanceViewer->getValues(); |
|
| 52 | 52 | $count=$this->_instanceViewer->count(); |
| 53 | 53 | $separators=$this->_instanceViewer->getSeparators(); |
| 54 | 54 | $headers=$this->_instanceViewer->getHeaders(); |
| 55 | 55 | $wrappers=$this->_instanceViewer->getWrappers(); |
| 56 | 56 | \sort($separators); |
| 57 | 57 | $size=\sizeof($separators); |
| 58 | - if($size===1){ |
|
| 59 | - foreach ($values as $v){ |
|
| 58 | + if ($size===1) { |
|
| 59 | + foreach ($values as $v) { |
|
| 60 | 60 | $form->addField($v); |
| 61 | 61 | } |
| 62 | - }else{ |
|
| 62 | + } else { |
|
| 63 | 63 | $separators[]=$count; |
| 64 | - for($i=0;$i<$size;$i++){ |
|
| 64 | + for ($i=0; $i<$size; $i++) { |
|
| 65 | 65 | $this->_generateFields($form, $values, $headers, $separators[$i], $separators[$i+1], $wrappers); |
| 66 | 66 | } |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - protected function _generateFields($form,$values,$headers,$sepFirst,$sepLast,$wrappers){ |
|
| 70 | + protected function _generateFields($form, $values, $headers, $sepFirst, $sepLast, $wrappers) { |
|
| 71 | 71 | $wrapper=null; |
| 72 | - $fields=\array_slice($values, $sepFirst+1,$sepLast-$sepFirst); |
|
| 73 | - if(isset($headers[$sepFirst+1])) |
|
| 74 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 75 | - if(isset($wrappers[$sepFirst+1])){ |
|
| 72 | + $fields=\array_slice($values, $sepFirst+1, $sepLast-$sepFirst); |
|
| 73 | + if (isset($headers[$sepFirst+1])) |
|
| 74 | + $form->addHeader($headers[$sepFirst+1], 4, true); |
|
| 75 | + if (isset($wrappers[$sepFirst+1])) { |
|
| 76 | 76 | $wrapper=$wrappers[$sepFirst+1]; |
| 77 | 77 | } |
| 78 | - if(\sizeof($fields)===1){ |
|
| 78 | + if (\sizeof($fields)===1) { |
|
| 79 | 79 | $added=$form->addField($fields[0]); |
| 80 | - }elseif(\sizeof($fields)>1){ |
|
| 80 | + }elseif (\sizeof($fields)>1) { |
|
| 81 | 81 | $added=$form->addFields($fields); |
| 82 | 82 | } |
| 83 | - if(isset($wrapper)) |
|
| 84 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
| 83 | + if (isset($wrapper)) |
|
| 84 | + $added->wrap($wrapper[0], $wrapper[1]); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | /** |
| 88 | 88 | * {@inheritDoc} |
| 89 | 89 | * @see \Ajax\common\Widget::getForm() |
| 90 | 90 | */ |
| 91 | - public function getForm(){ |
|
| 91 | + public function getForm() { |
|
| 92 | 92 | return $this->content["form"]; |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function addSeparatorAfter($fieldNum){ |
|
| 95 | + public function addSeparatorAfter($fieldNum) { |
|
| 96 | 96 | $fieldNum=$this->_getIndex($fieldNum); |
| 97 | 97 | $this->_instanceViewer->addSeparatorAfter($fieldNum); |
| 98 | 98 | return $this; |
@@ -107,12 +107,12 @@ discard block |
||
| 107 | 107 | return $this; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | - public function fieldAsReset($index,$cssStyle=NULL,$attributes=NULL){ |
|
| 111 | - return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){ |
|
| 112 | - $button=new HtmlButton($id,$value,$cssStyle); |
|
| 110 | + public function fieldAsReset($index, $cssStyle=NULL, $attributes=NULL) { |
|
| 111 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle){ |
|
| 112 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
| 113 | 113 | $button->setProperty("type", "reset"); |
| 114 | 114 | return $button; |
| 115 | - }, $index,$attributes); |
|
| 115 | + }, $index, $attributes); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | 118 | /** |
@@ -131,19 +131,19 @@ discard block |
||
| 131 | 131 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - public function addDividerBefore($index,$title){ |
|
| 134 | + public function addDividerBefore($index, $title) { |
|
| 135 | 135 | $index=$this->_getIndex($index); |
| 136 | 136 | $this->_instanceViewer->addHeaderDividerBefore($index, $title); |
| 137 | 137 | return $this; |
| 138 | 138 | } |
| 139 | 139 | |
| 140 | - public function addWrapper($index,$contentBefore,$contentAfter=null){ |
|
| 140 | + public function addWrapper($index, $contentBefore, $contentAfter=null) { |
|
| 141 | 141 | $index=$this->_getIndex($index); |
| 142 | - $this->_instanceViewer->addWrapper($index, $contentBefore,$contentAfter); |
|
| 142 | + $this->_instanceViewer->addWrapper($index, $contentBefore, $contentAfter); |
|
| 143 | 143 | return $this; |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | - public function run(JsUtils $js){ |
|
| 146 | + public function run(JsUtils $js) { |
|
| 147 | 147 | return parent::run($js); |
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | \ No newline at end of file |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | foreach ($values as $v){ |
| 60 | 60 | $form->addField($v); |
| 61 | 61 | } |
| 62 | - }else{ |
|
| 62 | + } else{ |
|
| 63 | 63 | $separators[]=$count; |
| 64 | 64 | for($i=0;$i<$size;$i++){ |
| 65 | 65 | $this->_generateFields($form, $values, $headers, $separators[$i], $separators[$i+1], $wrappers); |
@@ -70,18 +70,20 @@ discard block |
||
| 70 | 70 | protected function _generateFields($form,$values,$headers,$sepFirst,$sepLast,$wrappers){ |
| 71 | 71 | $wrapper=null; |
| 72 | 72 | $fields=\array_slice($values, $sepFirst+1,$sepLast-$sepFirst); |
| 73 | - if(isset($headers[$sepFirst+1])) |
|
| 74 | - $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 73 | + if(isset($headers[$sepFirst+1])) { |
|
| 74 | + $form->addHeader($headers[$sepFirst+1],4,true); |
|
| 75 | + } |
|
| 75 | 76 | if(isset($wrappers[$sepFirst+1])){ |
| 76 | 77 | $wrapper=$wrappers[$sepFirst+1]; |
| 77 | 78 | } |
| 78 | 79 | if(\sizeof($fields)===1){ |
| 79 | 80 | $added=$form->addField($fields[0]); |
| 80 | - }elseif(\sizeof($fields)>1){ |
|
| 81 | + } elseif(\sizeof($fields)>1){ |
|
| 81 | 82 | $added=$form->addFields($fields); |
| 82 | 83 | } |
| 83 | - if(isset($wrapper)) |
|
| 84 | - $added->wrap($wrapper[0],$wrapper[1]); |
|
| 84 | + if(isset($wrapper)) { |
|
| 85 | + $added->wrap($wrapper[0],$wrapper[1]); |
|
| 86 | + } |
|
| 85 | 87 | } |
| 86 | 88 | |
| 87 | 89 | /** |