1
|
|
|
<?php |
2
|
|
|
namespace Ajax\semantic\html\modules; |
3
|
|
|
|
4
|
|
|
use Ajax\semantic\html\base\HtmlSemCollection; |
5
|
|
|
use Ajax\semantic\html\elements\HtmlSegment; |
6
|
|
|
use Ajax\semantic\html\collections\menus\HtmlMenu; |
7
|
|
|
use Ajax\semantic\html\base\constants\Side; |
8
|
|
|
use Ajax\JsUtils; |
9
|
|
|
|
10
|
|
|
class HtmlTab extends HtmlSemCollection{ |
11
|
|
|
protected $params=array(); |
12
|
|
|
|
13
|
|
|
public function __construct( $identifier, $tabs=array()){ |
14
|
|
|
parent::__construct( $identifier, "div", ""); |
15
|
|
|
$menu=new HtmlMenu("menu".$this->identifier); |
16
|
|
|
$menu->asTab(false)->setAttachment(NULL,Side::TOP); |
|
|
|
|
17
|
|
|
$this->content["menu"]=$menu; |
18
|
|
|
$this->addItems($tabs); |
19
|
|
|
if(\sizeof($tabs)>0) |
20
|
|
|
$this->activate(0); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
protected function createItem($value){ |
24
|
|
|
$count=$this->count(); |
25
|
|
|
$title=$value; |
26
|
|
|
$content=NULL; |
27
|
|
|
if(\is_array($value)){ |
28
|
|
|
$title=@$value[0];$content=@$value[1]; |
29
|
|
|
} |
30
|
|
|
$menuItem=$this->content["menu"]->addItem($title); |
31
|
|
|
$menuItem->addToProperty("data-tab", $menuItem->getIdentifier()); |
32
|
|
|
$menuItem->removeProperty("href"); |
33
|
|
|
$segment=new HtmlSegment("item-".$this->identifier."-".$count, $content); |
34
|
|
|
$segment->setAttachment(NULL,Side::BOTTOM)->addToProperty("class", "tab")->addToProperty("data-tab",$menuItem->getIdentifier()); |
|
|
|
|
35
|
|
|
return $segment; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function activate($index){ |
39
|
|
|
$this->content["menu"]->getItem($index)->setActive(true); |
40
|
|
|
$this->content[$index]->setActive(true); |
41
|
|
|
return $this; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function addPanel($title,$content){ |
45
|
|
|
return $this->addItem([$title,$content]); |
|
|
|
|
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* render the content of $controller::$action and set the response to a new panel |
50
|
|
|
* @param JsUtils $js |
51
|
|
|
* @param string $title The panel title |
52
|
|
|
* @param Controller $initialController |
53
|
|
|
* @param string $controller a Phalcon controller |
54
|
|
|
* @param string $action a Phalcon action |
55
|
|
|
* @param array $params |
56
|
|
|
*/ |
57
|
|
|
public function forwardPanel(JsUtils $js,$title,$initialController,$controller,$action,$params=array()){ |
58
|
|
|
return $this->addPanel($title, $js->forward($initialController, $controller, $action,$params)); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* render the content of an existing view : $controller/$action and set the response to a new panel |
63
|
|
|
* @param JsUtils $js |
64
|
|
|
* @param string $title The panel title |
65
|
|
|
* @param Controller $initialController |
66
|
|
|
* @param string $viewName |
67
|
|
|
* @param $params The parameters to pass to the view |
68
|
|
|
*/ |
69
|
|
|
public function renderViewPanel(JsUtils $js,$title,$initialController, $viewName, $params=array()) { |
70
|
|
|
return $this->addPanel($title, $js->renderContent($initialController, $viewName,$params)); |
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
/* |
74
|
|
|
* (non-PHPdoc) |
75
|
|
|
* @see BaseHtml::run() |
76
|
|
|
*/ |
77
|
|
|
public function run(JsUtils $js) { |
78
|
|
View Code Duplication |
if(isset($this->_bsComponent)===false) |
|
|
|
|
79
|
|
|
$this->_bsComponent=$js->semantic()->tab("#".$this->identifier." .item",$this->params); |
80
|
|
|
$this->addEventsOnRun($js); |
81
|
|
|
return $this->_bsComponent; |
82
|
|
|
} |
83
|
|
|
} |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: