1
|
|
|
<?php |
2
|
|
|
namespace Ajax\semantic\html\base; |
3
|
|
|
|
4
|
|
|
use Ajax\JsUtils; |
5
|
|
|
use Ajax\service\JArray; |
6
|
|
|
/** |
7
|
|
|
* Sem class for navigation elements : Breadcrumbs and Pagination |
8
|
|
|
* @author jc |
9
|
|
|
* @version 1.001 |
10
|
|
|
*/ |
11
|
|
|
abstract class HtmlSemNavElement extends HtmlSemCollection { |
12
|
|
|
/** |
13
|
|
|
* @var string the root site |
14
|
|
|
*/ |
15
|
|
|
protected $root; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var String the html attribute which contains the elements url. default : data-ajax |
19
|
|
|
*/ |
20
|
|
|
protected $attr; |
21
|
|
|
|
22
|
|
|
protected $_contentSeparator=""; |
23
|
|
|
|
24
|
|
|
|
25
|
|
|
public function __construct($identifier,$tagName,$baseClass){ |
26
|
|
|
parent::__construct($identifier,$tagName,$baseClass); |
27
|
|
|
$this->root=""; |
28
|
|
|
$this->attr="data-ajax"; |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Associate an ajax get to the elements, displayed in $targetSelector |
33
|
|
|
* $attr member is used to build each element url |
34
|
|
|
* @param string $targetSelector the target of the get |
35
|
|
|
* @param string $attr the html attribute used to build the elements url |
|
|
|
|
36
|
|
|
* @return HtmlNavElement |
37
|
|
|
*/ |
38
|
|
|
public function autoGetOnClick($targetSelector){ |
39
|
|
|
return $this->getOnClick($this->root, $targetSelector,array("attr"=>$this->attr)); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function contentAsString(){ |
43
|
|
|
return JArray::implode($this->_contentSeparator, $this->content); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Generate the jquery script to set the elements to the HtmlNavElement |
48
|
|
|
* @param JsUtils $jsUtils |
49
|
|
|
*/ |
50
|
|
|
public function jsSetContent(JsUtils $jsUtils){ |
51
|
|
|
$jsUtils->html("#".$this->identifier,str_replace("\"","'", $this->contentAsString()),true); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
public function getRoot() { |
55
|
|
|
return $this->root; |
56
|
|
|
} |
57
|
|
|
public function setRoot($root) { |
58
|
|
|
$this->root = $root; |
59
|
|
|
return $this; |
60
|
|
|
} |
61
|
|
|
public function getAttr() { |
62
|
|
|
return $this->attr; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Define the html attribute for each element url in ajax |
67
|
|
|
* @param string $attr html attribute |
68
|
|
|
* @return HtmlNavElement |
69
|
|
|
*/ |
70
|
|
|
public function setAttr($attr) { |
71
|
|
|
$this->attr = $attr; |
72
|
|
|
return $this; |
73
|
|
|
} |
74
|
|
|
|
75
|
|
View Code Duplication |
public function __call($method, $args) { |
|
|
|
|
76
|
|
|
if(isset($this->$method) && is_callable($this->$method)) { |
77
|
|
|
return call_user_func_array( |
78
|
|
|
$this->$method, |
79
|
|
|
$args |
80
|
|
|
); |
81
|
|
|
} |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
public abstract function fromDispatcher($dispatcher,$startIndex=0); |
|
|
|
|
85
|
|
|
|
86
|
|
|
|
87
|
|
|
public function setContentDivider($divider,$index=NULL) { |
88
|
|
|
$divider="<div class='divider'> {$divider} </div>"; |
89
|
|
|
return $this->setDivider($divider, $index); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function setIconContentDivider($iconContentDivider,$index=NULL) { |
93
|
|
|
$contentDivider="<i class='".$iconContentDivider." icon divider'></i>"; |
94
|
|
|
return $this->setDivider($contentDivider, $index); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
protected function setDivider($divider,$index){ |
98
|
|
|
if(isset($index)){ |
99
|
|
|
if(\is_array($this->_contentSeparator)===false) |
100
|
|
|
$this->_contentSeparator=array_fill (0, $this->count()-1,$this->_contentSeparator); |
|
|
|
|
101
|
|
|
$this->_contentSeparator[$index]=$divider; |
102
|
|
|
}else{ |
103
|
|
|
$this->_contentSeparator=$divider; |
104
|
|
|
} |
105
|
|
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
protected function getContentDivider($index){ |
109
|
|
|
if(\is_array($this->_contentSeparator)===true){ |
110
|
|
|
return @$this->_contentSeparator[$index]; |
111
|
|
|
} |
112
|
|
|
return $this->_contentSeparator; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
|
116
|
|
|
} |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.