Exemplo n.º 1
0
 /**
  * New files form
  *
  * @param   integer	$id_area Area ID
  * @param   string  $category Category name
  * @param   string  $subcategory Subcategory name
  * @return  void
  */
 public function add($id_area = 0, $category = '', $subcategory = '')
 {
     // load dictionaries
     $this->dict->get_wordarray(array('form', 'files'));
     // build the form
     $fields = array();
     $mod = new File_model();
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">');
     $fields[] = array('label' => _AREA, 'type' => 'select', 'value' => $id_area, 'name' => 'id_area', 'options' => array($mod->get_areas(), 'id', 'title'), 'multiple' => 4, 'extra' => 'class="large"');
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">');
     $fields[] = array('label' => null, 'type' => 'hidden', 'value' => 'files', 'name' => 'link');
     $fields[] = array('label' => _CATEGORY, 'type' => 'text', 'value' => $category == '-' ? '' : $category, 'name' => 'category', 'extra' => 'class="large"', 'rule' => 'required');
     $fields[] = array('label' => _SUBCATEGORY, 'type' => 'text', 'value' => $subcategory == '-' ? '' : $subcategory, 'name' => 'subcategory', 'extra' => 'class="large"', 'rule' => 'required');
     $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>');
     $fields[] = array('label' => _FILE, 'type' => 'file', 'value' => '', 'name' => 'xname', 'rule' => 'required', 'multiple' => 5, 'extra' => 'class="large"');
     // to handle file's label
     $file_array = array('xname' => _FILE);
     // if submitted
     if (X4Route_core::$post) {
         $e = X4Validation_helper::form($fields, 'upload');
         if ($e) {
             $this->adding($_POST, $file_array);
         } else {
             $this->notice($fields);
         }
         die;
     }
     // content
     $view = new X4View_core('files/upload_file');
     $view->id_area = $id_area;
     $view->category = $category;
     $view->subcategory = $subcategory;
     // form builder
     $view->form = X4Form_helper::doform('upload', $_SERVER["REQUEST_URI"], $fields, array(_RESET, _SUBMIT, 'buttons'), 'post', 'enctype="multipart/form-data"', 'onclick="setUploadForm(\'upload\', \'xname\');"');
     $view->render(TRUE);
 }