Example #1
0
 /**
  * @param sPath string 前后都没有/
  */
 protected function writeSubMenu(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager, $sWidgetVarName)
 {
     $arrTagName = array('menu', 'item');
     foreach ($aObject->childElementsIterator() as $aChild) {
         if ($aChild instanceof Node and in_array($aChild->tagName(), $arrTagName)) {
             $aItemNode = $aChild;
             $aItemAttrs = $aItemNode->attributes();
             if ($aItemAttrs->has('id')) {
                 $sItemId = $aItemAttrs->string('id');
                 if ($aChild->tagName() === 'menu') {
                     $aAttrValue = AttributeValue::createInstance('instance', " \$aStack->get()->getMenuByPath( '{$sItemId}' ) ");
                 } else {
                     $aAttrValue = AttributeValue::createInstance('instance', " \$aStack->get()->getItemByPath( '{$sItemId}' ) ");
                 }
                 $aItemAttrs->add($aAttrValue);
                 $aAttrValue->setParent($aObjectContainer);
                 $aAttrValue = AttributeValue::createInstance('display', false);
                 $aItemAttrs->add($aAttrValue);
                 $aAttrValue->setParent($aObjectContainer);
             } else {
                 // @todo for add
             }
         }
     }
     if (!$aObjectContainer->variableDeclares()->hasDeclared('aStack')) {
         $aObjectContainer->variableDeclares()->declareVarible('aStack', 'new \\org\\jecat\\framework\\util\\Stack()');
     }
     $aDev->write("\t\$aStack->put({$sWidgetVarName});");
     $aDev->write("\t\$aVariables->aStack = \$aStack;");
     $this->compileChildren($aObject, $aObjectContainer, $aDev, $aCompilerManager);
     $aDev->write("\t\$aStack->out();");
 }
Example #2
0
 public function set($sName, $sValue, $sQuoteType = '"', $nPosition = -1, $nLine = -1)
 {
     $aVal = new AttributeValue($sName, $sQuoteType, $nPosition, $nLine);
     $aVal->setSource($sValue);
     $this->add($aVal);
 }