コード例 #1
0
ファイル: abstractor.php プロジェクト: neel/bong
 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');
 }
コード例 #2
0
ファイル: source.php プロジェクト: neel/bong
 private function source($component)
 {
     ControllerTray::instance()->bongParsing = false;
     $this->data->exists = false;
     $this->data->sourceRequested = false;
     if ($component) {
         $this->data->file = $component->filePath();
         $this->data->exists = true;
         $this->data->source = $component->source();
     }
     if ($this->data->exists && isset($_GET['source'])) {
         $this->data->sourceRequested = true;
     }
 }
コード例 #3
0
ファイル: SpiritEngine.php プロジェクト: neel/bong
 /**
  * <pre>
  * Instanciates the Spirit
  * 		Calls the methodName method with the given args
  * 		render the view of that Method
  * returns the output as string
  * </pre>
  * @note SpiritController* is reused if already instantiated once. 
  * @note e.g. one SpiritController is not instanciated more than once
  * @warning Throws Exception if Tried to Call non Existing method
  * @warning If View for that Specific method is not found general View of that Controler will be Called  
  * @param string $spiritName
  * @param string $methodName='main'
  * @param array $args=array()
  */
 public function run($spiritName, $methodName = 'main', $args = array())
 {
     $controller = $this->executeLogic($spiritName, $methodName, $args);
     $this->storeXDO($controller->xdo);
     //{ Make Controller properties Accessible through View
     $meta = $controller->meta;
     $xdo = $controller->xdo;
     $data = $controller->data;
     //}
     $controller->serialize();
     //{ Run the Coordinator
     $params = null;
     $coordinatorPath = $this->coordinator($spiritName);
     if (file_exists($coordinatorPath)) {
         require $coordinatorPath;
         $coordinatorClassName = ucfirst($spiritName) . 'Coordinator';
         if (class_exists($coordinatorClassName)) {
             $params = new $coordinatorClassName();
             $coordinatorReflection = new ReflectionObject($params);
             try {
                 $method = $coordinatorReflection->getMethod($methodName);
                 $method->invoke($params);
                 //TODO No Arguments ? Think Again
             } catch (ReflectionException $ex) {
                 //TODO Call the dafult method
                 assert("/*Cannot get method  {$coordinatorClassName}::{$methodName}*/");
             }
         } else {
             assert("/*No Class  {$coordinatorClassName} found*/");
         }
     } else {
         //Coordinator is Optional
     }
     //}
     ob_start();
     $__viewName = $this->view($spiritName, $methodName);
     $scope = function () use($__viewName, $controller, $data, $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;
                 case 'embed':
                     return !$instanceId ? $controller->embed($spiritName)->call($methodName, $arguments) : $controller->embed($spiritName)->instance($instanceId)->call($methodName, $arguments);
                     break;
             }
         }));
         $parser->setNsFocus('bong');
         $parser->setText($this->viewContents);
         $this->spiritInfo = new stdClass();
         $this->spiritInfo->name = $spiritName;
         $this->spiritInfo->method = $methodName;
         $this->viewContents = $parser->parse();
     }
     if (ControllerTray::instance()->renderLayout) {
         ob_start();
         require $this->layout($spiritName, $methodName);
         $this->responseBuffer = ob_get_contents();
         ob_end_clean();
     } else {
         $this->responseBuffer = ControllerTray::instance()->trim ? trim($this->viewContents) : $this->viewContents;
     }
     //echo $this->viewContents;
     //echo $this->responseBuffer;
 }
コード例 #4
0
ファイル: project.php プロジェクト: neel/bong
 public function methodLink($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;
     $method = $controller->methodByName($methodName);
     $this->data->method = $method;
     $this->data->methodName = $methodName;
     $this->data->arguments = $method->arguments();
     //Backend::saveUnSessioned('explorer.'.$this->xdo->project->name, $explorer);
 }
コード例 #5
0
ファイル: ResponseDeliveryTrait.php プロジェクト: neel/bong
 public function execute()
 {
     ControllerTray::instance()->renderLayout = false;
     $this->engine->run();
     return $this->engine->response();
 }
コード例 #6
0
ファイル: BongAppController.php プロジェクト: neel/bong
 public function renderViewAsXSLT()
 {
     ControllerTray::instance()->xsltView = true;
 }
コード例 #7
0
ファイル: MVCEngine.php プロジェクト: neel/bong
 private function view()
 {
     $views = array(Path::instance()->currentProject('apps.view.+&controller.-&method.@' . (ControllerTray::instance()->alternateView ? ControllerTray::instance()->alternateView : 'view') . '.php'), Path::instance()->currentProject('apps.view.+&controller.@view.php'), Path::instance()->currentProject('*****@*****.**'), Path::instance()->evaluate('*****@*****.**'));
     foreach ($views as $i => $view) {
         if (file_exists($view)) {
             if (ControllerTray::instance()->alternateView && $i > 0) {
                 //TODO throw AlternateViewNotFoundException
             }
             if ($i > 0) {
                 $this->_systemView = true;
             }
             return $view;
         }
     }
 }