示例#1
0
 public function setScript(core\request $path, $sContext = '')
 {
     //$path->parse();
     $bError = null;
     $parser = \Sylma::getManager('parser');
     $messages = new html\context\Messages();
     $contexts = new core\argument\Readable(array('errors' => $this->initMessages(), 'messages' => $messages, 'js-common' => new html\context\JS(), 'js' => new html\context\JS(array('load' => new template\binder\context\Load()))));
     $this->setContexts($contexts);
     $parser->setContext('messages', $messages);
     $debug = $this->getManager('init')->getArgument('window');
     try {
         $result = $this->runScript($path->getFile(), $path->getArguments(), $this->getManager('init')->loadPOST(true), $debug);
     } catch (core\exception $e) {
         $result = '';
         $e->save(false);
         $bError = true;
         $messages->add(array('content' => 'An error has occured'));
     }
     if (\Sylma::isAdmin()) {
         $errors = $contexts->get('errors');
     } else {
         $errors = null;
     }
     $classes = $contexts->get('js/classes', false);
     $this->setSettings(array('content' => $this->formatContent($result), 'objects' => $contexts->get('js/load/objects', false), 'classes' => $classes ? $classes->asStringVar() : null, 'error' => $bError, 'errors' => $errors, 'messages' => $contexts->get('messages')));
 }
示例#2
0
 protected function runExecutable(core\request $path)
 {
     $sExtension = $path->getExtension();
     if ($this->getFactory()->findClass($sExtension, '', false)) {
         // with window
         $window = $this->create($sExtension, array($this));
         \Sylma::setManager('window', $window);
         $sResult = $this->createWindowBuilder()->loadObject($path, $window);
     } else {
         // no window
         $this->setHeaderContent($this->getMime($sExtension));
         $path->parse();
         $file = $path->asFile();
         if ($file->getExtension() !== 'vml') {
             $this->send404();
             $file = $this->getFile($this->getErrorPath());
             //$this->launchException('Can execute only view');
         }
         $sResult = (string) $this->prepareScript($file, $path->getArguments());
     }
     return $sResult;
 }
示例#3
0
 public function loadObject(core\request $path, $window)
 {
     $path->parse();
     $window->setScript($path);
     return $window->asString();
 }