1212use Ajax \semantic \html \base \constants \RevealType ;
1313use Ajax \semantic \html \elements \HtmlButtonGroups ;
1414use Ajax \semantic \html \content \view \HtmlViewContent ;
15- use Ajax \service \JReflection ;
1615
1716abstract class HtmlViewItem extends HtmlSemDoubleElement {
18-
19- protected $ _sortContentBy =[];
17+ use ContentPartTrait;
2018
2119 public function __construct ($ identifier ,$ baseClass ,$ content =NULL ) {
2220 parent ::__construct ($ identifier , "div " , $ baseClass );
@@ -47,9 +45,9 @@ private function createContent($content, $baseClass="content") {
4745 return $ result ;
4846 }
4947
50- private function addElementInContent ($ key , $ element ) {
48+ private function addElementIn ($ key , $ element ) {
5149 if (\array_key_exists ($ key , $ this ->content ) === false ) {
52- $ this ->content [$ key ]=array () ;
50+ $ this ->content [$ key ]=[] ;
5351 }
5452 if ($ this ->content [$ key ] instanceof HtmlViewContent)
5553 $ this ->content [$ key ]->addElement ($ element );
@@ -58,23 +56,12 @@ private function addElementInContent($key, $element) {
5856 return $ element ;
5957 }
6058
61- private function getPart ($ part , $ index =NULL ) {
62- if ($ this ->content instanceof HtmlViewContent){
63- return $ this ->content ->getPart ($ part ,$ index );
64- }
65- if (\array_key_exists ($ part , $ this ->content )) {
66- if (isset ($ index ))
67- return $ this ->content [$ part ][$ index ];
68- return $ this ->content [$ part ];
69- }
70- return NULL ;
71- }
7259
7360 public function addHeader ($ header , $ niveau =4 , $ type ="page " ) {
7461 if (!$ header instanceof HtmlHeader) {
7562 $ header =new HtmlHeader ("header- " . $ this ->identifier , $ niveau , $ header , $ type );
7663 }
77- return $ this ->addElementInContent ("header " ,$ this ->createContent ($ header ));
64+ return $ this ->addElementIn ("header " ,$ this ->createContent ($ header ));
7865 }
7966
8067 public function addImage ($ image , $ title ="" ) {
@@ -85,12 +72,12 @@ public function addImage($image, $title="") {
8572 return $ this ->content ["image " ]= $ image ;
8673 }
8774
88- public function addReveal ($ visibleContent , $ hiddenContent =NULL , $ type =RevealType::FADE , $ attributeType =NULL ) {
75+ public function addReveal ($ visibleContent , $ hiddenContent =NULL , $ type =RevealType::FADE , $ attributeType =NULL , $ key = " extra-content " ) {
8976 $ reveal =$ visibleContent ;
9077 if (!$ visibleContent instanceof HtmlReveal) {
9178 $ reveal =new HtmlReveal ("reveral- " . $ this ->identifier , $ visibleContent , $ hiddenContent , $ type , $ attributeType );
9279 }
93- return $ this ->content [" image " ]= $ reveal ;
80+ return $ this ->content [$ key ]= $ reveal ;
9481 }
9582
9683 public function addRevealImage ($ visibleContent , $ hiddenContent =NULL , $ type =RevealType::FADE , $ attributeType =NULL ) {
@@ -105,23 +92,23 @@ public function addExtraContent($content=array()) {
10592 return $ this ->content ["extra-content " ]= $ this ->createContent ($ content , "extra content " );
10693 }
10794
108- public function addContent ($ content =array (), $ before =false ) {
95+ /* public function addContent($content=array(), $before=false) {
10996 if (!$content instanceof HtmlViewContent) {
11097 $content=$this->createContent($content);
11198 }
11299 $this->content["content"]->addElement($content);
113100 return $content;
114- }
101+ }*/
115102
116103 /**
117104 * @param array $elements
118105 * @param boolean $asIcons
119- * @return \Ajax\semantic\html\elements\HtmlButtonGroups
106+ * @param string $part
107+ * @param boolean $before
108+ * @return HtmlButtonGroups
120109 */
121- public function addButtons ($ elements =array (), $ asIcons =false ,$ key ="extra-content " ){
122- $ buttons =new HtmlButtonGroups ("buttons- " .$ this ->identifier ,$ elements ,$ asIcons );
123- $ this ->addElementInContent ($ key , $ buttons );
124- return $ buttons ;
110+ public function addContentButtons ($ elements =array (), $ asIcons =false ,$ part ="extra " ,$ before =false ){
111+ return $ this ->content ["content " ]->addContentButtons ($ elements ,$ asIcons ,$ part , $ before );
125112 }
126113
127114
@@ -132,11 +119,11 @@ public function addItemHeaderContent($header, $metas=array(), $description=NULL,
132119
133120 public function addItemContent ($ content =array ()) {
134121 $ count =\sizeof ($ this ->content );
135- return $ this ->addElementInContent ("content " , new HtmlViewContent ("content- " . $ count . "- " . $ this ->identifier , $ content ));
122+ return $ this ->addElementIn ("content " , new HtmlViewContent ("content- " . $ count . "- " . $ this ->identifier , $ content ));
136123 }
137124
138- public function getItemContent ($ index = NULL ) {
139- return $ this ->content [ "content " ]-> getPart ( $ index );
125+ public function getItemContent () {
126+ return $ this ->getPart ( "content " , null , true );
140127 }
141128
142129 public function getItemExtraContent () {
0 commit comments