@@ -25,7 +25,7 @@ |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function setDisabled($disable=true) { |
| 28 | - if($disable) |
|
| 28 | + if ($disable) |
|
| 29 | 29 | $this->addState(State::DISABLED); |
| 30 | 30 | return $this; |
| 31 | 31 | } |
@@ -25,8 +25,9 @@ |
||
| 25 | 25 | } |
| 26 | 26 | |
| 27 | 27 | public function setDisabled($disable=true) { |
| 28 | - if($disable) |
|
| 29 | - $this->addState(State::DISABLED); |
|
| 28 | + if($disable) { |
|
| 29 | + $this->addState(State::DISABLED); |
|
| 30 | + } |
|
| 30 | 31 | return $this; |
| 31 | 32 | } |
| 32 | 33 | } |
| 33 | 34 | \ No newline at end of file |
@@ -19,33 +19,33 @@ |
||
| 19 | 19 | class DataElement extends Widget { |
| 20 | 20 | |
| 21 | 21 | public function __construct($identifier, $modelInstance=NULL) { |
| 22 | - parent::__construct($identifier, null,$modelInstance); |
|
| 23 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,2), false); |
|
| 22 | + parent::__construct($identifier, null, $modelInstance); |
|
| 23 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 2), false); |
|
| 24 | 24 | $this->content["table"]->setDefinition(); |
| 25 | 25 | } |
| 26 | 26 | |
| 27 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 27 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 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]); |
|
| 37 | - return parent::compile($js,$view); |
|
| 36 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
| 37 | + return parent::compile($js, $view); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * @param HtmlTable $table |
| 42 | 42 | */ |
| 43 | - protected function _generateContent($table){ |
|
| 43 | + protected function _generateContent($table) { |
|
| 44 | 44 | $captions=$this->_instanceViewer->getCaptions(); |
| 45 | - $values= $this->_instanceViewer->getValues(); |
|
| 45 | + $values=$this->_instanceViewer->getValues(); |
|
| 46 | 46 | $count=$this->_instanceViewer->count(); |
| 47 | - for($i=0;$i<$count;$i++){ |
|
| 48 | - $table->addRow([$captions[$i],$values[$i]]); |
|
| 47 | + for ($i=0; $i<$count; $i++) { |
|
| 48 | + $table->addRow([$captions[$i], $values[$i]]); |
|
| 49 | 49 | } |
| 50 | 50 | } |
| 51 | 51 | |
@@ -9,41 +9,41 @@ |
||
| 9 | 9 | class FormInstanceViewer extends InstanceViewer { |
| 10 | 10 | protected $separators; |
| 11 | 11 | |
| 12 | - public function __construct($identifier,$instance=NULL, $captions=NULL) { |
|
| 13 | - parent::__construct($identifier,$instance=NULL, $captions=NULL); |
|
| 12 | + public function __construct($identifier, $instance=NULL, $captions=NULL) { |
|
| 13 | + parent::__construct($identifier, $instance=NULL, $captions=NULL); |
|
| 14 | 14 | $this->separators=[-1]; |
| 15 | - $this->defaultValueFunction=function($name,$value,$index){ |
|
| 15 | + $this->defaultValueFunction=function($name, $value, $index) { |
|
| 16 | 16 | $caption=$this->getCaption($index); |
| 17 | - $input=new HtmlFormInput($this->widgetIdentifier."-".$name,$caption,"text",$value); |
|
| 17 | + $input=new HtmlFormInput($this->widgetIdentifier."-".$name, $caption, "text", $value); |
|
| 18 | 18 | $input->setName($name); |
| 19 | 19 | return $input; |
| 20 | 20 | }; |
| 21 | 21 | } |
| 22 | 22 | |
| 23 | - protected function _beforeAddProperty($index,&$field){ |
|
| 24 | - if(JString::endswith($field, "\n")===true){ |
|
| 23 | + protected function _beforeAddProperty($index, &$field) { |
|
| 24 | + if (JString::endswith($field, "\n")===true) { |
|
| 25 | 25 | $this->addSeparatorAfter($index); |
| 26 | 26 | } |
| 27 | - if($index>1 && JString::startswith($field, "\n")===true){ |
|
| 27 | + if ($index>1 && JString::startswith($field, "\n")===true) { |
|
| 28 | 28 | $this->addSeparatorAfter($index-1); |
| 29 | 29 | } |
| 30 | 30 | $field=\str_replace("\n", "", $field); |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function getFieldName($index){ |
|
| 33 | + public function getFieldName($index) { |
|
| 34 | 34 | $property=$this->getProperty($index); |
| 35 | - if($property instanceof \ReflectionProperty){ |
|
| 35 | + if ($property instanceof \ReflectionProperty) { |
|
| 36 | 36 | $result=$property->getName(); |
| 37 | - }elseif(\is_callable($property)){ |
|
| 37 | + }elseif (\is_callable($property)) { |
|
| 38 | 38 | $result=$this->visibleProperties[$index]; |
| 39 | - }else{ |
|
| 39 | + } else { |
|
| 40 | 40 | $result=$property; |
| 41 | 41 | } |
| 42 | 42 | return $result; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - public function addSeparatorAfter($fieldNum){ |
|
| 46 | - if(\array_search($fieldNum, $this->separators)===false) |
|
| 45 | + public function addSeparatorAfter($fieldNum) { |
|
| 46 | + if (\array_search($fieldNum, $this->separators)===false) |
|
| 47 | 47 | $this->separators[]=$fieldNum; |
| 48 | 48 | return $this; |
| 49 | 49 | } |
@@ -34,17 +34,18 @@ |
||
| 34 | 34 | $property=$this->getProperty($index); |
| 35 | 35 | if($property instanceof \ReflectionProperty){ |
| 36 | 36 | $result=$property->getName(); |
| 37 | - }elseif(\is_callable($property)){ |
|
| 37 | + } elseif(\is_callable($property)){ |
|
| 38 | 38 | $result=$this->visibleProperties[$index]; |
| 39 | - }else{ |
|
| 39 | + } else{ |
|
| 40 | 40 | $result=$property; |
| 41 | 41 | } |
| 42 | 42 | return $result; |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function addSeparatorAfter($fieldNum){ |
| 46 | - if(\array_search($fieldNum, $this->separators)===false) |
|
| 47 | - $this->separators[]=$fieldNum; |
|
| 46 | + if(\array_search($fieldNum, $this->separators)===false) { |
|
| 47 | + $this->separators[]=$fieldNum; |
|
| 48 | + } |
|
| 48 | 49 | return $this; |
| 49 | 50 | } |
| 50 | 51 | |
@@ -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 | } |
@@ -21,8 +21,9 @@ discard block |
||
| 21 | 21 | $this->widgetIdentifier=$identifier; |
| 22 | 22 | $this->values=[]; |
| 23 | 23 | $this->afterCompile=[]; |
| 24 | - if(isset($instance)) |
|
| 25 | - $this->setInstance($instance); |
|
| 24 | + if(isset($instance)) { |
|
| 25 | + $this->setInstance($instance); |
|
| 26 | + } |
|
| 26 | 27 | $this->setCaptions($captions); |
| 27 | 28 | $this->captionCallback=NULL; |
| 28 | 29 | $this->defaultValueFunction=function($name,$value){return $value;}; |
@@ -40,8 +41,9 @@ discard block |
||
| 40 | 41 | |
| 41 | 42 | public function getIdentifier(){ |
| 42 | 43 | $value=self::$index; |
| 43 | - if(isset($this->values["identifier"])) |
|
| 44 | - $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 44 | + if(isset($this->values["identifier"])) { |
|
| 45 | + $value=$this->values["identifier"](self::$index,$this->instance); |
|
| 46 | + } |
|
| 45 | 47 | return $value; |
| 46 | 48 | } |
| 47 | 49 | |
@@ -65,19 +67,19 @@ discard block |
||
| 65 | 67 | $value=$property->getValue($this->instance); |
| 66 | 68 | if(isset($this->values[$index])){ |
| 67 | 69 | $value= $this->values[$index]($value,$this->instance,$index); |
| 68 | - }else{ |
|
| 70 | + } else{ |
|
| 69 | 71 | $value=$this->_getDefaultValue($property->getName(),$value, $index); |
| 70 | 72 | } |
| 71 | - }else{ |
|
| 72 | - if(\is_callable($property)) |
|
| 73 | - $value=$property($this->instance); |
|
| 74 | - elseif(\is_array($property)){ |
|
| 73 | + } else{ |
|
| 74 | + if(\is_callable($property)) { |
|
| 75 | + $value=$property($this->instance); |
|
| 76 | + } elseif(\is_array($property)){ |
|
| 75 | 77 | $values=\array_map(function($v) use ($index){return $this->_getValue($v, $index);}, $property); |
| 76 | 78 | $value=\implode("", $values); |
| 77 | - }else{ |
|
| 79 | + } else{ |
|
| 78 | 80 | if(isset($this->values[$index])){ |
| 79 | 81 | $value= $this->values[$index]($property,$this->instance,$index); |
| 80 | - }else{ |
|
| 82 | + } else{ |
|
| 81 | 83 | $value=$property; |
| 82 | 84 | } |
| 83 | 85 | } |
@@ -100,10 +102,10 @@ discard block |
||
| 100 | 102 | if(isset($vb[$index])){ |
| 101 | 103 | if(\is_array($vb[$index])){ |
| 102 | 104 | $this->visibleProperties[$index][]=$field; |
| 103 | - }else{ |
|
| 105 | + } else{ |
|
| 104 | 106 | $this->visibleProperties[$index]=[$vb[$index],$field]; |
| 105 | 107 | } |
| 106 | - }else{ |
|
| 108 | + } else{ |
|
| 107 | 109 | return $this->insertField($index, $field); |
| 108 | 110 | } |
| 109 | 111 | return $this; |
@@ -139,7 +141,7 @@ discard block |
||
| 139 | 141 | $this->reflect=new \ReflectionClass($instance); |
| 140 | 142 | if(\sizeof($this->visibleProperties)===0){ |
| 141 | 143 | $this->properties=$this->getDefaultProperties(); |
| 142 | - }else{ |
|
| 144 | + } else{ |
|
| 143 | 145 | foreach ($this->visibleProperties as $property){ |
| 144 | 146 | $this->setInstanceProperty($property); |
| 145 | 147 | } |
@@ -150,22 +152,23 @@ discard block |
||
| 150 | 152 | private function setInstanceProperty($property){ |
| 151 | 153 | if(\is_callable($property)){ |
| 152 | 154 | $this->properties[]=$property; |
| 153 | - }elseif(\is_string($property)){ |
|
| 155 | + } elseif(\is_string($property)){ |
|
| 154 | 156 | try{ |
| 155 | 157 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 156 | 158 | $rProperty=$this->reflect->getProperty($property); |
| 157 | 159 | $this->properties[]=$rProperty; |
| 158 | - }catch(\Exception $e){ |
|
| 160 | + } catch(\Exception $e){ |
|
| 159 | 161 | $this->_beforeAddProperty(\sizeof($this->properties), $property); |
| 160 | 162 | $this->properties[]=$property; |
| 161 | 163 | } |
| 162 | - }elseif(\is_int($property)){ |
|
| 164 | + } elseif(\is_int($property)){ |
|
| 163 | 165 | $props=$this->getDefaultProperties(); |
| 164 | - if(isset($props[$property])) |
|
| 165 | - $this->properties[]=$props[$property]; |
|
| 166 | - else |
|
| 167 | - $this->properties[]=$property; |
|
| 168 | - }else{ |
|
| 166 | + if(isset($props[$property])) { |
|
| 167 | + $this->properties[]=$props[$property]; |
|
| 168 | + } else { |
|
| 169 | + $this->properties[]=$property; |
|
| 170 | + } |
|
| 171 | + } else{ |
|
| 169 | 172 | $this->properties[]=$property; |
| 170 | 173 | } |
| 171 | 174 | } |
@@ -209,12 +212,13 @@ discard block |
||
| 209 | 212 | if(isset($this->captions[$index])){ |
| 210 | 213 | return $this->captions[$index]; |
| 211 | 214 | } |
| 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]; |
|
| 215 | + if($this->properties[$index] instanceof \ReflectionProperty) { |
|
| 216 | + return $this->properties[$index]->getName(); |
|
| 217 | + } elseif(\is_callable($this->properties[$index])) { |
|
| 218 | + return ""; |
|
| 219 | + } else { |
|
| 220 | + return $this->properties[$index]; |
|
| 221 | + } |
|
| 218 | 222 | } |
| 219 | 223 | |
| 220 | 224 | public function getCaptions(){ |
@@ -223,7 +227,7 @@ discard block |
||
| 223 | 227 | for($i=\sizeof($captions);$i<$this->count();$i++){ |
| 224 | 228 | $captions[]=""; |
| 225 | 229 | } |
| 226 | - }else{ |
|
| 230 | + } else{ |
|
| 227 | 231 | $captions=[]; |
| 228 | 232 | $index=0; |
| 229 | 233 | $count=$this->count(); |
@@ -239,8 +243,9 @@ discard block |
||
| 239 | 243 | } |
| 240 | 244 | |
| 241 | 245 | public function setCaption($index,$caption){ |
| 242 | - if(isset($this->captions)===false) |
|
| 243 | - $this->captions=[]; |
|
| 246 | + if(isset($this->captions)===false) { |
|
| 247 | + $this->captions=[]; |
|
| 248 | + } |
|
| 244 | 249 | $this->captions[$index]=$caption; |
| 245 | 250 | return $this; |
| 246 | 251 | } |
@@ -9,15 +9,15 @@ discard block |
||
| 9 | 9 | protected $image; |
| 10 | 10 | |
| 11 | 11 | public function __construct($identifier, $content=NULL) { |
| 12 | - parent::__construct($identifier,"item",$content); |
|
| 12 | + parent::__construct($identifier, "item", $content); |
|
| 13 | 13 | } |
| 14 | - protected function initContent($content){ |
|
| 15 | - if(\is_array($content)){ |
|
| 16 | - if(JArray::isAssociative($content)===false){ |
|
| 14 | + protected function initContent($content) { |
|
| 15 | + if (\is_array($content)) { |
|
| 16 | + if (JArray::isAssociative($content)===false) { |
|
| 17 | 17 | $icon=@$content[0]; |
| 18 | 18 | $title=@$content[1]; |
| 19 | 19 | $desc=@$content[2]; |
| 20 | - }else{ |
|
| 20 | + } else { |
|
| 21 | 21 | $icon=@$content["icon"]; |
| 22 | 22 | $image=@$content["image"]; |
| 23 | 23 | $title=@$content["title"]; |
@@ -25,21 +25,21 @@ discard block |
||
| 25 | 25 | $desc=@$content["description"]; |
| 26 | 26 | $items=@$content["items"]; |
| 27 | 27 | } |
| 28 | - if(isset($icon)){ |
|
| 28 | + if (isset($icon)) { |
|
| 29 | 29 | $this->setIcon($icon); |
| 30 | 30 | } |
| 31 | - if(isset($image)){ |
|
| 31 | + if (isset($image)) { |
|
| 32 | 32 | $this->setImage($image); |
| 33 | 33 | } |
| 34 | - if(isset($title)){ |
|
| 35 | - $this->setTitle($title,$desc); |
|
| 36 | - }elseif (isset($header)){ |
|
| 37 | - $this->setTitle($header,$desc,"header"); |
|
| 34 | + if (isset($title)) { |
|
| 35 | + $this->setTitle($title, $desc); |
|
| 36 | + }elseif (isset($header)) { |
|
| 37 | + $this->setTitle($header, $desc, "header"); |
|
| 38 | 38 | } |
| 39 | - if(isset($items)){ |
|
| 39 | + if (isset($items)) { |
|
| 40 | 40 | $this->addList($items); |
| 41 | 41 | } |
| 42 | - }else{ |
|
| 42 | + } else { |
|
| 43 | 43 | $this->setContent($content); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | return $list; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function getList(){ |
|
| 53 | + public function getList() { |
|
| 54 | 54 | return $this->content["list"]; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function getItem($index){ |
|
| 57 | + public function getItem($index) { |
|
| 58 | 58 | return $this->getList()->getItem($index); |
| 59 | 59 | } |
| 60 | 60 | } |
| 61 | 61 | \ No newline at end of file |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | $icon=@$content[0]; |
| 18 | 18 | $title=@$content[1]; |
| 19 | 19 | $desc=@$content[2]; |
| 20 | - }else{ |
|
| 20 | + } else{ |
|
| 21 | 21 | $icon=@$content["icon"]; |
| 22 | 22 | $image=@$content["image"]; |
| 23 | 23 | $title=@$content["title"]; |
@@ -33,13 +33,13 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | if(isset($title)){ |
| 35 | 35 | $this->setTitle($title,$desc); |
| 36 | - }elseif (isset($header)){ |
|
| 36 | + } elseif (isset($header)){ |
|
| 37 | 37 | $this->setTitle($header,$desc,"header"); |
| 38 | 38 | } |
| 39 | 39 | if(isset($items)){ |
| 40 | 40 | $this->addList($items); |
| 41 | 41 | } |
| 42 | - }else{ |
|
| 42 | + } else{ |
|
| 43 | 43 | $this->setContent($content); |
| 44 | 44 | } |
| 45 | 45 | } |
@@ -12,8 +12,8 @@ discard block |
||
| 12 | 12 | $output=$input; |
| 13 | 13 | } |
| 14 | 14 | if (\is_array($input)) { |
| 15 | - if (sizeof($input) > 0) { |
|
| 16 | - if (self::containsElement($input) === false) { |
|
| 15 | + if (sizeof($input)>0) { |
|
| 16 | + if (self::containsElement($input)===false) { |
|
| 17 | 17 | $output=self::wrapStrings($input, $js, $separator=' ', $valueQuote='"'); |
| 18 | 18 | } else { |
| 19 | 19 | $output=self::wrapObjects($input, $js, $separator, $valueQuote); |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | private static function containsElement($input) { |
| 27 | - foreach ( $input as $v ) { |
|
| 27 | + foreach ($input as $v) { |
|
| 28 | 28 | if (\is_object($v) || \is_array($v)) |
| 29 | 29 | return true; |
| 30 | 30 | } |
@@ -32,9 +32,9 @@ discard block |
||
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public static function wrapStrings($input, $js, $separator=' ', $valueQuote='"') { |
| 35 | - if (JArray::isAssociative($input) === true) { |
|
| 36 | - $result=implode($separator, array_map(function ($v, $k) use($valueQuote) { |
|
| 37 | - return $k . '=' . $valueQuote . $v . $valueQuote; |
|
| 35 | + if (JArray::isAssociative($input)===true) { |
|
| 36 | + $result=implode($separator, array_map(function($v, $k) use($valueQuote) { |
|
| 37 | + return $k.'='.$valueQuote.$v.$valueQuote; |
|
| 38 | 38 | }, $input, array_keys($input))); |
| 39 | 39 | } else { |
| 40 | 40 | $result=implode($separator, array_values($input)); |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public static function wrapObjects($input, $js=NULL, $separator=' ', $valueQuote='"') { |
| 46 | - return implode($separator, array_map(function ($v) use($js, $separator, $valueQuote) { |
|
| 46 | + return implode($separator, array_map(function($v) use($js, $separator, $valueQuote) { |
|
| 47 | 47 | if (is_object($v)) |
| 48 | 48 | return $v->compile($js); |
| 49 | 49 | elseif (\is_array($v)) { |
@@ -25,8 +25,9 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | private static function containsElement($input) { |
| 27 | 27 | foreach ( $input as $v ) { |
| 28 | - if (\is_object($v) || \is_array($v)) |
|
| 29 | - return true; |
|
| 28 | + if (\is_object($v) || \is_array($v)) { |
|
| 29 | + return true; |
|
| 30 | + } |
|
| 30 | 31 | } |
| 31 | 32 | return false; |
| 32 | 33 | } |
@@ -44,12 +45,13 @@ discard block |
||
| 44 | 45 | |
| 45 | 46 | public static function wrapObjects($input, $js=NULL, $separator=' ', $valueQuote='"') { |
| 46 | 47 | return implode($separator, array_map(function ($v) use($js, $separator, $valueQuote) { |
| 47 | - if (is_object($v)) |
|
| 48 | - return $v->compile($js); |
|
| 49 | - elseif (\is_array($v)) { |
|
| 48 | + if (is_object($v)) { |
|
| 49 | + return $v->compile($js); |
|
| 50 | + } elseif (\is_array($v)) { |
|
| 50 | 51 | return self::wrap($v, $js, $separator, $valueQuote); |
| 51 | - } else |
|
| 52 | - return $v; |
|
| 52 | + } else { |
|
| 53 | + return $v; |
|
| 54 | + } |
|
| 53 | 55 | }, $input)); |
| 54 | 56 | } |
| 55 | 57 | } |
| 56 | 58 | \ No newline at end of file |
@@ -13,7 +13,7 @@ discard block |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | public function setClass($classNames) { |
| 16 | - if(\is_array($classNames)){ |
|
| 16 | + if (\is_array($classNames)) { |
|
| 17 | 17 | $classNames=implode(" ", $classNames); |
| 18 | 18 | } |
| 19 | 19 | $this->setProperty("class", $classNames); |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | public function fromArray($array) { |
| 46 | 46 | $array=parent::fromArray($array); |
| 47 | - foreach ( $array as $key => $value ) { |
|
| 47 | + foreach ($array as $key => $value) { |
|
| 48 | 48 | $this->setProperty($key, $value); |
| 49 | 49 | } |
| 50 | 50 | return $array; |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | if (\is_array($elements)) { |
| 62 | 62 | foreach ( $elements as $key => $element ) { |
| 63 | 63 | $iid=$this->getElementsCount()+1; |
| 64 | - if ($element instanceof HtmlDropdownItem) |
|
| 65 | - $this->elements []=$element; |
|
| 66 | - else if (\is_array($element)) { |
|
| 64 | + if ($element instanceof HtmlDropdownItem) { |
|
| 65 | + $this->elements []=$element; |
|
| 66 | + } else if (\is_array($element)) { |
|
| 67 | 67 | if (is_string($key)===true) { |
| 68 | 68 | $dropdown=new HtmlDropdown($this->identifier."-dropdown-".$iid); |
| 69 | 69 | $dropdown->addItems($element); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $li=new HtmlBsDoubleElement($this->identifier."-li-".$iid, "li"); |
| 90 | 90 | if($caption instanceof HtmlLink){ |
| 91 | 91 | $link=$caption; |
| 92 | - }else{ |
|
| 92 | + } else{ |
|
| 93 | 93 | $link=new HtmlLink($this->identifier."-link-".$iid, $href, $caption); |
| 94 | 94 | } |
| 95 | 95 | $li->setContent($link); |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | parent::__construct($identifier); |
| 28 | 28 | $this->tagName="ul"; |
| 29 | 29 | $this->_template='<%tagName% id="%identifier%" class="nav navbar-nav %class%">%elements%</%tagName%>'; |
| 30 | - $this->elements=array (); |
|
| 30 | + $this->elements=array(); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function setClass($value) { |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function addElement($element) { |
| 42 | - if($element instanceof HtmlLink){ |
|
| 42 | + if ($element instanceof HtmlLink) { |
|
| 43 | 43 | $this->addLink($element); |
| 44 | 44 | } else if (is_object($element)) { |
| 45 | 45 | $this->elements []=$element; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | public function addElements($elements) { |
| 61 | 61 | if (\is_array($elements)) { |
| 62 | - foreach ( $elements as $key => $element ) { |
|
| 62 | + foreach ($elements as $key => $element) { |
|
| 63 | 63 | $iid=$this->getElementsCount()+1; |
| 64 | 64 | if ($element instanceof HtmlDropdownItem) |
| 65 | 65 | $this->elements []=$element; |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | public function addLink($caption, $href="#") { |
| 88 | 88 | $iid=$this->getElementsCount()+1; |
| 89 | 89 | $li=new HtmlBsDoubleElement($this->identifier."-li-".$iid, "li"); |
| 90 | - if($caption instanceof HtmlLink){ |
|
| 90 | + if ($caption instanceof HtmlLink) { |
|
| 91 | 91 | $link=$caption; |
| 92 | - }else{ |
|
| 92 | + } else { |
|
| 93 | 93 | $link=new HtmlLink($this->identifier."-link-".$iid, $href, $caption); |
| 94 | 94 | } |
| 95 | 95 | $li->setContent($link); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | public function run(JsUtils $js) { |
| 125 | - foreach ( $this->elements as $element ) { |
|
| 125 | + foreach ($this->elements as $element) { |
|
| 126 | 126 | $element->run($js); |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @param int $index |
| 144 | 144 | * @return BaseHtml |
| 145 | 145 | */ |
| 146 | - public function getElement($index){ |
|
| 146 | + public function getElement($index) { |
|
| 147 | 147 | return $this->elements[$index]; |
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | \ 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 AND ! class_exists('CI_DB')){ |
|
| 92 | - if ($db_conn === TRUE){ |
|
| 93 | - $db_conn = ''; |
|
| 91 | + if ($db_conn!==FALSE AND !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); |