public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject, 'aObject'); $aAttrs = $aObject->attributes(); if (!$aAttrs->has('id')) { throw new Exception("widget标签缺少必要属性:%s", 'id'); } $sId = $aAttrs->get('id'); $aDev->write("\$__ui_widget = \$aVariables->get('theView')->widget( {$sId} ) ;\r\n"); $aDev->write("if(!\$__ui_widget){"); $aDev->write("\tthrow new \\org\\jecat\\framework\\lang\\Exception('指定的widget id(%s)不存在,无法显示该widget的消息队列',array({$sId})) ; \r\n"); $aDev->write("}else{"); // 使用 <msgqueue> 节点内部的模板内容 if ($aTemplate = $aObject->getChildNodeByTagName('template')) { $sOldMsgQueueVarVarName = '$' . parent::assignVariableName('_aOldMsgQueueVar'); $aDev->write("\t{$sOldMsgQueueVarVarName}=\$aVariables->get('aMsgQueue') ;"); $aDev->write("\t\$aVariables->set('aMsgQueue',\$__ui_widget->messageQueue()) ;"); $this->compileChildren($aTemplate, $aObjectContainer, $aDev, $aCompilerManager); $aDev->write("\t\$aVariables->set('aMsgQueue',{$sOldMsgQueueVarVarName}) ;"); } else { $aDev->write("\tif( \$__ui_widget->messageQueue()->count() ){ \r\n"); $aDev->write("\t\t\$__ui_widget->messageQueue()->display(\$this,\$aDevice) ;\r\n"); $aDev->write("\t}\r\n"); } $aDev->write("}"); }
public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { if ($aObject instanceof \org\jecat\framework\ui\xhtml\ObjectBase and !$aObject->count()) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Text", $aObject, 'aObject'); $sText = $aObject->source(); // locale translate do { if (!trim($sText)) { break; } // 排除 script/style 等标签中的内容 if ($aParent = $aObject->parent() and $aParent instanceof Node and in_array(strtolower($aParent->tagName()), array('script', 'style'))) { break; } // 仅 title alt 等属性 if ($aObject instanceof AttributeValue and !in_array(strtolower($aObject->name()), array('title', 'alt'))) { break; } // 过滤 注释 和 doctype 声明 if (preg_match('/^\\s*<\\!.*>\\s*$/', $sText)) { break; } $sText = Locale::singleton()->trans($sText, null, 'ui'); } while (0); $aDev->output($sText); } else { $this->compileChildren($aObject, $aObjectContainer, $aDev, $aCompilerManager); } }
public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject, 'aObject'); if (!$aObjectContainer->variableDeclares()->hasDeclared('aStackForLoopIsEnableToRun')) { $aObjectContainer->variableDeclares()->declareVarible('aStackForLoopIsEnableToRun', 'new \\org\\jecat\\framework\\util\\Stack()'); } $aAttrs = $aObject->attributes(); $sIdx = $aAttrs->has('idx') ? $aAttrs->string('idx') : ''; $sItem = $aAttrs->has('item') ? $aAttrs->string('item') : 'theModel'; $sFor = $aAttrs->has('for') ? $aAttrs->get('for') : "\$aVariables->get('theModel')"; $aDev->write("if(\$aForModel={$sFor}){\r\n"); if ($sIdx) { $aDev->write("\t\${$sIdx}=0;\r\n"); } $aDev->write("\t\$aStackForLoopIsEnableToRun->put(false);"); $aDev->write("\t\tforeach(\$aForModel->childIterator() as \$__aChildModel){\r\n"); $aDev->write("\t\t\t\$aVariables->set('{$sItem}',\$__aChildModel) ;\r\n\t\t\$bLoopIsEnableToRun = & \$aStackForLoopIsEnableToRun->getRef();\r\n\t\t\$bLoopIsEnableToRun = true;\r\n"); if ($sIdx) { $aDev->write("\t\t\t\$aVariables->set('{$sIdx}',\${$sIdx}++) ;\r\n"); } if (!$aObject->headTag()->isSingle()) { $this->compileChildren($aObject, $aObjectContainer, $aDev, $aCompilerManager); $aDev->write("\t}\r\n}\r\n"); } }
public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Macro", $aObject, 'aObject'); if ($aCompiler = $this->subCompiler($aObject->macroType())) { $aCompiler->compile($aObject, $aObjectContainer, $aDev, $aCompilerManager); } else { $aDev->write($aObject->source()); } }
public function set($sName, $Value) { if ($this->sClass) { Assert::type($this->sClass, $Value, 'Value'); } $oldVal = isset($this->arrDatas[$sName]) ? $this->arrDatas[$sName] : null; $this->arrDatas[$sName] = $Value; return $oldVal; }
public function complete(IObject $aObject, string $aSource, $nPosition) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Macro", $aObject, 'aObject'); $sTextPos = $aObject->position() + strlen($aObject->borderStartMacro()) + 1; $sTextLen = $nPosition - strlen($aObject->borderEndMacro()) - $sTextPos + 1; $sText = $aSource->substr($sTextPos, $sTextLen); $aObject->setEndPosition($nPosition); $aObject->setSource($sText); return $aObject->parent(); }
public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject, 'aObject'); if ($aCompiler = $this->subCompiler(strtolower($aObject->tagName()))) { $aCompiler->compile($aObject, $aObjectContainer, $aDev, $aCompilerManager); } else { $this->compileTag($aObject->headTag(), $aObjectContainer, $aDev, $aCompilerManager); if ($aTailTag = $aObject->tailTag()) { $this->compileChildren($aObject, $aObjectContainer, $aDev, $aCompilerManager); $this->compileTag($aTailTag, $aObjectContainer, $aDev, $aCompilerManager); } } }
protected function generateOriginJointCode(GenerateStat $aStat) { Assert::type("org\\jecat\\framework\\lang\\compile\\object\\CallFunction", $aStat->aExecutePoint); $aStat->sOriginJointCode = ''; // 类名 或 对象变量 if ($aObject = $aStat->aExecutePoint->classToken()) { $aStat->sOriginJointCode .= $aObject->targetCode(); if (!$aStat->aExecutePoint->classToken()) { throw new Exception("方法调用缺少成员访问符"); } $aStat->sOriginJointCode .= $aStat->aExecutePoint->setAccessToken(); } // 函数名 $aStat->sOriginJointCode .= $aStat->aExecutePoint->targetCode(); }
public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject, 'aObject'); // 使用 <msgqueue> 节点内部的模板内容 if ($aTemplate = $aObject->getChildNodeByTagName('template')) { $sOldMsgQueueVarVarName = '$' . parent::assignVariableName('_aOldMsgQueueVar'); $aDev->write("\t{$sOldMsgQueueVarVarName}=\$aVariables->get('aMsgQueue') ;"); $aDev->write("\t\$aVariables->set('aMsgQueue',\$aVariables->get('theView')->messageQueue()) ;"); $this->compileChildren($aTemplate, $aObjectContainer, $aDev, $aCompilerManager); $aDev->write("\t\$aVariables->set('aMsgQueue',{$sOldMsgQueueVarVarName}) ;"); } else { $aDev->write("if( \$aVariables->get('theView')->messageQueue()->count() ){ \r\n"); $aDev->write("\t\$aVariables->get('theView')->messageQueue()->display(\$this,\$aDevice) ;\r\n"); $aDev->write("}\r\n"); } }
public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject, 'aObject'); $aAttrs = $aObject->attributes(); if ($aAttrs->has('name')) { $sName = $aAttrs->get('name'); } else { $aIterator = $aObject->iterator(); if (!($aFirst = $aIterator->current())) { throw new Exception("%s 对象却少数据名称", $aObject->tagName()); } $sName = '"' . addslashes($aFirst->source()) . '"'; } $aDev->write("if(\$theModel=\$aVariables->get('theModel')){\r\n"); $aDev->write("\t\$aDevice->write(\$theModel->data({$sName})) ;\r\n"); $aDev->write("}\r\n"); }
public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject, 'aObject'); if ($aTailTag = $aObject->tailTag()) { $aDev->write("if( !(\$aVariables->get('theView') instanceof \\org\\jecat\\framework\\mvc\\view\\IFormView) or \$aVariables->get('theView')->isShowForm() )\r\n{\r\n"); $this->compileTag($aObject->headTag(), $aObjectContainer, $aDev, $aCompilerManager); $aDev->write("\tif(\$aVariables->get('theView') instanceof \\org\\jecat\\framework\\mvc\\view\\IFormView){\r\n"); $aDev->write("\t\t"); $aDev->output('<input type="hidden" name="'); $aDev->write("\t\t\$aDevice->write( \$aVariables->get('theView')->htmlFormSignature() ) ;\r\n"); $aDev->output('" value="1" />'); $aDev->output('<input type="hidden" name="act" value="submit" />'); $aDev->write("\t}\r\n"); $this->compileChildren($aObject, $aObjectContainer, $aDev, $aCompilerManager); $this->compileTag($aTailTag, $aObjectContainer, $aDev, $aCompilerManager); $aDev->write("}\r\n"); } else { throw new Exception("form 节点必须是成对标签形式(位置:%d行)。", $aObject->line()); } }
public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject, 'aObject'); $aAttrs = $aObject->attributes(); if (!$aAttrs->has('rel')) { $aAttrs->set('rel', 'stylesheet'); } if ($aAttrs->has('src') and !$aAttrs->has('href')) { $aAttrs->set('href', $aAttrs->string('src')); } if (strtolower($aAttrs->string('rel')) == 'stylesheet' and !$aAttrs->bool('ignore')) { $sHref = $aAttrs->get('href'); $aDev->preprocessStream()->write("jc\\resrc\\HtmlResourcePool::singleton()->addRequire({$sHref},jc\\resrc\\HtmlResourcePool::RESRC_CSS) ;"); // 清除后文中的空白字符 ClearCompiler::clearAfterWhitespace($aObject); } else { $this->compileTag($aObject->headTag(), $aObjectContainer, $aDev, $aCompilerManager); $this->compileChildren($aObject, $aObjectContainer, $aDev, $aCompilerManager); if ($aTailTag = $aObject->tailTag()) { $this->compileChildren($aObject, $aObjectContainer, $aDev, $aCompilerManager); $this->compileTag($aTailTag, $aObjectContainer, $aDev, $aCompilerManager); } } }
public function complete(IObject $aObject, string $aSource, $nPosition) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Tag", $aObject, 'aObject'); $aNode = $aObject->parent(); Assert::type("org\\jecat\\framework\\ui\\xhtml\\Node", $aNode); $sTagLen = $nPosition - $aObject->position() + 1; $sTagSource = $aSource->substr($aObject->position(), $sTagLen); $aObject->setSource($sTagSource); $aObject->setEndPosition($nPosition); // 单行标签 if ($sTagSource[strlen($sTagSource) - 2] == '/') { if ($aObject->isTail()) { throw new Exception("UI引擎在分析模板时无法确定标签类型,不能同时是尾标签和单行标签。位置:%d行", $aObject->line()); } $aObject->setTagType(Tag::TYPE_SINGLE); } // 头标签/单行标签 if ($aObject->isHead()) { // 处理属性 $aAttrs = $aObject->attributes(); $aAttrValIterator = $aAttrs->valueIterator(); $arrAttrs = array(); $arrRemoveVal = array(); $aPrevAttrVal = null; for ($aAttrValIterator->rewind(); $aVal = $aAttrValIterator->current(); $aAttrValIterator->next()) { if ($aVal->source() == '=') { // 属性名 if (!$aPrevAttrVal) { throw new Exception("UI引擎在分析模板时遇到空属性名称。位置:%d行", $aVal->line()); } $aAttrName = $aPrevAttrVal; if ($aAttrName->quoteType()) { throw new Exception("UI引擎在分析模板时遇到无效的节点属性名称,属性名称不能使用引号。位置:%d行", $aAttrName->line()); } $sAttrName = $aAttrName->source(); // 属性值 $aAttrValIterator->next(); $aAttrVal = $aAttrValIterator->current(); if (!$aAttrVal) { continue; throw new Exception("UI引擎在分析模板时遇到错误:属性名:%s没有对应的属性值。位置:%d行", array($sAttrName, $aVal->line())); } $aAttrVal->setName($sAttrName); // 移除 val name array_pop($arrAttrs); $arrAttrs[] = $aAttrVal; } else { $arrAttrs[] = $aVal; } $aPrevAttrVal = $aAttrValIterator->current(); } $aAttrs->clear(); foreach ($arrAttrs as $aAttrVal) { $aAttrs->add($aAttrVal); } if ($aObject->isSingle()) { // 单行标签节点结束 return ParserStateNode::singleton()->complete($aNode, $aSource, $nPosition); } else { return $aNode; } } else { if ($aObject->isTail()) { if ($aNode->tagName() != $aObject->name()) { throw new Exception("遇到不匹配的XHTML节点,头标签:%s(line:%d), 尾标签:%s(line:%d)", array($aNode->tagName(), $aNode->line(), $aObject->name(), $aObject->line())); } // 节点结束 return ParserStateNode::singleton()->complete($aNode, $aSource, $nPosition); } else { throw new Exception("遇到无效的xhtml标签。源文:%s", $sTagSource); } } }
public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject, 'aObject'); $aDev->write("\r\n// display message queue -------------------------------------"); // 确定需要display的 MessageQueue 对像 // ---------------------- if ($aObject->attributes()->has('for')) { $aDev->write("\$__ui_msgqueue = " . $aObject->attributes()->expression('for') . " ;"); } else { $aDev->write("\$__ui_msgqueue = \$aVariables->get('theController')? \$aVariables->get('theController')->messageQueue(): null ;"); } $aDev->write("if( \$__ui_msgqueue instanceof \\org\\jecat\\framework\\message\\IMessageQueueHolder ){"); $aDev->write("\t\$__ui_msgqueue = \$__ui_msgqueue->messageQueue() ;"); $aDev->write("}"); $aDev->write("\\org\\jecat\\framework\\lang\\Assert::type( '\\\\org\\jecat\\framework\\\\message\\\\IMessageQueue',\$__ui_msgqueue);"); // 确定使用的 template // ---------------------- // template 属性 $sTemplate = $aObject->attributes()->has('template') ? $aObject->attributes()->get('template') : 'null'; // <template> 内部字节点的模板内容 $sIsSubtemplate = 'false'; if ($aTemplate = $aObject->getChildNodeByTagName('template')) { $nSubtemplateIndex = (int) $aDev->properties()->get('nMessageQueueSubtemplateIndex') + 1; $aDev->properties()->set('nMessageQueueSubtemplateIndex', $nSubtemplateIndex); $sSubTemplateName = '__subtemplate_for_messagequeue_' . $nSubtemplateIndex; $aDev->write("if(!function_exists('{$sSubTemplateName}')){function {$sSubTemplateName}(\$aVariables,\$aDevice){"); $this->compileChildren($aTemplate, $aObjectContainer, $aDev, $aCompilerManager); $aDev->write("}}"); $sTemplate = "'{$sSubTemplateName}'"; $sIsSubtemplate = 'true'; } // 显示模式 // ------------------------------- switch ($aObject->attributes()->has('mode') ? strtolower($aObject->attributes()->string('mode')) : 'soft') { case 'hard': $aDev->write("// display message queue by HARD mode"); $aDev->write("if( !\$__device_for_msgqueue = \$__ui_msgqueue->properties()->get('aDisplayDevice') ){"); $aDev->write("\t\$__device_for_msgqueue = new \\org\\jecat\\framework\\io\\OutputStreamBuffer() ;"); $aDev->write("\t\$__ui_msgqueue->properties()->set('aDisplayDevice',\$__device_for_msgqueue) ;"); $aDev->write("}"); $aDev->write("\$__device_for_msgqueue->redirect(\$aDevice) ;"); $sCancelDisplay = ' and $__device_for_msgqueue->isEmpty()'; break; case 'force': $aDev->write("// display message queue by FORCE mode"); $aDev->write("\$__device_for_msgqueue = \$aDevice ;"); $sCancelDisplay = ''; break; default: // soft $aDev->write("// display message queue by SOFT mode"); $aDev->write("if( !\$__device_for_msgqueue = \$__ui_msgqueue->properties()->get('aDisplayDevice') ){"); $aDev->write("\t\$__device_for_msgqueue = new \\org\\jecat\\framework\\io\\OutputStreamBuffer() ;"); $aDev->write("\t\$__ui_msgqueue->properties()->set('aDisplayDevice',\$__device_for_msgqueue) ;"); $aDev->write("}"); $aDev->write("\$aDevice->write(\$__device_for_msgqueue) ;"); $sCancelDisplay = ' and $__device_for_msgqueue->isEmpty()'; break; } $aDev->write("if( \$__ui_msgqueue->count(){$sCancelDisplay} ){ "); $aDev->write("\t\$__ui_msgqueue->display(\$this,\$__device_for_msgqueue,{$sTemplate},{$sIsSubtemplate}) ;"); $aDev->write("}"); $aDev->write("// -------------------------------------\r\n"); }
public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject, 'aObject'); if (!$aObjectContainer->variableDeclares()->hasDeclared('aStackForLoopIsEnableToRun')) { $aObjectContainer->variableDeclares()->declareVarible('aStackForLoopIsEnableToRun', 'new \\org\\jecat\\framework\\util\\Stack()'); } $aAttrs = $aObject->attributes(); $sStartValue = $aAttrs->has("start") ? $aAttrs->expression("start") : '0'; $sEndValue = $aAttrs->expression("end"); $sStepValue = $aAttrs->has("step") ? $aAttrs->expression("step") : '1'; $sVarAutoName = NodeCompiler::assignVariableName('$__loop_var_'); $sIdxAutoName = NodeCompiler::assignVariableName('$__loop_idx_'); $sEndName = NodeCompiler::assignVariableName('$__loop_end_'); $sStepName = NodeCompiler::assignVariableName('$__loop_step_'); $aDev->write("\t\t{$sEndName} = {$sEndValue} ; \n\t\t\t\t\t\t\t\t{$sStepName} = {$sStepValue} ;\n\t\t\t\t\t\t\t\t{$sIdxAutoName} = 0;\n\t\t\t\t\t\t\t\t\$aStackForLoopIsEnableToRun->put(false);\n\t\t\t\t\t\t\t\tfor( {$sVarAutoName} = {$sStartValue} ; {$sVarAutoName} <= {$sEndName} ; {$sVarAutoName} += {$sStepName} ){\n\t\t\t\t\t\t\t\t\$bLoopIsEnableToRun = & \$aStackForLoopIsEnableToRun->getRef();\n\t\t\t\t\t\t\t\t\$bLoopIsEnableToRun = true; \n\t\t\t\t\t\t"); if ($aAttrs->has("var")) { $sVarUserName = $aAttrs->string("var"); $aDev->write("\t\t\t\$aVariables->{$sVarUserName} = {$sVarAutoName} ;"); } if ($aAttrs->has("idx")) { $sIdxUserName = $aAttrs->string("idx"); $aDev->write("\t\t\t\$aVariables->{$sIdxUserName} = {$sIdxAutoName} ;\n\t\t\t\t\t\t\t\t\t\t{$sIdxAutoName}++;"); } // $aDev->write ( "\$bLoopIsEnableToRun = & \$aStackForLoopIsEnableToRun->getRef(); // \$bLoopIsEnableToRun = true;" ); if (!$aObject->headTag()->isSingle()) { $this->compileChildren($aObject, $aObjectContainer, $aDev, $aCompilerManager); $aDev->write('} '); } }
protected function checkType(IObject $aObject) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject, 'aObject'); }
/** * 创建调用原始链接点的代码 */ protected function generateOriginJointCode(GenerateStat $aStat) { Assert::type("org\\jecat\\framework\\lang\\compile\\object\\FunctionDefine", $aStat->aExecutePoint); $aStat->sOriginJointMethodName = '__aop_jointpoint_' . $aStat->aExecutePoint->nameToken()->targetCode() . '_' . md5($aStat->aExecutePoint->belongsClass()->name()); $aStat->sOriginJointCode = ''; $aStat->sOriginJointCode .= $aStat->aExecutePoint->staticToken() ? 'self::' : '$this->'; $aStat->sOriginJointCode .= $aStat->sOriginJointMethodName; }
public function add($aChild, $sName = null, $bTakeover = true) { Assert::type(__NAMESPACE__ . '\\IObject', $aChild); parent::add($aChild, $sName, $bTakeover); }
public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\weave\\WeaveinObject", $aObject, 'aObject'); $aDev->write($aObject->compiled()); }
public function examineEnd(string $aSource, &$nPosition, IObject $aObject) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\AttributeValue", $aObject, 'aObject'); $sByte = $aSource->byte($nPosition); $sQuote = $aObject->quoteType(); // 有引号的 if ($sQuote) { if ($aObject->quoteType() == $sByte) { return true; } else { if ($sByte == '\\') { $nPosition++; } return false; } } else { $sNextByte = $aSource->byte($nPosition + 1); if (in_array($sNextByte, array('=', '>'))) { return true; } // 空白字符 if (preg_match('/\\s/', $sNextByte)) { return true; } return false; } }
public function display($sSourceFile, $aVariables = null, IOutputStream $aDevice = null) { Assert::type(array('\\org\\jecat\\framework\\util\\IHashTable', 'array', 'null'), $aVariables); if (is_array($aVariables)) { $aVariables = new HashTable($aVariables); } // compile $aCompiledFile = $this->compileSourceFile($sSourceFile); // render $this->render($aCompiledFile, $aVariables, $aDevice); }
public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager) { Assert::type("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject, 'aObject'); $aAttrs = $aObject->attributes(); // 指定view名称 if ($aAttrs->has('xpath')) { $sXpath = $aAttrs->get('xpath'); } else { if ($aAttrs->has('name')) { $sXpath = $aAttrs->get('name'); } else { $sXpath = null; } } if ($sXpath) { $arrViewXPaths = "array({$sXpath})"; $bUseXpath = true; } else { $arrViewXPaths = 'null'; $bUseXpath = false; } $sLayout = $aAttrs->string('layout') ?: ViewAssembler::layout_vertical; // model if ($aAttrs->has('mode')) { $nMode = ViewAssembler::filterModeToPriority($aAttrs->string('mode')); } else { $nMode = $bUseXpath ? ViewAssembler::hard : ViewAssembler::soft; } $nNodeViewId =& $aDev->properties(true)->getRef('node.view.id'); if ($nNodeViewId === null) { $nNodeViewId = 0; } else { $nNodeViewId++; } $sViewAssemblyListId = "\$this->id().'-pos{$nNodeViewId}'"; // 视图的预处理 $aDev->preprocessStream()->write("\r\n// define view assembly list -------------------"); $aDev->preprocessStream()->write("if( empty(\$this) or !(\$this instanceof jc\\mvc\\view\\IView) )"); $aDev->preprocessStream()->write("{"); $aDev->preprocessStream()->write("\tthrow new jc\\lang\\Exception('UI标签 <view> 必须用于视图类。') ;"); $aDev->preprocessStream()->write("}"); $aDev->preprocessStream()->write("jc\\mvc\\view\\ViewAssembler::singleton()->defineAssemblyList(\r\n\t\t{$sViewAssemblyListId}\r\n\t\t, '{$sLayout}'\r\n\t\t, array(\r\n\t\t\t'priority' => {$nMode},\r\n\t\t\t'xpaths' => {$arrViewXPaths},\r\n\t\t\t'view' => \$this ,\r\n\t\t)\r\n) ;"); $aDev->write("\r\n// display views "); $sViewAssemblyListId = "\$aVariables->theView->id().'-pos{$nNodeViewId}'"; $aDev->write("jc\\mvc\\view\\ViewAssembler::singleton()->displayAssemblyList({$sViewAssemblyListId},\$aDevice) ;"); return; }