Esempio n. 1
0
 public function application($bDefaultGlobal = true)
 {
     if ($this->aApplication) {
         return $this->aApplication;
     } else {
         return $bDefaultGlobal ? Application::singleton() : null;
     }
 }
Esempio n. 2
0
 /**
  * 创建 Application 系统中的核心对象
  * 如果没有 Application 单件对像,则将传入的 Application对像做为 Application 的全局单件
  */
 public function buildApplication(Application $aApp, $sApplicationRootPath)
 {
     $aOriApp = Application::switchSingleton($aApp);
     // filesystem
     Folder::setSingleton(new Folder($sApplicationRootPath));
     // 初始化 class loader
     ClassLoader::setSingleton($this->createClassLoader($aApp));
     // AccessRouter
     AccessRouter::setSingleton($this->createAccessRouter($aApp));
     // Request
     Request::setSingleton($this->createRequest($aApp));
     // setting
     Setting::setSingleton($this->createSetting($aApp));
     if ($aOriApp) {
         Application::setSingleton($aOriApp);
     }
 }
Esempio n. 3
0
 public function __construct(Application $aApp = null)
 {
     parent::__construct();
     foreach (self::$arrDataSources as $sVarName) {
         if (isset($GLOBALS[$sVarName])) {
             if (!($aDataSrc = DataSrc::flyweight(array('request', $sVarName), false))) {
                 $aDataSrc = new DataSrc($GLOBALS[$sVarName], true);
                 DataSrc::setFlyweight($aDataSrc, array('request', $sVarName));
             }
             $this->addChild($aDataSrc);
         }
     }
     // $_FILES
     $this->buildUploadFiles($aApp ?: Application::singleton());
     //
     $this->sRequestUrl = (empty($_SERVER['HTTPS']) ? 'http://' : 'https://') . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $this->set(parent::DATANAME_USERCALL, true);
 }
Esempio n. 4
0
 /**
  * Enter description here ...
  * 
  * @return org\jecat\framework\system\Application
  */
 public function application($bDefaultGlobal = true)
 {
     return Application::singleton();
 }
Esempio n. 5
0
 public function __construct(ResourceManager $aResourceManager = null)
 {
     parent::__construct();
     $this->aResourceManager = $aResourceManager ? $aResourceManager : Application::singleton()->publicFolders();
     $this->addRequire('org.jecat.framework:style/style.css', self::RESRC_CSS);
 }
Esempio n. 6
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");
 }
Esempio n. 7
0
 /**
  * 渲染视图,渲染后的结果(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;
 }