|
1 | 1 | <?php
|
2 |
| - |
3 | 2 | namespace Ajax\semantic\html\content;
|
4 | 3 |
|
5 |
| - |
6 | 4 | use Ajax\service\JArray;
|
7 | 5 | use Ajax\semantic\html\elements\HtmlList;
|
| 6 | + |
8 | 7 | class HtmlListItem extends HtmlAbsractItem {
|
| 8 | + |
9 | 9 | protected $image;
|
10 | 10 |
|
11 |
| - public function __construct($identifier, $content=NULL) { |
12 |
| - parent::__construct($identifier,"item",$content); |
| 11 | + public function __construct($identifier, $content = NULL) { |
| 12 | + parent::__construct($identifier, "item", $content); |
13 | 13 | }
|
14 |
| - protected function initContent($content){ |
15 |
| - if(\is_array($content)){ |
16 |
| - if(JArray::isAssociative($content)===false){ |
17 |
| - $icon=@$content[0]; |
18 |
| - $title=@$content[1]; |
19 |
| - $desc=@$content[2]; |
20 |
| - }else{ |
21 |
| - $icon=@$content["icon"]; |
22 |
| - $image=@$content["image"]; |
23 |
| - $title=@$content["title"]; |
24 |
| - $header=@$content["header"]; |
25 |
| - $desc=@$content["description"]; |
26 |
| - $items=@$content["items"]; |
| 14 | + |
| 15 | + protected function initContent($content) { |
| 16 | + if (\is_array($content)) { |
| 17 | + if (JArray::isAssociative($content) === false) { |
| 18 | + $icon = $content[0] ?? null; |
| 19 | + $title = $content[1] ?? null; |
| 20 | + $desc = $content[2] ?? null; |
| 21 | + } else { |
| 22 | + $icon = $content["icon"] ?? null; |
| 23 | + $image = $content["image"] ?? null; |
| 24 | + $title = $content["title"] ?? null; |
| 25 | + $header = $content["header"] ?? null; |
| 26 | + $desc = $content["description"] ?? null; |
| 27 | + $items = $content["items"] ?? null; |
27 | 28 | }
|
28 |
| - if(isset($icon)){ |
| 29 | + if (isset($icon)) { |
29 | 30 | $this->setIcon($icon);
|
30 | 31 | }
|
31 |
| - if(isset($image)){ |
| 32 | + if (isset($image)) { |
32 | 33 | $this->setImage($image);
|
33 | 34 | }
|
34 |
| - if(isset($title)){ |
35 |
| - $this->setTitle($title,$desc); |
36 |
| - }elseif (isset($header)){ |
37 |
| - $this->setTitle($header,$desc,"header"); |
| 35 | + if (isset($title)) { |
| 36 | + $this->setTitle($title, $desc); |
| 37 | + } elseif (isset($header)) { |
| 38 | + $this->setTitle($header, $desc, "header"); |
38 | 39 | }
|
39 |
| - if(isset($items)){ |
| 40 | + if (isset($items)) { |
40 | 41 | $this->addList($items);
|
41 | 42 | }
|
42 |
| - }else{ |
| 43 | + } else { |
43 | 44 | $this->setContent($content);
|
44 | 45 | }
|
45 | 46 | }
|
46 |
| - public function addList($items=array(),$ordered=false) { |
47 |
| - $list=new HtmlList("", $items); |
48 |
| - if($ordered) |
| 47 | + |
| 48 | + public function addList($items = array(), $ordered = false) { |
| 49 | + $list = new HtmlList("", $items); |
| 50 | + if ($ordered) |
49 | 51 | $list->setOrdered();
|
50 | 52 | $list->setClass("list");
|
51 |
| - $this->content["list"]=$list; |
| 53 | + $this->content["list"] = $list; |
52 | 54 | return $list;
|
53 | 55 | }
|
54 | 56 |
|
55 |
| - public function getList(){ |
| 57 | + public function getList() { |
56 | 58 | return $this->content["list"];
|
57 | 59 | }
|
58 | 60 |
|
59 |
| - public function getItem($index){ |
| 61 | + public function getItem($index) { |
60 | 62 | return $this->getList()->getItem($index);
|
61 | 63 | }
|
62 | 64 | }
|
0 commit comments