/**
  * Get module navigation
  */
 public function action_module()
 {
     // get request
     $request = Request::initial();
     // get settings
     $settings = Settings::factory($request->controller());
     // navigation viewer
     $navigation = Viewer::instance('Navigation')->settings($settings->get('navigation'))->request(Request::initial())->acl(Acl::instance());
     // create view
     $view = View::factory($settings->get('view.navigation'), array('navigation' => $navigation));
     // raise event
     Event::raise($this, Event::BEFORE_NAVIGATION_RENDER, array('navigation' => $navigation));
     // render view
     $this->response->body($view->render());
 }
 /**
  * INIT
  */
 public function init()
 {
     // call parent before
     parent::init();
     //create settings
     //read from website specific settings before general settings
     $this->_settings = Settings::factory($this->_controller, array('settings' . DIRECTORY_SEPARATOR . $this->_website . DIRECTORY_SEPARATOR, 'settings'));
     // set up listeners
     $this->listeners();
     // set up navigation
     if (Request::current()->is_initial() === TRUE) {
         $navigation = Viewer::instance('Navigation');
         $navigation->breadcrumb(Text::instance()->get('section.start'), URL::to('Start'));
         $navigation->breadcrumb(Text::instance()->get('module.name'), URL::to($this->_controller));
         $navigation->title(Text::instance()->get('title.' . $this->_action));
     }
 }
 /**
  * update
  */
 public function action_update()
 {
     // get id
     $id = $this->param('id');
     // create new model
     $model = ORM::factory($this->_settings->get('model'), $id);
     // add item to navigation
     Viewer::instance('Navigation')->item($model);
     // create form
     $form = Form::factory($this->_settings->get('form'));
     // add request to form
     $form->request($this->request);
     // add text to form
     $form->text(Text::instance());
     // add alias settings to form
     $form->alias($this->_settings->get('alias.global') ? 'multiple' : ($this->_settings->get('alias.module') ? 'single' : FALSE));
     // add model to form
     $form->model($model);
     // get viewport
     $viewport = $this->request->param('viewport');
     // add urls
     if ($viewport === 'item') {
         // urls when directly updating in a dialog
         $form->urls(array('submit' => URL::to($this->request->controller() . '@update:' . $id, array('query' => 'after=update')), 'submit_back' => URL::to($this->request->controller() . '@update:' . $id, array('query' => 'after=close')), 'back' => URL::to($this->request->controller() . '@close'), 'preview' => URL::to($this->request->controller() . '@preview:' . $id)));
     } else {
         // default urls
         $url_back = State::instance()->get('url.back', FALSE);
         State::instance()->set('url.back', FALSE);
         $form->urls(array('submit' => URL::to($this->request->controller() . '@update:' . $id, array('query' => 'after=update')), 'submit_back' => URL::to($this->request->controller() . '@update:' . $id), 'back' => $url_back ? $url_back : URL::to($this->request->controller()), 'preview' => URL::to($this->request->controller() . '@preview:' . $id)));
     }
     // raise event
     Event::raise($this, Event::AFTER_UPDATE_FORM, array('form' => $form, 'model' => $model));
     // do the action
     if ($this->update($model, $form)) {
         // get after
         if ($this->request->query('after') === 'update') {
             $params = array('controller' => $this->request->controller(), 'action' => 'update', 'id' => $id);
         } elseif ($this->request->query('after') === 'close') {
             $params = array('controller' => $this->request->controller(), 'action' => 'close', 'id' => $id);
         } else {
             $params = array();
         }
         //redirect
         $this->redirect_done('updated', $params);
     }
 }