예제 #1
0
 /**
  * Fetches the meta data from the index by a given file path or file info array.
  * This function tries to find an index entry for a file from uploads/. Files in uploads/ are copies from files from fileadmin/ or direct uploads.
  * The meta data that might be found is not directly meant for the uploads-file but normally it matches the file and you get what you expect.
  * But for example the file might be placed in fileadmin/ twice with different meta data. Then you can't say which meta data you will get for the uploads-file.
  *
  * IMPORTANT
  * The meta data does NOT include data of the uploads file itself but a matching file which is placed in fileadmin/!
  *
  * @param	mixed		$fileInfo Is a file path or an array containing a file info from tx_dam::file_compileInfo().
  * @param 	string 		$uploadsPath Uploads path. will be prepended if $fileInfo is a path (string).
  * @param	string		$fields A list of fields to be fetched. Default is a list of fields generated by tx_dam_db::getMetaInfoFieldList().
  * @param	string		$mode TYPO3_MODE to be used: 'FE', 'BE'. Constant TYPO3_MODE is default.
  * @return	array
  */
 function meta_findDataForUploadsFile($fileInfo, $uploadsPath = '', $fields = '', $mode = TYPO3_MODE)
 {
     $meta = false;
     if (!is_array($fileInfo)) {
         $uploadsPath = tx_dam::path_makeClean($uploadsPath);
         $fileInfo = tx_dam::file_compileInfo($uploadsPath . $fileInfo);
     }
     if (is_array($fileInfo) and $fileInfo['__exists']) {
         $fields = $fields ? $fields : tx_dam_db::getMetaInfoFieldList();
         $where = array();
         $where['enableFields'] = tx_dam_db::enableFields('tx_dam', '', $mode);
         $fileList = tx_dam::file_relativeSitePath($fileInfo);
         if ($rows = tx_dam_db::getMetaForUploads($fileList, '', $fields)) {
             reset($rows);
             $meta = current($rows);
         }
     }
     return $meta;
 }