Example #1
0
 /**
  * Build file metadata object
  *
  * @return  object
  */
 public function getMetadata($item = NULL, $type = 'file', $params = array())
 {
     if ($item === NULL) {
         return false;
     }
     $path = isset($params['path']) ? $params['path'] : $this->get('path');
     $dirPath = isset($params['subdir']) ? $params['subdir'] : NULL;
     $remotes = isset($params['remoteConnections']) ? $params['remoteConnections'] : array();
     $localPath = $dirPath ? $dirPath . DS . $item : $item;
     $file = new Models\File($localPath, $path);
     $file->set('type', $type);
     if ($type == 'folder') {
         $file->clear('ext');
     }
     // Synced file?
     if (!empty($remotes) && isset($remotes[$file->get('localPath')])) {
         // Pick up data from sync record
         $syncRecord = $remotes[$file->get('localPath')];
         $file->set('remote', $syncRecord->service);
         $file->set('remoteId', $syncRecord->remote_id);
         $file->set('remoteTitle', $syncRecord->remote_title);
         $file->set('remoteParent', $syncRecord->remote_parent);
         $file->set('author', $syncRecord->remote_author);
         $file->set('modified', $syncRecord->remote_modified);
         $file->set('mimeType', $syncRecord->remote_format);
         $file->set('converted', $syncRecord->remote_editing);
         $file->set('originalId', $syncRecord->original_id);
         $file->set('originalPath', $syncRecord->original_path);
         $file->set('originalFormat', $syncRecord->original_format);
         $file->set('recordId', $syncRecord->id);
     }
     return $file;
 }