@@ -20,8 +20,9 @@ discard block |
||
| 20 | 20 | $this->widgetIdentifier=$identifier; |
| 21 | 21 | $this->values=[]; |
| 22 | 22 | $this->afterCompile=[]; |
| 23 | - if(isset($instance)) |
|
| 24 | - $this->setInstance($instance); |
|
| 23 | + if(isset($instance)) { |
|
| 24 | + $this->setInstance($instance); |
|
| 25 | + } |
|
| 25 | 26 | $this->setCaptions($captions); |
| 26 | 27 | $this->captionCallback=NULL; |
| 27 | 28 | } |
@@ -38,8 +39,9 @@ discard block |
||
| 38 | 39 | |
| 39 | 40 | public function getIdentifier(){ |
| 40 | 41 | $value=self::$index; |
| 41 | - if(isset($this->values["identifier"])) |
|
| 42 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 42 | + if(isset($this->values["identifier"])) { |
|
| 43 | + $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 44 | + } |
|
| 43 | 45 | return $value; |
| 44 | 46 | } |
| 45 | 47 | |
@@ -62,19 +64,19 @@ discard block |
||
| 62 | 64 | $value=$property->getValue($this->instance); |
| 63 | 65 | if(isset($this->values[$index])){ |
| 64 | 66 | $value= $this->values[$index]($value,$this->instance,$index); |
| 65 | - }else{ |
|
| 67 | + } else{ |
|
| 66 | 68 | $value=$this->_getDefaultValue($property->getName(),$value, $index); |
| 67 | 69 | } |
| 68 | - }else{ |
|
| 69 | - if(\is_callable($property)) |
|
| 70 | - $value=$property($this->instance); |
|
| 71 | - elseif(\is_array($property)){ |
|
| 70 | + } else{ |
|
| 71 | + if(\is_callable($property)) { |
|
| 72 | + $value=$property($this->instance); |
|
| 73 | + } elseif(\is_array($property)){ |
|
| 72 | 74 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
| 73 | 75 | $value=\implode("", $values); |
| 74 | - }else{ |
|
| 76 | + } else{ |
|
| 75 | 77 | if(isset($this->values[$index])){ |
| 76 | 78 | $value= $this->values[$index]($property,$this->instance,$index); |
| 77 | - }else{ |
|
| 79 | + } else{ |
|
| 78 | 80 | $value=$property; |
| 79 | 81 | } |
| 80 | 82 | } |
@@ -97,10 +99,10 @@ discard block |
||
| 97 | 99 | if(isset($vb[$index])){ |
| 98 | 100 | if(\is_array($vb[$index])){ |
| 99 | 101 | $this->visibleProperties[$index][]=$field; |
| 100 | - }else{ |
|
| 102 | + } else{ |
|
| 101 | 103 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
| 102 | 104 | } |
| 103 | - }else{ |
|
| 105 | + } else{ |
|
| 104 | 106 | return $this->insertField($index, $field); |
| 105 | 107 | } |
| 106 | 108 | return $this; |
@@ -136,7 +138,7 @@ discard block |
||
| 136 | 138 | $this->reflect=new \ReflectionClass($instance); |
| 137 | 139 | if(\sizeof($this->visibleProperties)===0){ |
| 138 | 140 | $this->properties=$this->getDefaultProperties(); |
| 139 | - }else{ |
|
| 141 | + } else{ |
|
| 140 | 142 | foreach ($this->visibleProperties as $property){ |
| 141 | 143 | $this->setInstanceProperty($property); |
| 142 | 144 | } |
@@ -147,22 +149,23 @@ discard block |
||
| 147 | 149 | private function setInstanceProperty($property){ |
| 148 | 150 | if(\is_callable($property)){ |
| 149 | 151 | $this->properties[]=$property; |
| 150 | - }elseif(\is_string($property)){ |
|
| 152 | + } elseif(\is_string($property)){ |
|
| 151 | 153 | try{ |
| 152 | 154 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 153 | 155 | $rProperty=$this->reflect->getProperty($property); |
| 154 | 156 | $this->properties[]=$rProperty; |
| 155 | - }catch(\Exception $e){ |
|
| 157 | + } catch(\Exception $e){ |
|
| 156 | 158 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 157 | 159 | $this->properties[]=$property; |
| 158 | 160 | } |
| 159 | - }elseif(\is_int($property)){ |
|
| 161 | + } elseif(\is_int($property)){ |
|
| 160 | 162 | $props=$this->getDefaultProperties(); |
| 161 | - if(isset($props[$property])) |
|
| 162 | - $this->properties[]=$props[$property]; |
|
| 163 | - else |
|
| 164 | - $this->properties[]=$property; |
|
| 165 | - }else{ |
|
| 163 | + if(isset($props[$property])) { |
|
| 164 | + $this->properties[]=$props[$property]; |
|
| 165 | + } else { |
|
| 166 | + $this->properties[]=$property; |
|
| 167 | + } |
|
| 168 | + } else{ |
|
| 166 | 169 | $this->properties[]=$property; |
| 167 | 170 | } |
| 168 | 171 | } |
@@ -206,12 +209,13 @@ discard block |
||
| 206 | 209 | if(isset($this->captions[$index])){ |
| 207 | 210 | return $this->captions[$index]; |
| 208 | 211 | } |
| 209 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 210 | - return $this->properties[$index]->getName(); |
|
| 211 | - elseif(\is_callable($this->properties[$index])) |
|
| 212 | - return ""; |
|
| 213 | - else |
|
| 214 | - return $this->properties[$index]; |
|
| 212 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
| 213 | + return $this->properties[$index]->getName(); |
|
| 214 | + } elseif(\is_callable($this->properties[$index])) { |
|
| 215 | + return ""; |
|
| 216 | + } else { |
|
| 217 | + return $this->properties[$index]; |
|
| 218 | + } |
|
| 215 | 219 | } |
| 216 | 220 | |
| 217 | 221 | public function getCaptions(){ |
@@ -220,7 +224,7 @@ discard block |
||
| 220 | 224 | for($i=\sizeof($captions);$i<$this->count();$i++){ |
| 221 | 225 | $captions[]=""; |
| 222 | 226 | } |
| 223 | - }else{ |
|
| 227 | + } else{ |
|
| 224 | 228 | $captions=[]; |
| 225 | 229 | $index=0; |
| 226 | 230 | $count=$this->count(); |
@@ -236,8 +240,9 @@ discard block |
||
| 236 | 240 | } |
| 237 | 241 | |
| 238 | 242 | public function setCaption($index,$caption){ |
| 239 | - if(isset($this->captions)===false) |
|
| 240 | - $this->captions=[]; |
|
| 243 | + if(isset($this->captions)===false) { |
|
| 244 | + $this->captions=[]; |
|
| 245 | + } |
|
| 241 | 246 | $this->captions[$index]=$caption; |
| 242 | 247 | return $this; |
| 243 | 248 | } |
@@ -17,165 +17,165 @@ discard block |
||
| 17 | 17 | |
| 18 | 18 | public static $index=0; |
| 19 | 19 | |
| 20 | - public function __construct($identifier,$instance=NULL,$captions=NULL){ |
|
| 20 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
| 21 | 21 | $this->widgetIdentifier=$identifier; |
| 22 | 22 | $this->values=[]; |
| 23 | 23 | $this->afterCompile=[]; |
| 24 | - if(isset($instance)) |
|
| 24 | + if (isset($instance)) |
|
| 25 | 25 | $this->setInstance($instance); |
| 26 | 26 | $this->setCaptions($captions); |
| 27 | 27 | $this->captionCallback=NULL; |
| 28 | - $this->defaultValueFunction=function($name,$value){return $value;}; |
|
| 28 | + $this->defaultValueFunction=function($name, $value) {return $value; }; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function getValues(){ |
|
| 31 | + public function getValues() { |
|
| 32 | 32 | $values=[]; |
| 33 | 33 | $index=0; |
| 34 | 34 | $count=$this->count(); |
| 35 | - while($index<$count){ |
|
| 35 | + while ($index<$count) { |
|
| 36 | 36 | $values[]=$this->getValue($index++); |
| 37 | 37 | } |
| 38 | 38 | return $values; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function getIdentifier(){ |
|
| 41 | + public function getIdentifier() { |
|
| 42 | 42 | $value=self::$index; |
| 43 | - if(isset($this->values["identifier"])) |
|
| 44 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 43 | + if (isset($this->values["identifier"])) |
|
| 44 | + $value=$this->values["identifier"](self::$index, $this->instance); |
|
| 45 | 45 | return $value; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public function getValue($index){ |
|
| 48 | + public function getValue($index) { |
|
| 49 | 49 | $property=$this->properties[$index]; |
| 50 | 50 | return $this->_getValue($property, $index); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - protected function _beforeAddProperty($index,&$field){ |
|
| 53 | + protected function _beforeAddProperty($index, &$field) { |
|
| 54 | 54 | |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - protected function _getDefaultValue($name,$value,$index){ |
|
| 57 | + protected function _getDefaultValue($name, $value, $index) { |
|
| 58 | 58 | $func=$this->defaultValueFunction; |
| 59 | - return $func($name,$value,$index); |
|
| 59 | + return $func($name, $value, $index); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - protected function _getValue($property,$index){ |
|
| 63 | - if($property instanceof \ReflectionProperty){ |
|
| 62 | + protected function _getValue($property, $index) { |
|
| 63 | + if ($property instanceof \ReflectionProperty) { |
|
| 64 | 64 | $property->setAccessible(true); |
| 65 | 65 | $value=$property->getValue($this->instance); |
| 66 | - if(isset($this->values[$index])){ |
|
| 67 | - $value= $this->values[$index]($value,$this->instance,$index); |
|
| 68 | - }else{ |
|
| 69 | - $value=$this->_getDefaultValue($property->getName(),$value, $index); |
|
| 66 | + if (isset($this->values[$index])) { |
|
| 67 | + $value=$this->values[$index]($value, $this->instance, $index); |
|
| 68 | + } else { |
|
| 69 | + $value=$this->_getDefaultValue($property->getName(), $value, $index); |
|
| 70 | 70 | } |
| 71 | - }else{ |
|
| 72 | - if(\is_callable($property)) |
|
| 71 | + } else { |
|
| 72 | + if (\is_callable($property)) |
|
| 73 | 73 | $value=$property($this->instance); |
| 74 | - elseif(\is_array($property)){ |
|
| 75 | - $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
|
| 74 | + elseif (\is_array($property)) { |
|
| 75 | + $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index); }, $property); |
|
| 76 | 76 | $value=\implode("", $values); |
| 77 | - }else{ |
|
| 78 | - if(isset($this->values[$index])){ |
|
| 79 | - $value= $this->values[$index]($property,$this->instance,$index); |
|
| 80 | - }else{ |
|
| 77 | + } else { |
|
| 78 | + if (isset($this->values[$index])) { |
|
| 79 | + $value=$this->values[$index]($property, $this->instance, $index); |
|
| 80 | + } else { |
|
| 81 | 81 | $value=$property; |
| 82 | 82 | } |
| 83 | 83 | } |
| 84 | 84 | } |
| 85 | - if(isset($this->afterCompile[$index])){ |
|
| 86 | - if(\is_callable($this->afterCompile[$index])){ |
|
| 87 | - $this->afterCompile[$index]($value,$this->instance,$index); |
|
| 85 | + if (isset($this->afterCompile[$index])) { |
|
| 86 | + if (\is_callable($this->afterCompile[$index])) { |
|
| 87 | + $this->afterCompile[$index]($value, $this->instance, $index); |
|
| 88 | 88 | } |
| 89 | 89 | } |
| 90 | 90 | return $value; |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function insertField($index,$field){ |
|
| 94 | - array_splice( $this->visibleProperties, $index, 0, $field ); |
|
| 93 | + public function insertField($index, $field) { |
|
| 94 | + array_splice($this->visibleProperties, $index, 0, $field); |
|
| 95 | 95 | return $this; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - public function insertInField($index,$field){ |
|
| 98 | + public function insertInField($index, $field) { |
|
| 99 | 99 | $vb=$this->visibleProperties; |
| 100 | - if(isset($vb[$index])){ |
|
| 101 | - if(\is_array($vb[$index])){ |
|
| 100 | + if (isset($vb[$index])) { |
|
| 101 | + if (\is_array($vb[$index])) { |
|
| 102 | 102 | $this->visibleProperties[$index][]=$field; |
| 103 | - }else{ |
|
| 104 | - $this->visibleProperties[$index]=[$vb[$index],$field]; |
|
| 103 | + } else { |
|
| 104 | + $this->visibleProperties[$index]=[$vb[$index], $field]; |
|
| 105 | 105 | } |
| 106 | - }else{ |
|
| 106 | + } else { |
|
| 107 | 107 | return $this->insertField($index, $field); |
| 108 | 108 | } |
| 109 | 109 | return $this; |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - public function addField($field){ |
|
| 112 | + public function addField($field) { |
|
| 113 | 113 | $this->visibleProperties[]=$field; |
| 114 | 114 | return $this; |
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - public function count(){ |
|
| 117 | + public function count() { |
|
| 118 | 118 | return \sizeof($this->properties); |
| 119 | 119 | } |
| 120 | 120 | |
| 121 | - public function visiblePropertiesCount(){ |
|
| 121 | + public function visiblePropertiesCount() { |
|
| 122 | 122 | return \sizeof($this->visibleProperties); |
| 123 | 123 | } |
| 124 | 124 | |
| 125 | - public function getProperty($index){ |
|
| 125 | + public function getProperty($index) { |
|
| 126 | 126 | return $this->properties[$index]; |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - protected function showableProperty(\ReflectionProperty $rProperty){ |
|
| 130 | - return JString::startswith($rProperty->getName(),"_")===false; |
|
| 129 | + protected function showableProperty(\ReflectionProperty $rProperty) { |
|
| 130 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public function setInstance($instance) { |
| 134 | - if(\is_string($instance)){ |
|
| 134 | + if (\is_string($instance)) { |
|
| 135 | 135 | $instance=new $instance(); |
| 136 | 136 | } |
| 137 | 137 | $this->instance=$instance; |
| 138 | 138 | $this->properties=[]; |
| 139 | 139 | $this->reflect=new \ReflectionClass($instance); |
| 140 | - if(\sizeof($this->visibleProperties)===0){ |
|
| 140 | + if (\sizeof($this->visibleProperties)===0) { |
|
| 141 | 141 | $this->properties=$this->getDefaultProperties(); |
| 142 | - }else{ |
|
| 143 | - foreach ($this->visibleProperties as $property){ |
|
| 142 | + } else { |
|
| 143 | + foreach ($this->visibleProperties as $property) { |
|
| 144 | 144 | $this->setInstanceProperty($property); |
| 145 | 145 | } |
| 146 | 146 | } |
| 147 | 147 | return $this; |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | - private function setInstanceProperty($property){ |
|
| 151 | - if(\is_callable($property)){ |
|
| 150 | + private function setInstanceProperty($property) { |
|
| 151 | + if (\is_callable($property)) { |
|
| 152 | 152 | $this->properties[]=$property; |
| 153 | - }elseif(\is_string($property)){ |
|
| 154 | - try{ |
|
| 153 | + }elseif (\is_string($property)) { |
|
| 154 | + try { |
|
| 155 | 155 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 156 | 156 | $rProperty=$this->reflect->getProperty($property); |
| 157 | 157 | $this->properties[]=$rProperty; |
| 158 | - }catch(\Exception $e){ |
|
| 158 | + }catch (\Exception $e) { |
|
| 159 | 159 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 160 | 160 | $this->properties[]=$property; |
| 161 | 161 | } |
| 162 | - }elseif(\is_int($property)){ |
|
| 162 | + }elseif (\is_int($property)) { |
|
| 163 | 163 | $props=$this->getDefaultProperties(); |
| 164 | - if(isset($props[$property])) |
|
| 164 | + if (isset($props[$property])) |
|
| 165 | 165 | $this->properties[]=$props[$property]; |
| 166 | 166 | else |
| 167 | 167 | $this->properties[]=$property; |
| 168 | - }else{ |
|
| 168 | + } else { |
|
| 169 | 169 | $this->properties[]=$property; |
| 170 | 170 | } |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - protected function getDefaultProperties(){ |
|
| 173 | + protected function getDefaultProperties() { |
|
| 174 | 174 | $result=[]; |
| 175 | 175 | $properties=$this->reflect->getProperties(); |
| 176 | - foreach ($properties as $property){ |
|
| 176 | + foreach ($properties as $property) { |
|
| 177 | 177 | $showable=$this->showableProperty($property); |
| 178 | - if($showable!==false){ |
|
| 178 | + if ($showable!==false) { |
|
| 179 | 179 | $result[]=$property; |
| 180 | 180 | } |
| 181 | 181 | } |
@@ -187,12 +187,12 @@ discard block |
||
| 187 | 187 | return $this; |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - public function setValueFunction($index,$callback){ |
|
| 190 | + public function setValueFunction($index, $callback) { |
|
| 191 | 191 | $this->values[$index]=$callback; |
| 192 | 192 | return $this; |
| 193 | 193 | } |
| 194 | 194 | |
| 195 | - public function setIdentifierFunction($callback){ |
|
| 195 | + public function setIdentifierFunction($callback) { |
|
| 196 | 196 | $this->values["identifier"]=$callback; |
| 197 | 197 | return $this; |
| 198 | 198 | } |
@@ -205,41 +205,41 @@ discard block |
||
| 205 | 205 | return $this->properties; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - public function getCaption($index){ |
|
| 209 | - if(isset($this->captions[$index])){ |
|
| 208 | + public function getCaption($index) { |
|
| 209 | + if (isset($this->captions[$index])) { |
|
| 210 | 210 | return $this->captions[$index]; |
| 211 | 211 | } |
| 212 | - if($this->properties[$index] instanceof \ReflectionProperty) |
|
| 212 | + if ($this->properties[$index] instanceof \ReflectionProperty) |
|
| 213 | 213 | return $this->properties[$index]->getName(); |
| 214 | - elseif(\is_callable($this->properties[$index])) |
|
| 214 | + elseif (\is_callable($this->properties[$index])) |
|
| 215 | 215 | return ""; |
| 216 | 216 | else |
| 217 | 217 | return $this->properties[$index]; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - public function getCaptions(){ |
|
| 221 | - if(isset($this->captions)){ |
|
| 222 | - $captions= $this->captions; |
|
| 223 | - for($i=\sizeof($captions);$i<$this->count();$i++){ |
|
| 220 | + public function getCaptions() { |
|
| 221 | + if (isset($this->captions)) { |
|
| 222 | + $captions=$this->captions; |
|
| 223 | + for ($i=\sizeof($captions); $i<$this->count(); $i++) { |
|
| 224 | 224 | $captions[]=""; |
| 225 | 225 | } |
| 226 | - }else{ |
|
| 226 | + } else { |
|
| 227 | 227 | $captions=[]; |
| 228 | 228 | $index=0; |
| 229 | 229 | $count=$this->count(); |
| 230 | - while($index<$count){ |
|
| 230 | + while ($index<$count) { |
|
| 231 | 231 | $captions[]=$this->getCaption($index++); |
| 232 | 232 | } |
| 233 | 233 | } |
| 234 | - if(isset($this->captionCallback) && \is_callable($this->captionCallback)){ |
|
| 234 | + if (isset($this->captionCallback) && \is_callable($this->captionCallback)) { |
|
| 235 | 235 | $callback=$this->captionCallback; |
| 236 | - $callback($captions,$this->instance); |
|
| 236 | + $callback($captions, $this->instance); |
|
| 237 | 237 | } |
| 238 | 238 | return $captions; |
| 239 | 239 | } |
| 240 | 240 | |
| 241 | - public function setCaption($index,$caption){ |
|
| 242 | - if(isset($this->captions)===false) |
|
| 241 | + public function setCaption($index, $caption) { |
|
| 242 | + if (isset($this->captions)===false) |
|
| 243 | 243 | $this->captions=[]; |
| 244 | 244 | $this->captions[$index]=$caption; |
| 245 | 245 | return $this; |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | * @param callable $callback function called after the field compilation |
| 258 | 258 | * @return \Ajax\semantic\widgets\datatable\InstanceViewer |
| 259 | 259 | */ |
| 260 | - public function afterCompile($index,$callback){ |
|
| 260 | + public function afterCompile($index, $callback) { |
|
| 261 | 261 | $this->afterCompile[$index]=$callback; |
| 262 | 262 | return $this; |
| 263 | 263 | } |
@@ -13,6 +13,9 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class HtmlIconGroups extends HtmlSemCollection { |
| 15 | 15 | |
| 16 | + /** |
|
| 17 | + * @param string $identifier |
|
| 18 | + */ |
|
| 16 | 19 | public function __construct($identifier, $icons=array(), $size="") { |
| 17 | 20 | parent::__construct($identifier, "i", "icons"); |
| 18 | 21 | $this->addItems($icons); |
@@ -14,8 +14,9 @@ |
||
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | public function asAvatar($caption=NULL) { |
| 17 | - if (isset($caption)) |
|
| 18 | - $this->wrap("", $caption); |
|
| 17 | + if (isset($caption)) { |
|
| 18 | + $this->wrap("", $caption); |
|
| 19 | + } |
|
| 19 | 20 | return $this->addToProperty("class", "avatar"); |
| 20 | 21 | } |
| 21 | 22 | |
@@ -4,7 +4,7 @@ |
||
| 4 | 4 | |
| 5 | 5 | trait HtmlLinkTrait { |
| 6 | 6 | |
| 7 | - abstract public function setProperty($name,$value); |
|
| 7 | + abstract public function setProperty($name, $value); |
|
| 8 | 8 | abstract public function getProperty($name); |
| 9 | 9 | |
| 10 | 10 | public function setHref($value) { |
@@ -14,8 +14,8 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | public function setAttachment($toElement, $side=Side::BOTH) { |
| 16 | 16 | if (isset($toElement)) { |
| 17 | - $toElement->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 17 | + $toElement->addToPropertyCtrl("class", "attached", array("attached")); |
|
| 18 | 18 | } |
| 19 | - return $this->addToPropertyCtrl("class", $side . " attached", Side::getConstantValues("attached")); |
|
| 19 | + return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached")); |
|
| 20 | 20 | } |
| 21 | 21 | } |
| 22 | 22 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | trait LabeledIconTrait { |
| 14 | 14 | |
| 15 | 15 | abstract public function addToProperty($name, $value, $separator=" "); |
| 16 | - abstract public function addContent($content,$before=false); |
|
| 16 | + abstract public function addContent($content, $before=false); |
|
| 17 | 17 | |
| 18 | 18 | /** |
| 19 | 19 | * Adds an icon before or after |
@@ -22,17 +22,17 @@ discard block |
||
| 22 | 22 | * @param boolean $labeled |
| 23 | 23 | * @return \Ajax\semantic\html\elements\HtmlIcon |
| 24 | 24 | */ |
| 25 | - public function addIcon($icon,$before=true,$labeled=false){ |
|
| 25 | + public function addIcon($icon, $before=true, $labeled=false) { |
|
| 26 | 26 | $iconO=$icon; |
| 27 | - if(\is_string($icon)){ |
|
| 27 | + if (\is_string($icon)) { |
|
| 28 | 28 | $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
| 29 | 29 | } |
| 30 | - if($labeled!==false){ |
|
| 31 | - $direction=($before===true)?Direction::LEFT:Direction::RIGHT; |
|
| 30 | + if ($labeled!==false) { |
|
| 31 | + $direction=($before===true) ? Direction::LEFT : Direction::RIGHT; |
|
| 32 | 32 | $this->addToProperty("class", $direction." labeled icon"); |
| 33 | 33 | $this->tagName="div"; |
| 34 | 34 | } |
| 35 | - $this->addContent($iconO,$before); |
|
| 35 | + $this->addContent($iconO, $before); |
|
| 36 | 36 | return $iconO; |
| 37 | 37 | } |
| 38 | 38 | } |
| 39 | 39 | \ No newline at end of file |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function setContent($content) { |
| 21 | - $this->content=new HtmlSemDoubleElement("content-" . $this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content)); |
|
| 21 | + $this->content=new HtmlSemDoubleElement("content-".$this->identifier, "div", "content", new HtmlSemDoubleElement("", "div", "center", $content)); |
|
| 22 | 22 | return $this; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function asIcon($icon, $title, $subHeader=NULL) { |
| 26 | - $header=new HtmlHeader("header-" . $this->identifier); |
|
| 26 | + $header=new HtmlHeader("header-".$this->identifier); |
|
| 27 | 27 | $header->asIcon($icon, $title, $subHeader); |
| 28 | - if ($this->_inverted === false) |
|
| 28 | + if ($this->_inverted===false) |
|
| 29 | 29 | $header->setInverted(); |
| 30 | 30 | return $this->setContent($header); |
| 31 | 31 | } |
@@ -42,13 +42,13 @@ discard block |
||
| 42 | 42 | |
| 43 | 43 | public function run(JsUtils $js) { |
| 44 | 44 | if ($this->_container instanceof HtmlSingleElement) |
| 45 | - $this->_bsComponent=$js->semantic()->dimmer("#" . $this->_container->getIdentifier(), $this->_params); |
|
| 45 | + $this->_bsComponent=$js->semantic()->dimmer("#".$this->_container->getIdentifier(), $this->_params); |
|
| 46 | 46 | return parent::run($js); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function jsShow() { |
| 50 | 50 | if (isset($this->_container)) |
| 51 | - return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");'; |
|
| 51 | + return '$("#.'.$this->_container->getIdentifier().').dimmer("show");'; |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | public function setBlurring() { |
@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | public function asIcon($icon, $title, $subHeader=NULL) { |
| 26 | 26 | $header=new HtmlHeader("header-" . $this->identifier); |
| 27 | 27 | $header->asIcon($icon, $title, $subHeader); |
| 28 | - if ($this->_inverted === false) |
|
| 29 | - $header->setInverted(); |
|
| 28 | + if ($this->_inverted === false) { |
|
| 29 | + $header->setInverted(); |
|
| 30 | + } |
|
| 30 | 31 | return $this->setContent($header); |
| 31 | 32 | } |
| 32 | 33 | |
@@ -41,14 +42,16 @@ discard block |
||
| 41 | 42 | } |
| 42 | 43 | |
| 43 | 44 | public function run(JsUtils $js) { |
| 44 | - if ($this->_container instanceof HtmlSingleElement) |
|
| 45 | - $this->_bsComponent=$js->semantic()->dimmer("#" . $this->_container->getIdentifier(), $this->_params); |
|
| 45 | + if ($this->_container instanceof HtmlSingleElement) { |
|
| 46 | + $this->_bsComponent=$js->semantic()->dimmer("#" . $this->_container->getIdentifier(), $this->_params); |
|
| 47 | + } |
|
| 46 | 48 | return parent::run($js); |
| 47 | 49 | } |
| 48 | 50 | |
| 49 | 51 | public function jsShow() { |
| 50 | - if (isset($this->_container)) |
|
| 51 | - return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");'; |
|
| 52 | + if (isset($this->_container)) { |
|
| 53 | + return '$("#.' . $this->_container->getIdentifier() . ').dimmer("show");'; |
|
| 54 | + } |
|
| 52 | 55 | } |
| 53 | 56 | |
| 54 | 57 | public function setBlurring() { |
@@ -8,12 +8,12 @@ discard block |
||
| 8 | 8 | use Ajax\semantic\html\base\constants\Direction; |
| 9 | 9 | |
| 10 | 10 | class HtmlSearch extends HtmlSemDoubleElement { |
| 11 | - private $_elements=array (); |
|
| 12 | - private $_searchFields=array ("title" ); |
|
| 11 | + private $_elements=array(); |
|
| 12 | + private $_searchFields=array("title"); |
|
| 13 | 13 | private $_local=false; |
| 14 | 14 | |
| 15 | 15 | public function __construct($identifier, $placeholder=NULL, $icon=NULL) { |
| 16 | - parent::__construct("search-" . $identifier, "div", "ui search", array ()); |
|
| 16 | + parent::__construct("search-".$identifier, "div", "ui search", array()); |
|
| 17 | 17 | $this->createField($placeholder, $icon); |
| 18 | 18 | $this->createResult(); |
| 19 | 19 | $this->_params["type"]="standard"; |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | private function createResult() { |
| 35 | - $this->content["result"]=new HtmlSemDoubleElement("results-" . $this->identifier, "div", "results"); |
|
| 35 | + $this->content["result"]=new HtmlSemDoubleElement("results-".$this->identifier, "div", "results"); |
|
| 36 | 36 | return $this->content["result"]; |
| 37 | 37 | } |
| 38 | 38 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | public function setUrl($url) { |
| 52 | - $this->_params["apiSettings"]="%{url: %quote%" . $url . "%quote%}%"; |
|
| 52 | + $this->_params["apiSettings"]="%{url: %quote%".$url."%quote%}%"; |
|
| 53 | 53 | return $this; |
| 54 | 54 | } |
| 55 | 55 | |
@@ -72,16 +72,16 @@ discard block |
||
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public function run(JsUtils $js) { |
| 75 | - $this->_params["onSelect"]='%function(result,response){$(%quote%#' . $this->identifier . '%quote%).trigger(%quote%onSelect%quote%, {%quote%result%quote%: result, %quote%response%quote%:response} );}%'; |
|
| 75 | + $this->_params["onSelect"]='%function(result,response){$(%quote%#'.$this->identifier.'%quote%).trigger(%quote%onSelect%quote%, {%quote%result%quote%: result, %quote%response%quote%:response} );}%'; |
|
| 76 | 76 | $searchFields=\json_encode($this->_searchFields); |
| 77 | 77 | $searchFields=str_ireplace("\"", "%quote%", $searchFields); |
| 78 | - $this->_params["searchFields"]="%" . $searchFields . "%"; |
|
| 79 | - if ($this->_local === true) { |
|
| 78 | + $this->_params["searchFields"]="%".$searchFields."%"; |
|
| 79 | + if ($this->_local===true) { |
|
| 80 | 80 | $this->_params["source"]="%content%"; |
| 81 | - $this->addEvent("beforeExecute", "var content=" . $this->resultsToJson() . ";"); |
|
| 81 | + $this->addEvent("beforeExecute", "var content=".$this->resultsToJson().";"); |
|
| 82 | 82 | } |
| 83 | - if (isset($this->_bsComponent) === false) { |
|
| 84 | - $this->_bsComponent=$js->semantic()->search("#" . $this->identifier, $this->_params); |
|
| 83 | + if (isset($this->_bsComponent)===false) { |
|
| 84 | + $this->_bsComponent=$js->semantic()->search("#".$this->identifier, $this->_params); |
|
| 85 | 85 | } |
| 86 | 86 | $this->addEventsOnRun($js); |
| 87 | 87 | return $this->_bsComponent; |
@@ -21,10 +21,12 @@ |
||
| 21 | 21 | |
| 22 | 22 | private function createField($placeholder=NULL, $icon=NULL) { |
| 23 | 23 | $field=new HtmlInput($this->identifier); |
| 24 | - if (isset($placeholder)) |
|
| 25 | - $field->setPlaceholder($placeholder); |
|
| 26 | - if (isset($icon)) |
|
| 27 | - $field->addIcon($icon, Direction::RIGHT); |
|
| 24 | + if (isset($placeholder)) { |
|
| 25 | + $field->setPlaceholder($placeholder); |
|
| 26 | + } |
|
| 27 | + if (isset($icon)) { |
|
| 28 | + $field->addIcon($icon, Direction::RIGHT); |
|
| 29 | + } |
|
| 28 | 30 | //TODO check getField |
| 29 | 31 | $field->getDataField()->setClass("prompt"); |
| 30 | 32 | $this->content["field"]=$field; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | trait JqueryEventsTrait { |
| 13 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 13 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * Blur |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | */ |
| 53 | 53 | public function _click($element='this', $js=array(), $ret_false=TRUE) { |
| 54 | 54 | if (!is_array($js)) { |
| 55 | - $js=array ( |
|
| 55 | + $js=array( |
|
| 56 | 56 | $js |
| 57 | 57 | ); |
| 58 | 58 | } |
@@ -16,18 +16,39 @@ discard block |
||
| 16 | 16 | protected $_states=[ ]; |
| 17 | 17 | protected $_baseClass; |
| 18 | 18 | |
| 19 | + /** |
|
| 20 | + * @param string $name |
|
| 21 | + */ |
|
| 19 | 22 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
| 20 | 23 | |
| 24 | + /** |
|
| 25 | + * @param string $name |
|
| 26 | + */ |
|
| 21 | 27 | abstract protected function addToPropertyCtrl($name, $value, $typeCtrl); |
| 22 | 28 | |
| 29 | + /** |
|
| 30 | + * @param string $name |
|
| 31 | + */ |
|
| 23 | 32 | abstract protected function addToPropertyCtrlCheck($name, $value, $typeCtrl); |
| 24 | 33 | |
| 34 | + /** |
|
| 35 | + * @param string $name |
|
| 36 | + */ |
|
| 25 | 37 | abstract public function addToProperty($name, $value, $separator=" "); |
| 26 | 38 | |
| 39 | + /** |
|
| 40 | + * @param string $name |
|
| 41 | + */ |
|
| 27 | 42 | abstract public function setProperty($name, $value); |
| 28 | 43 | |
| 44 | + /** |
|
| 45 | + * @param HtmlIcon $content |
|
| 46 | + */ |
|
| 29 | 47 | abstract public function addContent($content,$before=false); |
| 30 | 48 | |
| 49 | + /** |
|
| 50 | + * @param string $jsCode |
|
| 51 | + */ |
|
| 31 | 52 | abstract public function onCreate($jsCode); |
| 32 | 53 | |
| 33 | 54 | public function addVariation($variation) { |
@@ -108,7 +129,7 @@ discard block |
||
| 108 | 129 | /** |
| 109 | 130 | * show it is currently unable to be interacted with |
| 110 | 131 | * @param boolean $disable |
| 111 | - * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
|
| 132 | + * @return BaseTrait |
|
| 112 | 133 | */ |
| 113 | 134 | public function setDisabled($disable=true) { |
| 114 | 135 | if($disable) |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | * @property string $identifier |
| 13 | 13 | */ |
| 14 | 14 | trait BaseTrait { |
| 15 | - protected $_variations=[ ]; |
|
| 16 | - protected $_states=[ ]; |
|
| 15 | + protected $_variations=[]; |
|
| 16 | + protected $_states=[]; |
|
| 17 | 17 | protected $_baseClass; |
| 18 | 18 | |
| 19 | 19 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -26,7 +26,7 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | abstract public function setProperty($name, $value); |
| 28 | 28 | |
| 29 | - abstract public function addContent($content,$before=false); |
|
| 29 | + abstract public function addContent($content, $before=false); |
|
| 30 | 30 | |
| 31 | 31 | abstract public function onCreate($jsCode); |
| 32 | 32 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | $this->setProperty("class", $this->_baseClass); |
| 48 | 48 | if (\is_string($variations)) |
| 49 | 49 | $variations=\explode(" ", $variations); |
| 50 | - foreach ( $variations as $variation ) { |
|
| 50 | + foreach ($variations as $variation) { |
|
| 51 | 51 | $this->addVariation($variation); |
| 52 | 52 | } |
| 53 | 53 | return $this; |
@@ -61,7 +61,7 @@ discard block |
||
| 61 | 61 | public function addVariations($variations=array()) { |
| 62 | 62 | if (\is_string($variations)) |
| 63 | 63 | $variations=\explode(" ", $variations); |
| 64 | - foreach ( $variations as $variation ) { |
|
| 64 | + foreach ($variations as $variation) { |
|
| 65 | 65 | $this->addVariation($variation); |
| 66 | 66 | } |
| 67 | 67 | return $this; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | public function addStates($states=array()) { |
| 71 | 71 | if (\is_string($states)) |
| 72 | 72 | $states=\explode(" ", $states); |
| 73 | - foreach ( $states as $state ) { |
|
| 73 | + foreach ($states as $state) { |
|
| 74 | 74 | $this->addState($state); |
| 75 | 75 | } |
| 76 | 76 | return $this; |
@@ -80,17 +80,17 @@ discard block |
||
| 80 | 80 | $this->setProperty("class", $this->_baseClass); |
| 81 | 81 | if (\is_string($states)) |
| 82 | 82 | $states=\explode(" ", $states); |
| 83 | - foreach ( $states as $state ) { |
|
| 83 | + foreach ($states as $state) { |
|
| 84 | 84 | $this->addState($state); |
| 85 | 85 | } |
| 86 | 86 | return $this; |
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function addIcon($icon, $before=true) { |
| 90 | - return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
| 90 | + return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function addSticky($context="body"){ |
|
| 93 | + public function addSticky($context="body") { |
|
| 94 | 94 | $this->onCreate("$('#".$this->identifier."').sticky({ context: '".$context."'});"); |
| 95 | 95 | return $this; |
| 96 | 96 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
| 112 | 112 | */ |
| 113 | 113 | public function setDisabled($disable=true) { |
| 114 | - if($disable) |
|
| 114 | + if ($disable) |
|
| 115 | 115 | $this->addToProperty("class", "disabled"); |
| 116 | 116 | return $this; |
| 117 | 117 | } |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | * |
| 138 | 138 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
| 139 | 139 | */ |
| 140 | - public function asHeader(){ |
|
| 140 | + public function asHeader() { |
|
| 141 | 141 | return $this->addToProperty("class", "header"); |
| 142 | 142 | } |
| 143 | 143 | |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | * show it is currently the active user selection |
| 146 | 146 | * @return \Ajax\semantic\html\base\HtmlSemDoubleElement |
| 147 | 147 | */ |
| 148 | - public function setActive($value=true){ |
|
| 148 | + public function setActive($value=true) { |
|
| 149 | 149 | return $this->addToProperty("class", "active"); |
| 150 | 150 | } |
| 151 | 151 | |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | public function setFloated($direction="right") { |
| 164 | - return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
| 164 | + return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | public function floatRight() { |
@@ -45,8 +45,9 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | public function setVariations($variations) { |
| 47 | 47 | $this->setProperty("class", $this->_baseClass); |
| 48 | - if (\is_string($variations)) |
|
| 49 | - $variations=\explode(" ", $variations); |
|
| 48 | + if (\is_string($variations)) { |
|
| 49 | + $variations=\explode(" ", $variations); |
|
| 50 | + } |
|
| 50 | 51 | foreach ( $variations as $variation ) { |
| 51 | 52 | $this->addVariation($variation); |
| 52 | 53 | } |
@@ -59,8 +60,9 @@ discard block |
||
| 59 | 60 | } |
| 60 | 61 | |
| 61 | 62 | public function addVariations($variations=array()) { |
| 62 | - if (\is_string($variations)) |
|
| 63 | - $variations=\explode(" ", $variations); |
|
| 63 | + if (\is_string($variations)) { |
|
| 64 | + $variations=\explode(" ", $variations); |
|
| 65 | + } |
|
| 64 | 66 | foreach ( $variations as $variation ) { |
| 65 | 67 | $this->addVariation($variation); |
| 66 | 68 | } |
@@ -68,8 +70,9 @@ discard block |
||
| 68 | 70 | } |
| 69 | 71 | |
| 70 | 72 | public function addStates($states=array()) { |
| 71 | - if (\is_string($states)) |
|
| 72 | - $states=\explode(" ", $states); |
|
| 73 | + if (\is_string($states)) { |
|
| 74 | + $states=\explode(" ", $states); |
|
| 75 | + } |
|
| 73 | 76 | foreach ( $states as $state ) { |
| 74 | 77 | $this->addState($state); |
| 75 | 78 | } |
@@ -78,8 +81,9 @@ discard block |
||
| 78 | 81 | |
| 79 | 82 | public function setStates($states) { |
| 80 | 83 | $this->setProperty("class", $this->_baseClass); |
| 81 | - if (\is_string($states)) |
|
| 82 | - $states=\explode(" ", $states); |
|
| 84 | + if (\is_string($states)) { |
|
| 85 | + $states=\explode(" ", $states); |
|
| 86 | + } |
|
| 83 | 87 | foreach ( $states as $state ) { |
| 84 | 88 | $this->addState($state); |
| 85 | 89 | } |
@@ -111,8 +115,9 @@ discard block |
||
| 111 | 115 | * @return \Ajax\semantic\html\elements\HtmlSemDoubleElement |
| 112 | 116 | */ |
| 113 | 117 | public function setDisabled($disable=true) { |
| 114 | - if($disable) |
|
| 115 | - $this->addToProperty("class", "disabled"); |
|
| 118 | + if($disable) { |
|
| 119 | + $this->addToProperty("class", "disabled"); |
|
| 120 | + } |
|
| 116 | 121 | return $this; |
| 117 | 122 | } |
| 118 | 123 | |