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
|
|
|
use Ajax\JsUtils; |
9
|
|
|
|
10
|
|
|
abstract class HtmlViewGroups extends HtmlSemCollection { |
11
|
|
|
|
12
|
|
|
public function __construct($identifier, $uiClass,$items=array()) { |
13
|
|
|
parent::__construct($identifier, "div", $uiClass); |
14
|
|
|
$this->addItems($items); |
15
|
|
|
} |
16
|
|
|
|
17
|
|
|
abstract protected function createElement(); |
18
|
|
|
|
19
|
|
|
protected function createItem($value) { |
20
|
|
|
$result=$this->createElement(); |
21
|
|
|
if (\is_array($value)) { |
22
|
|
|
$header=JArray::getValue($value, "header", 0); |
23
|
|
|
$metas=JArray::getValue($value, "metas", 1); |
24
|
|
|
$description=JArray::getValue($value, "description", 2); |
25
|
|
|
$image=JArray::getValue($value, "image", 3); |
26
|
|
|
$extra=JArray::getValue($value, "extra", 4); |
27
|
|
|
if (isset($image)) { |
28
|
|
|
$result->addImage($image); |
29
|
|
|
} |
30
|
|
|
$result->addItemHeaderContent($header, $metas, $description); |
31
|
|
|
if (isset($extra)) { |
32
|
|
|
$result->addExtraContent($extra); |
33
|
|
|
} |
34
|
|
|
} else |
35
|
|
|
$result->addItemContent($value); |
36
|
|
|
return $result; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* Defines the ites width (alias for setWidth) |
41
|
|
|
* @param int $wide |
42
|
|
|
*/ |
43
|
|
|
public function setWide($wide) { |
44
|
|
|
$wide=Wide::getConstants()["W" . $wide]; |
45
|
|
|
return $this->addToPropertyCtrl("class", $wide, Wide::getConstants()); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
abstract public function newItem($identifier); |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return HtmlViewGroups |
52
|
|
|
*/ |
53
|
|
|
public function getItem($index){ |
54
|
|
|
return parent::getItem($index); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function getItemContent($itemIndex, $contentIndex) { |
58
|
|
|
$item=$this->getItem($itemIndex); |
59
|
|
|
if (isset($item)) { |
60
|
|
|
return $item->getItemContent($contentIndex); |
|
|
|
|
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function fromDatabaseObject($object, $function) { |
65
|
|
|
return $this->addItem($function($object)); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
public function run(JsUtils $js){ |
69
|
|
|
$result=parent::run($js); |
70
|
|
|
return $result->setItemSelector(".item"); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.