Exemplo n.º 1
0
 public function desc($id)
 {
     ControllerTray::instance()->renderLayout = false;
     http::contentType('application/json');
     $this->data->id = $id;
     $this->data->info = new \ROM\BongUserData();
     $this->data->info->load($id . '.usr');
 }
Exemplo n.º 2
0
 public function execute()
 {
     http::freeze();
     //a Spirit Cannot send any HTTP Header unless It is used as ResponseService
     $this->engine->executeLogic();
     http::release();
     http::contentType('application/json');
     return json_encode($this->engine->xdo());
 }
Exemplo n.º 3
0
 public function execute()
 {
     http::freeze();
     //a Spirit Cannot send any HTTP Header unless It is used as ResponseService
     $this->engine->run();
     http::release();
     http::contentType('text/xml');
     return $this->engine->xdo()->toXML()->saveXML();
 }
Exemplo n.º 4
0
 public function main($name = null, $age = null)
 {
     http::contentType('text/html');
     $this->bootStrapJs();
     if (!$this->cached() || $name) {
         $this->xdo->name = $name;
     }
     if (!$this->cached() || $age) {
         $this->xdo->age = $age;
     }
     //$this->switchView('alternateView');
 }
Exemplo n.º 5
0
 public function execute()
 {
     http::freeze();
     //a Spirit Cannot send any HTTP Header unless It is used as ResponseService
     $this->engine->run();
     http::release();
     $xdo = $this->engine->xdo();
     $navigation = $this->engine->getNavigation();
     if (isset($xdo->{$navigation->propertyName})) {
         $value = $xdo->{$navigation->propertyName};
         if (is_array($value) || is_object($value)) {
             http::contentType('application/json');
             return json_encode($value);
         } else {
             http::contentType('text/plain');
             return $value;
         }
     }
     return null;
 }
Exemplo n.º 6
0
Arquivo: layout.php Projeto: neel/bong
			@import url("<?php 
    echo $css;
    ?>
");
			<?php 
}
?>
		</style>
		
	</head>
	<body>
		<div id="bong-admin-header">
			<input type="text" name="search" class="bong-admin-doc-search" value="Search" />
			<a href="<?php 
echo Resource::link();
?>
/user/logout" class="bong-admin-header-cntrl">Logout</a>
			<a href="#" class="bong-admin-header-cntrl">Settings</a>
			<a href="#" class="bong-admin-home">bong</a>
		</div>
		<div id="bong-admin-body">
			<?php 
echo $this->viewContents;
?>
		</div>
		<div id="bong-admin-editor-minimize-area"></div>
	</body>
</html>
<?php 
http::contentType('text/html');
Exemplo n.º 7
0
 public function createControllerMethodParams($methodName)
 {
     $backend = null;
     if (Backend::ExistsUnSessioned('explorer.' . $this->xdo->project->name)) {
         $explorer = Backend::LoadUnSessioned('explorer.' . $this->xdo->project->name);
     } else {
         $explorer = Structs\Admin\Project::create($this->xdo->project->name);
         /*Create From reflection*/
     }
     $this->data->controllerName = $this->xdo->controllerName;
     $controller = $explorer->controllerByName($this->xdo->controllerName);
     $this->data->controller = $controller;
     ControllerTray::instance()->renderLayout = false;
     http::contentType('application/json');
     $method = $controller->methodByName($methodName);
     $this->data->methodName = $methodName;
     $this->data->success = false;
     $this->data->success = $method->genParams();
     //Backend::saveUnSessioned('explorer.'.$this->xdo->project->name, $explorer);
 }
