/**
  * Return the instance of the controller.
  * 
  * @return  \Notebook\AjaxController
  */
 public static function instance()
 {
     static $result = null;
     if (empty($result)) {
         $result = new self(Access::instance());
     }
     return $result;
 }
 /**
  *
  * 
  */
 function init()
 {
     $form_name = get_lang('Import');
     $this->add_header($form_name);
     $this->add_hidden(Request::PARAM_SEC_TOKEN, Access::instance()->get_token());
     $label = get_lang('File');
     $this->add_file('file', $label);
     $this->addRule('file', get_lang('ThisFieldIsRequired'), 'required');
     $this->add_button('save', get_lang('Save'), array('class' => 'btn save'));
     $label = get_lang('CSVMustLookLike');
     $label = "{$label}";
     $help = '<pre>
                 <b>title</b>;<b>description</b>;
                 "Hello";"Hola";
                 "Good";"Bueno";
              </pre>';
     $this->add_html($label . $help);
 }
 /**
  *
  * @param \Notebook\Notebook $notebook
  */
 function init($notebook = null)
 {
     $this->set_notebook($notebook);
     $defaults = array();
     $defaults['title'] = $notebook->title;
     $defaults['description'] = $notebook->description;
     $this->add_hidden('c_id', $notebook->c_id);
     $this->add_hidden('id', $notebook->id);
     $this->add_hidden('session_id', $notebook->session_id);
     $this->add_hidden(Request::PARAM_SEC_TOKEN, Access::instance()->get_token());
     $form_name = $notebook->id ? get_lang('ModifyNote') : get_lang('NoteAddNew');
     $this->add_header($form_name);
     $this->add_textfield('title', get_lang('NoteTitle'), $required = true, array('class' => 'span3'));
     if (api_is_allowed_to_edit()) {
         $toolbar = array('ToolbarSet' => 'Notebook', 'Width' => '100%', 'Height' => '300');
     } else {
         $toolbar = array('ToolbarSet' => 'NotebookStudent', 'Width' => '100%', 'Height' => '300', 'UserStatus' => 'student');
     }
     $this->add_html_editor('description', get_lang('NoteComment'), true, api_is_allowed_to_edit(), $toolbar);
     $this->add_button('save', get_lang('Save'), array('class' => 'btn save'));
     $this->setDefaults($defaults);
 }