Esempio n. 1
0
 /**
  * Display the admin 'files' page
  *
  * @return void
  **/
 function screen_files($id)
 {
     if (isset($_POST['rescan']) && check_admin_referer('drainhole-add_file')) {
         $hole = DH_Hole::get($id);
         do_action('drainhole_scan', $hole);
         $scanned = $hole->scan();
         DH_Hole::flush();
         if ($scanned == 0) {
             $this->render_message(__('No new files were found', 'drain-hole'));
         } else {
             if ($scanned == 1) {
                 $this->render_message(sprintf(__ngettext('%d new file was found', '%d new files were found', $scanned, 'drain-hole'), $scanned));
             }
         }
     } else {
         if (isset($_POST['upload']) && check_admin_referer('drainhole-add_file')) {
             $hole = DH_Hole::get($id);
             if (DH_File::upload($hole, $_POST['filename'], $_FILES['file'])) {
                 DH_Hole::flush();
                 $this->render_message('Your files were successfully updated', 'drain-hole');
                 do_action('drainhole_upload', $hole);
             } else {
                 $this->render_error('Your files were not updated', 'drain-hole');
             }
         }
     }
     $pager = new DH_Pager($_GET, $_SERVER['REQUEST_URI'], 'file', 'ASC', 'drainhole-files');
     $files = DH_File::get_by_hole($id, $pager);
     $hole = DH_Hole::get($id);
     $this->render_admin('files', array('files' => $files, 'hole' => $hole, 'pager' => $pager));
 }