Exemplo n.º 8
0
 /**
  * \algorithm
  * layoutPath:
  * 		projectLayout = Path::currentProject(apps.layout.+controller.@layout.php)
  * 		if exists(projectLayout)
  * 			return projectLayout
  * 		else return default Layout
  * 
  * paramPath:
  * 		projectParam = Path::currentProject(apps.layout.+controller.@param.php)
  * 		if exists(projectParam)
  * 			return projectParam
  * 		else return default param
  * 
  * viewPath:
  * 		return Path::currentProject(apps.layout.+controller.-method.@view.php)
  * 
  * controllerPath:
  * 		return Path::currentProject(apps.+controller)
  * 
  * processView:
  * 		require(viewPath())
  * 
  * main:
  * 		require(paramPath())
  * 		require(controllerPath())
  * 		startOutputBuffering()
  * 		$controller = new Controller();
  * 		closure syncVars(&$controller){
  * 			foreach($controller->data as $key => &$value){
  * 				local $key = $value;
  * 			}
  * 			processView()
  * 		}
  * 		$this->viewContents = getOutputBufferContents()
  * 		endOutputBuffering()
  * 		startOutputBuffering()
  * 		require(layoutPath())
  * 		$response = getOutputBufferContents()
  * 		endOutputBuffering()
  * 
  * \endalgorithm
  */
 public function run()
 {
     $controller = $this->executeLogic();
     //$this->storeXDO($controller->xdo);
     //{ Make Variables Accessible to View
     $data = $controller->data;
     if (isset($controller->xdo)) {
         $xdo = $controller->xdo;
     }
     if (isset($controller->session)) {
         $session = $controller->session;
     }
     $meta = $controller->meta;
     //}
     //{ Load The View
     if (ControllerTray::instance()->renderView) {
         if (isset($this->_methodReturn) && is_int($this->_methodReturn) && $this->_methodReturn == -1) {
             return;
         }
         $__viewName = $this->view();
         ob_start();
         $scope = function () use($__viewName, $controller, $data, $session, $xdo, $meta) {
             require $__viewName;
         };
         $scope();
         $this->viewContents = ob_get_contents();
         ob_end_clean();
         if (ControllerTray::instance()->bongParsing) {
             $parser = new \SuSAX\Parser(new BongParser(function ($spiritName, $methodName, $arguments, $tagName, $instanceId = null) use($controller) {
                 switch ($tagName) {
                     case 'spirit':
                         return !$instanceId ? $controller->spirit($spiritName)->call($methodName, $arguments) : $controller->spirit($spiritName)->instance($instanceId)->call($methodName, $arguments);
                         break;
                 }
             }));
             $parser->setNsFocus('bong');
             $parser->setText($this->viewContents);
             $this->viewContents = $parser->parse();
         }
         if ($this->_systemView) {
             $controller->dumpStrap();
         }
     }
     //}
     if (ControllerTray::instance()->renderView && ControllerTray::instance()->renderLayout) {
         /// < Layout cannot be rendered If no View is rendered
         $this->mergeParams();
         $params = $this->_arrangedParams;
         ob_start();
         require $this->layout();
         $this->responseBuffer = ob_get_contents();
         ob_end_clean();
     } else {
         if (ControllerTray::instance()->renderView) {
             $this->responseBuffer = ControllerTray::instance()->trim ? trim($this->viewContents) : $this->viewContents;
         } else {
             if (isset($this->_methodReturn)) {
                 switch (ControllerTray::instance()->responseType) {
                     case 'scrap/xml':
                         http::contentType('text/xml');
                         $packer = new XMLPacker($this->_methodReturn);
                         $this->responseBuffer = $packer->toXML()->saveXML();
                         break;
                     case 'scrap/json':
                         http::contentType('application/json');
                         $this->responseBuffer = json_encode($this->_methodReturn);
                         break;
                     case 'scrap/plain':
                     default:
                         http::contentType('text/plain');
                         $this->responseBuffer = $this->_methodReturn;
                 }
             }
         }
     }
     if (ControllerTray::instance()->xsltView) {
         $this->processXSLView($controller->storage());
     }
     //echo $this->responseBuffer;
 }
Exemplo n.º 9
0
 public function run()
 {
     if (Fstab::instance()->projectExists($this->projectName)) {
         $projectDir = Path::instance()->evaluate(':' . $this->projectName);
         if (is_dir($projectDir)) {
             $evPath = $this->navigation->systemResource ? '' : ":{$this->projectName}.";
             $evPath .= "share.";
             switch ($this->navigation->resourceType) {
                 case 'img':
                     $evPath .= 'image';
                     break;
                 case 'css':
                     $evPath .= 'css';
                     break;
                 case 'js':
                     $evPath .= 'javascript';
                     break;
                 case 'xslt':
                     $evPath .= 'xslt';
                     break;
                 case 'scrap':
                     $evPath .= 'scrap';
                     break;
                 default:
             }
             $evPath .= ".@{$this->navigation->estimatedContentName}";
             $resourcePath = Path::instance()->evaluate($evPath);
             if (is_file($resourcePath)) {
                 $mime = mime_content_type($resourcePath);
                 switch ($this->navigation->resourceType) {
                     case 'img':
                         http::contentType($mime);
                         break;
                     case 'css':
                         http::contentType('text/css');
                         break;
                     case 'js':
                         http::contentType('text/javascript');
                         break;
                     case 'xslt':
                         http::contentType('text/xml+xslt');
                         break;
                     case 'scrap':
                         http::contentType('text/plain');
                         break;
                     default:
                 }
                 switch ($this->navigation->resourceType) {
                     case 'img':
                         $this->responseBuffer = file_get_contents($resourcePath);
                         break;
                     default:
                         ob_start();
                         require $resourcePath;
                         $this->responseBuffer = ob_get_contents();
                         ob_end_clean();
                 }
             } else {
                 throw new FileNotFoundException($resourcePath ? $resourcePath : 'null <Resource Path Could not be Resolved> ');
             }
         } else {
             throw new ProjectDirNotFoundException($this->projectName);
         }
     } else {
         throw new ProjectNotFoundException($this->projectName);
     }
 }