Esempio n. 1
0
 /**
  * Initialises Widget stuff.
  */
 function __construct($light = false, $view = null)
 {
     if ($view != null) {
         $this->_view = $view;
     }
     $this->user = new \User();
     $this->load();
     $this->name = get_class($this);
     // If light loading enabled, we stop here
     if ($light) {
         return;
     }
     // Put default widget init here.
     $this->ajax = Ajax::getInstance();
     if (!$this->ajax->isRegistered($this->name)) {
         // Generating Ajax calls.
         $refl = new \ReflectionClass($this->name);
         $meths = $refl->getMethods();
         foreach ($meths as $method) {
             if (preg_match('#^ajax#', $method->name)) {
                 $pars = $method->getParameters();
                 $params = [];
                 foreach ($pars as $param) {
                     $params[] = $param->name;
                 }
                 $this->ajax->defun($this->name, $method->name, $params);
             }
         }
     }
     $config = array('tpl_dir' => $this->respath('', true), 'cache_dir' => CACHE_PATH, 'tpl_ext' => 'tpl', 'auto_escape' => false);
     // We load the template engine
     $this->view = new Tpl();
     $this->view->objectConfigure($config);
     $this->view->assign('c', $this);
     $this->pure = false;
 }
Esempio n. 2
0
 function printScripts()
 {
     $out = '';
     $widgets = Wrapper::getInstance();
     $scripts = array_merge($this->scripts, $widgets->loadjs());
     foreach ($scripts as $script) {
         $out .= '<script type="text/javascript" src="' . $script . '"></script>' . "\n";
     }
     $ajaxer = Ajax::getInstance();
     $out .= $ajaxer->genJs();
     return $out;
 }