1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Ajax\semantic\html\views; |
4
|
|
|
|
5
|
|
|
use Ajax\semantic\html\base\HtmlSemCollection; |
6
|
|
|
use Ajax\service\JArray; |
7
|
|
|
use Ajax\semantic\html\base\constants\Wide; |
8
|
|
|
|
9
|
|
|
class HtmlCardGroups extends HtmlSemCollection { |
10
|
|
|
|
11
|
|
|
public function __construct($identifier, $cards=array()) { |
12
|
|
|
parent::__construct($identifier, "div", "ui cards"); |
13
|
|
|
$this->addItems($cards); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
protected function createItem($value) { |
17
|
|
|
$result=new HtmlCard("card-" . $this->count()); |
18
|
|
|
if (\is_array($value)) { |
19
|
|
|
$header=JArray::getValue($value, "header", 0); |
20
|
|
|
$metas=JArray::getValue($value, "metas", 1); |
21
|
|
|
$description=JArray::getValue($value, "description", 2); |
22
|
|
|
$image=JArray::getValue($value, "image", 3); |
23
|
|
|
$extra=JArray::getValue($value, "extra", 4); |
24
|
|
|
if (isset($image)) { |
25
|
|
|
$result->addImage($image); |
26
|
|
|
} |
27
|
|
|
$result->addCardHeaderContent($header, $metas, $description); |
28
|
|
|
if (isset($extra)) { |
29
|
|
|
$result->addExtraContent($extra); |
30
|
|
|
} |
31
|
|
|
} else |
32
|
|
|
$result->addCardContent($value); |
33
|
|
|
return $result; |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* Defines the cards width (alias for setWidth) |
38
|
|
|
* @param int $wide |
39
|
|
|
*/ |
40
|
|
|
public function setWide($wide) { |
41
|
|
|
$wide=Wide::getConstants()["W" . $wide]; |
42
|
|
|
return $this->addToPropertyCtrl("class", $wide, Wide::getConstants()); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function newCard($identifier) { |
46
|
|
|
return new HtmlCard($identifier); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function getCard($index) { |
50
|
|
|
return $this->getItem($index); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function getCardContent($cardIndex, $contentIndex) { |
54
|
|
|
$card=$this->getItem($cardIndex); |
55
|
|
|
if (isset($card)) { |
56
|
|
|
return $card->getCardContent($contentIndex); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function fromDatabaseObject($object, $function) { |
61
|
|
|
return $this->addItem($function($object)); |
62
|
|
|
} |
63
|
|
|
} |