Exemplo n.º 1
0
 public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager)
 {
     Type::check("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject);
     $sLang = strtolower($aObject->attributes()->string('lang'));
     if (in_array($sLang, array('text/php', 'php')) and $aTailTag = $aObject->tailTag()) {
         // 编译头标签
         $this->compileTag($aObject->headTag(), $aObjectContainer, $aDev, $aCompilerManager);
         // 设置代码"上色器"
         $sVarName = parent::assignVariableName();
         $aDev->write("\r\n");
         $aDev->write("\${$sVarName} = new \\org\\jecat\\framework\\ui\\xhtml\\compiler\\node\\CodeColor() ;\r\n");
         $aDev->write("\\org\\jecat\\framework\\io\\StdOutputFilterMgr::singleton()->add(array(\${$sVarName},'outputFilter')) ;\r\n");
         $aDev->write("");
         // 编译 node body
         $this->compileChildren($aObject, $aObjectContainer, $aDev, $aCompilerManager);
         // 输出代码
         $aDev->write("\r\n");
         $aDev->write("\\org\\jecat\\framework\\io\\StdOutputFilterMgr::singleton()->remove( array(\${$sVarName},'outputFilter') ) ;\r\n");
         $aDev->write("\${$sVarName}->output(\$aDevice) ;");
         $aDev->write("");
         // 编译尾标签
         $this->compileTag($aTailTag, $aObjectContainer, $aDev, $aCompilerManager);
     } else {
         parent::compile($aObject, $aObjectContainer, $aDev, $aCompilerManager);
     }
 }
Exemplo n.º 2
0
 public function compile(IObject $aObject, ObjectContainer $aObjectContainer, TargetCodeOutputStream $aDev, CompilerManager $aCompilerManager)
 {
     Type::check("org\\jecat\\framework\\ui\\xhtml\\Node", $aObject);
     $aAttrs = $aObject->attributes();
     $sType = strtolower($aAttrs->string('type'));
     if (in_array($sType, array('text/php', 'php'))) {
         foreach ($aObject->iterator() as $aChild) {
             if ($aChild instanceof AttributeValue) {
                 continue;
             }
             $aDev->write(ExpressionCompiler::compileExpression($aChild->source(), $aObjectContainer->variableDeclares(), false, true));
         }
     } else {
         if ($aAttrs->has('src') and !$aAttrs->bool('ignore')) {
             $sSrc = $aAttrs->get('src');
             $aDev->preprocessStream()->write("\\org\\jecat\\framework\\resrc\\HtmlResourcePool::singleton()->addRequire({$sSrc},\\org\\jecat\\framework\\resrc\\HtmlResourcePool::RESRC_JS) ;");
             // 清除后文中的空白字符
             ClearCompiler::clearAfterWhitespace($aObject);
         } else {
             parent::compile($aObject, $aObjectContainer, $aDev, $aCompilerManager);
         }
     }
 }