示例#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 = AjaxController::getInstance();
     // 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 = array();
             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;
 }
示例#2
0
 function printScripts()
 {
     $out = '';
     $widgets = WidgetWrapper::getInstance();
     $scripts = array_merge($this->scripts, $widgets->loadjs());
     foreach ($scripts as $script) {
         $out .= '<script type="text/javascript" src="' . $script . '"></script>' . "\n";
     }
     $ajaxer = AjaxController::getInstance();
     $out .= $ajaxer->genJs();
     return $out;
 }