Beispiel #1
0
 public function getBlock($name)
 {
     global $core;
     $args = func_get_args();
     $class_name = $this->resolve_block_class($name);
     if ($class_name) {
         array_shift($args);
         I18n::push_scope($this->flat_id);
         I18n::push_scope($this->flat_id . '.' . $name);
         try {
             $block = new $class_name($this, array(), $args);
             // 				$rendered_block = $block->render();
         } catch (\ICanBoogie\SecurityException $e) {
             I18n::pop_scope();
             I18n::pop_scope();
             throw $e;
         } catch (\Exception $e) {
             $block = \ICanBoogie\Debug::format_alert($e);
         }
         I18n::pop_scope();
         I18n::pop_scope();
         return $block;
     }
     // 		\ICanBoogie\log_info("Block class not found for <q>$name</q> falling to callbacks.");
     return call_user_func_array(PHP_MAJOR_VERSION > 5 || PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 2 ? 'parent::' . __FUNCTION__ : array($this, 'parent::' . __FUNCTION__), $args);
 }
Beispiel #2
0
 /**
  * Renders the inner HTML of the view.
  *
  * If the data provided implements {@link \Brickrouge\CSSClassNames}, the class names of the
  * record are added those of the view element.
  *
  * @param Context $context
  *
  * @throws \Exception
  *
  * @return string The inner HTML of the view element.
  */
 protected function render_inner_html(Context $context)
 {
     $this->data = $bind = $this->resolve_bind();
     if (!$bind && $this->renders != ViewOptions::RENDERS_OTHER) {
         $this->element->add_class('empty');
         $html = (string) $this->render_empty_inner_html();
         $this->fire_render_empty_inner_html($html);
         return $html;
     }
     if (is_array($bind) && reset($bind) instanceof Node) {
         new \BlueTihi\Context\LoadedNodesEvent($context, $bind);
     } elseif ($bind instanceof Node) {
         new \BlueTihi\Context\LoadedNodesEvent($context, [$bind]);
     } elseif ($bind instanceof \Brickrouge\CSSClassNames) {
         $this->element['class'] .= ' ' . $bind->css_class;
     }
     /* @var $template_resolver \ICanBoogie\Render\TemplateResolver */
     $template_resolver = clone $this->app->template_resolver;
     $engines = $this->app->template_engines;
     $tries = [];
     $this->template_tries =& $tries;
     $template_pathname = $template_resolver->resolve($this->id, $engines->extensions, $tries);
     if (!$template_pathname) {
         throw new TemplateNotFound("Unable to find template for {$this->id}.", $tries);
     }
     $this->template_pathname = $template_pathname;
     I18n::push_scope($this->module->flat_id);
     try {
         $html = $engines->render($template_pathname, $bind, $this->resolve_variables());
         I18n::pop_scope();
         return $html;
     } catch (\Exception $e) {
         I18n::pop_scope();
         throw $e;
     }
 }