phpMv  -UI toolkit 2.4.12
jQuery, jQuery UI, Twitter Bootstrap and Semantic-UI library for php & php MVC Frameworks
HtmlViewGroups.php
Go to the documentation of this file.
1 <?php
2 
4 
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 
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 
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 }
static getValue($array, $key, $pos)
Definition: JArray.php:10
static getConstants()
Definition: BaseEnum.php:17
setWide($wide)
Defines the ites width (alias for setWidth)
addItem($item)
adds and returns an item
__construct($identifier, $uiClass, $items=array())
Base class for Semantic Html collections.
JQuery PHP library.
Definition: JsUtils.php:23
addToPropertyCtrl($name, $value, $typeCtrl)