Exemplo n.º 1
0
 /**
  * Returns an array of meta data for a list of files from the uploads folder.
  * This can be used to get meta data for "uploads" files.
  *
  * IMPORTANT
  * The meta data does NOT include data of the uploads file itself but a matching file which is placed in fileadmin/!
  *
  * @param 	mixed 		$fileList Comma list or array of files
  * @param 	string 		$uploadsPath Uploads path. If empty each file have to have a path prepended.
  * @param	string		$fields The fields to select. Needs to be prepended with table name: tx_dam.uid, tx_dam.title
  * @param	array		$whereClauses WHERE clauses as array with associative keys (which can be used to overwrite 'enableFields') or a single one as string.
  * @return array
  */
 function getMetaForUploads($fileList, $uploadsPath = '', $fields = '', $whereClauses = array())
 {
     $select_fields = $fields ? $fields : 'tx_dam.*';
     if (!isset($whereClauses['file_hash'])) {
         $whereClauses['file_hash'] = 'tx_dam_file_tracking.file_hash=tx_dam.file_hash';
     }
     $uploadsPath = tx_dam::path_makeClean($uploadsPath);
     $fileList = is_array($fileList) ? $fileList : explode(',', $fileList);
     $files = array();
     foreach ($fileList as $filepath) {
         $filepath = $uploadsPath . $filepath;
         $fileInfo = tx_dam::file_compileInfo($uploadsPath . $filepath);
         if ($fileInfo['__exists']) {
             // a file might be twice in fileadmin/
             // this will just use the first found entry
             // I can'T see how to detect which file (they are the same) has the right meta data for the uploads file
             $whereClauses['file_name'] = 'tx_dam_file_tracking.file_name=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($fileInfo['file_name'], 'tx_dam_file_tracking');
             $whereClauses['file_path'] = 'tx_dam_file_tracking.file_path=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($fileInfo['file_path'], 'tx_dam_file_tracking');
             $where = tx_dam_db::fillWhereClauseArray($whereClauses);
             $rows = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($select_fields, 'tx_dam, tx_dam_file_tracking', implode(' AND ', $where), '', '', '1');
             reset($rows);
             $files[$filepath] = current($rows);
         }
     }
     return $files;
 }