11<?php
2-
32namespace Ajax \common ;
43
5-
64use Ajax \common \components \SimpleComponent ;
75use Ajax \JsUtils ;
86use Ajax \common \html \BaseHtml ;
97
108/**
119 * BaseGui Phalcon library
10+ *
1211 * @author jcheron
13- * @version 1.001
12+ * @version 1.02
1413 */
1514
1615/**
1716 * BaseGui
1817 */
1918class BaseGui {
19+
2020 protected $ autoCompile ;
21+
2122 protected $ components ;
23+
2224 protected $ htmlComponents ;
25+
2326 /**
2427 *
2528 * @var \Ajax\JsUtils
2629 */
2730 protected $ js ;
2831
29- public function __construct ($ autoCompile= true ) {
30- $ this ->autoCompile = $ autoCompile ;
31- $ this ->components = array ();
32- $ this ->htmlComponents = array ();
32+ public function __construct ($ autoCompile = true ) {
33+ $ this ->autoCompile = $ autoCompile ;
34+ $ this ->components = array ();
35+ $ this ->htmlComponents = array ();
3336 }
3437
3538 public function isAutoCompile () {
3639 return $ this ->autoCompile ;
3740 }
3841
3942 public function setAutoCompile ($ autoCompile ) {
40- $ this ->autoCompile = $ autoCompile ;
43+ $ this ->autoCompile = $ autoCompile ;
4144 return $ this ;
4245 }
4346
44- public function compile ($ internal= false ) {
45- if ($ internal ===false && $ this ->autoCompile ===true )
47+ public function compile ($ internal = false ) {
48+ if ($ internal === false && $ this ->autoCompile === true )
4649 throw new \Exception ("Impossible to compile if autoCompile is set to 'true' " );
47- foreach ( $ this ->components as $ component ) {
50+ foreach ($ this ->components as $ component ) {
4851 $ component ->compile ();
4952 }
5053 }
5154
5255 public function setJs (JsUtils $ js ) {
53- $ this ->js = $ js ;
56+ $ this ->js = $ js ;
5457 }
5558
5659 public function addComponent (SimpleComponent $ component , $ attachTo , $ params ) {
57- if ($ this ->autoCompile ){
58- if ($ attachTo !=null ){
59- if (!isset ($ this ->components [$ attachTo ])){
60- $ this ->components [$ attachTo ]=$ component ;
60+ if ($ this ->autoCompile ) {
61+ if ($ attachTo != null ) {
62+ if (! isset ($ this ->components [$ attachTo ])) {
63+ $ this ->components [$ attachTo ] = $ component ;
64+ } else {
65+ $ this ->components [] = $ component ;
6166 }
6267 $ component ->attach ($ attachTo );
63- }else {
64- $ this ->components []= $ component ;
68+ } else {
69+ $ this ->components [] = $ component ;
6570 }
6671 }
6772 if (isset ($ params ))
@@ -71,17 +76,17 @@ public function addComponent(SimpleComponent $component, $attachTo, $params) {
7176 }
7277
7378 public function addHtmlComponent (BaseHtml $ htmlComponent ) {
74- $ this ->htmlComponents [$ htmlComponent ->getIdentifier ()]= $ htmlComponent ;
79+ $ this ->htmlComponents [$ htmlComponent ->getIdentifier ()] = $ htmlComponent ;
7580 return $ htmlComponent ;
7681 }
7782
78- public function compileHtml (JsUtils $ js= NULL , &$ view= NULL ) {
79- foreach ( $ this ->htmlComponents as $ htmlComponent ) {
83+ public function compileHtml (JsUtils $ js = NULL , &$ view = NULL ) {
84+ foreach ($ this ->htmlComponents as $ htmlComponent ) {
8085 $ htmlComponent ->compile ($ js , $ view );
8186 }
8287 }
83-
84- public function matchHtmlComponents ($ callback ){
85- return array_filter ($ this ->htmlComponents ,$ callback );
88+
89+ public function matchHtmlComponents ($ callback ) {
90+ return array_filter ($ this ->htmlComponents , $ callback );
8691 }
8792}
0 commit comments