/**
  * tx_dam::path_makeXXX()
  */
 public function test_path_makeXXX()
 {
     $GLOBALS['T3_VAR']['ext']['dam']['pathInfoCache'] = array();
     $filepath = $this->getFixtureFilename();
     $filename = tx_dam::file_basename($filepath);
     $testpath = tx_dam::file_dirname($filepath);
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeAbsolute($path);
     self::assertEquals($path, $testpath, 'File path differs: ' . $path . ' (' . $testpath . ')');
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeAbsolute($path);
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeAbsolute($path);
     self::assertEquals($path, $testpath, 'Path differs: ' . $path . ' (' . $testpath . ')');
     $testpath = '/aaa/../bbb/./ccc//ddd';
     $testpathClean = '/bbb/ccc/ddd/';
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::path_makeAbsolute($path);
     self::assertEquals($path, $testpathClean, 'Path differs: ' . $path . ' (' . $testpathClean . ')');
     $testpath = PATH_site . '/aaa/../bbb/./ccc//ddd';
     $testpathClean = 'bbb/ccc/ddd/';
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     self::assertEquals($path, $testpathClean, 'Path differs: ' . $path . ' (' . $testpathClean . ')');
 }
示例#2
0
 /**
  * Register a path to additional file type icons
  *
  * @param	string		$path Path to icon files ("EXT:" prefix will be resolved)
  * @param	string		$mode TYPO3_MODE to be used: 'FE', 'BE'. Constant TYPO3_MODE is default.
  * @return	void
  */
 function register_fileIconPath($path, $mode = TYPO3_MODE)
 {
     $path = tx_dam::path_makeClean(t3lib_div::getFileAbsFileName($path));
     if (!is_array($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['fileIconPaths_' . $mode])) {
         $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['fileIconPaths_' . $mode] = array();
         $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['fileIconPaths_' . $mode][] = $path;
     } else {
         array_unshift($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['dam']['fileIconPaths_' . $mode], $path);
     }
 }
 /**
  * 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;
 }