Example #1
0
 function fill()
 {
     if (!$this->filled) {
         $this->filled = true;
         if ($custom = $this->fullCustomID()) {
             $handler = Block::factory($custom);
             $func = 'menu_' . strtolower($action = Block::actionFrom($custom));
             if (method_exists($handler, $func)) {
                 $handler->{$func}($this);
             } else {
                 $this->html = $handler->execute($action, $this->argArray())->render();
             }
         }
     }
     return $this;
 }
Example #2
0
 function serve($args = array())
 {
     if ($server = $this->findServer()) {
         // replace (:N) patterns inside controller string, e.g.: 'user@(;1)'.
         static::references($server, $args);
         // prepend arguments that can be defined in the server string after
         // a space: 'help@show contacts'.
         $server = strtok($server, ' ');
         $prepend = '' . strtok(null);
         $prepend === '' or $args = array_merge(explode(' ', $prepend), $args);
         // construct server instance (either a Block or a regular Controller).
         $this->lastArgs = $args;
         $block = $this->lastServer = Block::factory($server);
         // if server is not a traditional controller but a Vane block - set it up.
         if ($block instanceof Block) {
             $block->top = $this->lastLayout;
             $block->isServer = true;
         }
         // produce response (can be of arbitrary type).
         $this->lastArgs = $args;
         $response = $block->execute(Block::actionFrom($server), $args);
         // convert response to a Laravel\Response descendant.
         return with(new Block())->toResponse($response);
     }
 }
Example #3
0
 public function render_block($block, $block_name = NULL)
 {
     $block->data = isset($block->data) ? $block->data : array();
     $block->data = !is_array($block->data) ? (array) @json_decode($block->data, TRUE) : $block->data;
     $data['_block'] = $block;
     $data['_data'] = $block->data;
     $after = View::factory('page/block/_after', $data);
     $view = Model_Page_Block_Template::view($block->page_block_template_id, $data);
     $before = View::factory('page/block/_before', $data);
     if (!$view) {
         return View::factory('page/block/_not_found', ['name' => $block_name])->render();
     }
     // helpers
     $view->helper = Block::factory($block, $block_name, $view);
     if (!isset($view->page)) {
         View::bind_global('page', $this);
     }
     return $before->render() . $view->render() . $after->render();
 }