Пример #1
0
 function preProcessForm(&$values)
 {
     if (empty($values['filename'])) {
         include_once 'n_filesystem.php';
         $values['filename'] = NFilesystem::cleanFileName($values['title']);
     }
     parent::preProcessForm($values);
 }
Пример #2
0
 function processFiles(&$values, $files_array)
 {
     include_once 'n_filesystem.php';
     $form =& $this->form;
     $model =& $this->model;
     $pk = $model->primaryKey();
     foreach ($files_array as $field => $vals) {
         $tmp_file = $vals['value']['tmp_name'];
         if (!is_uploaded_file($tmp_file)) {
             $values[$field] = '';
             continue;
         }
         $path = array();
         if ($vals['type'] == 'cms_file') {
             $path[] = $this->controller->name;
             $path[] = $model->{$pk};
         }
         $path[] = substr(md5(microtime()), 20);
         $path[] = NFilesystem::cleanFileName($vals['value']['name']);
         $filename = implode('/', $path);
         $tmp_file = $model->beforeUpload($field, $tmp_file);
         $newfile = NUpload::moveUpload($tmp_file, $filename);
         $values[$field] = $newfile ? $newfile : '';
     }
 }