示例#1
0
 public function prepareView(\Nethgui\View\ViewInterface $view)
 {
     $module = $this->getTargetModule();
     if (is_null($module)) {
         $view->setTemplate(FALSE);
         return;
     }
     $moduleView = $view->spawnView($module);
     $module->prepareView($moduleView);
     $renderer = new \Nethgui\Module\Help\Renderer($moduleView, $this->getFileNameResolver(), 0);
     echo $renderer->render();
     exit(0);
     // FIXME not so correct, but works..
 }
示例#2
0
 /**
  * For each known format extension adds a subview that renders into an html
  * fragment that include the required resources.
  * 
  * @param \Nethgui\View\ViewInterface $view
  * @return void
  */
 public function prepareViewXhtml(\Nethgui\View\ViewInterface $view)
 {
     $fragments = array('js' => "<script src='%URI'></script>", 'css' => "<link rel='stylesheet' type='text/css' href='%URI' />");
     foreach (array_keys($fragments) as $ext) {
         $view[$ext] = $view->spawnView($this);
         $thisModule = $this;
         $templateClosure = function (\Nethgui\Renderer\AbstractRenderer $renderer) use($ext, $thisModule, $fragments) {
             $uriList = $thisModule->getUseList($ext);
             $cachedFile = $thisModule->getFileName($ext);
             if ($cachedFile !== FALSE) {
                 $uriList[] = $renderer->getModuleUrl('/Resource/' . $cachedFile);
             }
             $output = '';
             foreach ($uriList as $uri) {
                 $output .= strtr($fragments[$ext], array('%URI' => $uri));
             }
             return $output;
         };
         $view[$ext]->setTemplate($templateClosure);
     }
     $view->setTemplate(FALSE);
 }
示例#3
0
 /**
  *
  * @param \Nethgui\View\ViewInterface $view
  * @param string $key The data row key
  * @param array $values The data row values
  * @param array &$rowMetadata The metadadata row values, like css classes
  * @return \Nethgui\View\ViewInterface 
  */
 public function prepareViewForColumnActions(\Nethgui\View\ViewInterface $view, $key, $values, &$rowMetadata)
 {
     $cellView = $view->spawnView($this->getParent());
     $cellView->setTemplate(array($this, 'renderColumnActions'));
     foreach ($this->getParent()->getRowActions() as $action) {
         $actionId = $action->getIdentifier();
         $actionInfo = array();
         $actionInfo[] = $cellView->translate($actionId . '_label');
         $actionInfo[] = $cellView->getModuleUrl(sprintf('%s/%s', $action->getIdentifier(), $key));
         $cellView[$actionId] = $actionInfo;
     }
     return $cellView;
 }
 /**
  * Save a request/response round, putting the next view data in the response
  * 
  * @param \Nethgui\View\ViewInterface $view 
  */
 private function prepareNextViewOptimized(\Nethgui\View\ViewInterface $view)
 {
     $np = $this->currentAction->nextPath();
     if ($np === FALSE) {
         return;
     }
     $nextModule = $this->getAction(\Nethgui\array_head(explode('/', $np)));
     $location = $view->getModuleUrl($np);
     if ($nextModule instanceof \Nethgui\View\ViewableInterface) {
         // spawn and prepare the next view data:
         $nextView = $view->spawnView($nextModule, TRUE);
         $nextModule->prepareView($nextView);
         if ($view->getTargetFormat() === $view::TARGET_JSON) {
             $nextView->getCommandList()->prefetched();
             // placeholder.
             $nextView->getCommandList()->show();
             // Display the prefetched view
             $this->getPlatform()->setDetachedProcessCondition('success', array('location' => array('url' => $location . '?taskStatus=success&taskId={taskId}'), 'freeze' => TRUE))->setDetachedProcessCondition('failure', array('location' => array('url' => $location . '?taskStatus=failure&taskId={taskId}'), 'freeze' => TRUE));
         } else {
             // show is implemented as HTTP redirection. Avoid self-loops:
             if ($nextModule !== $this->currentAction) {
                 $view->getCommandList()->sendQuery($location);
             }
         }
     } else {
         // next path does not corresponds to a child action: start
         // a new query request to get the next view data:
         $view->getCommandList()->sendQuery($location);
     }
 }