function main(&$backRef, $menuItems, $file, $uid)
 {
     // Returns directly, because the clicked item was not a file
     if ($backRef->cmLevel == 0 && $uid != '') {
         return $menuItems;
     }
     // Returns directly, because the clicked item was not the second level menu from DAM records
     if ($backRef->cmLevel == 1 && t3lib_div::_GP('subname') != 'tx_dam_cm_file') {
         return $menuItems;
     }
     $this->backRef =& $backRef;
     // this is second level menu from DAM records
     $fileDAM = t3lib_div::_GP('txdamFile');
     $file = $fileDAM ? $fileDAM : $file;
     if (@is_file($file)) {
         $item = tx_dam::file_compileInfo($file);
         $permsEdit = tx_dam::access_checkFile($item) && tx_dam::access_checkFileOperation('editFile');
         $permsDelete = tx_dam::access_checkFile($item) && tx_dam::access_checkFileOperation('deleteFile');
     } elseif (@is_dir($file)) {
         $item = tx_dam::path_compileInfo($file);
         $permsEdit = tx_dam::access_checkPath($item) && tx_dam::access_checkFileOperation('renameFolder');
         $permsDelete = tx_dam::access_checkPath($item) && tx_dam::access_checkFileOperation('deleteFolder');
     } else {
         return $menuItems;
     }
     // clear the existing menu now and fill it with DAM specific things
     $damMenuItems = array();
     // see typo3/alt_clickmenu.php:clickmenu::enableDisableItems() for iParts[3]
     // which is called after this function
     $backRef->iParts[3] = '';
     $actionCall = t3lib_div::makeInstance('tx_dam_actionCall');
     if (is_array($backRef->disabledItems)) {
         foreach ($backRef->disabledItems as $idName) {
             $actionCall->removeAction($idName);
         }
     }
     $actionCall->setRequest('context', $item);
     $actionCall->setEnv('returnUrl', t3lib_div::_GP('returnUrl'));
     $actionCall->setEnv('backPath', $backRef->PH_backPath);
     $actionCall->setEnv('defaultCmdScript', PATH_txdam_rel . 'mod_cmd/index.php');
     $actionCall->setEnv('defaultEditScript', PATH_txdam_rel . 'mod_edit/index.php');
     $actionCall->setEnv('actionPerms', tx_dam::access_checkFileOperation());
     $actionCall->setEnv('permsEdit', $permsEdit);
     $actionCall->setEnv('permsDelete', $permsDelete);
     $actionCall->setEnv('cmLevel', $backRef->cmLevel);
     $actionCall->setEnv('cmParent', t3lib_div::_GP('parentname'));
     $actionCall->initActions(true);
     $actions = $actionCall->renderActionsContextMenu(true);
     foreach ($actions as $id => $action) {
         if ($action['isDivider']) {
             $damMenuItems[$id] = 'spacer';
         } else {
             $onclick = $action['onclick'] ? $action['onclick'] : $this->createOnClick($action['url'], $action['dontHide']);
             $damMenuItems[$id] = $backRef->linkItem($GLOBALS['LANG']->makeEntities($action['label']), $backRef->excludeIcon($action['icon']), $onclick, $action['onlyCM'], $action['dontHide']);
         }
     }
     // clear the file context menu, allow additional items from extensions,
     // like TemplaVoila, and the display constraints
     // once a DAM file is found
     foreach ($menuItems as $key => $var) {
         if (!t3lib_div::inList('edit,rename,info,copy,cut,delete', $key) && !array_key_exists($key, $damMenuItems)) {
             $damMenuItems[$key] = $var;
         }
     }
     return $damMenuItems;
 }
    /**
     * Do the file indexing
     * Read files from a directory index them and output a result table
     *
     * @return	string		HTML content
     */
    function checkUploads($indexSessionID)
    {
        global $LANG, $TYPO3_CONF_VARS;
        // makes sense? Was a hint on php.net
        ob_end_flush();
        // get session data - which might have left files stored
        $indexSession = $this->indexSessionFetch();
        $where = array();
        if ($age = intval($this->pObj->MOD_SETTINGS['tx_dam_tools_indexupdate.age'])) {
            $where['tstamp'] = 'tstamp<' . (time() - $age);
        }
        if ($indexSessionID == '' or !isset($indexSession['ID']) or !($indexSession['ID'] == $indexSessionID) or $indexSession['currentCount'] == 0) {
            $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dam_file_tracking', '');
            $files = array();
            $files = $this->getFilesInDir(PATH_site . 'uploads/', true, $files);
            $countTotal = count($files);
            $indexSession = $this->indexSessionNew($countTotal, $files);
        }
        if (is_array($indexSession['data'])) {
            $damIndexing = t3lib_div::makeInstance('tx_dam_indexing');
            $damIndexing->init();
            $damIndexing->dryRun = TRUE;
            foreach ($indexSession['data'] as $key => $file) {
                // increase progress bar
                $indexSession['currentCount']++;
                $fileHash = tx_dam::file_calcHash($file);
                $fileInfo = tx_dam::file_compileInfo($file);
                $fields_values = array('tstamp' => time(), 'file_name' => $fileInfo['file_name'], 'file_path' => $fileInfo['file_path'], 'file_size' => $fileInfo['file_size'], 'file_ctime' => min($fileInfo['file_ctime'], $fileInfo['file_mtime']), 'file_hash' => $fileHash);
                $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_dam_file_tracking', $fields_values);
                $fileInfo = array_merge($fileInfo, $damIndexing->getFileMimeType($file));
                $fileInfo['media_type'] = tx_dam::convert_mediaType($fileInfo['file_mime_type']);
                $ctable = array();
                $ctable[] = '&nbsp;';
                $ctable[] = tx_dam::icon_getFileTypeImgTag($fileInfo, 'align="top"') . '&nbsp;' . htmlspecialchars(t3lib_div::fixed_lgd_cs($fileInfo['file_name'], 30));
                $ctable[] = htmlspecialchars(t3lib_div::fixed_lgd_cs($fileInfo['file_path'], -30));
                $this->indexing_addTableRow($ctable);
                $msg = $LANG->getLL('tx_dam_tools_indexupdate.updatedMessage', 1);
                $code = sprintf($msg, $indexSession['currentCount'], $indexSession['totalFilesCount']);
                $this->indexing_setMessage($code);
                $this->indexing_progressBar($indexSession['currentCount'], $indexSession['totalFilesCount']);
                $this->indexing_flushNow();
                $this->indexSessionWrite($indexSession);
                if ($this->indexEndtime < time() and $indexSession['currentCount'] < $indexSession['totalFilesCount']) {
                    $params = $this->pObj->addParams;
                    $params['indexSessionID'] = $indexSession['ID'];
                    echo '
						<script type="text/javascript">  window.location.href = unescape("' . t3lib_div::rawUrlEncodeJS(tx_dam_SCbase::linkThisScriptStraight($params)) . '"); </script>';
                    exit;
                }
            }
        } elseif ($indexSession['totalFilesCount'] == 0) {
            $code = $LANG->getLL('tx_dam_tools_indexupdate.no_files');
            $this->indexing_setMessage($code);
        }
        $this->indexing_finished();
        // finished - clear session
        $this->indexSessionClear();
    }
 /**
  * Main function, rendering the content of the rename form
  *
  * @return	void
  */
 function main()
 {
     global $LANG;
     $content = '';
     // Cleaning and checking target
     if ($this->pObj->file[0]) {
         $this->file = tx_dam::file_compileInfo($this->pObj->file[0]);
         $this->meta = tx_dam::meta_getDataForFile($this->file);
     } elseif ($id = intval($this->pObj->record['tx_dam'][0])) {
         $this->meta = tx_dam::meta_getDataByUid($id);
         $this->file = tx_dam::file_compileInfo($this->meta);
     }
     if (!is_array($this->meta)) {
         $fileType = tx_dam::file_getType($this->file);
         $this->meta = array_merge($this->file, $fileType);
         $this->meta['uid'] = 0;
     }
     if ($this->file['file_accessable']) {
         if (is_array($this->pObj->data) and $this->pObj->data['upload']) {
             $error = tx_dam::process_replaceFile($this->meta, $this->pObj->data);
             if ($error) {
                 $content .= $GLOBALS['SOBE']->getMessageBox($LANG->getLL('error'), htmlspecialchars($error), $this->pObj->buttonBack(0), 2);
             } else {
                 $this->pObj->redirect();
             }
         } else {
             $content .= $this->renderForm();
         }
     } else {
         // this should have happen in index.php already
         $content .= $this->pObj->accessDeniedMessageBox($this->file['file_name']);
     }
     return $content;
 }
 /**
  * Notifies the DAM about (external) changes to names and movements about files or folders.
  * This will update all related meta data
  *
  * @param	string		$src File/folder name with path of the source that was changed.
  * @param	string		$dest File/folder name with path of the destination which is a new name or/and a new location.
  * @return	void
  */
 function notify_fileCopied($src, $dest)
 {
     if (@is_file($dest)) {
         if ($meta = tx_dam::meta_getDataForFile($src, '*', true)) {
             $fileInfo = tx_dam::file_compileInfo($dest);
             $values = $meta;
             $values['uid'] = 'NEW';
             $values['deleted'] = '0';
             $values['file_name'] = $fileInfo['file_name'];
             $values['file_path'] = $fileInfo['file_path'];
             $values['file_mtime'] = $fileInfo['file_mtime'];
             if ($meta['file_dl_name'] == $meta['file_name']) {
                 $values['file_dl_name'] = $fileInfo['file_name'];
             }
             tx_dam_db::insertUpdateData($values);
         } else {
             // file is not yet indexed
             tx_dam::index_autoProcess($dest);
         }
         // the item is a folder
     } elseif (@is_dir($dest)) {
         tx_dam_db::cloneFilePath($src, $dest);
     }
     // else unknown
 }
 /**
  * tx_dam::file_relativeSitePath()
  */
 public function test_file_relativeSitePath()
 {
     $GLOBALS['T3_VAR']['ext']['dam']['pathInfoCache'] = array();
     $filepath = $this->getFixtureFilename();
     $filename = tx_dam::file_basename($filepath);
     $testpath = tx_dam::file_dirname($filepath);
     $relPath = t3lib_extmgm::siteRelPath('dam') . 'tests/fixtures/' . $filename;
     $path = tx_dam::path_makeClean($testpath);
     $path = tx_dam::path_makeRelative($path);
     $path = tx_dam::file_relativeSitePath($path . $filename);
     self::assertEquals($path, $relPath, 'File path differs: ' . $path . ' (' . $relPath . ')');
     $filepath = $this->getFixtureFilename();
     $fileinfo = tx_dam::file_compileInfo($filepath, $ignoreExistence = false);
     $path = tx_dam::file_relativeSitePath($fileinfo);
     self::assertEquals($path, $relPath, 'File path differs: ' . $path . ' (' . $relPath . ')');
 }
 /**
  * Returns an array with file/dir items + an array with the sorted items
  *
  * @param	string		Path (absolute) to read
  * @param	mixed		$allowTypes List or array of allow directory entry types: file, dir, link. Empty is all kinds of stuff.
  * @return	void
  */
 function read($path, $allowTypes = 'file')
 {
     $allowTypes = is_array($allowTypes) ? $allowTypes : t3lib_div::trimExplode(',', $allowTypes, true);
     if ($path) {
         $tempArray = array();
         $path = tx_dam::path_makeAbsolute($path);
         if (is_object($d = @dir($path))) {
             while ($entry = $d->read()) {
                 $filepath = $path . $entry;
                 // check for allow file types: eg. file, dir, link
                 if (@file_exists($filepath) && (!$allowTypes || in_array($type = filetype($filepath), $allowTypes))) {
                     // if filename matches exclude list this file is skipped
                     foreach ($this->excludeRegex as $expr) {
                         if (preg_match($expr, $entry)) {
                             continue 2;
                         }
                     }
                     // if filename don't matches allow list this file is skipped
                     foreach ($this->allowRegex as $expr) {
                         if (!preg_match($expr, $entry)) {
                             continue 2;
                         }
                     }
                     if ($type === 'file') {
                         $fileInfo = tx_dam::file_compileInfo($filepath);
                         if (is_array($meta = tx_dam::meta_getDataForFile($fileInfo))) {
                             // the newer stat data will be merged over the stored meta data
                             $fileInfo = array_merge($meta, $fileInfo);
                         } else {
                             $mimeType = tx_dam::file_getType($filepath);
                             $fileInfo = array_merge($fileInfo, $mimeType);
                         }
                         if (count($this->excludeFileTypes) and in_array($fileInfo['file_type'], $this->excludeFileTypes)) {
                             continue;
                         }
                         if (count($this->allowFileTypes) and !in_array($fileInfo['file_type'], $this->allowFileTypes)) {
                             continue;
                         }
                         if ($this->enableAutoIndexing) {
                             $this->autoIndex($fileInfo);
                         }
                     } elseif ($type === 'dir' or $type === 'link') {
                         $fileInfo = tx_dam::path_compileInfo($filepath);
                     }
                     // the file is valid so we add it to the list
                     $this->entries[] = $fileInfo;
                     $this->countBytes += $fileInfo['file_size'];
                 }
             }
             $d->close();
             $this->sort();
             $this->rewind();
         }
     }
 }
 /**
  * get basic file meta info
  *
  * @param	string		$pathname absolute path to file
  * @param	boolean		$calcHash if true a hash of the file will be created
  * @return	array		file information
  */
 function getFileNodeInfo($pathname, $calcHash = false)
 {
     $meta = false;
     $fileInfo = tx_dam::file_compileInfo($pathname);
     if (is_array($fileInfo) && $fileInfo['__exists']) {
         $meta = array();
         if ($calcHash) {
             $fileInfo['file_hash'] = tx_dam::file_calcHash($fileInfo);
         }
         $meta['fields'] = $fileInfo;
         $meta['file'] = $fileInfo;
     }
     if ($this->writeDevLog and $meta) {
         t3lib_div::devLog('getFileNodeInfo()', 'tx_dam_indexing', 0, $fileInfo);
     }
     if ($this->writeDevLog and !$meta) {
         t3lib_div::devLog('getFileNodeInfo() failed', 'tx_dam_indexing', 1, $fileInfo);
     }
     return $meta;
 }
 /**
  * Add an uploads file to the tracking table of the DAM.
  * This is needed to make it possible to identify files copied to uploads/
  *
  */
 function trackingUploadsFile($fileInfo, $hash = '')
 {
     $fileInfo = is_array($fileInfo) ? $fileInfo : tx_dam::file_compileInfo($fileInfo);
     if ($fileInfo['__exists'] and t3lib_div::isFirstPartOfStr($fileInfo['file_path'], 'uploads/')) {
         $hash = $hash ? $hash : tx_dam::file_calcHash($fileInfo);
         $where = 'file_name=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($fileInfo['file_name'], 'tx_dam_file_tracking') . ' AND file_path=' . $GLOBALS['TYPO3_DB']->fullQuoteStr($fileInfo['file_path'], 'tx_dam_file_tracking');
         $GLOBALS['TYPO3_DB']->exec_DELETEquery('tx_dam_file_tracking', $where);
         $fields_values = array('tstamp' => time(), 'file_name' => $fileInfo['file_name'], 'file_path' => $fileInfo['file_path'], 'file_size' => $fileInfo['file_size'], 'file_ctime' => max($fileInfo['file_ctime'], $fileInfo['file_mtime']), 'file_hash' => $hash);
         $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_dam_file_tracking', $fields_values);
     }
 }
 /**
  * Returns a image-tag, URL and attributes for a image preview
  *
  * @param	mixed		$fileInfo Is a file path or an array containing a file info from tx_dam::file_compileInfo().
  * @param	string		$size Optional: $size is [w]x[h] of the image preview. 56 is default.
  * @param	mixed		$imgAttributes additional attributes for the image tag
  * @return	array		Thumbnail image tag, url and attributes with width/height
  * @todo calc width/height from cm size or similar when hpixels not available
  * @todo return false when file is missing?
  */
 function preview($fileInfo, $size = '', $imgAttributes = '')
 {
     // get some file information
     if (!is_array($fileInfo)) {
         $fileInfo = tx_dam::file_compileInfo($fileInfo);
     }
     $filepath = tx_dam::file_absolutePath($fileInfo);
     if ($filepath and @file_exists($filepath) and @is_file($filepath)) {
         $fileType = tx_dam::file_getType($fileInfo);
         if (!tx_dam_image::isPreviewPossible($fileType)) {
             return array();
         }
         if (!is_array($imgAttributes)) {
             $imgAttributes = tx_dam_image::tools_explodeAttributes($imgAttributes);
         }
         $imgAttributes['alt'] = isset($imgAttributes['alt']) ? $imgAttributes['alt'] : ($fileInfo['alt_text'] ? $fileInfo['alt_text'] : $fileInfo['title']);
         $imgAttributes['title'] = isset($imgAttributes['title']) ? $imgAttributes['title'] : $imgAttributes['alt'];
         // Check and parse the size parameter
         $size = trim($size);
         list($sizeX, $sizeY) = tx_dam_image::parseSize($size);
         $sizeMax = $max = max($sizeX, $sizeY);
         // get maximum image pixel size
         $maxImageSize = 0;
         if ($fileInfo['hpixels']) {
             $maxImageSize = max($fileInfo['hpixels'], $fileInfo['vpixels']);
         } elseif (t3lib_div::inList('gif,jpg,png', $fileType['file_type'])) {
             if (is_array($imgInfo = @getimagesize($filepath))) {
                 $fileInfo['hpixels'] = $imgInfo[0];
                 $fileInfo['vpixels'] = $imgInfo[1];
                 $maxImageSize = max($fileInfo['hpixels'], $fileInfo['vpixels']);
             }
         }
         // calculate the image preview size
         $useOriginalImage = false;
         if ($maxImageSize and $maxImageSize <= $sizeMax) {
             $useOriginalImage = true;
             $thumbSizeX = $fileInfo['hpixels'];
             $thumbSizeY = $fileInfo['vpixels'];
             $imgAttributes['width'] = $thumbSizeX;
             $imgAttributes['height'] = $thumbSizeY;
         } elseif ($maxImageSize) {
             list($thumbSizeX, $thumbSizeY) = tx_dam_image::calcSize($fileInfo['hpixels'], $fileInfo['vpixels'], $sizeX, $sizeY);
             $imgAttributes['width'] = $thumbSizeX;
             $imgAttributes['height'] = $thumbSizeY;
             $size = $thumbSizeX . 'x' . $thumbSizeY;
         } elseif (tx_dam_image::isPreviewPossible($fileType)) {
             $thumbSizeX = $sizeX;
             $thumbSizeY = $sizeY;
             $size = $thumbSizeX . 'x' . $thumbSizeY;
         } else {
             $thumbSizeX = 0;
             $thumbSizeY = 0;
         }
         $url = '';
         $thumbnail = '';
         if ($thumbSizeX) {
             // use the original image if it's size fits to the image preview size
             if ($useOriginalImage) {
                 if (TYPO3_MODE === 'FE') {
                     $url = preg_replace('#^' . preg_quote(PATH_site) . '#', '', $filepath);
                 } else {
                     $url = $GLOBALS['BACK_PATH'] . '../' . preg_replace('#^' . preg_quote(PATH_site) . '#', '', $filepath);
                 }
                 // use thumbs.php script
             } else {
                 $check = basename($filepath) . ':' . filemtime($filepath) . ':' . $GLOBALS['TYPO3_CONF_VARS']['SYS']['encryptionKey'];
                 $url = 'thumbs.php?';
                 $url .= '&file=' . rawurlencode($filepath);
                 $url .= $size ? '&size=' . $size : '';
                 $url .= '&md5sum=' . t3lib_div::shortMD5($check);
                 $url .= '&dummy=' . $GLOBALS['EXEC_TIME'];
                 if (TYPO3_MODE === 'FE') {
                     $url = TYPO3_mainDir . $url;
                 } else {
                     $url = $GLOBALS['BACK_PATH'] . $url;
                 }
             }
         }
         $imgAttributes = tx_dam_image::tools_implodeAttributes($imgAttributes);
         $thumbnail = '<img src="' . htmlspecialchars($url) . '"' . $imgAttributes . ' />';
     }
     return array('img' => $thumbnail, 'url' => $url, 'attributes' => $imgAttributes, 'sizeX' => $thumbSizeX, 'sizeY' => $thumbSizeY);
 }
