@@ -8,23 +8,23 @@ |
||
| 8 | 8 | |
| 9 | 9 | protected $_modelInstance; |
| 10 | 10 | |
| 11 | - public function __construct($identifier,$modelInstance=NULL) { |
|
| 11 | + public function __construct($identifier, $modelInstance=NULL) { |
|
| 12 | 12 | parent::__construct($identifier); |
| 13 | 13 | $this->_template="%wrapContentBefore%%content%%wrapContentAfter%"; |
| 14 | - if(isset($modelInstance)); |
|
| 14 | + if (isset($modelInstance)); |
|
| 15 | 15 | $this->show($modelInstance); |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - public function show($modelInstance){ |
|
| 18 | + public function show($modelInstance) { |
|
| 19 | 19 | $this->_modelInstance=$modelInstance; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - public function getInstanceClassName(){ |
|
| 23 | - if(\is_array($this->_modelInstance)){ |
|
| 24 | - if(\sizeof($this->_modelInstance)>0){ |
|
| 22 | + public function getInstanceClassName() { |
|
| 23 | + if (\is_array($this->_modelInstance)) { |
|
| 24 | + if (\sizeof($this->_modelInstance)>0) { |
|
| 25 | 25 | return \get_class($this->_modelInstance[0]); |
| 26 | 26 | } |
| 27 | - }else{ |
|
| 27 | + } else { |
|
| 28 | 28 | return \get_class($this->_modelInstance); |
| 29 | 29 | } |
| 30 | 30 | return false; |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | $viewVars=$view->viewVars; |
| 14 | 14 | if (isset($viewVars["q"]) === false) { |
| 15 | 15 | $controls=array (); |
| 16 | - }else{ |
|
| 16 | + } else{ |
|
| 17 | 17 | $controls=$viewVars["q"]; |
| 18 | 18 | } |
| 19 | 19 | $controls[$identifier]=$content; |
@@ -21,8 +21,8 @@ discard block |
||
| 21 | 21 | use Ajax\semantic\traits\SemanticWidgetsTrait; |
| 22 | 22 | |
| 23 | 23 | class Semantic extends BaseGui { |
| 24 | - use SemanticComponentsTrait,SemanticHtmlElementsTrait,SemanticHtmlCollectionsTrait, |
|
| 25 | - SemanticHtmlModulesTrait,SemanticHtmlViewsTrait,SemanticWidgetsTrait; |
|
| 24 | + use SemanticComponentsTrait, SemanticHtmlElementsTrait, SemanticHtmlCollectionsTrait, |
|
| 25 | + SemanticHtmlModulesTrait, SemanticHtmlViewsTrait, SemanticWidgetsTrait; |
|
| 26 | 26 | |
| 27 | 27 | private $language; |
| 28 | 28 | |
@@ -110,12 +110,12 @@ discard block |
||
| 110 | 110 | return $this->addHtmlComponent(new HtmlSticky($identifier, $content)); |
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - public function setLanguage($language){ |
|
| 114 | - if($language!==$this->language){ |
|
| 113 | + public function setLanguage($language) { |
|
| 114 | + if ($language!==$this->language) { |
|
| 115 | 115 | $file=\realpath(dirname(__FILE__)."/semantic/components/validation/languages/".$language.".js"); |
| 116 | - if(\file_exists($file)){ |
|
| 116 | + if (\file_exists($file)) { |
|
| 117 | 117 | $script=\file_get_contents($file); |
| 118 | - $this->js->exec($script,true); |
|
| 118 | + $this->js->exec($script, true); |
|
| 119 | 119 | $this->language=$language; |
| 120 | 120 | } |
| 121 | 121 | } |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | * @param array $instances |
| 14 | 14 | * @return ListView |
| 15 | 15 | */ |
| 16 | - public function listView($identifier,$model, $instances){ |
|
| 17 | - return $this->addHtmlComponent(new ListView($identifier,$model,$instances)); |
|
| 16 | + public function listView($identifier, $model, $instances) { |
|
| 17 | + return $this->addHtmlComponent(new ListView($identifier, $model, $instances)); |
|
| 18 | 18 | } |
| 19 | 19 | } |
| 20 | 20 | \ No newline at end of file |
@@ -10,72 +10,72 @@ discard block |
||
| 10 | 10 | private $visibleProperties; |
| 11 | 11 | private $values; |
| 12 | 12 | |
| 13 | - public function __construct($instance=NULL,$captions=NULL){ |
|
| 13 | + public function __construct($instance=NULL, $captions=NULL) { |
|
| 14 | 14 | $this->values=[]; |
| 15 | - if(isset($instance)) |
|
| 15 | + if (isset($instance)) |
|
| 16 | 16 | $this->setInstance($instance); |
| 17 | 17 | $this->setCaptions($captions); |
| 18 | 18 | } |
| 19 | 19 | |
| 20 | - public function getCaption($index){ |
|
| 20 | + public function getCaption($index) { |
|
| 21 | 21 | return $this->properties[$index]->getName(); |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - public function getCaptions(){ |
|
| 25 | - if(isset($this->captions)){ |
|
| 24 | + public function getCaptions() { |
|
| 25 | + if (isset($this->captions)) { |
|
| 26 | 26 | return $this->captions; |
| 27 | 27 | } |
| 28 | 28 | $captions=[]; |
| 29 | 29 | $index=0; |
| 30 | 30 | $count=$this->count(); |
| 31 | - while($index<$count){ |
|
| 31 | + while ($index<$count) { |
|
| 32 | 32 | $captions[]=$this->getCaption($index++); |
| 33 | 33 | } |
| 34 | 34 | return $captions; |
| 35 | 35 | } |
| 36 | 36 | |
| 37 | - public function getValues(){ |
|
| 37 | + public function getValues() { |
|
| 38 | 38 | $values=[]; |
| 39 | 39 | $index=0; |
| 40 | 40 | $count=$this->count(); |
| 41 | - while($index<$count){ |
|
| 41 | + while ($index<$count) { |
|
| 42 | 42 | $values[]=$this->getValue($index++); |
| 43 | 43 | } |
| 44 | 44 | return $values; |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function getValue($index){ |
|
| 47 | + public function getValue($index) { |
|
| 48 | 48 | $this->properties[$index]->setAccessible(true); |
| 49 | 49 | $value=$this->properties[$index]->getValue($this->instance); |
| 50 | - if(isset($this->values[$index])){ |
|
| 51 | - $value= $this->values[$index]($value); |
|
| 50 | + if (isset($this->values[$index])) { |
|
| 51 | + $value=$this->values[$index]($value); |
|
| 52 | 52 | } |
| 53 | 53 | return $value; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - public function count(){ |
|
| 56 | + public function count() { |
|
| 57 | 57 | return \sizeof($this->properties); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function showableProperty(\ReflectionProperty $rProperty){ |
|
| 61 | - if(\is_array($this->visibleProperties)){ |
|
| 60 | + public function showableProperty(\ReflectionProperty $rProperty) { |
|
| 61 | + if (\is_array($this->visibleProperties)) { |
|
| 62 | 62 | return \array_search($rProperty->getName(), $this->visibleProperties); |
| 63 | 63 | } |
| 64 | - return JString::startswith($rProperty->getName(),"_")===false; |
|
| 64 | + return JString::startswith($rProperty->getName(), "_")===false; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public function setInstance($instance) { |
| 68 | - if(\is_string($instance)){ |
|
| 68 | + if (\is_string($instance)) { |
|
| 69 | 69 | $instance=new $instance(); |
| 70 | 70 | } |
| 71 | 71 | $this->instance=$instance; |
| 72 | 72 | $this->properties=[]; |
| 73 | 73 | $this->reflect=new \ReflectionClass($instance); |
| 74 | 74 | $properties=$this->reflect->getProperties(); |
| 75 | - foreach ($properties as $property){ |
|
| 75 | + foreach ($properties as $property) { |
|
| 76 | 76 | $showable=$this->showableProperty($property); |
| 77 | - if($showable!==false){ |
|
| 78 | - if(\is_int($showable)) |
|
| 77 | + if ($showable!==false) { |
|
| 78 | + if (\is_int($showable)) |
|
| 79 | 79 | $this->properties[$showable]=$property; |
| 80 | 80 | else |
| 81 | 81 | $this->properties[]=$property; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | return $this; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function setValueFunction($index,$callback){ |
|
| 97 | + public function setValueFunction($index, $callback) { |
|
| 98 | 98 | $this->values[$index]=$callback; |
| 99 | 99 | } |
| 100 | 100 | |
@@ -12,8 +12,9 @@ discard block |
||
| 12 | 12 | |
| 13 | 13 | public function __construct($instance=NULL,$captions=NULL){ |
| 14 | 14 | $this->values=[]; |
| 15 | - if(isset($instance)) |
|
| 16 | - $this->setInstance($instance); |
|
| 15 | + if(isset($instance)) { |
|
| 16 | + $this->setInstance($instance); |
|
| 17 | + } |
|
| 17 | 18 | $this->setCaptions($captions); |
| 18 | 19 | } |
| 19 | 20 | |
@@ -75,10 +76,11 @@ discard block |
||
| 75 | 76 | foreach ($properties as $property){ |
| 76 | 77 | $showable=$this->showableProperty($property); |
| 77 | 78 | if($showable!==false){ |
| 78 | - if(\is_int($showable)) |
|
| 79 | - $this->properties[$showable]=$property; |
|
| 80 | - else |
|
| 81 | - $this->properties[]=$property; |
|
| 79 | + if(\is_int($showable)) { |
|
| 80 | + $this->properties[$showable]=$property; |
|
| 81 | + } else { |
|
| 82 | + $this->properties[]=$property; |
|
| 83 | + } |
|
| 82 | 84 | } |
| 83 | 85 | } |
| 84 | 86 | return $this; |
@@ -9,26 +9,26 @@ discard block |
||
| 9 | 9 | class ListView extends Widget { |
| 10 | 10 | |
| 11 | 11 | |
| 12 | - public function run(JsUtils $js){ |
|
| 12 | + public function run(JsUtils $js) { |
|
| 13 | 13 | parent::run($js); |
| 14 | 14 | } |
| 15 | 15 | |
| 16 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 17 | - parent::__construct($identifier, $model,$modelInstance); |
|
| 16 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 17 | + parent::__construct($identifier, $model, $modelInstance); |
|
| 18 | 18 | $this->_instanceViewer=new InstanceViewer(); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 21 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 22 | 22 | $this->_instanceViewer->setInstance($this->_model); |
| 23 | 23 | $captions=$this->_instanceViewer->getCaptions(); |
| 24 | - $table=new HtmlTable($this->identifier,0,\sizeof($captions)); |
|
| 24 | + $table=new HtmlTable($this->identifier, 0, \sizeof($captions)); |
|
| 25 | 25 | $table->setHeaderValues($captions); |
| 26 | - $table->fromDatabaseObjects($this->_modelInstance, function($instance){ |
|
| 26 | + $table->fromDatabaseObjects($this->_modelInstance, function($instance) { |
|
| 27 | 27 | $this->_instanceViewer->setInstance($instance); |
| 28 | 28 | return $this->_instanceViewer->getValues(); |
| 29 | 29 | }); |
| 30 | 30 | $this->content=$table; |
| 31 | - return parent::compile($js,$view); |
|
| 31 | + return parent::compile($js, $view); |
|
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | public function getInstanceViewer() { |
@@ -40,17 +40,17 @@ discard block |
||
| 40 | 40 | return $this; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function setCaptions($captions){ |
|
| 43 | + public function setCaptions($captions) { |
|
| 44 | 44 | $this->_instanceViewer->setCaptions($captions); |
| 45 | 45 | return $this; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public function setFields($fields){ |
|
| 48 | + public function setFields($fields) { |
|
| 49 | 49 | $this->_instanceViewer->setVisibleProperties($fields); |
| 50 | 50 | return $this; |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | - public function setValueFunction($index,$callback){ |
|
| 53 | + public function setValueFunction($index, $callback) { |
|
| 54 | 54 | $this->_instanceViewer->setValueFunction($index, $callback); |
| 55 | 55 | return $this; |
| 56 | 56 | } |