Skip to content
Browse files

Merge branch '0.8' of github.com:JeCat/framework into 0.8

  • Loading branch information...
2 parents 5559b3e + 3162aa5 commit ab682b33b92cec68ac2f761ae17740aec66fcde2 @aleechou aleechou committed Jun 8, 2012
View
1 class/bean/BeanFactory.php
@@ -65,6 +65,7 @@ static public function singleton($bCreateNew=true,$createArgvs=null,$sClass=null
$aSingleton->registerBeanClass("org\\jecat\\framework\\mvc\\view\\widget\\RadioGroup",'radio') ;
$aSingleton->registerBeanClass("org\\jecat\\framework\\mvc\\view\\widget\\Text",'hidden') ;
+ $aSingleton->registerBeanClass("org\\jecat\\framework\\mvc\\view\\widget\\Text",'password') ;
// verifyers
View
51 class/mvc/view/uicompiler/WidgetCompiler.php
@@ -33,6 +33,7 @@
use org\jecat\framework\ui\ObjectContainer;
use org\jecat\framework\bean\BeanConfXml;
use org\jecat\framework\ui\xhtml\Attributes;
+use org\jecat\framework\ui\xhtml\Expression;
/**
*
@@ -143,8 +144,24 @@ protected function writeObject(Attributes $aAttrs , ObjectContainer $aObjectCont
protected function writeAttr(Attributes $aAttrs , TargetCodeOutputStream $aDev , $sWidgetVarName){
$arrAttr = array();
foreach($aAttrs as $sName=>$aValue){
+ if(
+ in_array(
+ $sName ,
+ array(
+ 'instance'
+ )
+ )
+ ){
+ continue;
+ }
$arrNamePart = explode('.',$sName);
+ // expression
+ if( count($arrNamePart) >1 and end($arrNamePart) ==='type' ){
+ continue;
+ }
+
+
$arrSubAttr = &$arrAttr ;
foreach($arrNamePart as $sNamePart){
if( !isset( $arrSubAttr[$sNamePart] ) ){
@@ -153,15 +170,41 @@ protected function writeAttr(Attributes $aAttrs , TargetCodeOutputStream $aDev ,
$arrSubAttr = & $arrSubAttr[$sNamePart];
}
- $arrSubAttr = trim($aAttrs->get($sName) ,'"');
+ $arrSubAttr = $aAttrs->get($sName) ;
unset($arrSubAttr);
}
- $strAttrExport = var_export( $arrAttr , true );
- $aDev->putCode(" \$arrBean = $strAttrExport ;",'preprocess');
- $aDev->putCode(" \$arrBean = $strAttrExport ;",'render');
+ $aDev->putCode(" \$arrBean = ",'preprocess');
+ $this->writeAttrPri( $arrAttr , $aDev , 1 , 'preprocess' );
+ $aDev->putCode(" ;",'preprocess');
$aDev->putCode(" {$sWidgetVarName}->buildBean( \$arrBean ); ",'preprocess');
+
+ $aDev->putCode(" \$arrBean = ",'render');
+ $this->writeAttrPri( $arrAttr , $aDev , 1 , 'render' );
+ $aDev->putCode(" ;",'render');
+ }
+
+ private function writeAttrPri(array $arrAttr,TargetCodeOutputStream $aDev , $nTabCount , $sSubTemplateName){
+ $aDev->putCode(str_repeat(' ',$nTabCount)." array(" , $sSubTemplateName );
+
+ foreach($arrAttr as $key => $value){
+ if( is_string( $value ) or is_int( $value ) ){
+ $aDev->putCode( str_repeat(' ',$nTabCount).'"'.$key.'"'.' => '.$value.' ,' , $sSubTemplateName );
+ }else
+ if( is_array( $value ) ){
+ $aDev->putCode( str_repeat(' ',$nTabCount).'"'.$key.'"'.' => ', $sSubTemplateName );
+ $this->writeAttrPri( $value , $aDev , $nTabCount+1 , $sSubTemplateName );
+ $aDev->putCode( ' , ', $sSubTemplateName );
+ }else if( $value instanceof Expression ){
+ //echo 'expression:';var_dump($value);
+ $aDev->putCode( str_repeat(' ',$nTabCount).'"'.$key.'"'.' => ', $sSubTemplateName );
+ $aDev->putCode( $value , $sSubTemplateName );
+ $aDev->putCode( ' , ', $sSubTemplateName );
+ }
+ }
+
+ $aDev->putCode(str_repeat(' ',$nTabCount)." )",$sSubTemplateName);
}
protected function writeBean(IObject $aObject , TargetCodeOutputStream $aDev , $sWidgetVarName){
View
20 class/mvc/view/widget/menu/Menu.php
@@ -30,6 +30,7 @@
use org\jecat\framework\ui\UI;
use org\jecat\framework\io\IOutputStream;
use org\jecat\framework\util\IHashTable;
+use org\jecat\framework\util\HashTable;
HtmlResourcePool::singleton()->addRequire('org.jecat.framework:style/widget/menu.css',HtmlResourcePool::RESRC_CSS) ;
HtmlResourcePool::singleton()->addRequire('org.jecat.framework:js/mvc/view/widget/menu.js',HtmlResourcePool::RESRC_JS) ;
@@ -357,27 +358,30 @@ public function findActiveSubMenu($nDepth)
public function display(UI $aUI,IHashTable $aVariables=null,IOutputStream $aDevice=null)
{
- if(($depth=$this->attribute('depth'))!==null)
+ $arrAttr = $aVariables->get('attr');
+ if( isset($arrAttr['depth']) and $depth = $arrAttr['depth'] )
{
if( $aMenu = $this->findActiveSubMenu((int)$depth) )
{
+ unset($arrAttr['depth']);
+ $aVariables->set('attr',$arrAttr);
$aMenu->display($aUI,$aVariables,$aDevice);
}
}
- else if(($xpath=$this->attribute('xpath'))!==null)
+ else if( isset( $arrAttr['xpath']) and $xpath=$arrAttr['xpath'] )
{
if( $aMenu = $this ->getMenuByPath($xpath) )
{
$aMenu->display($aUI,$aVariables,$aDevice);
}
}
-
- else
+ else if( isset( $arrAttr['showDepths'] ) and $showDepths = (int)$arrAttr['showDepths'] and $showDepths > 0)
{
- if($this->showDepths()!=0 || $this->isRenderAll() )
- {
- parent::display($aUI,$aVariables,$aDevice) ;
- }
+ $arrAttr['showDepths'] = $showDepths -1 ;
+ $aVariables->set('attr',$arrAttr);
+ parent::display($aUI,$aVariables,$aDevice) ;
+ }else if( !isset( $arrAttr['showDepths'] ) ){
+ parent::display($aUI,$aVariables,$aDevice) ;
}
}
View
2 template/WidgetItem.template.html
@@ -14,6 +14,6 @@
</if>
<if "$theWidget->isDisplaySubMenu()" >
- <widget instance="$theWidget->subMenu()" />
+ <widget instance="$theWidget->subMenu()" attr.showDepths="$attr['showDepths']" attr.showDepths.type="expression" />
</if>
</li>
View
2 template/WidgetMenu.template.html
@@ -6,7 +6,7 @@
showOnMouseOver="{=$theWidget->isShowOnMouseOver()?'on':'off'}"
showDepth="{=$theWidget->showDepths()}" >
<foreach for='$theWidget->itemIterator()' item='aItem'>
- <widget instance='$aItem' />
+ <widget instance='$aItem' attr.showDepths="$attr['showDepths']" attr.showDepths.type="expression" />
</foreach>
<li class="clear"></li>
</ul>

0 comments on commit ab682b3

Please sign in to comment.
Something went wrong with that request. Please try again.