Feature #24076 » 0016414_fal_core.patch
t3lib/class.t3lib_befunc.php | ||
---|---|---|
$uploaddir = (is_null($uploaddir)) ? $TCA[$table]['columns'][$field]['config']['uploadfolder'] : $uploaddir;
|
||
$uploaddir = preg_replace('#/$#','', $uploaddir);
|
||
/**
|
||
* FAL stuff
|
||
*/
|
||
if (t3lib_extMgm::isLoaded('fal')) {
|
||
if (isset($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fal']['tableAndFieldMapping'][$table])) {
|
||
$repo = t3lib_div::makeInstance('t3lib_file_Repository');
|
||
foreach ($GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['fal']['tableAndFieldMapping'][$table] as $overlayField => $fieldName) {
|
||
$references = $repo->getFilesFromRelation($fieldName, $table, intval($row['uid']));
|
||
$references = t3lib_file_Helper::createCsvListOfFilepaths($references);
|
||
$row[$fieldName] = $references;
|
||
$row[$overlayField] = $references;
|
||
};
|
||
}
|
||
$uploaddir = '';
|
||
}
|
||
// Set thumbs-script:
|
||
if (!$GLOBALS['TYPO3_CONF_VARS']['GFX']['thumbnails']) {
|
||
$thumbScript = 'gfx/notfound_thumb.gif';
|
t3lib/class.t3lib_div.php | ||
---|---|---|
if ($OK) { $OK = rmdir($path); }
|
||
} else { // If $dirname is a file, simply remove it
|
||
$OK = unlink($path);
|
||
if (t3lib_extMgm::isLoaded('fal')) {
|
||
$fileRepository = t3lib_div::makeInstance('t3lib_file_Repository');
|
||
$fileRecord = $fileRepository->getFileByPath($path);
|
||
$OK = $fileRecord->delete();
|
||
} else {
|
||
$OK = unlink($path);
|
||
}
|
||
}
|
||
clearstatcache();
|
t3lib/class.t3lib_extfilefunc.php | ||
---|---|---|
return TRUE;
|
||
} elseif ($this->useRecycler != 2) { // if $this->useRecycler==2 then we cannot delete for real!!
|
||
if (@is_file($theFile)) { // If we are deleting a file...
|
||
$fileRepository = t3lib_div::makeInstance('t3lib_file_Repository');
|
||
$file = $fileRepository->getFileByPath($theFile);
|
||
if ($this->actionPerms['deleteFile']) {
|
||
if ($this->checkPathAgainstMounts($theFile)) {
|
||
if (@unlink($theFile)) {
|
||
if ($file->delete()) {
|
||
$this->writelog(4,0,1,'File "%s" deleted',Array($theFile));
|
||
return TRUE;
|
||
} else $this->writelog(4,1,110,'Could not delete file "%s". Write-permission problem?', Array($theFile));
|
||
... | ... | |
$theFile = $_FILES['upload_'.$id]['tmp_name']; // filename of the uploaded file
|
||
$theFileSize = $_FILES['upload_'.$id]['size']; // filesize of the uploaded file
|
||
$theName = $this->cleanFileName(stripslashes($_FILES['upload_'.$id]['name']), (isset($cmds['charset']) ? $cmds['charset'] : '')); // The original filename
|
||
if (is_uploaded_file($theFile) && $theName) { // Check the file
|
||
if (is_file($theFile) && $theName) { // Check the file
|
||
if ($this->actionPerms['uploadFile']) {
|
||
if ($theFileSize<($this->maxUploadFileSize*1024)) {
|
||
$fI = t3lib_div::split_fileref($theName);
|
t3lib/class.t3lib_extmgm.php | ||
---|---|---|
$TCA[$content_table]['columns'][$content_field]['config']['allowed'].=','.$table;
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Get field TCA configuration (only "config" part) for File Abstraction Layer
|
||
* fields.
|
||
*
|
||
* @param string $fieldName Field name
|
||
* @param string $allowedFileTypes Comma list of allowed file extensions (e.g. "jpg,gif,png"). By default, it's allowing TYPO3_CONF_VARS[GFX][imagefile_ext].
|
||
* @param array $overrideArray Array to override or add configuration options
|
||
* @return array Field TCA configuration "config" section for the field
|
||
*/
|
||
public static function getFileFieldTCAConfig($fieldName, $allowedFileTypes = '', array $overrideArray = array()) {
|
||
if(!$allowedFileTypes) {
|
||
$allowedFileTypes = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'];
|
||
}
|
||
$TCAFieldConfig = t3lib_div::array_merge_recursive_overrule(array(
|
||
'type' => 'group',
|
||
'internal_type' => 'db',
|
||
'allowed' => 'sys_files',
|
||
'internal_subtype' => 'file_record',
|
||
'internal_subtype_allowed' => $allowedFileTypes,
|
||
'prepend_tname' => 1,
|
||
'show_thumbs' => 0,
|
||
'size' => 5,
|
||
'minitems' => 0,
|
||
#'maxitems' => 100,
|
||
'MM_opposite_field' => 'file_usage',
|
||
'MM' => 'sys_files_usage_mm',
|
||
'MM_match_fields' => array('ident' => $fieldName),
|
||
'wizards' => array(
|
||
'falrendering' => array(
|
||
'type' => 'userFunc',
|
||
'userFunc' => 'tx_fal_tceforms_wizard->tx_fal_fieldwizard',
|
||
),
|
||
),
|
||
), $overrideArray);
|
||
|
||
return $TCAFieldConfig;
|
||
}
|
||
/**
|
||
* Add PlugIn to Static Template #43
|
t3lib/class.t3lib_page.php | ||
---|---|---|
* @return array Page row which is overlayed with language_overlay record (or the overlay record alone)
|
||
*/
|
||
function getPageOverlay($pageInput,$lUid=-1) {
|
||
// Initialize:
|
||
if ($lUid<0) $lUid = $this->sys_language_uid;
|
||
$row = NULL;
|
||
... | ... | |
if (is_array($row)) {
|
||
$row['_PAGES_OVERLAY'] = TRUE;
|
||
$row['_PAGES_OVERLAY_UID'] = $row['uid'];
|
||
// Unset vital fields that are NOT allowed to be overlaid:
|
||
unset($row['uid']);
|
||
... | ... | |
}
|
||
// Initialize:
|
||
// add FAL media field to the rootline
|
||
if (t3lib_extMgm::isLoaded('fal')) {
|
||
$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields'] .= ', media_rel';
|
||
}
|
||
$selFields = t3lib_div::uniqueList('pid,uid,t3ver_oid,t3ver_wsid,t3ver_state,t3ver_swapmode,title,alias,nav_title,media,layout,hidden,starttime,endtime,fe_group,extendToSubpages,doktype,TSconfig,storage_pid,is_siteroot,mount_pid,mount_pid_ol,fe_login_mode,'.$GLOBALS['TYPO3_CONF_VARS']['FE']['addRootLineFields']);
|
||
$this->error_getRootLine = '';
|
||
$this->error_getRootLine_failPid = 0;
|
t3lib/class.t3lib_tceforms.php | ||
---|---|---|
'noBrowser' => $noList || (isset($config['disable_controls']) && t3lib_div::inList($config['disable_controls'], 'browser')),
|
||
'noList' => $noList,
|
||
);
|
||
$item.= $this->dbFileIcons($PA['itemFormElName'],'db',implode(',',$tempFT),$itemArray,'',$params,$PA['onFocus'],$table,$field,$row['uid']);
|
||
$item.= $this->dbFileIcons($PA['itemFormElName'], 'db', implode(',',$tempFT), $itemArray,'',$params,$PA['onFocus'],$table,$field,$row['uid'], $config['internal_subtype'], $config['internal_subtype_allowed']);
|
||
break;
|
||
}
|
||
... | ... | |
* @param string $uid: (optional) uid of table record processing for
|
||
* @return string The form fields for the selection.
|
||
*/
|
||
function dbFileIcons($fName,$mode,$allowed,$itemArray,$selector='',$params=array(),$onFocus='',$table='',$field='',$uid='') {
|
||
function dbFileIcons($fName,$mode,$allowed,$itemArray,$selector='',$params=array(),$onFocus='',$table='',$field='',$uid='', $subtype='', $subtype_allowed='') {
|
||
|
||
if($mode === 'db' && $subtype === 'file_record') {
|
||
$elementBrowserMode = 'file';
|
||
$elementBrowserAllowed = $subtype_allowed;
|
||
$isFalMode = 1;
|
||
} else {
|
||
$elementBrowserMode = $mode;
|
||
$elementBrowserAllowed = $allowed;
|
||
$isFalMode = 0;
|
||
}
|
||
|
||
$disabled = '';
|
||
if($this->renderReadonly || $params['readOnly']) {
|
||
$disabled = ' disabled="disabled"';
|
||
... | ... | |
$rOnClickInline = 'inline.revertUnique(\''.$objectPrefix.'\',null,\''.$uid.'\');';
|
||
}
|
||
}
|
||
$aOnClick='setFormValueOpenBrowser(\''.$mode.'\',\''.($fName.'|||'.$allowed.'|'.$aOnClickInline).'\'); return false;';
|
||
$aOnClick='setFormValueOpenBrowser(\''.$elementBrowserMode.'\',\''.($fName.'|||'.$elementBrowserAllowed.'|'.$aOnClickInline).'||||'.($isFalMode?1:0).'\'); return false;';
|
||
$icons['R'][]='<a href="#" onclick="'.htmlspecialchars($aOnClick).'">'.
|
||
t3lib_iconWorks::getSpriteIcon('actions-insert-record', array('title' => htmlspecialchars($this->getLL('l_browse_' . ($mode == 'db' ? 'db' : 'file'))))) .
|
||
t3lib_iconWorks::getSpriteIcon('actions-insert-record', array('title' => htmlspecialchars($this->getLL('l_browse_' . $elementBrowserMode)))) .
|
||
'</a>';
|
||
}
|
||
if($elementBrowserMode === 'file' && $isFalMode === 1){
|
||
$pageRenderer = $GLOBALS['SOBE']->doc->getPageRenderer();
|
||
$pageRenderer->addExtOnReadyCode("
|
||
Ext.get(Ext.getDom('".$fName."_uploadButton')).on('click',function(e){
|
||
e.stopEvent();
|
||
top.TYPO3.FileUploadWindow.showFalTceFormsUploadDialog('" . $fName . "','" . $elementBrowserAllowed . "');
|
||
});
|
||
");
|
||
$icons['R'][]= '<a id="'.$fName.'_uploadButton" title="'.$GLOBALS['LANG']->makeEntities($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_core.xml:cm.upload',1)).'">' .
|
||
t3lib_iconWorks::getSpriteIcon('actions-edit-upload') .
|
||
'</a>';
|
||
}
|
||
|
||
if (!$params['dontShowMoveIcons']) {
|
||
if ($sSize>=5) {
|
||
$icons['L'][]='<a href="#" onclick="setFormValueManipulate(\''.$fName.'\',\'Top\'); return false;">'.
|
||
... | ... | |
}
|
||
//
|
||
switch((string)$wConf['type']) {
|
||
switch((string)$wConf['type']) {
|
||
case 'userFunc':
|
||
case 'script':
|
||
case 'popup':
|
t3lib/core_autoload.php | ||
---|---|---|
<?php
|
||
// DO NOT CHANGE THIS FILE! It is automatically generated by extdeveval::buildAutoloadRegistry.
|
||
// This file was generated on 2009-11-25 23:05
|
||
// This file was generated on 2010-11-12 13:23
|
||
$t3libClasses = array(
|
||
return array(
|
||
'gzip_encode' => PATH_t3lib . 'class.gzip_encode.php',
|
||
't3lib_admin' => PATH_t3lib . 'class.t3lib_admin.php',
|
||
't3lib_ajax' => PATH_t3lib . 'class.t3lib_ajax.php',
|
||
... | ... | |
't3lib_compressor' => PATH_t3lib . 'class.t3lib_compressor.php',
|
||
't3lib_cs' => PATH_t3lib . 'class.t3lib_cs.php',
|
||
't3lib_db' => PATH_t3lib . 'class.t3lib_db.php',
|
||
't3lib_db_preparedstatement' => PATH_t3lib . 'db/class.t3lib_db_preparedstatement.php',
|
||
't3lib_diff' => PATH_t3lib . 'class.t3lib_diff.php',
|
||
't3lib_div' => PATH_t3lib . 'class.t3lib_div.php',
|
||
't3lib_exception' => PATH_t3lib . 'class.t3lib_exception.php',
|
||
... | ... | |
't3lib_pagetree' => PATH_t3lib . 'class.t3lib_pagetree.php',
|
||
't3lib_parsehtml' => PATH_t3lib . 'class.t3lib_parsehtml.php',
|
||
't3lib_parsehtml_proc' => PATH_t3lib . 'class.t3lib_parsehtml_proc.php',
|
||
't3lib_pdohelper' => PATH_t3lib . 'class.t3lib_pdohelper.php',
|
||
't3lib_positionmap' => PATH_t3lib . 'class.t3lib_positionmap.php',
|
||
't3lib_querygenerator' => PATH_t3lib . 'class.t3lib_querygenerator.php',
|
||
't3lib_readmail' => PATH_t3lib . 'class.t3lib_readmail.php',
|
||
... | ... | |
't3lib_rteapi' => PATH_t3lib . 'class.t3lib_rteapi.php',
|
||
't3lib_scbase' => PATH_t3lib . 'class.t3lib_scbase.php',
|
||
't3lib_softrefproc' => PATH_t3lib . 'class.t3lib_softrefproc.php',
|
||
't3lib_spritemanager' => PATH_t3lib . 'class.t3lib_spritemanager.php',
|
||
't3lib_sqlengine' => PATH_t3lib . 'class.t3lib_sqlengine.php',
|
||
't3lib_sqlengine_resultobj' => PATH_t3lib . 'class.t3lib_sqlengine.php',
|
||
't3lib_sqlparser' => PATH_t3lib . 'class.t3lib_sqlparser.php',
|
||
... | ... | |
't3lib_cache_frontend_stringfrontend' => PATH_t3lib . 'cache/frontend/class.t3lib_cache_frontend_stringfrontend.php',
|
||
't3lib_cache_frontend_variablefrontend' => PATH_t3lib . 'cache/frontend/class.t3lib_cache_frontend_variablefrontend.php',
|
||
't3lib_cache_frontend_frontend' => PATH_t3lib . 'cache/frontend/interfaces/interface.t3lib_cache_frontend_frontend.php',
|
||
't3lib_db_preparedstatement' => PATH_t3lib . 'db/class.t3lib_db_preparedstatement.php',
|
||
't3lib_error_abstractexceptionhandler' => PATH_t3lib . 'error/class.t3lib_error_abstractexceptionhandler.php',
|
||
't3lib_error_debugexceptionhandler' => PATH_t3lib . 'error/class.t3lib_error_debugexceptionhandler.php',
|
||
't3lib_error_errorhandler' => PATH_t3lib . 'error/class.t3lib_error_errorhandler.php',
|
||
... | ... | |
't3lib_error_productionexceptionhandler' => PATH_t3lib . 'error/class.t3lib_error_productionexceptionhandler.php',
|
||
't3lib_error_errorhandlerinterface' => PATH_t3lib . 'error/interface.t3lib_error_errorhandlerinterface.php',
|
||
't3lib_error_exceptionhandlerinterface' => PATH_t3lib . 'error/interface.t3lib_error_exceptionhandlerinterface.php',
|
||
't3lib_extjs_extdirectapi' => PATH_t3lib . 'extjs/class.t3lib_extjs_extdirectapi.php',
|
||
't3lib_extjs_extdirectdebug' => PATH_t3lib . 'extjs/class.t3lib_extjs_extdirectdebug.php',
|
||
't3lib_extjs_extdirectrouter' => PATH_t3lib . 'extjs/class.t3lib_extjs_extdirectrouter.php',
|
||
't3lib_file_collection' => PATH_t3lib . 'file/class.t3lib_file_Collection.php',
|
||
't3lib_file_file' => PATH_t3lib . 'file/class.t3lib_file_File.php',
|
||
't3lib_file_frontendaccess' => PATH_t3lib . 'file/class.t3lib_file_frontendaccess.php',
|
||
't3lib_file_indexer' => PATH_t3lib . 'file/class.t3lib_file_Indexer.php',
|
||
't3lib_file_helper' => PATH_t3lib . 'file/class.t3lib_file_Helper.php',
|
||
't3lib_file_mount' => PATH_t3lib . 'file/class.t3lib_file_Mount.php',
|
||
't3lib_file_repository' => PATH_t3lib . 'file/class.t3lib_file_Repository.php',
|
||
't3lib_file_backend_fileadminbackend' => PATH_t3lib . 'file/backend/class.t3lib_file_backend_FileadminBackend.php',
|
||
't3lib_file_backend_interface' => PATH_t3lib . 'file/backend/interface.t3lib_file_backend_Interface.php',
|
||
't3lib_file_storage_filesystemstorage' => PATH_t3lib . 'file/storage/class.t3lib_file_storage_filesystemstorage.php',
|
||
't3lib_file_storage_interface' => PATH_t3lib . 'file/storage/interface.t3lib_file_storage_interface.php',
|
||
't3lib_file_streams_streamwrapperinterface' => PATH_t3lib . 'file/streams/interface.t3lib_file_streams_streamwrapperinterface.php',
|
||
't3lib_file_streams_streamwrapperadapter' => PATH_t3lib . 'file/streams/class.t3lib_file_streams_streamwrapperadapter.php',
|
||
't3lib_file_exception_filenotfound' => PATH_t3lib . 'file/exception/class.t3lib_file_exception_filenotfound.php',
|
||
't3lib_browselinkshook' => PATH_t3lib . 'interfaces/interface.t3lib_browselinkshook.php',
|
||
't3lib_extfilefunctions_processdatahook' => PATH_t3lib . 'interfaces/interface.t3lib_extfilefunctions_processdatahook.php',
|
||
't3lib_localrecordlistgettablehook' => PATH_t3lib . 'interfaces/interface.t3lib_localrecordlistgettablehook.php',
|
||
't3lib_pageselect_getpagehook' => PATH_t3lib . 'interfaces/interface.t3lib_pageselect_getpagehook.php',
|
||
't3lib_pageselect_getrecordoverlayhook' => PATH_t3lib . 'interfaces/interface.t3lib_pageselect_getrecordoverlayhook.php',
|
||
't3lib_pageselect_getpageoverlayhook' => PATH_t3lib . 'interfaces/interface.t3lib_pageselect_getpageoverlayhook.php',
|
||
't3lib_pageselect_getrecordoverlayhook' => PATH_t3lib . 'interfaces/interface.t3lib_pageselect_getrecordoverlayhook.php',
|
||
't3lib_singleton' => PATH_t3lib . 'interfaces/interface.t3lib_singleton.php',
|
||
't3lib_spritemanager_spriteicongenerator' => PATH_t3lib . 'interfaces/interface.t3lib_spritemanager_spriteicongenerator.php',
|
||
't3lib_tceformsinlinehook' => PATH_t3lib . 'interfaces/interface.t3lib_tceformsinlinehook.php',
|
||
't3lib_tcemain_checkmodifyaccesslisthook' => PATH_t3lib . 'interfaces/interface.t3lib_tcemain_checkmodifyaccesslisthook.php',
|
||
't3lib_tcemain_processuploadhook' => PATH_t3lib . 'interfaces/interface.t3lib_tcemain_processuploadhook.php',
|
||
't3lib_mail_message' => PATH_t3lib . 'mail/class.t3lib_mail_message.php',
|
||
't3lib_mail_mailer' => PATH_t3lib . 'mail/class.t3lib_mail_mailer.php',
|
||
't3lib_matchcondition_abstract' => PATH_t3lib . 'matchcondition/class.t3lib_matchcondition_abstract.php',
|
||
't3lib_matchcondition_backend' => PATH_t3lib . 'matchcondition/class.t3lib_matchcondition_backend.php',
|
||
't3lib_matchcondition_frontend' => PATH_t3lib . 'matchcondition/class.t3lib_matchcondition_frontend.php',
|
||
't3lib_pdohelper' => PATH_t3lib . 'class.t3lib_pdohelper.php',
|
||
't3lib_message_abstractmessage' => PATH_t3lib . 'message/class.t3lib_message_abstractmessage.php',
|
||
't3lib_spritemanager_simplehandler' => PATH_t3lib . 'spritemanager/class.t3lib_spritemanager_simplehandler.php',
|
||
't3lib_spritemanager_spritegenerator' => PATH_t3lib . 'spritemanager/class.t3lib_spritemanager_spritegenerator.php',
|
||
't3lib_tceforms_suggest' => PATH_t3lib . 'tceforms/class.t3lib_tceforms_suggest.php',
|
||
't3lib_tceforms_suggest_defaultreceiver' => PATH_t3lib . 'tceforms/class.t3lib_tceforms_suggest_defaultreceiver.php',
|
||
't3lib_utility_client' => PATH_t3lib . 'utility/class.t3lib_utility_client.php',
|
||
't3lib_utility_debug' => PATH_t3lib . 'utility/class.t3lib_utility_debug.php',
|
||
't3lib_utility_http' => PATH_t3lib . 'utility/class.t3lib_utility_http.php',
|
||
't3lib_utility_mail' => PATH_t3lib . 'utility/class.t3lib_utility_mail.php',
|
||
't3lib_utility_phpoptions' => PATH_t3lib . 'utility/class.t3lib_utility_phpoptions.php',
|
||
... | ... | |
't3lib_tree_tca_databasetreedataprovider' => PATH_t3lib . 'tree/tca/class.t3lib_tree_tca_databasetreedataprovider.php',
|
||
't3lib_tree_tca_dataproviderfactory' => PATH_t3lib . 'tree/tca/class.t3lib_tree_tca_dataproviderfactory.php',
|
||
't3lib_tree_tca_tcatree' => PATH_t3lib . 'tree/tca/class.t3lib_tree_tca_tcatree.php',
|
||
'tslib_adminpanel' => PATH_tslib . 'class.tslib_adminpanel.php',
|
||
'tslib_cobj' => PATH_tslib . 'class.tslib_content.php',
|
||
'tslib_frameset' => PATH_tslib . 'class.tslib_content.php',
|
||
'tslib_tableoffset' => PATH_tslib . 'class.tslib_content.php',
|
||
'tslib_controltable' => PATH_tslib . 'class.tslib_content.php',
|
||
'tslib_eidtools' => PATH_tslib . 'class.tslib_eidtools.php',
|
||
'tslib_extdirecteid' => PATH_tslib . 'class.tslib_extdirecteid.php',
|
||
'tslib_fe' => PATH_tslib . 'class.tslib_fe.php',
|
||
'tslib_fecompression' => PATH_tslib . 'class.tslib_fecompression.php',
|
||
'tslib_fetce' => PATH_tslib . 'class.tslib_fetce.php',
|
||
'tslib_feuserauth' => PATH_tslib . 'class.tslib_feuserauth.php',
|
||
'tslib_gifbuilder' => PATH_tslib . 'class.tslib_gifbuilder.php',
|
||
'tslib_mediawizardcoreprovider' => PATH_tslib . 'class.tslib_mediawizardcoreprovider.php',
|
||
'tslib_mediawizardmanager' => PATH_tslib . 'class.tslib_mediawizardmanager.php',
|
||
'tslib_menu' => PATH_tslib . 'class.tslib_menu.php',
|
||
'tslib_tmenu' => PATH_tslib . 'class.tslib_menu.php',
|
||
'tslib_gmenu' => PATH_tslib . 'class.tslib_menu.php',
|
||
'tslib_imgmenu' => PATH_tslib . 'class.tslib_menu.php',
|
||
'tslib_jsmenu' => PATH_tslib . 'class.tslib_menu.php',
|
||
'tspagegen' => PATH_tslib . 'class.tslib_pagegen.php',
|
||
'fe_loaddbgroup' => PATH_tslib . 'class.tslib_pagegen.php',
|
||
'tslib_pibase' => PATH_tslib . 'class.tslib_pibase.php',
|
||
'tslib_search' => PATH_tslib . 'class.tslib_search.php',
|
||
'sc_tslib_showpic' => PATH_tslib . 'showpic.php',
|
||
'tx_cms_mediaitems' => PATH_tslib . 'hooks/class.tx_cms_mediaitems.php',
|
||
'tx_cms_treelistcacheupdate' => PATH_tslib . 'hooks/class.tx_cms_treelistcacheupdate.php',
|
||
'tslib_content_cobjgetsinglehook' => PATH_tslib . 'interfaces/interface.tslib_content_cobjgetsinglehook.php',
|
||
'tslib_content_getdatahook' => PATH_tslib . 'interfaces/interface.tslib_content_getdatahook.php',
|
||
'tslib_cobj_getimgresourcehook' => PATH_tslib . 'interfaces/interface.tslib_content_getimgresourcehook.php',
|
||
'tslib_content_postinithook' => PATH_tslib . 'interfaces/interface.tslib_content_postinithook.php',
|
||
'tslib_content_stdwraphook' => PATH_tslib . 'interfaces/interface.tslib_content_stdwraphook.php',
|
||
'tslib_mediawizardprovider' => PATH_tslib . 'interfaces/interface.tslib_mediawizardprovider.php',
|
||
'tslib_menu_filtermenupageshook' => PATH_tslib . 'interfaces/interface.tslib_menu_filterMenuPagesHook.php',
|
||
'user_various' => PATH_tslib . 'media/scripts/example_callfunction.php',
|
||
'tslib_gmenu_foldout' => PATH_tslib . 'media/scripts/gmenu_foldout.php',
|
||
'tslib_gmenu_layers' => PATH_tslib . 'media/scripts/gmenu_layers.php',
|
||
'tslib_tmenu_layers' => PATH_tslib . 'media/scripts/tmenu_layers.php',
|
||
);
|
||
$tslibClasses = require(PATH_typo3 . 'sysext/cms/ext_autoload.php');
|
||
return array_merge($t3libClasses, $tslibClasses);
|
||
?>
|
t3lib/file/class.t3lib_file_Collection.php | ||
---|---|---|
<?php
|
||
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
|
||
* All rights reserved
|
||
*
|
||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||
* free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2 of the License, or
|
||
* (at your option) any later version.
|
||
*
|
||
* The GNU General Public License can be found at
|
||
* http://www.gnu.org/copyleft/gpl.html.
|
||
* A copy is found in the textfile GPL.txt and important notices to the license
|
||
* from the author is found in LICENSE.txt distributed with these scripts.
|
||
*
|
||
*
|
||
* This script is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* This copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
/**
|
||
* Probably safe to ignore at this time
|
||
*/
|
||
class t3lib_file_Collection {
|
||
private $backend;
|
||
|
||
public function __construct(t3lib_file_backend_Interface $backend) {
|
||
$this->backend = $backend;
|
||
}
|
||
}
|
||
?>
|
t3lib/file/class.t3lib_file_File.php | ||
---|---|---|
<?php
|
||
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
|
||
* All rights reserved
|
||
*
|
||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||
* free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2 of the License, or
|
||
* (at your option) any later version.
|
||
*
|
||
* The GNU General Public License can be found at
|
||
* http://www.gnu.org/copyleft/gpl.html.
|
||
* A copy is found in the textfile GPL.txt and important notices to the license
|
||
* from the author is found in LICENSE.txt distributed with these scripts.
|
||
*
|
||
*
|
||
* This script is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* This copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
class t3lib_file_File {
|
||
/**
|
||
* The uid of this file's record
|
||
*
|
||
* @var integer
|
||
*/
|
||
protected $uid;
|
||
/**
|
||
* The name of this file. This is only the filename without the path
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $filename;
|
||
/**
|
||
* The mount this file is located in
|
||
*
|
||
* @var t3lib_file_Mount
|
||
*/
|
||
protected $mount;
|
||
/**
|
||
* The path to this file (inside the file mount)
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $path = NULL;
|
||
/**
|
||
* The file size
|
||
*
|
||
* @var integer
|
||
*/
|
||
protected $size;
|
||
/**
|
||
* The SHA-1 hash sum of the file
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $hash;
|
||
public function __construct(t3lib_file_Mount $mount, array $fileData) {
|
||
$this->mount = $mount;
|
||
$this->uid = $fileData['uid'];
|
||
$this->name = $fileData['file_name'];
|
||
$this->path = $fileData['file_path'];
|
||
$this->size = $fileData['file_size'];
|
||
$this->hash = $fileData['file_hash'];
|
||
}
|
||
public function getThumbnail() {
|
||
/** @todo: Implement */
|
||
}
|
||
public function getThumbnailUrl() {
|
||
/** @todo: Implement */
|
||
}
|
||
/**
|
||
* @param string $table
|
||
* @param integer $uid
|
||
* @param string $field
|
||
* @param string $flexFormStructurePath Optional.
|
||
* @return void
|
||
*/
|
||
public function addRelation($table, $uid, $field, $flexFormStructurePath = NULL) {
|
||
/** @todo: Implement */
|
||
}
|
||
public function getRelatedRecords($table = '') {
|
||
/** @todo: Implement */
|
||
}
|
||
public function getUrl() {
|
||
return $this->mount->getUrlForPath($this->path);
|
||
}
|
||
public function writeFile($content) {
|
||
/** @todo: Implement */
|
||
}
|
||
public function getUid() {
|
||
return $this->uid;
|
||
}
|
||
public function getName() {
|
||
return $this->name;
|
||
}
|
||
public function getPath() {
|
||
return $this->path;
|
||
}
|
||
public function getSize() {
|
||
return $this->size;
|
||
}
|
||
public function getHash() {
|
||
return $this->hash;
|
||
}
|
||
public function replaceWithLocalFile($filePath) {
|
||
}
|
||
public function getFileCopyForLocalProcessing() {
|
||
}
|
||
public function copyInsideMount($newPath) {
|
||
}
|
||
public function copyToMount(t3lib_file_Mount $mount, $newPath) {
|
||
}
|
||
public function moveInsideMount($newPath) {
|
||
}
|
||
public function moveToMount(t3lib_file_Mount $mount, $newPath) {
|
||
}
|
||
public function getContents() {
|
||
}
|
||
public function getFileHandle($mode) {
|
||
}
|
||
}
|
||
?>
|
t3lib/file/class.t3lib_file_Helper.php | ||
---|---|---|
<?php
|
||
|
||
class t3lib_file_Helper {
|
||
public static function getOrCreateFileObjectFromPath($fileNameAndPath) {
|
||
/** @var $fileRepository t3lib_file_Repository */
|
||
$fileRepository = t3lib_div::makeInstance('t3lib_file_Repository');
|
||
$relativePath = substr($fileNameAndPath, strlen(PATH_site));
|
||
|
||
try {
|
||
return $fileRepository->getFileByPath($relativePath);
|
||
} catch(t3lib_file_exception_FileNotFound $e) {
|
||
|
||
$mount = self::getMountFromFilePath($relativePath);
|
||
$fileUid = t3lib_file_Indexer::addFileToIndex($mount, $relativePath);
|
||
|
||
return $fileRepository->getFileById($fileUid);
|
||
}
|
||
}
|
||
|
||
/**
|
||
* Creates a comma separated list of file paths from a list of file objects
|
||
*
|
||
* @param array $fileObjects The file objects to iterate over
|
||
* @return string A comma separated list of paths to the files.
|
||
* @static
|
||
* @author Andreas Wolf <andreas.wolf@ikt-werk.de>
|
||
*
|
||
* TODO: check how this will work for remote files
|
||
*/
|
||
public static function createCsvListOfFilepaths(array $fileObjects) {
|
||
$csv = array();
|
||
foreach ($fileObjects as $file) {
|
||
$csv[] = $file->getPath() . $file->getName();
|
||
}
|
||
|
||
return implode(',', $csv);
|
||
}
|
||
|
||
/**
|
||
* Extracts the mount from a FAL file path (<mount>/path/to/file/inside/mount)
|
||
*
|
||
* @param string $filePath The path to the file
|
||
* @static
|
||
* @return t3lib_file_Mount|boolean FALSE if the mount could not be resolved
|
||
*/
|
||
public static function getMountFromFilePath($filePath) {
|
||
$pathParts = explode('/', $filePath, 2);
|
||
$mountAlias = array_shift($pathParts);
|
||
$mount = t3lib_file_Mount::getInstanceForAlias($mountAlias);
|
||
|
||
if (!is_object($mount)) {
|
||
return FALSE;
|
||
}
|
||
return $mount;
|
||
}
|
||
}
|
||
|
||
?>
|
t3lib/file/class.t3lib_file_Indexer.php | ||
---|---|---|
<?php
|
||
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
|
||
* All rights reserved
|
||
*
|
||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||
* free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2 of the License, or
|
||
* (at your option) any later version.
|
||
*
|
||
* The GNU General Public License can be found at
|
||
* http://www.gnu.org/copyleft/gpl.html.
|
||
* A copy is found in the textfile GPL.txt and important notices to the license
|
||
* from the author is found in LICENSE.txt distributed with these scripts.
|
||
*
|
||
*
|
||
* This script is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* This copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
class t3lib_file_Indexer {
|
||
public function indexDirectory() {
|
||
}
|
||
/**
|
||
* Add a file to the index. This only works for files that already reside in the virtual
|
||
* file system we use; so you have to move the file to a mount manually.
|
||
*
|
||
* @param t3lib_file_Mount The mount the file resides in.
|
||
* @param string Path to the file, relative to the mount root
|
||
* @return t3lib_file_File The file record, if the file could be successfully indexed
|
||
*
|
||
* TODO check if file exists
|
||
*/
|
||
public static function addFileToIndex(t3lib_file_Mount $mount, $filePath) {
|
||
$fileName = basename($filePath);
|
||
$folder = dirname($filePath) . '/';
|
||
$backend = $mount->getStorageBackend();
|
||
$success = $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_files', array(
|
||
'file_name' => $fileName,
|
||
'file_path' => $folder,
|
||
'file_size' => $backend->getSize($filePath),
|
||
'file_mtime' => $backend->getModificationTime($filePath),
|
||
'file_hash' => $backend->getFileHash($filePath),
|
||
'mount' => $mount->getUid(),
|
||
'crdate' => $GLOBALS['EXEC_TIME'],
|
||
'tstamp' => $GLOBALS['EXEC_TIME']
|
||
));
|
||
/** @var $repo t3lib_file_Repository */
|
||
return $GLOBALS['TYPO3_DB']->sql_insert_id();
|
||
//$repo = t3lib_div::makeInstance('t3lib_file_Repository');
|
||
//return $repo->getFileById($GLOBALS['TYPO3_DB']->sql_insert_id());
|
||
}
|
||
public function updateFileIndex(t3lib_file_File $file) {
|
||
/** @todo: Implement */
|
||
}
|
||
/**
|
||
* Delete a file from index
|
||
*
|
||
* @param integer UID of the file record to remove from index
|
||
* @return void
|
||
*/
|
||
public static function deleteFileFromIndex($file) {
|
||
$sucess = $GLOBALS['TYPO3_DB']->exec_UPDATEquery('sys_files', 'uid=' . $file,
|
||
array('deleted' => 1)
|
||
);
|
||
}
|
||
}
|
||
?>
|
t3lib/file/class.t3lib_file_Mount.php | ||
---|---|---|
<?php
|
||
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
|
||
* All rights reserved
|
||
*
|
||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||
* free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2 of the License, or
|
||
* (at your option) any later version.
|
||
*
|
||
* The GNU General Public License can be found at
|
||
* http://www.gnu.org/copyleft/gpl.html.
|
||
* A copy is found in the textfile GPL.txt and important notices to the license
|
||
* from the author is found in LICENSE.txt distributed with these scripts.
|
||
*
|
||
*
|
||
* This script is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* This copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
class t3lib_file_Mount {
|
||
/**
|
||
* The backend this mount uses
|
||
*
|
||
* @var t3lib_file_storage_Interface
|
||
*/
|
||
protected $storageBackend;
|
||
/**
|
||
* The base url for this file mount
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $baseUrl;
|
||
protected $uid;
|
||
/**
|
||
* @var array<t3lib_file_Mount>
|
||
*/
|
||
private static $instances = array();
|
||
public function __construct($mountInformation) {
|
||
$this->uid = $mountInformation['uid'];
|
||
$this->alias = $mountInformation['alias'];
|
||
}
|
||
public static function getInstanceForUid($mountUid) {
|
||
if (count(self::$instances) == 0) {
|
||
self::loadMountsFromDatabase();
|
||
}
|
||
if (self::$instances[$mountUid]) {
|
||
return self::$instances[$mountUid];
|
||
}
|
||
throw new RuntimeException("Mount with uid $mountUid was not found.");
|
||
}
|
||
/**
|
||
* Returns an instance of a file mount by its alias
|
||
*
|
||
* @param string $alias
|
||
* @return void
|
||
* @static
|
||
*/
|
||
public static function getInstanceForAlias($alias) {
|
||
if (count(self::$instances) == 0) {
|
||
self::loadMountsFromDatabase();
|
||
}
|
||
foreach (self::$instances as $instance) {
|
||
if ($instance->getAlias() == $alias) {
|
||
return $instance;
|
||
}
|
||
}
|
||
throw new RuntimeException("FAL mount $alias was not found.");
|
||
}
|
||
/**
|
||
* Loads all existing FAL mounts from the database and initializes them for later use.
|
||
*
|
||
* @return void
|
||
* @static
|
||
*/
|
||
protected static function loadMountsFromDatabase() {
|
||
$mountRecord = array('alias' => 'fileadmin', 'uid' => 0, 'storage_backend' => 't3lib_file_storage_FileSystemStorage');
|
||
$storageConfiguration = array('relative' => TRUE, 'path' => 'fileadmin/');
|
||
self::$instances[0] = self::mountObjectFactory($mountRecord, $storageConfiguration);
|
||
$mountRecords = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_files_mounts');
|
||
foreach ($mountRecords as $mountRecord) {
|
||
$storageConfiguration = t3lib_div::xml2array($mountRecord['backend_configuration']);
|
||
$storageConfiguration = self::extractValuesFromFlexformArray($storageConfiguration['data']);
|
||
self::$instances[$mountRecord['uid']] = self::mountObjectFactory($mountRecord, $storageConfiguration);
|
||
}
|
||
}
|
||
/**
|
||
* Factory method for mount objects.
|
||
*
|
||
* @param $mountRecord
|
||
* @param $storageConfiguration
|
||
*
|
||
* @throws RuntimeException
|
||
* @return void
|
||
* @static
|
||
*/
|
||
protected static function mountObjectFactory($mountRecord, $storageConfiguration) {
|
||
$storageBackendClass = $mountRecord['storage_backend'];
|
||
if (!class_exists($storageBackendClass)) {
|
||
throw new RuntimeException("Class $storageBackendClass does not exist.");
|
||
}
|
||
$storageBackend = t3lib_div::makeInstance($storageBackendClass, $storageConfiguration);
|
||
$mountObject = new t3lib_file_Mount($mountRecord);
|
||
$mountObject->setStorageBackend($storageBackend);
|
||
return $mountObject;
|
||
}
|
||
/**
|
||
* Helper function to ease unit testing. Ignore in normal operation.
|
||
*
|
||
* @param array $instances
|
||
* @return void
|
||
* @static
|
||
*/
|
||
public static function _setInstances(array $instances) {
|
||
self::$instances = $instances;
|
||
}
|
||
/**
|
||
* Helper method for extracting values from a single-language FlexForm. This method does not care about double
|
||
* field names, so use with caution (in FlexForms, the same field name may be used in different sheets)
|
||
*
|
||
* @param $flexformArray
|
||
* @return array
|
||
* @static
|
||
*/
|
||
protected static function extractValuesFromFlexformArray(array $flexformArray) {
|
||
foreach ($flexformArray as $sheet) {
|
||
foreach ($sheet as $language) {
|
||
foreach ($language as $fieldName => $fieldValue) {
|
||
$values[$fieldName] = $fieldValue['vDEF'];
|
||
}
|
||
}
|
||
}
|
||
return $values;
|
||
}
|
||
/**
|
||
* @param t3lib_file_storage_Interface $storageBackend The backend to use
|
||
*
|
||
*/
|
||
public function setStorageBackend(t3lib_file_storage_Interface $storageBackend) {
|
||
$this->storageBackend = $storageBackend;
|
||
$this->baseUrl = $this->storageBackend->getBaseUrl();
|
||
}
|
||
/**
|
||
* Returns the storage backend used by this file mount.
|
||
*
|
||
* @return t3lib_file_storage_Interface
|
||
*/
|
||
public function getStorageBackend() {
|
||
return $this->storageBackend;
|
||
}
|
||
/**
|
||
* Creates a directory inside this mount. Success of this operation depends - among other things - on the directory
|
||
* support by the backend.
|
||
*
|
||
* @param $path The path to create the directory in
|
||
* @param $directoryName The directory to create
|
||
* @return boolean TRUE if the directory could be created
|
||
*/
|
||
public function createDirectory($path, $directoryName) {
|
||
return $this->storageBackend->createDirectory($path, $directoryName);
|
||
}
|
||
/**
|
||
* Returns a URL for a path in this mount
|
||
*
|
||
* @param $path
|
||
* @return string
|
||
*/
|
||
public function getUrlForPath($path) {
|
||
return $this->baseUrl . $path;
|
||
}
|
||
public function getUid() {
|
||
return $this->uid;
|
||
}
|
||
public function getAlias() {
|
||
return $this->alias;
|
||
}
|
||
}
|
||
?>
|
t3lib/file/class.t3lib_file_Repository.php | ||
---|---|---|
<?php
|
||
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
|
||
* All rights reserved
|
||
*
|
||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||
* free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2 of the License, or
|
||
* (at your option) any later version.
|
||
*
|
||
* The GNU General Public License can be found at
|
||
* http://www.gnu.org/copyleft/gpl.html.
|
||
* A copy is found in the textfile GPL.txt and important notices to the license
|
||
* from the author is found in LICENSE.txt distributed with these scripts.
|
||
*
|
||
*
|
||
* This script is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* This copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
class t3lib_file_Repository implements t3lib_Singleton {
|
||
/**
|
||
* Get the file by ID
|
||
*
|
||
* @param integer UID of the file record
|
||
* @return t3lib_file_File A file object instance
|
||
*/
|
||
public function getFileById($uid) {
|
||
$recordData = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_files', 'uid=' . $uid);
|
||
$mount = $this->getMountForFile($recordData);
|
||
if (count($recordData) == 0) {
|
||
throw new t3lib_file_exception_FileNotFound();
|
||
}
|
||
return new t3lib_file_File($mount, $recordData[0]);
|
||
}
|
||
/**
|
||
*
|
||
*/
|
||
public function getFilesFromRelation($field, $table, $recordUid) {
|
||
if(TYPO3_MODE === 'FE') { // @TODO: Check if constant name and value TYPO3_MODE === 'FE' are correct for checking for FE.
|
||
$GLOBALS['TSFE']->includeTCA();
|
||
}
|
||
t3lib_div::loadTCA($table);
|
||
$assetObjects = array();
|
||
// get column definition
|
||
$MMfieldTCA = $GLOBALS['TCA'][$table]['columns'][$field]['config'];
|
||
$dbGroup = t3lib_div::makeInstance('t3lib_loadDBGroup');
|
||
$dbGroup->start($recordUid, 'sys_files', $MMfieldTCA['MM'], intval($recordUid), $table, $MMfieldTCA);
|
||
$assetIds = $dbGroup->tableArray['sys_files'];
|
||
if (is_array($assetIds)) {
|
||
foreach ($assetIds as $key => $uid) {
|
||
$assetObjects[] = $this->getFileById($uid);
|
||
}
|
||
}
|
||
return $assetObjects;
|
||
}
|
||
/**
|
||
* Returns a file object by the file's complete path.
|
||
*
|
||
* @param string $filePath The path to the file. May contain the alias of the mount if this is not given as the second parameter.
|
||
* @param t3lib_file_Mount $mount The mount the file is located in (optional). If this is not given, the mount is extracted from the first part of the path.
|
||
* @return t3lib_file_File
|
||
*
|
||
* @throws t3lib_file_exception_FileNotFound
|
||
*
|
||
* TODO: respect file mount (extract it from the path or take it as parameter - both ways should be supported)
|
||
*/
|
||
public function getFileByPath($filePath, $mount = NULL) {
|
||
if ($mount == NULL) {
|
||
$pathParts = explode('/', $filePath, 2);
|
||
$mountAlias = array_shift($pathParts);
|
||
$mount = t3lib_file_Mount::getInstanceForAlias($mountAlias);
|
||
}
|
||
$fileName = substr($filePath, strrpos($filePath, '/') + 1);
|
||
$folderPath = substr($filePath, 0, strrpos($filePath, '/') + 1);
|
||
$recordData = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_files',
|
||
'file_path = "' . $folderPath . '" AND file_name = "' . $fileName . '" AND mount = ' . intval($mount->getUid));
|
||
if (count($recordData) == 0) {
|
||
throw new t3lib_file_exception_FileNotFound();
|
||
}
|
||
$mount = $this->getMountForFile($recordData);
|
||
return new t3lib_file_File($mount, $recordData[0]);
|
||
}
|
||
/**
|
||
* Returns all files that are related to a certain field in a certain record.
|
||
*
|
||
* @param string $table The table
|
||
* @param integer $recordUid The record uid
|
||
* @param string $fieldName The field name
|
||
* @param string $structurePath The structure path in FlexForm data inside $field (optional)
|
||
* @return array
|
||
*
|
||
* TODO: define what is returned by this method (a list of file uids or complete file records)
|
||
*/
|
||
public function getReferencedFilesForRecordField($table, $recordUid, $fieldName, $structurePath = '') {
|
||
//
|
||
}
|
||
/**
|
||
* Returns the mount record for a specified file.
|
||
*
|
||
* @param array $fileRecord
|
||
* @return void
|
||
*/
|
||
protected function getMountForFile(array $fileRecord) {
|
||
$mount = $fileRecord['mount'];
|
||
return t3lib_file_Mount::getInstanceForUid($mount);
|
||
}
|
||
/**
|
||
* @throws t3lib_file_exception_FileNotFound
|
||
* @param $filePath
|
||
* @return array
|
||
*
|
||
* TODO: respect file mount (extract it from the path or take it as parameter - both ways should be supported)
|
||
*/
|
||
public function getAllInPath($filePath) {
|
||
$recordData = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_files',
|
||
'file_path = "' . $filePath . '"');
|
||
if (count($recordData) == 0) {
|
||
throw new t3lib_file_exception_FileNotFound();
|
||
}
|
||
$mount = $this->getMountForFile($recordData[0]);
|
||
$files = array();
|
||
foreach ($recordData as $data) {
|
||
$files[] = new t3lib_file_File($mount, $data);
|
||
}
|
||
return $files;
|
||
}
|
||
}
|
||
?>
|
t3lib/file/exception/class.t3lib_file_exception_filenotfound.php | ||
---|---|---|
<?php
|
||
class t3lib_file_exception_FileNotFound extends RuntimeException {
|
||
}
|
t3lib/file/storage/class.t3lib_file_storage_filesystemstorage.php | ||
---|---|---|
<?php
|
||
class t3lib_file_storage_FileSystemStorage implements t3lib_file_storage_Interface {
|
||
/**
|
||
* @var array The configuration for this backend
|
||
*/
|
||
protected $configuration;
|
||
/**
|
||
* @var string
|
||
*/
|
||
protected $basePath;
|
||
/**
|
||
* @param array $configuration The configuration for the backend
|
||
*/
|
||
public function __construct($configuration) {
|
||
$this->configuration = $configuration;
|
||
if ($configuration['relative']) {
|
||
$this->basePath = t3lib_div::resolveBackPath(PATH_site . $configuration['path']);
|
||
} else {
|
||
$this->basePath = $configuration['path'];
|
||
}
|
||
$this->basePath = rtrim($this->basePath, '/') . '/';
|
||
// TODO: throw exception if $this->basePath does not exist
|
||
}
|
||
public function read($path) {
|
||
return file_get_contents($path);
|
||
}
|
||
public function write($path, $content) {
|
||
return file_put_contents($path, $content);
|
||
}
|
||
public function delete($path) {
|
||
if ($this->exists($path)) {
|
||
unlink($path);
|
||
}
|
||
}
|
||
public function exists($path) {
|
||
return file_exists($path);
|
||
}
|
||
public function getModificationTime($path) {
|
||
if ($this->exists($path)) {
|
||
return filemtime($path);
|
||
}
|
||
}
|
||
public function getFileHash($path) {
|
||
if ($this->exists($path)) {
|
||
return sha1_file($path);
|
||
}
|
||
}
|
||
public function getSize($path) {
|
||
if ($this->exists($path)) {
|
||
return filesize($path);
|
||
}
|
||
}
|
||
public function getBasePath() {
|
||
return $this->basePath;
|
||
}
|
||
public function getBaseUrl() {
|
||
if ($this->configuration['relative']) {
|
||
return $this->configuration['path'];
|
||
}
|
||
}
|
||
public function open($path, $mode) {}
|
||
/**
|
||
* Copies a file inside this storage. All parameters are relative to the base of this storage
|
||
*
|
||
* @param $path
|
||
* @param $newPath
|
||
* @return void
|
||
*/
|
||
public function copyFile($path, $newPath) {
|
||
$path = $this->basePath . $path;
|
||
$newPath = $this->basePath . $newPath;
|
||
if (!file_exists($path)) {
|
||
throw new InvalidArgumentException('Source file does not exist.');
|
||
}
|
||
if (!copy($path, $newPath)) {
|
||
throw new RuntimeException("Copying file '$path' to '$newPath' failed.");
|
||
}
|
||
}
|
||
/**
|
||
* Moves a file inside this storage.
|
||
*
|
||
* @param string $oldPath The file to move
|
||
* @param string $newPath The location to move to
|
||
* @return void
|
||
*
|
||
* @throws InvalidArgumentException If the file does not exist or there is a file at the new location
|
||
*/
|
||
public function moveFile($oldPath, $newPath) {
|
||
$oldPath = $this->basePath . $oldPath;
|
||
$newPath = $this->basePath . $newPath;
|
||
if (!file_exists($oldPath)) {
|
||
throw new InvalidArgumentException('Source file does not exist.');
|
||
}
|
||
if (file_exists($newPath)) {
|
||
throw new InvalidArgumentException('Target file already exists.');
|
||
}
|
||
rename($oldPath, $newPath);
|
||
}
|
||
/**
|
||
* Creates a directory inside a path
|
||
*
|
||
* @return boolean
|
||
*/
|
||
public function createDirectory($path, $directoryName) {
|
||
$path = rtrim($this->basePath . $path, '/') . '/';
|
||
return mkdir($path . $directoryName);
|
||
}
|
||
/**
|
||
* Returns a list of all files and directories inside a path
|
||
*
|
||
* @param string $path
|
||
* @return void
|
||
*/
|
||
public function getListing($path) {}
|
||
}
|
||
?>
|
t3lib/file/storage/interface.t3lib_file_storage_interface.php | ||
---|---|---|
<?php
|
||
/***************************************************************
|
||
* Copyright notice
|
||
*
|
||
* (c) 1999-2010 Kasper Skårhøj (kasperYYYY@typo3.com)
|
||
* All rights reserved
|
||
*
|
||
* This script is part of the TYPO3 project. The TYPO3 project is
|
||
* free software; you can redistribute it and/or modify
|
||
* it under the terms of the GNU General Public License as published by
|
||
* the Free Software Foundation; either version 2 of the License, or
|
||
* (at your option) any later version.
|
||
*
|
||
* The GNU General Public License can be found at
|
||
* http://www.gnu.org/copyleft/gpl.html.
|
||
* A copy is found in the textfile GPL.txt and important notices to the license
|
||
* from the author is found in LICENSE.txt distributed with these scripts.
|
||
*
|
||
*
|
||
* This script is distributed in the hope that it will be useful,
|
||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
* GNU General Public License for more details.
|
||
*
|
||
* This copyright notice MUST APPEAR in all copies of the script!
|
||
***************************************************************/
|
||
interface t3lib_file_storage_Interface {
|
||
public function getBasePath();
|
||
public function getBaseUrl();
|
||
public function open($path, $mode);
|
||
/**
|
||
* Read the contents of a file
|
||
*
|
||
* @param string Absolute path to the file
|
||
* @return string File contents
|
||
*/
|
||
public function read($path);
|
||
/**
|
||
* Write data into a file
|
||
*
|
||
* @param string Absolute path to the file
|
||
* @param string File contents
|
||
* @return boolean Success of operation
|
||
*/
|
||
public function write($path, $content);
|
||
/**
|
||
* Delete the file
|
||
*
|
||
* @param string Absolute path to the file
|
||
* @return void
|
||
*/
|
||
public function delete($path);
|
||
/**
|
||
* Check if file or directory exists
|
||
*
|
||
* @param string Absolute path to the file
|
||
* @return boolean True if the file or folder exists, false otherwise
|
||
*/
|
||
public function exists($path);
|
||
/**
|
||
* Get timestamp of when the file was last modified
|
||
*
|
||
* @param string Absolute path to the file
|
||
* @return integer Timestamp
|
||
*/
|
||
public function getModificationTime($path);
|
||
/**
|
||
* Get the sha1 hash of the file
|
||
*
|
||
* @param string Absolute path to the file
|
||
* @return string Hash of the content
|
||
*/
|
||
public function getFileHash($path);
|
||
/**
|
||
* Get the file size of the content
|
||
*
|
||
* @param string Absolute path to the file
|
||
* @return integer Size of the file in bytes
|
||
*/
|
||
public function getSize($path);
|
||
/**
|
||
* Copies a file inside this storage. All parameters are relative to the base of this storage
|
||
*
|
||
* @param $path
|
||
* @param $newPath
|
||
* @return void
|
||
*/
|
||
public function copyFile($path, $newPath);
|
||
public function moveFile($oldPath, $newPath);
|
||
/**
|
||
* Creates a directory inside a path
|
||
*
|
||
* @return boolean TRUE if the directory could be created
|
||
*/
|
||
public function createDirectory($path, $directoryName);
|
||
/**
|
||
* Returns a list of all files and directories inside a path
|
||
*
|
||
* @param string $path
|
||
* @return void
|
||
*/
|
||
public function getListing($path);
|
||
}
|
||
?>
|
t3lib/file_bak_Andreas/class.t3lib_file_file.php | ||
---|---|---|
<?php
|
||
/**
|
||
* The file class of the TYPO3 File Abstraction Layer
|
||
*/
|
||
class t3lib_file_File {
|
||
|
||
/**
|
||
* The uid of this node
|
||
*
|
||
* @var integer
|
||
*/
|
||
protected $uid;
|
||
/**
|
||
* The name of this node. This is only the name on the current leve, no path
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $name;
|
||
/**
|
||
* The parent node of this node
|
||
*
|
||
* @var t3lib_file_Mount
|
||
*/
|
||
protected $mount;
|
||
/**
|
||
* The path to this file (inside the file mount)
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $path = NULL;
|
||
/**
|
||
* The file size
|
||
*
|
||
* @var integer
|
||
*/
|
||
protected $size;
|
||
/**
|
||
* The hash sum of the file
|
||
* TODO: decide on a hashing algorithm
|
||
*
|
||
* @var string
|
||
*/
|
||
protected $hash;
|
||
public function __construct($fileData) {
|
||
$this->uid = $fileData['uid'];
|
||
$this->name = $fileData['name'];
|
||
$this->path = $fileData['path'];
|
||
$this->size = $fileData['size'];
|
||
}
|
||
public function getUid() {
|
||
return $this->uid;
|
||
}
|
||
public function getName() {
|
||
return $this->name;
|
||
}
|
||
public function getPath() {
|
||
return $this->path;
|
||
}
|
||
public function getSize() {
|
||
return $this->size;
|
||
}
|
||
}
|
||
?>
|
t3lib/file_bak_Andreas/class.t3lib_file_repository.php | ||
---|---|---|
<?php
|
||
/**
|
||
* Repository class for files.
|
||
*
|
||
* @TODO add support for file mounts
|
||
*
|
||
*/
|
||
class t3lib_file_Repository {
|
||
/**
|
||
* @static
|
||
* @throws t3lib_file_exception_FileNotFound
|
||
* @param integer $uid
|
||
* @return t3lib_file_File
|
||
*
|
||
* @TODO define how to handle more than one match (which would point to an error in the database structure)
|
||
*/
|
||
public static function getByUid($uid) {
|
||
$recordData = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows('*', 'sys_files', 'uid=' . $uid);
|
||
if (count($recordData) == 0) {
|