Exemple #10
0
 /**
  * Compiles meta/fielInfo data for file and record items
  *
  * @return array Item array. Key is uid or md5 of filepath
  */
 function compileFilesAndRecordsData()
 {
     $items = array();
     if (count($this->file)) {
         foreach ($this->file as $filepath) {
             $fileInfo = tx_dam::file_compileInfo($filepath, true);
             $meta = tx_dam::meta_getDataForFile($fileInfo, '*');
             if (!is_array($meta)) {
                 $fileType = tx_dam::file_getType($filepath);
                 $meta = array_merge($fileInfo, $fileType);
                 $meta['uid'] = 0;
             }
             $id = $meta['uid'] ? $meta['uid'] : md5(tx_dam::file_absolutePath($fileInfo));
             $items[$id] = array_merge($meta, $fileInfo);
         }
     } elseif (count($this->record['tx_dam'])) {
         foreach ($this->record['tx_dam'] as $uid) {
             if ($meta = tx_dam::meta_getDataByUid($uid, '*')) {
                 $fileInfo = tx_dam::file_compileInfo($meta, true);
                 $items[$meta['uid']] = array_merge($meta, $fileInfo);
             }
         }
     }
     return $items;
 }
 /**
  * Collects physical informations about the file.
  * This means the file must be existent.
  *
  * @param	mixed		$fileInfo Is a file path or an array containing a file info from tx_dam::file_compileInfo().  Default from getPathAbsolute().
  * @param	boolean		$ignoreExistence The existence of the file will not be checked and only the file path will be splitted.
  * @return	boolean		If the file exists and the info could be fetched.
  * @see tx_dam::file_compileInfo()
  */
 function fetchFileinfo($fileInfo = NULL, $ignoreExistence = true)
 {
     $this->isAvailable = false;
     $info = false;
     if (is_array($fileInfo) and $fileInfo['file_name'] and $fileInfo['file_path_absolute']) {
         $info = $fileInfo;
     } else {
         $fileInfo = $fileInfo ? $fileInfo : $this->filepath;
         $info = tx_dam::file_compileInfo($fileInfo, $ignoreExistence);
     }
     if (is_array($info)) {
         $this->fileInfo = $info;
         $this->filename = $this->fileInfo['file_name'];
         $this->pathNormalized = $this->fileInfo['file_path'];
         $this->pathAbsolute = $this->fileInfo['file_path_absolute'];
         $this->filepath = $this->pathAbsolute . $this->filename;
         $this->isAvailable = $this->fileInfo['__exists'];
         $this->update();
     }
     return $this->isAvailable;
 }
 /**
  * Insert a log entry
  *
  * The $addInfo array can override the defaults/detected values except the user_group which cannot be guessed.
  *
  * @param 	mixed  		$fileInfo see tx_dam.
  * @param 	integer 	$bytes_downloaded
  * @param 	boolean 	$protected Defines if it is a secure download
  * @param 	array 		$addInfo Additional infos to be written: host, user_id, user_name, user_group, page_id
  * @return 	integer 	Log id. See update().
  */
 function insert($fileInfo, $bytes_downloaded = 0, $protected = 0, $addInfo = array())
 {
     if (is_object($fileInfo)) {
         $fileInfo = $fileInfo->getMetaArray();
     } elseif (!is_array($fileInfo)) {
         $fileInfo = tx_dam::file_compileInfo($fileInfo);
     }
     $addInfo['host'] = $addInfo['host'] ? $addInfo['host'] : t3lib_div::getIndpEnv('REMOTE_ADDR');
     if (!$addInfo['user_id']) {
         if (is_object($GLOBALS['TSFE'])) {
             $addInfo['user_id'] = $GLOBALS['TSFE']->fe_user->user['uid'];
         } elseif (is_object($GLOBALS['BE_USER'])) {
             $addInfo['user_id'] = $GLOBALS['BE_USER']->user['uid'];
         }
     }
     // to be set from outside: $info['user_group']
     if (!$addInfo['page_id'] and is_object($GLOBALS['TSFE'])) {
         $addInfo['page_id'] = $GLOBALS['TSFE']->id;
     }
     $info = array_merge($fileInfo, $addInfo);
     $time = time();
     $row = array('pid' => tx_dam_db::getPidList(), 'tstamp' => intval($addInfo['tstamp']) ? intval($addInfo['tstamp']) : $time, 'crdate' => intval($addInfo['crdate']) ? intval($addInfo['crdate']) : $time, 'cruser_id' => intval($addInfo['cruser_id']), 'file_id' => intval($info['uid']), 'file_name' => $info['file_name'], 'file_path' => $info['file_path'], 'file_type' => $info['file_type'], 'media_type' => $info['media_type'], 'file_size' => $info['file_size'], 'bytes_downloaded' => $bytes_downloaded === true ? $info['file_size'] : intval($bytes_downloaded), 'protected' => $protected ? 1 : 0, 'host' => $info['host'], 'user_id' => $info['user_id'], 'user_name' => $info['user_name'], 'user_group' => $info['user_group'], 'page_id' => $info['page_id'], 'app_id' => $this->app_id, 'sitetitle' => $this->sitetitle, 'typo3_mode' => TYPO3_MODE);
     if ($res = $GLOBALS['TYPO3_DB']->exec_INSERTquery('tx_dam_log_download', $row)) {
         $id = $GLOBALS['TYPO3_DB']->sql_insert_id($res);
     }
     return $id;
 }
 /**
  * Returns a linked image-tag for thumbnail(s)
  *
  * @param	mixed		$fileInfo Is a file path or an array containing a file info from tx_dam::file_compileInfo().
  * @param	string		$size Optional: $size is [w]x[h] of the thumbnail. 56 is default.
  * @param	string		$titleContent Optional: Used as a title= attribute content
  * @param	mixed		$imgAttributes Optional: is additional attributes for the image tags
  * @param	mixed		$iconAttributes Optional: additional attributes for the image tags for file icons
  * @param	string		$onClick Optional: If falso no A tag with onclick will be wrapped. If NULL top.launchView() will be used. If string it's value will be used as onclick value.
  * @param	boolean		$makeFileIcon If true a file icon will be returned if no thumbnail is possible
  * @return	string		Thumbnail image tag.
  * @deprecated - really?
  */
 function thumbnail($fileInfo, $size = '', $titleContent = '', $imgAttributes = '', $iconAttributes = '', $onClick = NULL, $makeFileIcon = TRUE)
 {
     // get some file information
     if (!is_array($fileInfo)) {
         $fileInfo = tx_dam::file_compileInfo($fileInfo);
     }
     if (!is_array($imgAttributes)) {
         $imgAttributes = tx_dam_guifunc::tools_explodeAttributes($imgAttributes);
     }
     $titleContent = $titleContent ? $titleContent : ($imgAttributes['title'] ? $imgAttributes['title'] : tx_dam_guiFunc::meta_compileHoverText($fileInfo, '', ' - '));
     $imgAttributes['title'] = $titleContent;
     if (!($onClick === false)) {
         $filepath = tx_dam::file_absolutePath($fileInfo);
         $imgAttributes['onclick'] = !is_null($onClick) ? $onClick : (TYPO3_MODE === 'BE' ? 'top.launchView(\'' . $filepath . '\',\'\',\'' . $GLOBALS['BACK_PATH'] . '\');return false;' : false);
     }
     if ($makeFileIcon) {
         if (!is_array($iconAttributes)) {
             $iconAttributes = tx_dam_guifunc::tools_explodeAttributes($iconAttributes);
         }
         $iconAttributes['title'] = isset($iconAttributes['title']) ? $iconAttributes['title'] : $titleContent;
     }
     $thumbnail = tx_dam_guiFunc::image_thumbnailIconImgTag($fileInfo, $size, $imgAttributes, $iconAttributes, $makeFileIcon);
     return $thumbnail;
 }