/**
  * @see \Components\Http_Scriptlet::dispatch() dispatch
  */
 public static function dispatch(Http_Scriptlet_Context $context_, Uri $uri_)
 {
     $response = $context_->getResponse();
     $content = null;
     try {
         // FIXME Temporary fix - create a explicit route for ui/scriptlet/embedded.
         if (Environment::isEmbedded()) {
             $scriptlet = new Ui_Scriptlet_Embedded();
             $scriptlet->request = $context_->getRequest();
             $scriptlet->response = $context_->getResponse();
             $method = $scriptlet->request->getMethod();
             if (false === method_exists($scriptlet, strtolower($method))) {
                 throw new Http_Exception('ui/scriptlet', null, Http_Exception::NOT_FOUND);
             }
             $content = $scriptlet->{$method}();
         } else {
             $content = parent::dispatch($context_, $uri_);
         }
     } catch (\Exception $e) {
         Runtime::addException($e);
         if ($e instanceof Http_Exception) {
             $e->sendHeader();
         }
     }
     echo $content;
 }
 public function __construct()
 {
     Environment::isEmbedded(true);
     $this->template = __DIR__ . '/embedded.tpl';
     $this->script('ui/jquery/jquery-1.11.2.min', false, false);
     $this->script('runtime/libstd');
     $this->script('ui/jquery/mobile/jquery.mobile.touch.min');
     $this->script('ui/common');
     $this->style('ui/common');
     $this->panel = new Ui_Panel('ui-panel');
     $this->panel->scriptlet = $this;
 }
 /**
  * Displays this panel or sub-panel.
  *
  * @param string $panel_ Name of sub-panel to display
  *
  * @throws Ui_Panel_Exception
  */
 public function display($panel_ = null)
 {
     if (null !== $panel_) {
         if (isset($this->m_children[$panel_])) {
             return $this->m_children[$panel_]->display();
         }
         return;
     }
     if (null === $this->m_form) {
         if (Environment::isEmbedded() && null !== $this->callback) {
             throw new Ui_Panel_Exception('ui/panel', 'Panels with callbacks require a form in embedded mode.');
         }
     } else {
         if ($this->m_form->id() === $this->id()) {
             $this->m_attributes['ui-panel-form'] = null;
             $this->m_classes['ui_panel_form'] = 'ui_panel_form';
             if ($this->ajaxEnabled) {
                 if (Environment::isEmbedded()) {
                     $path = [$this->name => \str\typeToPath(get_class($this))];
                     $panel = $this;
                     while ($panel = $panel->parent) {
                         $path[$panel->name] = \str\typeToPath(get_class($panel));
                     }
                     $this->m_attributes['ui-panel-path'] = json_encode(array_reverse($path));
                 }
             } else {
                 $this->tag = 'form';
             }
             if (isset($this->m_attributes['action'])) {
                 $this->m_attributes['action'] = $this->m_formProperties['action'];
             }
             $this->m_attributes['accept-charset'] = $this->m_formProperties['accept-charset'];
             $this->m_attributes['enctype'] = $this->m_formProperties['enctype'];
             $this->m_attributes['method'] = $this->m_formProperties['method'];
         }
     }
     if (null !== $this->tag) {
         printf('<%s id="%s" %s>', $this->tag, $this->id(), $this->attributes());
         if ('form' === $this->tag) {
             printf('<input type="hidden" name="ui-panel-submitted" value="%s">', $this->id());
         }
     }
     echo $this->render();
     if (null !== $this->tag) {
         printf('</%s>', $this->tag);
     }
 }