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