예제 #1
0
 public function make(IOutputStream $aDev)
 {
     foreach ($this->arrDeclareVariables as $sVarName => &$sInitExpression) {
         if ($sInitExpression !== null) {
             $aDev->write("\${$sVarName} = {$sInitExpression} ;");
         } else {
             $aDev->write("\${$sVarName} ;");
         }
     }
 }
예제 #2
0
파일: UI.php 프로젝트: JeCat/framework
 public function compile(IInputStream $aSourceInput, IOutputStream $aCompiledOutput, ObjectContainer $aObjectContainer = null, $bIntact = true)
 {
     if (!$aObjectContainer) {
         $aObjectContainer = new ObjectContainer();
     }
     // 解析
     $this->interpreters()->parse($aSourceInput, $aObjectContainer, $this);
     // 编译
     $aTargetCodeStream = new TargetCodeOutputStream();
     if ($bIntact) {
         $aTargetCodeStream->start();
     }
     $this->compilers()->compile($aObjectContainer, $aTargetCodeStream);
     if ($bIntact) {
         $aTargetCodeStream->finish();
     }
     $aCompiledOutput->write($aTargetCodeStream->bufferBytes(true));
 }
예제 #3
0
파일: Cycle.php 프로젝트: JeCat/framework
 public function printArr(IOutputStream $aDev)
 {
     $aDev->write($this->aArrIter->current());
     $this->aArrIter->next();
 }
예제 #4
0
 private function _displayAssemblyList(array &$arrAssemblyList, IOutputStream $aDevice, $sParentFrameLayout = null)
 {
     if (empty($arrAssemblyList['items'])) {
         return;
     }
     $aDevice->write($this->htmlWrapper($arrAssemblyList, $sParentFrameLayout));
     $aDebugging = Application::singleton()->isDebugging();
     foreach ($arrAssemblyList['items'] as &$arrAssemblyItem) {
         // 视图
         if ($arrAssemblyItem['type'] === 'view') {
             if (empty($arrAssemblyItem['object'])) {
                 if (empty($arrAssemblyItem['id'])) {
                     throw new Exception("视图类型的装配内容,缺少视图注册ID");
                 }
                 if (!($arrAssemblyItem['object'] = View::findRegisteredView($arrAssemblyItem['id']))) {
                     //throw new Exception("在根据装配单输出视图时,无法根据提供的视图ID找到视图对像:%s,该视图可能不存在或未注册。",$arrAssemblyItem['id']) ;
                     continue;
                 }
             }
             $bEmptyView = $arrAssemblyItem['object']->template() ? false : true;
             if (!$bEmptyView) {
                 $aDevice->write($this->htmlWrapper($arrAssemblyItem, $arrAssemblyList['layout']));
                 if ($aDebugging) {
                     $aDevice->write("<!-- view name: " . $arrAssemblyItem['object']->name() . " -->\r\n");
                 }
             }
             $arrAssemblyItem['object']->render($aDevice);
             if (!$bEmptyView) {
                 $aDevice->write("</div>\r\n");
             }
         } else {
             if ($arrAssemblyItem['type'] === 'frame') {
                 $this->_displayAssemblyList($arrAssemblyItem, $aDevice, $arrAssemblyList['layout']);
             } else {
                 throw new Exception("无效的装配内容类型:%s", $arrAssemblyItem['type']);
             }
         }
     }
     $aDevice->write("<div class='jc-layout-item-end'></div></div>\r\n");
 }
예제 #5
0
파일: View.php 프로젝트: JeCat/framework
 /**
  * 渲染视图,渲染后的结果(html)将输出到 $aDevice 参数中
  * @see org\jecat\framework\mvc\view.IView::render()
  */
 public function render(IOutputStream $aDevice)
 {
     if (!$this->bEnable) {
         return;
     }
     if ($this->aTemplateCompiledFile) {
         // render myself
         $aVars = $this->variables();
         $aVars->set('theView', $this);
         $aVars->set('theModel', $this->model());
         $aVars->set('theController', $this->aController);
         if ($this->aController) {
             $aVars->set('theParams', $this->aController->params());
         }
         // debug模式下,输出模板文件的路径
         if (Application::singleton()->isDebugging()) {
             if (!($aUI = $this->ui())) {
                 throw new Exception("无法取得 UI 对像。");
             }
             $aSrcMgr = $aUI->sourceFileManager();
             list($sNamespace, $sSourceFile) = $aSrcMgr->detectNamespace($this->template());
             if ($aTemplateFile = $aSrcMgr->find($sSourceFile, $sNamespace)) {
                 $sSourcePath = $aTemplateFile->path();
             } else {
                 $sSourcePath = "can not find template file: {$sNamespace}:{$sSourceFile}";
             }
             $aDevice->write("\r\n\r\n<!-- Template: {$sSourcePath} -->\r\n");
         }
         // render
         $this->ui()->render($this->aTemplateCompiledFile, $aVars, $aDevice, false, true);
     }
     // 显示流浪视图
     if ($this->sVagrantViewsAssemlyListId) {
         ViewAssembler::singleton()->displayAssemblyList($this->sVagrantViewsAssemlyListId, $aDevice);
     }
     $this->bRendered = true;
 }
예제 #6
0
파일: Model.php 프로젝트: JeCat/framework
 protected function printStructData(IOutputStream $aOutput = null, $nDepth = 0)
 {
     $aPrototype = $this->prototype();
     foreach ($aPrototype->columns() as $sDataName) {
         $aOutput->write(str_repeat("\t", $nDepth + 1) . "{$sDataName}: " . $this->data($sDataName) . "\r\n");
     }
 }