コード例 #1
0
ファイル: ViewFactory.php プロジェクト: spinit/osy
 public static function run($dispatcher, $model)
 {
     //Init new page html response;
     self::$page = new PageHtmlResponse();
     self::$page->printMicrotime = true;
     self::$model = $model;
     self::$model->select();
     self::$dispatcher = $dispatcher;
     self::$dispatcher->setContext(self);
     self::$dispatcher->setResponse(self::$page);
     //Init view;
     self::$param = $model->form;
     self::$param['command'] = array();
     self::$param['field-value-db-fix'] = array();
     if (!array_key_exists('state', $_REQUEST['osy']) && array_key_exists('state-initial', self::$param)) {
         $_REQUEST['osy']['state'] = self::$param['state-initial'];
     }
     if ($_REQUEST['osy']['state'] == 'read-only') {
         self::$param['mode'] = 'VIEW';
     }
     if (!array_key_exists('after-exec', self::$param)) {
         self::$param['after-exec'] = 'close';
     }
     self::$page->setTitle(self::$param['label']);
     self::$form = self::$page->getBody()->att('class', 'osy-body')->add(new Form('osy-form'))->att('method', 'post');
     //End init view
     //Dispatch form-init event
     self::$dispatcher->dispatch('form-init');
     //Dispatch form-before-load-component event
     self::$dispatcher->dispatch('form-before-load-component');
     //Initialize component factory
     ComponentFactory::init(self::getParam('mode'), self::$model);
     //Init extra view;
     static::initExtra();
     //Exec last init;
     self::initEnd();
     //Append Fields on Form
     self::buildForm();
     //Build Js function
     self::buildJsScript();
 }
コード例 #2
0
ファイル: ViewOpensymap.php プロジェクト: spinit/osy
 public function __construct($dispatcher, Model $model)
 {
     parent::__construct($dispatcher, $model);
     //Load data from database
     $this->model->select();
     //Init dispatcher
     $this->dispatcher = $dispatcher;
     $this->dispatcher->setContext($this);
     $this->dispatcher->setResponse($this->response);
     //Turn on print of elaboration time on the response
     $this->response->printMicrotime = true;
     //Grab parameters from del model;
     $this->param = $this->model->form;
     $this->param['command'] = array();
     $this->param['field-value-db-fix'] = array();
     if (!array_key_exists('state', $_REQUEST['osy']) && array_key_exists('state-initial', $this->param)) {
         $_REQUEST['osy']['state'] = $this->param['state-initial'];
     }
     if ($_REQUEST['osy']['state'] == 'read-only') {
         $this->param['mode'] = 'VIEW';
     }
     if (!array_key_exists('after-exec', $this->param)) {
         $this->param['after-exec'] = 'close';
     }
     $this->response->setTitle($this->param['label']);
     $this->form = $this->response->getBody()->att('class', 'osy-body')->add(new Form('osy-form'))->att('method', 'post');
     //End init view
     //Dispatch form-init event
     $this->dispatcher->dispatch('form-init');
     //Dispatch form-before-load-component event
     $this->dispatcher->dispatch('form-before-load-component');
     //Initialize component factory
     ComponentFactory::init($this->getParam('mode'), $this->model);
     //Init derived class
     $this->init();
 }
コード例 #3
0
ファイル: Controller.php プロジェクト: spinit/osy
 /**
  * Exec action ajax request from the view
  *
  * @return bool
  */
 public function ajaxAction($action)
 {
     //se il dispatch dell'evento "form-ajax + action" da risultato positivo (almeno 1 listener eseguito) rispondo.
     $response = new JsonResponse();
     $this->dispatcher->setResponse($response);
     if ($this->dispatcher->dispatch('form-ajax', $action) > 0) {
         return $response;
     }
     //se non è stato richiamato un trigger allora controllo se è stato richiamato l'aggiornamento di un componente
     foreach ($this->model->field as $fieldId => $fieldProp) {
         if ($fieldProp['name'] == $action) {
             ComponentFactory::init('ajax', $this->model);
             ComponentFactory::create($fieldProp)->ajaxResponse($this, $response);
             return $response;
         }
     }
 }