@@ -3,11 +3,18 @@ discard block |
||
| 3 | 3 | namespace Ajax\service; |
| 4 | 4 | |
| 5 | 5 | class JReflection { |
| 6 | + |
|
| 7 | + /** |
|
| 8 | + * @param \Ajax\common\html\HtmlCollection $object |
|
| 9 | + */ |
|
| 6 | 10 | public static function shortClassName($object){ |
| 7 | 11 | $classNameWithNamespace = get_class($object); |
| 8 | 12 | return substr($classNameWithNamespace, strrpos($classNameWithNamespace, '\\')+1); |
| 9 | 13 | } |
| 10 | 14 | |
| 15 | + /** |
|
| 16 | + * @param string $classname |
|
| 17 | + */ |
|
| 11 | 18 | public static function jsonObject($classname){ |
| 12 | 19 | $object=new $classname(); |
| 13 | 20 | $class = new \ReflectionClass($classname); |
@@ -29,10 +36,16 @@ discard block |
||
| 29 | 36 | return $object; |
| 30 | 37 | } |
| 31 | 38 | |
| 39 | + /** |
|
| 40 | + * @param string $callback |
|
| 41 | + */ |
|
| 32 | 42 | public static function callMethod($object,$callback,array $values){ |
| 33 | 43 | return \call_user_func_array([$object,$callback],$values); |
| 34 | 44 | } |
| 35 | 45 | |
| 46 | + /** |
|
| 47 | + * @param string $propertyName |
|
| 48 | + */ |
|
| 36 | 49 | public static function getterName($propertyName,$prefix="get"){ |
| 37 | 50 | return $prefix.\ucfirst($propertyName); |
| 38 | 51 | } |
@@ -28,8 +28,9 @@ discard block |
||
| 28 | 28 | $this->addImage($image); |
| 29 | 29 | } |
| 30 | 30 | $this->addHeaderContent($header, $metas, $description,$extra); |
| 31 | - } else |
|
| 32 | - $this->addContent($value); |
|
| 31 | + } else { |
|
| 32 | + $this->addContent($value); |
|
| 33 | + } |
|
| 33 | 34 | } |
| 34 | 35 | |
| 35 | 36 | public function addElement($content, $baseClass="") { |
@@ -62,8 +63,9 @@ discard block |
||
| 62 | 63 | |
| 63 | 64 | public function addImage($src="", $alt="", $size=NULL) { |
| 64 | 65 | $image=new HtmlImg("img-", $src, $alt); |
| 65 | - if (isset($size)) |
|
| 66 | - $image->setSize($size); |
|
| 66 | + if (isset($size)) { |
|
| 67 | + $image->setSize($size); |
|
| 68 | + } |
|
| 67 | 69 | $this->content['image']=$image; |
| 68 | 70 | return $image; |
| 69 | 71 | } |
@@ -73,8 +75,9 @@ discard block |
||
| 73 | 75 | foreach ( $metas as $meta ) { |
| 74 | 76 | $this->addMeta($meta); |
| 75 | 77 | } |
| 76 | - } else |
|
| 77 | - $this->addMeta($metas); |
|
| 78 | + } else { |
|
| 79 | + $this->addMeta($metas); |
|
| 80 | + } |
|
| 78 | 81 | return $this; |
| 79 | 82 | } |
| 80 | 83 | |
@@ -101,8 +104,9 @@ discard block |
||
| 101 | 104 | $result=new HtmlSemDoubleElement("", "span", "", $caption); |
| 102 | 105 | $this->addContent($result); |
| 103 | 106 | $result->setFloated($direction); |
| 104 | - } else |
|
| 105 | - $result=$this->addContent($caption); |
|
| 107 | + } else { |
|
| 108 | + $result=$this->addContent($caption); |
|
| 109 | + } |
|
| 106 | 110 | return $result; |
| 107 | 111 | } |
| 108 | 112 | |
@@ -114,8 +118,9 @@ discard block |
||
| 114 | 118 | } |
| 115 | 119 | |
| 116 | 120 | public function addHeaderContent($header, $metas=array(), $description=NULL,$extra=NULL) { |
| 117 | - if(isset($header)) |
|
| 118 | - $this->addElement($header, "header"); |
|
| 121 | + if(isset($header)) { |
|
| 122 | + $this->addElement($header, "header"); |
|
| 123 | + } |
|
| 119 | 124 | $this->addMetas($metas); |
| 120 | 125 | if (isset($description)) { |
| 121 | 126 | $this->addElement($description, "description"); |
@@ -131,8 +136,9 @@ discard block |
||
| 131 | 136 | return $this->content->getPart($part,$index); |
| 132 | 137 | } |
| 133 | 138 | if (\array_key_exists($part, $this->content)) { |
| 134 | - if (isset($index)) |
|
| 135 | - return $this->content[$part][$index]; |
|
| 139 | + if (isset($index)) { |
|
| 140 | + return $this->content[$part][$index]; |
|
| 141 | + } |
|
| 136 | 142 | return $this->content[$part]; |
| 137 | 143 | } |
| 138 | 144 | return NULL; |
@@ -21,8 +21,9 @@ discard block |
||
| 21 | 21 | public function __construct($identifier,$baseClass,$content=NULL) { |
| 22 | 22 | parent::__construct($identifier, "div", $baseClass); |
| 23 | 23 | $this->content=["content"=>new HtmlViewContent("content-".$this->identifier)]; |
| 24 | - if(isset($content)) |
|
| 25 | - $this->setContent($content); |
|
| 24 | + if(isset($content)) { |
|
| 25 | + $this->setContent($content); |
|
| 26 | + } |
|
| 26 | 27 | } |
| 27 | 28 | |
| 28 | 29 | public function setContent($value){ |
@@ -33,10 +34,12 @@ discard block |
||
| 33 | 34 | if (isset($image)) { |
| 34 | 35 | $this->addImage($image); |
| 35 | 36 | } |
| 36 | - if(isset($content)) |
|
| 37 | - $this->content["content"]->setContent($content); |
|
| 38 | - if(isset($extra)) |
|
| 39 | - $this->addExtraContent($extra); |
|
| 37 | + if(isset($content)) { |
|
| 38 | + $this->content["content"]->setContent($content); |
|
| 39 | + } |
|
| 40 | + if(isset($extra)) { |
|
| 41 | + $this->addExtraContent($extra); |
|
| 42 | + } |
|
| 40 | 43 | } |
| 41 | 44 | } |
| 42 | 45 | |
@@ -51,10 +54,11 @@ discard block |
||
| 51 | 54 | if (\array_key_exists($key, $this->content) === false) { |
| 52 | 55 | $this->content[$key]=array (); |
| 53 | 56 | } |
| 54 | - if($this->content[$key] instanceof HtmlViewContent) |
|
| 55 | - $this->content[$key]->addElement($element); |
|
| 56 | - else |
|
| 57 | - $this->content[$key][]=$element; |
|
| 57 | + if($this->content[$key] instanceof HtmlViewContent) { |
|
| 58 | + $this->content[$key]->addElement($element); |
|
| 59 | + } else { |
|
| 60 | + $this->content[$key][]=$element; |
|
| 61 | + } |
|
| 58 | 62 | return $element; |
| 59 | 63 | } |
| 60 | 64 | |
@@ -63,8 +67,9 @@ discard block |
||
| 63 | 67 | return $this->content->getPart($part,$index); |
| 64 | 68 | } |
| 65 | 69 | if (\array_key_exists($part, $this->content)) { |
| 66 | - if (isset($index)) |
|
| 67 | - return $this->content[$part][$index]; |
|
| 70 | + if (isset($index)) { |
|
| 71 | + return $this->content[$part][$index]; |
|
| 72 | + } |
|
| 68 | 73 | return $this->content[$part]; |
| 69 | 74 | } |
| 70 | 75 | return NULL; |
@@ -166,8 +171,9 @@ discard block |
||
| 166 | 171 | $this->addToProperty("class", "link"); |
| 167 | 172 | if ($href !== "") { |
| 168 | 173 | $this->setProperty("href", $href); |
| 169 | - if (isset($target)) |
|
| 170 | - $this->setProperty("target", $target); |
|
| 174 | + if (isset($target)) { |
|
| 175 | + $this->setProperty("target", $target); |
|
| 176 | + } |
|
| 171 | 177 | } |
| 172 | 178 | return $this; |
| 173 | 179 | } |