You are here

class webfm_fdesc in Web File Manager 5

Same name and namespace in other branches
  1. 5.2 webfm.module \webfm_fdesc

File description class

Hierarchy

Expanded class hierarchy of webfm_fdesc

File

./webfm.module, line 2301

View source
class webfm_fdesc {
  var $result;

  // Constructor:
  function webfm_fdesc($file) {
    $cwd = getcwd();
    $this->result = FALSE;
    $dir = dirname($file->fpath);

    //assume the object $file record path has a directory before the file name
    if (is_dir($dir)) {
      if (chdir($dir)) {
        if ($handle = opendir('.')) {
          while (($readdir = readdir($handle)) !== false) {
            if (is_dir($readdir)) {
              continue;
            }
            if (is_file($readdir) && $readdir == basename($file->fpath)) {
              $this->id = $file->fid;
              $this->n = strrev(substr(strrev($file->fpath), 0, strpos(strrev($file->fpath), '/')));
              $this->p = $dir;
              $this->e = array_pop(explode('.', $this->n));
              $this->s = $file->fsize;
              $this->uid = $file->uid;
              $_query = 'SELECT name FROM {users} WHERE uid = %d';
              $this->un = db_result(db_query($_query, $file->uid));

              // urldecode required for fields where user input is urlencoded
              $this->ftitle = urldecode($file->ftitle);
              $this->fdesc = urldecode($file->fdesc);
              $this->fcreatedate = $file->fcreatedate;
              $this->flang = urldecode($file->flang);
              $this->fpublisher = urldecode($file->fpublisher);
              $this->fformat = urldecode($file->fformat);
              $this->fversion = $file->fversion;
              $this->m = filemtime($readdir) ? @filemtime($readdir) : "";
              $this->result = TRUE;
              break;
            }
          }
          closedir($handle);
        }

        // Restore current working directory
        chdir($cwd);
      }
    }
  }

}

Members