Exemplo n.º 1
0
 /**
  * initialize BULK
  * this function call initXX() where XX = level
  *
  * @param integer level
  *
  * 0  - core-construct-after
  * 9  - shutdown-before
  * 91 - shutdown-after
  * 10 - halt-before @see self::halt()
  *
  * @return void
  */
 public function init($level = 0)
 {
     $method = "init{$level}";
     if (method_exists($this, $method)) {
         call_user_func(array($this, $method));
     }
     // looking for modules
     self::$modules->init($level);
 }
Exemplo n.º 2
0
 /**
  * Run block
  * Called from module::run_block
  * 
  * Params passed to 'block.data' 
  * action converted to object!
  * 
  * Extended params passed to {$block.params}
  * 
  * @param string $action action-name
  * @param array $params passed to {satblock}
  * @return bool|string
  * @throws modules_exception
  */
 function run($action, $params)
 {
     $modname = $this->get_context()->get_name();
     core::time_check('block', 1, 1);
     core::dprint('[BLOCK ' . $modname . '.' . $action . ']', core::E_DEBUG);
     // get block builtin properties
     $props = $this->get_block($action);
     // no block description found, try from file
     if (!$props) {
         $props = array('class' => true);
     }
     // assign params
     $props['params'] = $params;
     $_params = new aregistry($params);
     if (is_callable(array($this, $action))) {
         $data = call_user_func(array($this, $action), $_params);
     } elseif (!empty($props['class'])) {
         $action = is_string($props['class']) ? $props['class'] : $action;
         // try external file
         $file = $this->get_context()->get_root() . 'blocks/' . $action . loader::DOT_PHP;
         if (file_exists($file)) {
             require $file;
             $class = core_modules::ns($this->get_context()->get_name(), $action . '_block');
             if (!class_exists($class)) {
                 throw new module_exception('Class not exists - ' . $class);
             } else {
                 $data = with(new $class($this->get_context(), $props, $_params))->run();
             }
         } else {
             throw new module_exception('Block file not found - ' . $action);
         }
     } else {
         throw new module_exception('Not callable action supplied - ' . $action);
     }
     $return = $this->get_context()->renderer->render_block($props, $data);
     core::dprint('[/BLOCK]' . ' ' . core::time_check('block', 1), core::E_DEBUG);
     return $return;
 }