Completed
Push — master ( b23d1e...03b6f4 )
by Jean-Christophe
04:33
created

HtmlAccordion::renderContentPanel()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 6
1
<?php
2
3
namespace Ajax\bootstrap\html;
4
5
use Ajax\bootstrap\html\base\HtmlBsDoubleElement;
6
use Ajax\JsUtils;
7
8
9
/**
10
 * Composant Twitter Bootstrap Accordion
11
 * @see http://getbootstrap.com/javascript/#collapse-example-accordion
12
 * @author jc
13
 * @version 1.001
14
 */
15
class HtmlAccordion extends HtmlBsDoubleElement {
16
17
	public function __construct($identifier, $tagName="div") {
18
		parent::__construct($identifier, $tagName);
19
		$this->setClass("panel-group");
20
		$this->setRole("tablist");
21
		$this->setProperty("aria-multiselectable", "true");
22
		$this->content=array ();
23
	}
24
25
	public function addPanel($title, $content) {
26
		$nb=sizeof($this->content)+1;
27
		$panel=new HtmlPanel("panel-".$this->identifier."-".$nb);
28
		$link=new HtmlLink("lnk-panel-".$this->identifier."-".$nb);
29
		$link->setProperty("data-toggle", "collapse");
30
		$link->setProperty("data-parent", "#".$this->identifier);
31
		$link->setHref("#collapse-panel-".$this->identifier."-".$nb);
32
		$link->setContent($title);
33
		$panel->addHeader($link);
34
		$panel->setContent($content);
35
		$panel->setCollapsable(true);
36
		$this->content []=$panel;
37
		return $panel;
38
	}
39
40
	/**
41
	 * render the content of an existing view : $controller/$action and set the response to a new panel
42
	 * @param JsUtils $js
43
	 * @param string $title The panel title
44
	 * @param Controller $initialController
45
	 * @param string $viewName
46
	 * @param $params The parameters to pass to the view
47
	 */
48
	public function renderViewPanel(JsUtils $js,$title,$initialController, $viewName, $params=array()) {
49
		return $this->addPanel($title, $js->renderContent($initialController, $viewName,$params));
0 ignored issues
show
Documentation introduced by
$viewName is of type string, but the function expects a object<Ajax\view>.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
50
	}
51
52
		/**
53
	 * render the content of $controller::$action and set the response to a new panel
54
	 * @param JsUtils $js
55
	 * @param string $title The panel title
56
	 * @param Controller $initialController
57
	 * @param string $controller a Phalcon controller
58
	 * @param string $action a Phalcon action
59
	 * @param array $params
60
	 */
61
	public function forwardPanel(JsUtils $js,$title,$initialController,$controller,$action,$params=array()){
62
		return $this->addPanel($title, $js->forward($initialController, $controller, $action,$params));
63
	}
64
65
	public function run(JsUtils $js) {
66
		foreach ( $this->content as $content ) {
67
			$content->run($js);
68
		}
69
	}
70
71
	public function getPanel($index) {
72
		if ($index<sizeof($this->content))
73
			return $this->content [$index];
74
	}
75
}