[FEATURE] Integrate File Abstraction Layer Handling
authorTYPO3 FAL Team <typo3v4@typo3.org>
Fri, 20 Apr 2012 16:18:57 +0000 (18:18 +0200)
committerOliver Hader <oliver.hader@typo3.org>
Sat, 28 Apr 2012 13:14:40 +0000 (15:14 +0200)
The File Abstraction Layer Handling is based on the API and adds
the required TCA tables and configurations, upgrade wizards and
language labels.

Change-Id: I4c46ef1d8141562d44a8f53019be503c1c01e357
Resolves: #33750
Releases: 6.0
Reviewed-on: http://review.typo3.org/10654
Reviewed-by: Steffen Ritter
Reviewed-by: Tolleiv Nietsch
Tested-by: Tolleiv Nietsch
Reviewed-by: Oliver Hader
Tested-by: Oliver Hader
23 files changed:
t3lib/stddb/tables.php
t3lib/stddb/tables.sql
t3lib/stddb/tbl_be.php
t3lib/stddb/tbl_pages.php
t3lib/stddb/tca_sys_file.php [new file with mode: 0644]
t3lib/stddb/tca_sys_file_collection.php [new file with mode: 0644]
t3lib/stddb/tca_sys_file_reference.php [new file with mode: 0644]
t3lib/stddb/tca_sys_file_storage.php [new file with mode: 0644]
typo3/sysext/context_help/ext_tables.php
typo3/sysext/context_help/locallang_csh_sysfilestorage.xlf [new file with mode: 0644]
typo3/sysext/install/Classes/Updates/Base.php
typo3/sysext/install/Classes/Updates/File/FilemountUpdateWizard.php [new file with mode: 0644]
typo3/sysext/install/Classes/Updates/File/InitUpdateWizard.php [new file with mode: 0644]
typo3/sysext/install/Classes/Updates/File/TceformsUpdateWizard.php [new file with mode: 0644]
typo3/sysext/install/Classes/Updates/File/TtContentUploadsUpdateWizard.php [new file with mode: 0644]
typo3/sysext/install/ext_autoload.php
typo3/sysext/install/ext_localconf.php
typo3/sysext/lang/locallang_common.xlf
typo3/sysext/lang/locallang_general.xlf
typo3/sysext/lang/locallang_misc.xlf
typo3/sysext/lang/locallang_mod_file.xlf
typo3/sysext/lang/locallang_mod_file_list.xlf
typo3/sysext/lang/locallang_tca.xlf

index adfa1fe..57d8938 100644 (file)
@@ -312,6 +312,133 @@ $TCA['sys_collection'] = array(
 );
 
 /**
+ * Table "sys_file_storage":
+ * defines a root-point of a file storage, that is like a mount point.
+ * each storage is attached to a driver (local, webdav, amazons3) and thus is the entry-point
+ * for all files
+ */
+$TCA['sys_file_storage'] = array(
+       'ctrl' => array(
+               'title'     => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_storage',
+               'label'     => 'name',
+               'tstamp'    => 'tstamp',
+               'crdate'    => 'crdate',
+               'cruser_id' => 'cruser_id',
+               'default_sortby' => 'ORDER BY name',
+               'delete' => 'deleted',
+               'rootLevel' => TRUE,
+               'versioningWS_alwaysAllowLiveEdit' => TRUE,     // only have LIVE records of file storages
+               'enablecolumns' => array(
+                       'disabled' => 'hidden',
+               ),
+               'dividers2tabs'     => TRUE,
+               'requestUpdate' => 'driver',
+               'iconfile' => '_icon_ftp.gif',
+               'dynamicConfigFile' => 'T3LIB:tca_sys_file_storage.php',
+       ),
+);
+
+/**
+ * Table "sys_file":
+ * Represents all files that are tracked by TYPO3
+ * which are assets, single entries of files with additional metadata
+ */
+$TCA['sys_file'] = array(
+       'ctrl' => array(
+               'title'     => 'LLL:EXT:lang/locallang_tca.xlf:sys_file',
+               'label'     => 'name',
+               'tstamp'    => 'tstamp',
+               'crdate'    => 'crdate',
+               'cruser_id' => 'cruser_id',
+               'type'          => 'type',
+               'hideTable' => TRUE,
+               'rootLevel' => TRUE,
+               'versioningWS'             => TRUE,
+               'origUid'                  => 't3_origuid',
+               'default_sortby' => 'ORDER BY crdate DESC',
+               'delete' => 'deleted',
+               'dividers2tabs' => TRUE,
+               'typeicon_column' => 'type',
+               'typeicon_classes' => array(
+                       '1' => 'mimetypes-text-text',
+                       '2' => 'mimetypes-media-image',
+                       '3' => 'mimetypes-media-audio',
+                       '4' => 'mimetypes-media-video',
+                       '5' => 'mimetypes-application',
+                       'default' => 'mimetypes-other-other',
+               ),
+               'dynamicConfigFile' => 'T3LIB:tca_sys_file.php',
+               // @todo add icon file
+       ),
+);
+
+/**
+ * Table "sys_file_reference":
+ * Is a single usage of a sys_file record somewhere in the installation
+ * Is kind of like a MM-table between sys_file and e.g. tt_content:image that is shown up
+ * in TCA so additional metadata can be added for this specific kind of usage
+ */
+$TCA['sys_file_reference'] = array(
+       'ctrl' => array(
+               'title'     => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference',
+               'label'     => 'uid',
+               'tstamp'    => 'tstamp',
+               'crdate'    => 'crdate',
+               'cruser_id' => 'cruser_id',
+               'type' => 'uid_local:type',
+               'hideTable' => TRUE,
+               'rootLevel' => TRUE,
+               'sortby' => 'sorting',
+               'delete' => 'deleted',
+               'versioningWS' => TRUE, // records can and should be edited in workspaces
+               'shadowColumnsForNewPlaceholders' => 'tablenames,fieldname,uid_local,uid_foreign',
+               'enablecolumns' => array(
+                       'disabled' => 'hidden',
+               ),
+               'dynamicConfigFile' => 'T3LIB:tca_sys_file_reference.php',
+               // @todo add icon file
+       ),
+);
+t3lib_extMgm::allowTableOnStandardPages('sys_file_reference');
+
+/**
+ * Table "sys_file_collection":
+ * Represents a list of sys_file records
+ */
+$TCA['sys_file_collection'] = array(
+       'ctrl' => array(
+               'title'     => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_collection',
+               'label'     => 'title',
+               'tstamp'    => 'tstamp',
+               'crdate'    => 'crdate',
+               'cruser_id' => 'cruser_id',
+               'versioningWS' => TRUE,
+               'origUid' => 't3_origuid',
+               'languageField'            => 'sys_language_uid',
+               'transOrigPointerField'    => 'l10n_parent',
+               'transOrigDiffSourceField' => 'l10n_diffsource',
+               'default_sortby' => 'ORDER BY crdate',
+               'delete' => 'deleted',
+               'rootlevel' => -1,
+               'type' => 'type',
+               'typeicon_column' => 'type',
+               'typeicon_classes' => array(
+                       'default' => 'apps-filetree-folder-media',
+                       'static'  => 'apps-clipboard-images',
+                       'folder'  => 'apps-filetree-folder-media'
+               ),
+               'enablecolumns' => array(
+                       'disabled' => 'hidden',
+                       'starttime' => 'starttime',
+                       'endtime' => 'endtime',
+               ),
+               'dynamicConfigFile' => 'T3LIB:tca_sys_file_collection.php',
+               // @todo add icon file
+       ),
+);
+t3lib_extMgm::allowTableOnStandardPages('sys_file_collection');
+
+/**
  * Table "sys_history":
  * Holds history records, the config part is defined in t3lib/stddb/tbl_be.php
  */
index bc60488..cc084e7 100644 (file)
@@ -248,6 +248,198 @@ CREATE TABLE sys_filemounts (
   KEY parent (pid)
 );
 
+
+#
+# Table structure for table 'sys_file_storage'
+#
+CREATE TABLE sys_file_storage (
+       uid int(11) NOT NULL auto_increment,
+       pid int(11) DEFAULT '0' NOT NULL,
+       tstamp int(11) DEFAULT '0' NOT NULL,
+       crdate int(11) DEFAULT '0' NOT NULL,
+       cruser_id int(11) DEFAULT '0' NOT NULL,
+       deleted tinyint(4) DEFAULT '0' NOT NULL,
+       hidden tinyint(4) DEFAULT '0' NOT NULL,
+
+       name tinytext,
+       description text,
+       driver tinytext,
+       configuration text,
+       is_browsable tinyint(4) DEFAULT '0' NOT NULL,
+       is_public tinyint(4) DEFAULT '0' NOT NULL,
+       is_writable tinyint(4) DEFAULT '0' NOT NULL,
+       is_online tinyint(4) DEFAULT '1' NOT NULL,
+       processingfolder tinytext,
+
+       PRIMARY KEY (uid),
+       KEY parent (pid)
+);
+
+#
+# Table structure for table 'sys_file'
+#
+CREATE TABLE sys_file (
+       uid int(11) NOT NULL auto_increment,
+       pid int(11) DEFAULT '0' NOT NULL,
+       tstamp int(11) DEFAULT '0' NOT NULL,
+       crdate int(11) DEFAULT '0' NOT NULL,
+       cruser_id int(11) DEFAULT '0' NOT NULL,
+       t3ver_oid int(11) DEFAULT '0' NOT NULL,
+       t3ver_id int(11) DEFAULT '0' NOT NULL,
+       t3ver_wsid int(11) DEFAULT '0' NOT NULL,
+       t3ver_label varchar(30) DEFAULT '' NOT NULL,
+       t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
+       t3ver_stage int(11) DEFAULT '0' NOT NULL,
+       t3ver_count int(11) DEFAULT '0' NOT NULL,
+       t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
+       t3ver_move_id int(11) DEFAULT '0' NOT NULL,
+       t3_origuid int(11) DEFAULT '0' NOT NULL,
+       deleted tinyint(4) DEFAULT '0' NOT NULL,
+
+       type varchar(10) DEFAULT '' NOT NULL,
+       storage int(11) DEFAULT '0' NOT NULL,
+       identifier varchar(200) DEFAULT '' NOT NULL,
+       extension varchar(255) DEFAULT '' NOT NULL,
+       mime_type varchar(255) DEFAULT '' NOT NULL,
+       name tinytext,
+       sha1 tinytext,
+       size int(11) DEFAULT '0' NOT NULL,
+       creation_date int(11) DEFAULT '0' NOT NULL,
+       modification_date int(11) DEFAULT '0' NOT NULL,
+       width int(11) DEFAULT '0' NOT NULL,
+       height int(11) DEFAULT '0' NOT NULL,
+       description text,
+       alternative text,
+
+       PRIMARY KEY (uid),
+       KEY parent (pid),
+       KEY t3ver_oid (t3ver_oid,t3ver_wsid)
+);
+
+#
+# Table structure for table 'sys_file_processedfile'.
+# which is a "temporary" file, like an image preview
+# This table does not have a TCA representation, as it's only written do using direct SQL queries in the code
+#
+CREATE TABLE sys_file_processedfile (
+       uid int(11) NOT NULL auto_increment,
+       pid int(11) DEFAULT '0' NOT NULL,
+       tstamp int(11) DEFAULT '0' NOT NULL,
+       crdate int(11) DEFAULT '0' NOT NULL,
+       cruser_id int(11) DEFAULT '0' NOT NULL,
+       deleted tinyint(4) DEFAULT '0' NOT NULL,
+
+       storage int(11) DEFAULT '0' NOT NULL,
+       original int(11) DEFAULT '0' NOT NULL,
+       identifier varchar(200) DEFAULT '' NOT NULL,
+       name tinytext,
+       configuration text,
+       context varchar(200) DEFAULT '' NOT NULL,
+       checksum varchar(255) DEFAULT '' NOT NULL,
+       is_processed varchar(200) DEFAULT '' NOT NULL,
+       extension varchar(255) DEFAULT '' NOT NULL,
+       mime_type varchar(255) DEFAULT '' NOT NULL,
+       sha1 tinytext,
+       size int(11) DEFAULT '0' NOT NULL,
+       width int(11) DEFAULT '0' NOT NULL,
+       height int(11) DEFAULT '0' NOT NULL,
+
+       PRIMARY KEY (uid),
+       KEY parent (pid)
+);
+
+#
+# Table structure for table 'sys_file_reference'
+# which is one usage of a file with overloaded metadata
+#
+CREATE TABLE sys_file_reference (
+       uid int(11) NOT NULL auto_increment,
+       pid int(11) DEFAULT '0' NOT NULL,
+       tstamp int(11) DEFAULT '0' NOT NULL,
+       crdate int(11) DEFAULT '0' NOT NULL,
+       cruser_id int(11) DEFAULT '0' NOT NULL,
+       sorting int(10) DEFAULT '0' NOT NULL,
+       deleted tinyint(4) DEFAULT '0' NOT NULL,
+       hidden tinyint(4) DEFAULT '0' NOT NULL,
+
+       # Versioning fields
+       t3ver_oid int(11) DEFAULT '0' NOT NULL,
+       t3ver_id int(11) DEFAULT '0' NOT NULL,
+       t3ver_wsid int(11) DEFAULT '0' NOT NULL,
+       t3ver_label varchar(30) DEFAULT '' NOT NULL,
+       t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
+       t3ver_stage int(11) DEFAULT '0' NOT NULL,
+       t3ver_count int(11) DEFAULT '0' NOT NULL,
+       t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
+       t3ver_move_id int(11) DEFAULT '0' NOT NULL,
+       t3_origuid int(11) DEFAULT '0' NOT NULL,
+
+       # Reference fields (basically same as MM table)
+       uid_local int(11) DEFAULT '0' NOT NULL,
+       uid_foreign int(11) DEFAULT '0' NOT NULL,
+       tablenames varchar(255) DEFAULT '' NOT NULL,
+       fieldname tinytext,
+       sorting_foreign int(11) DEFAULT '0' NOT NULL,
+       table_local varchar(255) DEFAULT '' NOT NULL,
+
+       # Local usage overlay fields
+       title tinytext,
+       description text,
+       alternative tinytext,
+       link tinytext,
+       downloadname tinytext,
+
+       PRIMARY KEY (uid),
+       KEY uid_local (uid_local),
+       KEY uid_foreign (uid_foreign),
+       KEY parent (pid)
+);
+
+
+#
+# Table structure for table 'sys_file_collection'
+#
+CREATE TABLE sys_file_collection (
+       uid int(11) NOT NULL auto_increment,
+       pid int(11) DEFAULT '0' NOT NULL,
+       tstamp int(11) DEFAULT '0' NOT NULL,
+       crdate int(11) DEFAULT '0' NOT NULL,
+       cruser_id int(11) DEFAULT '0' NOT NULL,
+       t3ver_oid int(11) DEFAULT '0' NOT NULL,
+       t3ver_id int(11) DEFAULT '0' NOT NULL,
+       t3ver_wsid int(11) DEFAULT '0' NOT NULL,
+       t3ver_label varchar(30) DEFAULT '' NOT NULL,
+       t3ver_state tinyint(4) DEFAULT '0' NOT NULL,
+       t3ver_stage int(11) DEFAULT '0' NOT NULL,
+       t3ver_count int(11) DEFAULT '0' NOT NULL,
+       t3ver_tstamp int(11) DEFAULT '0' NOT NULL,
+       t3ver_move_id int(11) DEFAULT '0' NOT NULL,
+       t3_origuid int(11) DEFAULT '0' NOT NULL,
+       sys_language_uid int(11) DEFAULT '0' NOT NULL,
+       l10n_parent int(11) DEFAULT '0' NOT NULL,
+       l10n_diffsource mediumtext,
+       deleted tinyint(4) DEFAULT '0' NOT NULL,
+       hidden tinyint(4) DEFAULT '0' NOT NULL,
+       starttime int(11) DEFAULT '0' NOT NULL,
+       endtime int(11) DEFAULT '0' NOT NULL,
+
+       # Actual fields
+       title tinytext,
+       description text,
+       type varchar(6) DEFAULT 'static' NOT NULL,
+
+       # for type=static
+       files int(11) DEFAULT '0' NOT NULL,
+
+       # for type=folder:
+       storage int(11) DEFAULT '0' NOT NULL,
+       folder text NOT NULL,
+
+       PRIMARY KEY (uid),
+       KEY parent (pid),
+       KEY t3ver_oid (t3ver_oid,t3ver_wsid)
+);
+
 #
 # Table structure for table 'sys_collection'
 #
@@ -281,7 +473,6 @@ CREATE TABLE sys_collection (
        type varchar(32) DEFAULT 'static' NOT NULL,
        table_name tinytext,
        items int(11) DEFAULT '0' NOT NULL,
-       criteria text NOT NULL,
 
        PRIMARY KEY (uid),
        KEY parent (pid),
index 6412bd2..5f3e850 100644 (file)
@@ -667,16 +667,6 @@ $TCA['sys_filemounts'] = array(
                                'eval' => 'required,trim'
                        )
                ),
-               'path' => array(
-                       'label' => 'LLL:EXT:lang/locallang_tca.xml:sys_filemounts.path',
-                       'config' => array(
-                               'type' => 'input',
-                               'size' => '40',
-                               'max' => '120',
-                               'eval' => 'required,trim',
-                               'softref' => 'substitute'
-                       )
-               ),
                'hidden' => array(
                        'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.disable',
                        'config' => array(
@@ -684,19 +674,28 @@ $TCA['sys_filemounts'] = array(
                        )
                ),
                'base' => array(
-                       'label' => 'LLL:EXT:lang/locallang_tca.xml:sys_filemounts.base',
+                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.baseStorage',
                        'config' => array(
-                               'type' => 'radio',
-                               'items' => array(
-                                       array('LLL:EXT:lang/locallang_tca.xml:sys_filemounts.base_absolute', 0),
-                                       array('LLL:EXT:lang/locallang_tca.xml:sys_filemounts.base_relative', 1)
-                               ),
-                               'default' => 0
+                               'type' => 'select',
+                               'foreign_table' => 'sys_file_storage',
+                               'size' => 1,
+                               'maxitems' => 1,
                        )
-               )
+               ),
+               'path' => array(
+                       'label' => 'LLL:EXT:lang/locallang_general.xml:LGL.folder',
+                       'config' => array(
+                               'type' => 'select',
+                               'items' => array(),
+                               'itemsProcFunc' => 't3lib/file/Service/UserfilemountService.php:t3lib_file_Service_UserfilemountService->renderTceformsSelectDropdown'
+                       )
+               ),
        ),
        'types' => array(
-               '0' => array('showitem' => 'hidden;;;;1-1-1,title;;;;3-3-3,path,base')
+               '0' => array('showitem' => '--palette--;;mount, base, path'),
+       ),
+       'palettes' => array(
+               'mount' => array('showitem' => 'title,hidden', 'canNotCollapse' => 1)
        )
 );
 
@@ -849,17 +848,9 @@ $TCA['sys_collection'] = array(
                                'default' => 'static'
                        )
                ),
-               'criteria' => array(
-                       'exclude' => 0,
-                       'label' => '[filter]',
-                       'config' => array(
-                               'type' => 'passthrough'
-                       )
-               )
        ),
        'types' => array(
                'static' => array('showitem' => 'title;;1,type, description,table_name, items'),
-               'filter' => array('showitem' => 'title;;1,type, description,table_name')
        ),
        'palettes' => array(
                '1' => array('showitem' => 'starttime, endtime, fe_group, sys_language_uid, l10n_parent, l10n_diffsource, hidden')
index d349818..b1e4040 100644 (file)
@@ -610,17 +610,7 @@ $TCA['pages'] = array(
                'media' => array(
                        'exclude' => 1,
                        'label' => 'LLL:EXT:cms/locallang_tca.xml:pages.media',
-                       'config' => array(
-                               'type' => 'group',
-                               'internal_type' => 'file',
-                               'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] . ',html,htm,ttf,txt,css',
-                               'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
-                               'uploadfolder' => 'uploads/media',
-                               'show_thumbs' => '1',
-                               'size' => '3',
-                               'maxitems' => '100',
-                               'minitems' => '0',
-                       ),
+                       'config' => t3lib_extMgm::getFileFieldTCAConfig('media'),
                ),
                'is_siteroot' => array(
                        'exclude' => 1,
@@ -1083,4 +1073,25 @@ if (!t3lib_div::compat_version('4.2')) {
        ');
 }
 
+
+       // keep old code (pre-FAL) for installations that haven't upgraded yet. please remove this code in TYPO3 7.0
+       // @deprecated since TYPO3 6.0, please remove in TYPO3 7.0
+       // existing installation - and files are merged, nothing to do
+if ((!isset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['Tx_Install_Updates_File_TceformsUpdateWizard']) || !t3lib_div::inList($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['Tx_Install_Updates_File_TceformsUpdateWizard'], 'pages:media')) && !t3lib_div::compat_version('6.0')) {
+       t3lib_div::deprecationLog('This installation hasn\'t been migrated to FAL for the field $TCA[pages][columns][media] yet. Please do so before TYPO3 v7.');
+               // existing installation and no upgrade wizard was executed - and files haven't been merged: use the old code
+       $TCA['pages']['columns']['media']['config'] = array(
+               'type' => 'group',
+               'internal_type' => 'file',
+               'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'] . ',html,htm,ttf,txt,css',
+               'max_size' => $GLOBALS['TYPO3_CONF_VARS']['BE']['maxFileSize'],
+               'uploadfolder' => 'uploads/media',
+               'show_thumbs' => '1',
+               'size' => '3',
+               'maxitems' => '100',
+               'minitems' => '0',
+
+       );
+}
+
 ?>
diff --git a/t3lib/stddb/tca_sys_file.php b/t3lib/stddb/tca_sys_file.php
new file mode 100644 (file)
index 0000000..29c6c03
--- /dev/null
@@ -0,0 +1,134 @@
+<?php
+if (!defined ('TYPO3_MODE')) {
+       die ('Access denied.');
+}
+
+$TCA['sys_file'] = array (
+       'ctrl' => $TCA['sys_file']['ctrl'],
+       'interface' => array (
+               'showRecordFieldList' => 'storage, name, description, alternative, type, mime_type, size, sha1'
+       ),
+       'feInterface' => $TCA['sys_file']['feInterface'],
+       'columns' => array (
+               't3ver_label' => array (
+                       'label'  => 'LLL:EXT:lang/locallang_general.xml:LGL.versionLabel',
+                       'config' => array (
+                               'type' => 'input',
+                               'size' => '30',
+                               'max'  => '30',
+                       )
+               ),
+               'fileinfo' => array(
+                       'config' => array(
+                               'type' => 'user',
+                               'userFunc' => 't3lib/file/Utility/FileInfo.php:t3lib_file_utility_fileinfo->renderFileInfo'
+                       )
+               ),
+               'storage' => array(
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file.storage',
+                       'config' => array (
+                               'readOnly' => 1,
+                               'type' => 'select',
+                               'items' => array (
+                                       array('',0),
+                               ),
+                               'foreign_table' => 'sys_file_storage',
+                               'foreign_table_where' => 'ORDER BY sys_file_storage.name',
+                               'size' => 1,
+                               'minitems' => 0,
+                               'maxitems' => 1,
+                       )
+               ),
+               'identifier' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file.identifier',
+                       'config' => array (
+                               'readOnly' => 1,
+                               'type' => 'input',
+                               'size' => '30',
+                       )
+               ),
+               'name' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file.name',
+                       'config' => array (
+                               'type' => 'input',
+                               'size' => '30',
+                               'eval' => 'required'
+                       )
+               ),
+               'description' => array(
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file.description',
+                       'config' => array(
+                               'type' => 'text',
+                               'cols' => '40',
+                               'rows' => '3'
+                       )
+               ),
+               'alternative' => array(
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file.alternative',
+                       'config' => array(
+                               'type' => 'text',
+                               'cols' => '40',
+                               'rows' => '3'
+                       )
+               ),
+               'type' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file.type',
+                       'config' => array (
+                               'readOnly' => 1,
+                               'type' => 'select',
+                               'size' => '1',
+                               'items' => array(
+                                       array('LLL:EXT:lang/locallang_tca.xlf:sys_file.type.unknown',  0),
+                                       array('LLL:EXT:lang/locallang_tca.xlf:sys_file.type.text',     1),
+                                       array('LLL:EXT:lang/locallang_tca.xlf:sys_file.type.image',    2),
+                                       array('LLL:EXT:lang/locallang_tca.xlf:sys_file.type.audio',    3),
+                                       array('LLL:EXT:lang/locallang_tca.xlf:sys_file.type.video',    4),
+                                       array('LLL:EXT:lang/locallang_tca.xlf:sys_file.type.software', 5),
+                               ),
+                       )
+               ),
+               'mime_type' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file.mime_type',
+                       'config' => array (
+                               'readOnly' => 1,
+                               'type' => 'input',
+                               'size' => '30',
+                       )
+               ),
+               'sha1' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file.sha1',
+                       'config' => array (
+                               'readOnly' => 1,
+                               'type' => 'input',
+                               'size' => '30',
+                               'readOnly' => 1,
+                       )
+               ),
+               'size' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file.size',
+                       'config' => array (
+                               'readOnly' => 1,
+                               'type'     => 'input',
+                               'size'     => '8',
+                               'max'      => '30',
+                               'eval'     => 'int',
+                               'default' => 0
+                       )
+               ),
+       ),
+       'types' => array (
+               '1' => array('showitem' => 'fileinfo, name, description, alternative, storage')
+       ),
+       'palettes' => array()
+);
+
+?>
\ No newline at end of file
diff --git a/t3lib/stddb/tca_sys_file_collection.php b/t3lib/stddb/tca_sys_file_collection.php
new file mode 100644 (file)
index 0000000..c94952a
--- /dev/null
@@ -0,0 +1,148 @@
+<?php
+if (!defined ('TYPO3_MODE')) {
+       die ('Access denied.');
+}
+
+$TCA['sys_file_collection'] = array (
+       'ctrl' => $TCA['sys_file_collection']['ctrl'],
+       'interface' => array (
+               'showRecordFieldList' => 'sys_language_uid,l10n_parent,l10n_diffsource,hidden,starttime,endtime,files,title'
+       ),
+       'feInterface' => $TCA['sys_file_collection']['feInterface'],
+       'columns' => array (
+               't3ver_label' => array (
+                       'label'  => 'LLL:EXT:lang/locallang_general.xml:LGL.versionLabel',
+                       'config' => array (
+                               'type' => 'input',
+                               'size' => '30',
+                               'max'  => '30',
+                       )
+               ),
+               'sys_language_uid' => array (
+                       'exclude' => 1,
+                       'label'  => 'LLL:EXT:lang/locallang_general.xml:LGL.language',
+                       'config' => array (
+                               'type'                => 'select',
+                               'foreign_table'       => 'sys_language',
+                               'foreign_table_where' => 'ORDER BY sys_language.title',
+                               'items' => array(
+                                       array('LLL:EXT:lang/locallang_general.xml:LGL.allLanguages', -1),
+                                       array('LLL:EXT:lang/locallang_general.xml:LGL.default_value', 0)
+                               )
+                       )
+               ),
+               'l10n_parent' => array (
+                       'displayCond' => 'FIELD:sys_language_uid:>:0',
+                       'exclude'     => 1,
+                       'label'       => 'LLL:EXT:lang/locallang_general.xml:LGL.l18n_parent',
+                       'config'      => array (
+                               'type'  => 'select',
+                               'items' => array (
+                                       array('', 0),
+                               ),
+                               'foreign_table'       => 'sys_file_collection',
+                               'foreign_table_where' => 'AND sys_file_collection.pid=###CURRENT_PID### AND sys_file_collection.sys_language_uid IN (-1,0)',
+                       )
+               ),
+               'l10n_diffsource' => array (
+                       'config' => array (
+                               'type' => 'passthrough'
+                       )
+               ),
+               'hidden' => array (
+                       'exclude' => 1,
+                       'label'   => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
+                       'config'  => array (
+                               'type'    => 'check',
+                               'default' => '0'
+                       )
+               ),
+               'starttime' => array (
+                       'exclude' => 1,
+                       'label'   => 'LLL:EXT:lang/locallang_general.xml:LGL.starttime',
+                       'config'  => array (
+                               'type'     => 'input',
+                               'size'     => '8',
+                               'max'      => '20',
+                               'eval'     => 'date',
+                               'default'  => '0',
+                               'checkbox' => '0'
+                       )
+               ),
+               'endtime' => array (
+                       'exclude' => 1,
+                       'label'   => 'LLL:EXT:lang/locallang_general.xml:LGL.endtime',
+                       'config'  => array (
+                               'type'     => 'input',
+                               'size'     => '8',
+                               'max'      => '20',
+                               'eval'     => 'date',
+                               'checkbox' => '0',
+                               'default'  => '0',
+                               'range'    => array (
+                                       'upper' => mktime(3, 14, 7, 1, 19, 2038),
+                                       'lower' => mktime(0, 0, 0, date('m')-1, date('d'), date('Y'))
+                               )
+                       )
+               ),
+               'type' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_collection.type',
+                       'config' => array (
+                               'type' => 'select',
+                               'items' => array(
+                                       array('Static selection of files', 'static'),
+                                       array('Folder from Storage', 'folder'),
+                               ),
+                       )
+               ),
+               'files' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_collection.files',
+                       'config' => t3lib_extMgm::getFileFieldTCAConfig('files'),
+               ),
+               'title' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_collection.title',
+                       'config' => array (
+                               'type' => 'input',
+                               'size' => '30',
+                               'eval' => 'required'
+                       )
+               ),
+               'storage' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_collection.storage',
+                       'config' => array (
+                               'type' => 'select',
+                               'items' => array (
+                                       array('',0),
+                               ),
+                               'foreign_table' => 'sys_file_storage',
+                               'foreign_table_where' => 'ORDER BY sys_file_storage.name',
+                               'size' => 1,
+                               'minitems' => 0,
+                               'maxitems' => 1,
+                       )
+               ),
+               'folder' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_collection.folder',
+                       'config' => array(
+                               'type' => 'select',
+                               'items' => array(),
+                               'itemsProcFunc' => 't3lib/file/Service/UserfilemountService.php:t3lib_file_Service_UserfilemountService->renderTceformsSelectDropdown'
+                       )
+               ),
+       ),
+       'types' => array (
+               '0' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, title;;1, type, files'),
+               'static' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, title;;1, type, files'),
+               'folder' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, title;;1, type, storage, folder'),
+       ),
+       'palettes' => array (
+               '1' => array('showitem' => 'hidden, starttime, endtime')
+       )
+);
+
+?>
\ No newline at end of file
diff --git a/t3lib/stddb/tca_sys_file_reference.php b/t3lib/stddb/tca_sys_file_reference.php
new file mode 100644 (file)
index 0000000..3b76fd9
--- /dev/null
@@ -0,0 +1,232 @@
+<?php
+if (!defined ('TYPO3_MODE')) {
+       die ('Access denied.');
+}
+
+$TCA['sys_file_reference'] = array (
+       'ctrl' => $TCA['sys_file_reference']['ctrl'],
+       'interface' => array (
+               'showRecordFieldList' => 'hidden,uid_local,uid_foreign,tablenames,fieldname,sorting_foreign,table_local,title,description'
+       ),
+       'feInterface' => $TCA['sys_file_reference']['feInterface'],
+       'columns' => array (
+               'hidden' => array (
+                       'exclude' => 1,
+                       'label'   => 'LLL:EXT:lang/locallang_general.xml:LGL.hidden',
+                       'config'  => array (
+                               'type'    => 'check',
+                               'default' => '0'
+                       )
+               ),
+               'uid_local' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.uid_local',
+                       'config' => array (
+                               'type' => 'group',
+                               'internal_type' => 'db',
+                               'size' => 1,
+                               'maxitems' => 1,
+                               'minitems' => 0,
+                               'allowed' => 'sys_file',
+                               'filter' => array(
+
+                                       /*
+
+                                       Documentation:
+                                               The filter has two main items "fileType" and "fileExtension".
+                                               Each of them as the keys "allowed" and "disallowed".
+
+                                               => fileType can contain types from the t3lib_file_File::FILETYPE_* class constants
+                                               => fileExtension can contain file extensions like jpg, bmp, etc.
+
+                                               The fileType directive is always processed first, then fileExtension.
+                                               Disallowed takes precedence over allowed.
+                                               If something is specified to be disallowed, everything else is assumed to be allowed.
+                                               If something is specified to be allowed, everything else is assumed to be disallowed.
+
+                                               If no filter is set, everything is assumed to be allowed.
+
+                                       Example:
+
+                                       // Enable only Images or Videos, but exclude "*.bmp" files.
+
+                                       'fileType' => array(
+                                               'allowed' => array(t3lib_file_File::FILETYPE_IMAGE, t3lib_file_File::FILETYPE_VIDEO),
+                                               'disallowed' => array(),
+                                       ),
+                                       'fileExtension' =>  array(
+                                               'allowed' => array(),
+                                               'disallowed' => array('bmp'),
+                                       ),
+
+                                       */
+
+                                       'fileType' => array(
+                                               'allowed' => array(),
+                                               'disallowed' => array(),
+                                       ),
+                               ), // TODO: Verify that this filter is respected in both TCEForms/ElementBrowser and TCEMain
+                       ),
+               ),
+               'uid_foreign' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.uid_foreign',
+                       'config' => array (
+                               'type' => 'select',
+                               'items' => array (
+                                       array('',0),
+                               ),
+                               'foreign_table' => 'tt_content',
+                               'foreign_table_where' => 'ORDER BY tt_content.uid',
+                               'size' => 1,
+                               'minitems' => 0,
+                               'maxitems' => 1,
+                       )
+               ),
+               'tablenames' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.tablenames',
+                       'config' => array (
+                               'type' => 'input',
+                               'size' => '30',
+                               'eval' => 'trim',
+                       )
+               ),
+               'fieldname' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.fieldname',
+                       'config' => array (
+                               'type' => 'input',
+                               'size' => '30',
+                       )
+               ),
+               'sorting_foreign' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.sorting_foreign',
+                       'config' => array (
+                               'type'     => 'input',
+                               'size'     => '4',
+                               'max'      => '4',
+                               'eval'     => 'int',
+                               'checkbox' => '0',
+                               'range'    => array (
+                                       'upper' => '1000',
+                                       'lower' => '10'
+                               ),
+                               'default' => 0
+                       )
+               ),
+               'table_local' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.table_local',
+                       'config' => array (
+                               'type' => 'input',
+                               'size' => '20',
+                               'default' => 'sys_file',
+                       )
+               ),
+               'title' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.title',
+                       'config' => array (
+                               'type' => 'input',
+                               'size' => '22',
+                               'placeholder' => '__row|__foreign|name',
+                       )
+               ),
+               'link' => array(
+                       'exclude' => 1,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.link',
+                       'config' => array(
+                               'type' => 'input',
+                               'size' => '20',
+                               'wizards' => array(
+                                       '_PADDING' => 2,
+                                       'link' => array(
+                                               'type' => 'popup',
+                                               'title' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.link',
+                                               'icon' => 'link_popup.gif',
+                                               'script' => 'browse_links.php?mode=wizard',
+                                               'JSopenParams' => 'height=300,width=500,status=0,menubar=0,scrollbars=1',
+                                       ),
+                               ),
+                       ),
+               ),
+               'description' => array ( // This is used for captions in the frontend
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.description',
+                       'config' => array (
+                               'type' => 'text',
+                               'cols' => '24',
+                               'rows' => '5',
+                       )
+               ),
+               'alternative' => array (
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.alternative',
+                       'config' => array (
+                               'type' => 'input',
+                               'size' => '22',
+                               'placeholder' => '__row|__foreign|name',
+                       )
+               ),
+       ),
+       'types' => array (
+                       // Note that at the moment we define the same fields for every media type.
+                       // We leave the extensive definition of each type here anyway, to make clear that you can use it to differentiate between the types.
+               '0' => array(
+                       'showitem' => '
+                               --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.basicoverlayPalette;basicoverlayPalette,
+                               --palette--;;filePalette',
+               ),
+               t3lib_file_File::FILETYPE_TEXT => array(
+                       'showitem' => '
+                               --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.basicoverlayPalette;basicoverlayPalette,
+                               --palette--;;filePalette',
+               ),
+               t3lib_file_File::FILETYPE_IMAGE => array(
+                       'showitem' => '
+                               --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.basicoverlayPalette;basicoverlayPalette,
+                               --palette--;;filePalette',
+               ),
+               t3lib_file_File::FILETYPE_AUDIO => array(
+                       'showitem' => '
+                               --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.basicoverlayPalette;basicoverlayPalette,
+                               --palette--;;filePalette',
+               ),
+               t3lib_file_File::FILETYPE_VIDEO => array(
+                       'showitem' => '
+                               --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.basicoverlayPalette;basicoverlayPalette,
+                               --palette--;;filePalette',
+               ),
+               t3lib_file_File::FILETYPE_SOFTWARE => array(
+                       'showitem' => '
+                               --palette--;LLL:EXT:lang/locallang_tca.xlf:sys_file_reference.basicoverlayPalette;basicoverlayPalette,
+                               --palette--;;filePalette',
+               ),
+       ),
+       'palettes' => array(
+                       // used for basic overlays: having a file list etc
+               'basicoverlayPalette' => array(
+                       'showitem' => 'title,description',
+                       'canNotCollapse' => TRUE,
+               ),
+
+                       // used for everything that is an image (because it has a link and a alternative text)
+               'imageoverlayPalette' => array(
+                       'showitem' => '
+                               title,alternative;;;;3-3-3,--linebreak--,
+                               link,description
+                               ',
+                       'canNotCollapse' => TRUE,
+               ),
+
+                       // file palette, hidden but needs to be included all the time
+               'filePalette' => array(
+                       'showitem' => 'uid_local',
+                       'isHiddenPalette' => TRUE,
+               ),
+       )
+);
+
+?>
diff --git a/t3lib/stddb/tca_sys_file_storage.php b/t3lib/stddb/tca_sys_file_storage.php
new file mode 100644 (file)
index 0000000..afd4f46
--- /dev/null
@@ -0,0 +1,114 @@
+<?php
+if (!defined ('TYPO3_MODE')) {
+       die ('Access denied.');
+}
+
+/**
+ * File storages
+ */
+$TCA['sys_file_storage'] = array(
+       'ctrl' => $TCA['sys_file_storage']['ctrl'],
+       'interface' => array(
+               'showRecordFieldList' => 'hidden,name,description,driver,processingfolder,configuration'
+       ),
+       'feInterface' => $TCA['sys_file_storage']['feInterface'],
+       'columns' => array(
+               'hidden' => array(
+                       'exclude' => 1,
+                       'label'   => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_storage.hidden',
+                       'config'  => array(
+                               'type'    => 'check',
+                               'default' => '0'
+                       )
+               ),
+               'name' => array(
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_storage.name',
+                       'config' => array(
+                               'type' => 'input',
+                               'size' => '30',
+                       )
+               ),
+               'description' => array(
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_storage.description',
+                       'config' => array(
+                               'type' => 'text',
+                               'cols' => '30',
+                               'rows' => '5',
+                       )
+               ),
+               'is_browsable' => array(
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_storage.is_browsable',
+                       'config' => array(
+                               'type' => 'check',
+                               'default' => 1
+                       )
+               ),
+               'is_public' => array(
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_storage.is_public',
+                       'config' => array(
+                               'type' => 'check',
+                               'default' => 1
+                       )
+               ),
+               'is_writable' => array(
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_storage.is_writable',
+                       'config' => array(
+                               'type' => 'check',
+                               'default' => 1
+                       )
+               ),
+               'is_online' => array(
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_storage.is_online',
+                       'config' => array(
+                               'type' => 'check',
+                               'default' => 1
+                       )
+               ),
+               'processingfolder' => array(
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_storage.processingfolder',
+                       'config' => array(
+                               'type' => 'input',
+                               'placeholder' => t3lib_file_Storage::DEFAULT_ProcessingFolder,
+                               'size' => '20',
+                       )
+               ),
+               'driver' => array(
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_storage.driver',
+                       'config' => array(
+                               'type' => 'select',
+                               'items' => array(),
+                               'default' => '',
+                       )
+               ),
+               'configuration' => array(
+                       'exclude' => 0,
+                       'label' => 'LLL:EXT:lang/locallang_tca.xlf:sys_file_storage.configuration',
+                       'config' => array(
+                               'type' => 'flex',
+                               'ds_pointerField' => 'driver',
+                               'ds' => array(),
+                       ),
+                       'displayCond' => 'REC:NEW:false'
+               ),
+       ),
+       'types' => array(
+               '0' => array('showitem' => 'name, description, hidden, --div--;Configuration, driver, configuration, processingfolder, --div--;Access, --palette--;Capabilities;capabilities, is_online'),
+       ),
+       'palettes' => array(
+               'capabilities' => array('showitem' => 'is_browsable, is_public, is_writable', 'canNotCollapse' => TRUE)
+       )
+);
+
+/** @var t3lib_file_Driver_DriverRegistry $registry */
+$registry = t3lib_div::makeInstance('t3lib_file_Driver_DriverRegistry');
+$registry->addDriversToTCA();
+
+?>
\ No newline at end of file
index e38d091..f3dce2d 100755 (executable)
@@ -7,6 +7,7 @@ t3lib_extMgm::addLLrefForTCAdescr('pages','EXT:context_help/locallang_csh_pages.
 t3lib_extMgm::addLLrefForTCAdescr('pages_language_overlay','EXT:context_help/locallang_csh_pageslol.xml');
 t3lib_extMgm::addLLrefForTCAdescr('static_template','EXT:context_help/locallang_csh_statictpl.xml');
 t3lib_extMgm::addLLrefForTCAdescr('sys_domain','EXT:context_help/locallang_csh_sysdomain.xml');
+t3lib_extMgm::addLLrefForTCAdescr('sys_file_storage','EXT:context_help/locallang_csh_sysfilestorage.xml');
 t3lib_extMgm::addLLrefForTCAdescr('sys_template','EXT:context_help/locallang_csh_systmpl.xml');
 t3lib_extMgm::addLLrefForTCAdescr('tt_content','EXT:context_help/locallang_csh_ttcontent.xml');
 
diff --git a/typo3/sysext/context_help/locallang_csh_sysfilestorage.xlf b/typo3/sysext/context_help/locallang_csh_sysfilestorage.xlf
new file mode 100644 (file)
index 0000000..49c5b27
--- /dev/null
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xliff version="1.0">
+       <file source-language="en" datatype="plaintext" original="messages" date="2011-10-17T20:22:32Z" product-name="context_help">
+               <header/>
+               <body>
+                       <trans-unit id=".description" xml:space="preserve">
+                               <source>File storage, which acts as an entry root point to a file-based structure. See it like a drive or a hard drive volume in your local machine.</source>
+                       </trans-unit>
+                       <trans-unit id=".details" xml:space="preserve">
+                               <source></source>
+                       </trans-unit>
+                       <trans-unit id="hidden.description" xml:space="preserve">
+                               <source>Disabling the storage will result in removing it from any listings in the backend. Existing file relations will still exist.</source>
+                       </trans-unit>
+                       <trans-unit id="hidden.details" xml:space="preserve">
+                               <source>If you set up a file storage, it will show up on any folder lists, thus allowing to basically browse through the files in this file repository. If you set this checkbox, this storage will be excluded from any listings in the backend. Any existing file references will still exist further.</source>
+                       </trans-unit>
+                       <trans-unit id="name.description" xml:space="preserve">
+                               <source>The visible identifier for this file storage.</source>
+                       </trans-unit>
+                       <trans-unit id="name.details" xml:space="preserve">
+                               <source>The label entered here will be shown as the name for the entry point in the TYPO Backend. Be sure to make it descriptive and logical for your editors.</source>
+                       </trans-unit>
+                       <trans-unit id="description.description" xml:space="preserve">
+                               <source>A description of this storage.</source>
+                       </trans-unit>
+                       <trans-unit id="description.details" xml:space="preserve">
+                               <source>This description field is used to explain e.g. the location of the storage, also what this storage is meant for or what it contains.</source>
+                       </trans-unit>
+                       <trans-unit id="driver.description" xml:space="preserve">
+                               <source>Choose the driver as the technical backbone of the storage. Once you've chosen a driver, and saved it, additional configuration will show up.</source>
+                       </trans-unit>
+                       <trans-unit id="driver.details" xml:space="preserve">
+                               <source>The driver is the technical background of a storage, and thus also defines whether the location of the storage is local (= on the same machine as this TYPO3 installation) or remote like a WebDAV server connection. Search for extensions in the TYPO3 Extension Repository that extend this driver list.</source>
+                       </trans-unit>
+                       <trans-unit id="is_browsable.description" xml:space="preserve">
+                               <source>If set, backend users can browse through this storage. Otherwise it will show up as a unselectable item in the list.</source>
+                       </trans-unit>
+                       <trans-unit id="is_public.description" xml:space="preserve">
+                               <source>If set, then the files in this storage can be linked directly from the outside world. If this is not set, make sure to provide additional possibilities to access the files in this storage.</source>
+                       </trans-unit>
+                       <trans-unit id="is_writable.description" xml:space="preserve">
+                               <source>If set, then users are allowed to modify, add, delete files/folders on this storage.</source>
+                       </trans-unit>
+                       <trans-unit id="is_online.description" xml:space="preserve">
+                               <source>This flag is usually set. If TYPO3 cannot connect to this storage (because it maybe temporary down), then the flag will be checked, and the storage will behave like it is non-browsable in the TYPO3 backend. The admin needs to manually activate it again if it was offline.</source>
+                       </trans-unit>
+               </body>
+       </file>
+</xliff>
\ No newline at end of file
index f6c3cf2..1fecd42 100644 (file)
@@ -210,9 +210,10 @@ abstract class Tx_Install_Updates_Base {
         *
         * Writes the info in localconf.php
         *
+        * @param $confValue the configuration is set to this value
         * @return void
         */
-       protected function markWizardAsDone() {
+       protected function markWizardAsDone($confValue = 1) {
                /** @var t3lib_install $install */
                $install = t3lib_div::makeInstance('t3lib_install');
                $install->allowUpdateLocalConf = 1;
@@ -220,7 +221,7 @@ abstract class Tx_Install_Updates_Base {
                // Get lines from localconf file
                $lines = $install->writeToLocalconf_control();
                $wizardClassName = get_class($this);
-               $install->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'INSTALL\'][\'wizardDone\'][\'' . $wizardClassName . '\']', 1);
+               $install->setValueInLocalconfFile($lines, '$TYPO3_CONF_VARS[\'INSTALL\'][\'wizardDone\'][\'' . $wizardClassName . '\']', $confValue);
                $install->writeToLocalconf_control($lines);
        }
 
diff --git a/typo3/sysext/install/Classes/Updates/File/FilemountUpdateWizard.php b/typo3/sysext/install/Classes/Updates/File/FilemountUpdateWizard.php
new file mode 100644 (file)
index 0000000..a3fc2de
--- /dev/null
@@ -0,0 +1,179 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Tolleiv Nietsch <typo3@tolleiv.de>
+ *  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 3 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.
+ *
+ *  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!
+ ***************************************************************/
+
+/**
+ * Upgrade wizard which checks all existing filemounts
+ * and upgrades this them in case we have:
+ * a) absolute filemounts (base = 0) without related storage
+ * b) relative filemounts (base = 1) which aren't related to a storage
+ * further we assume that all other filemounts (base > 1) are already related to a storage
+ *
+ * @package     TYPO3
+ * @author       Tolleiv Nietsch <typo3@tolleiv.de>
+ * @license     http://www.gnu.org/copyleft/gpl.html
+ */
+class Tx_Install_Updates_File_FilemountUpdateWizard extends Tx_Install_Updates_Base {
+       /**
+        * @var string
+        */
+       protected $title = 'Migrate existing filemounts to be file abstraction layer compatible.';
+
+       /**
+        * @var t3lib_db
+        */
+       protected $db;
+
+       /**
+        * @var array
+        */
+       protected $sqlQueries = array();
+
+       /**
+        * @var t3lib_file_Storage
+        */
+       protected $storage;
+
+       /**
+        * @var t3lib_file_Repository_StorageRepository
+        */
+       protected $storageRepository;
+
+       /**
+        * Creates this object
+        */
+       public function __construct() {
+               $this->db = $GLOBALS['TYPO3_DB'];
+       }
+
+       /**
+        * Initialize the storage repository.
+        */
+       public function init() {
+               $this->storageRepository = t3lib_div::makeInstance('t3lib_file_Repository_StorageRepository');
+               $storages = $this->storageRepository->findAll();
+               $this->storage = $storages[0]; // take first found storage
+       }
+
+       /**
+        * Checks if an update is needed.
+        *
+        * @param       string          &$description: The description for the update
+        * @return      boolean         TRUE if an update is needed, FALSE otherwise
+        */
+       public function checkForUpdate(&$description) {
+
+               $description = 'Migrate all filemounts to be based on file abstraction layer storages.';
+               $filemountCount = $this->db->exec_SELECTcountRows(
+                       '*',
+                       'sys_filemounts',
+                       'base IN (0,1) ' . t3lib_BEfunc::deleteClause('sys_filemounts')
+               );
+
+               return $filemountCount > 0 && !$this->isWizardDone();
+       }
+
+       /**
+        * Performs the database update.
+        *
+        * @param       array           &$dbQueries: queries done in this update
+        * @param       mixed           &$customMessages: custom messages
+        * @return      boolean         TRUE on success, FALSE on error
+        */
+       public function performUpdate(&$dbQueries, &$customMessages) {
+
+               $this->init();
+
+               $this->migrateAbsoluteFilemounts();
+               $this->migrateRelativeFilemounts();
+
+               if (is_array($this->sqlQueries) && is_array($dbQueries)) {
+                       $dbQueries = array_merge($dbQueries, $this->sqlQueries);
+               }
+
+               $this->markWizardAsDone();
+               return TRUE;
+       }
+
+
+       /**
+        * Takes the existing absolute filemounts (base=0) and migrates them to use
+        * the existing fileadmin/ storage or a new storage.
+        */
+       protected function migrateAbsoluteFilemounts() {
+               $description = 'This is the local %s directory. This storage mount has been created by the TYPO3 upgrade wizards.';
+               $fileadminDir = PATH_site . $GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'];
+
+               $absoluteFilemounts = $this->db->exec_SELECTgetRows(
+                       '*',
+                       'sys_filemounts',
+                       'base = 0' . t3lib_BEfunc::deleteClause('sys_filemounts')
+               );
+
+               foreach ($absoluteFilemounts as $filemount) {
+                       if (stristr($filemount['path'], $fileadminDir)) {
+                               $storageId = $this->storage->getUid();
+                               $storagePath = str_replace($fileadminDir, '', $filemount['path']);
+                       } else {
+                               $storageId = $this->storageRepository->createLocalStorage(
+                                       $filemount['title'] . ' (auto-created)',
+                                       $filemount['path'],
+                                       'absolute',
+                                       sprintf($description, $filemount['path'])
+                               );
+                               $storagePath = '/';
+                               $this->sqlQueries[] = $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery;
+                       }
+
+                       $this->db->exec_UPDATEquery(
+                               'sys_filemounts',
+                               'uid=' . intval($filemount['uid']),
+                               array('base' => $storageId, 'path' => $storagePath)
+                       );
+                       $this->sqlQueries[] = $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery;
+               }
+       }
+
+       /**
+        * Relative filemounts are transformed to relate to our fileadmin/ storage
+        * and their path is modified to be a valid resource location
+        */
+       protected function migrateRelativeFilemounts() {
+               $relativeFilemounts = $this->db->exec_SELECTgetRows(
+                       '*',
+                       'sys_filemounts',
+                       'base = 1' . t3lib_BEfunc::deleteClause('sys_filemounts')
+               );
+
+               foreach ($relativeFilemounts as $filemount) {
+                       $this->db->exec_UPDATEquery(
+                               'sys_filemounts',
+                               'uid=' . intval($filemount['uid']),
+                               array('base' => $this->storage->getUid(), 'path' => '/' . ltrim($filemount['path'], '/'))
+                       );
+                       $this->sqlQueries[] = $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery;
+               }
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/Updates/File/InitUpdateWizard.php b/typo3/sysext/install/Classes/Updates/File/InitUpdateWizard.php
new file mode 100644 (file)
index 0000000..8cfa425
--- /dev/null
@@ -0,0 +1,103 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2012 Tolleiv Nietsch <info@tolleiv.de>
+ *  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 3 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.
+ *
+ *  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!
+ ***************************************************************/
+
+/**
+ * Upgrade wizard which creates all sys_file* tables. Required to ensure that all
+ * other FAL migration wizards can run properly.
+ *
+ * @package     TYPO3
+ * @author      Tolleiv Nietsch <info@tolleiv.de>
+ * @license     http://www.gnu.org/copyleft/gpl.html
+ */
+class Tx_Install_Updates_File_InitUpdateWizard extends Tx_Install_Updates_Base {
+       /**
+        * @var string
+        */
+       protected $title = 'Initialize FAL tables';
+
+       /**
+        * @var t3lib_install_Sql
+        */
+       protected $installerSql;
+
+       /**
+        * Creates this object.
+        */
+       public function __construct() {
+               $this->installerSql = t3lib_div::makeInstance('t3lib_install_Sql');
+       }
+
+       /**
+        * Checks if an update is needed
+        *
+        * @param       string          &$description: The description for the update
+        * @return      boolean         TRUE if an update is needed, FALSE otherwise
+        */
+       public function checkForUpdate(&$description) {
+               $description = 'Create the tables which are required for the file abstraction layer.';
+               return count($this->getRequiredUpdates()) > 0;
+       }
+
+       /**
+        * Performs the database update.
+        *
+        * @param       array           &$dbQueries: queries done in this update
+        * @param       mixed           &$customMessages: custom messages
+        * @return      boolean         TRUE on success, FALSE on error
+        */
+       public function performUpdate(&$dbQueries, &$customMessages) {
+               $updates = $this->getRequiredUpdates();
+               foreach ($updates as $update) {
+                       $GLOBALS['TYPO3_DB']->admin_query($update);
+                       $dbQueries[] = $update;
+               }
+               return TRUE;
+       }
+
+
+       /**
+        * Determine all create table statements which create the sys_file* tables
+        *
+        * @return array
+        */
+       protected function getRequiredUpdates() {
+               $requiredUpdates = array();
+
+               $fileContent = t3lib_div::getUrl(PATH_t3lib . 'stddb/tables.sql');
+               $FDfile = $this->installerSql->getFieldDefinitions_fileContent($fileContent);
+               $FDdb = $this->installerSql->getFieldDefinitions_database(TYPO3_db);
+               $diff = $this->installerSql->getDatabaseExtra($FDfile, $FDdb);
+               $update_statements = $this->installerSql->getUpdateSuggestions($diff);
+
+               foreach ((array) $update_statements['create_table'] as $string) {
+                       if (preg_match('/^CREATE TABLE sys_file($|_)/', $string)) {
+                               $requiredUpdates[] = $string;
+                       }
+               }
+
+               return $requiredUpdates;
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/Updates/File/TceformsUpdateWizard.php b/typo3/sysext/install/Classes/Updates/File/TceformsUpdateWizard.php
new file mode 100644 (file)
index 0000000..0635886
--- /dev/null
@@ -0,0 +1,259 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2011 Ingmar Schlecht <ingmar@typo3.org>
+ *  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 3 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.
+ *
+ *  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!
+ ***************************************************************/
+
+/**
+ * Upgrade wizard which goes through all files referenced in the tt_content.image filed
+ * and creates sys_file records as well as sys_file_reference records for the individual usages.
+ *
+ * @package     TYPO3
+ * @author Ingmar Schlecht <ingmar@typo3.org>
+ * @license     http://www.gnu.org/copyleft/gpl.html
+ */
+class Tx_Install_Updates_File_TceformsUpdateWizard extends Tx_Install_Updates_Base {
+       /**
+        * @var string
+        */
+       protected $title = 'Migrate file relations';
+
+       /**
+        * @var t3lib_file_Storage
+        */
+       protected $storage;
+
+       /**
+        * Initialize the storage repository.
+        */
+       public function init() {
+               /** @var $storageRepository t3lib_file_Repository_StorageRepository */
+               $storageRepository = t3lib_div::makeInstance('t3lib_file_Repository_StorageRepository');
+               $storages = $storageRepository->findAll();
+               $this->storage = $storages[0]; // take first found storage
+       }
+
+       /**
+        * Checks if an update is needed
+        *
+        * @param       string          &$description: The description for the update
+        * @return      boolean         TRUE if an update is needed, FALSE otherwise
+        */
+       public function checkForUpdate(&$description) {
+               // @todo Function below copied from sysext/install/updates/class.tx_coreupdates_imagelink.php, needs to be adopted
+
+               $description = 'TODO add description of FAL migration';
+
+                       // make this wizard always available
+               return TRUE;
+       }
+
+       /**
+        * Performs the database update.
+        *
+        * @param       array           &$dbQueries: queries done in this update
+        * @param       mixed           &$customMessages: custom messages
+        * @return      boolean         TRUE on success, FALSE on error
+        */
+       public function performUpdate(&$dbQueries, &$customMessages) {
+               $this->init();
+
+               ### Function below copied from sysext/install/updates/class.tx_coreupdates_imagelink.php
+
+               $tables = array(
+                       'tt_content' => array(
+                               'image' => array(
+                                       'sourcePath' => 'uploads/pics/',
+                                       'targetPath' => '_migrated/pics/', # relative to fileadmin
+                                       'titleTexts' => 'titleText',
+                                       'captions' => 'imagecaption',
+                                       'links' => 'image_link',
+                                       'alternativeTexts' => 'altText',
+                               ),
+                       ),
+                       'pages' => array(
+                               'media' => array(
+                                       'sourcePath' => 'uploads/media/',
+                                       'targetPath' => '_migrated/media/', # relative to fileadmin
+                               ),
+                       ),
+                       'pages_language_overlay' => array(
+                               'media' => array(
+                                       'sourcePath' => 'uploads/media/',
+                                       'targetPath' => '_migrated/media/', # relative to fileadmin
+                               ),
+                       ),
+               );
+                       // we write down the fields that were migrated. Like this: tt_content:media
+                       // so you can check whether a field was already migrated
+               if (isset($GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['Tx_Install_Updates_File_TceformsUpdateWizard'])) {
+                       $finishedFields = explode(',', $GLOBALS['TYPO3_CONF_VARS']['INSTALL']['wizardDone']['Tx_Install_Updates_File_TceformsUpdateWizard']);
+               } else {
+                       $finishedFields = array();
+               }
+
+               $result = TRUE;
+               if ($this->versionNumber >= 6000000) {
+                       /**
+                        * TODO
+                        *
+                        * - for each table:
+                        *   - get records from table
+                        *   - for each record:
+                        *     - for each field:
+                        *       - migrate field
+                        */
+                       foreach ($tables as $table => $tableConfiguration) {
+                               $fieldsToMigrate = array_keys($tableConfiguration);
+                               $fieldsToGet = array();
+                                       // find all additional fields we should get from the database
+                               foreach ($tableConfiguration as $field => $fieldConfiguration) {
+                                       $fieldKey = $table . ':' . $field;
+                                       if (array_search($fieldKey, $finishedFields) !== FALSE) {
+                                                       // this field was already migrated
+                                               continue;
+                                       } else {
+                                               $finishedFields[] = $fieldKey;
+                                       }
+
+                                       $fieldsToGet[] = $field;
+                                       if (isset($fieldConfiguration['titleTexts'])) {
+                                               $fieldsToGet[] = $fieldConfiguration['titleTexts'];
+                                       }
+                                       if (isset($fieldConfiguration['alternativeTexts'])) {
+                                               $fieldsToGet[] = $fieldConfiguration['alternativeTexts'];
+                                       }
+                                       if (isset($fieldConfiguration['captions'])) {
+                                               $fieldsToGet[] = $fieldConfiguration['captions'];
+                                       }
+                                       if (isset($fieldConfiguration['links'])) {
+                                               $fieldsToGet[] = $fieldConfiguration['links'];
+                                       }
+
+                               }
+
+                               $records = $this->getRecordsFromTable($table, $fieldsToGet);
+
+                               foreach ($records as $record) {
+                                       foreach ($fieldsToMigrate as $field) {
+                                               $dbQueries = array_merge($this->migrateField($table, $record, $field, $tableConfiguration[$field]));
+                                       }
+                               }
+                       }
+               }
+
+               $finishedFields = implode(',', $finishedFields);
+
+               $this->markWizardAsDone($finishedFields);
+
+               return $result;
+       }
+
+       protected function getRecordsFromTable($table, $relationFields) {
+               $fields = implode(',', array_merge($relationFields, array('uid', 'pid')));
+
+               $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows($fields, $table);
+
+               return $records;
+       }
+
+       protected function migrateField($table, $row, $fieldname, $fieldConfiguration) {
+               $fieldItems = t3lib_div::trimExplode(',', $row[$fieldname], TRUE);
+
+               if (empty($fieldItems) || is_numeric($row[$fieldname])) {
+                       return array();
+               }
+
+               if (isset($fieldConfiguration['titleTexts'])) {
+                       $titleTextField = $fieldConfiguration['titleTexts'];
+                       $titleTextContents = explode(LF, $row[$titleTextField]);
+               }
+               if (isset($fieldConfiguration['alternativeTexts'])) {
+                       $alternativeTextField = $fieldConfiguration['alternativeTexts'];
+                       $alternativeTextContents = explode(LF, $row[$alternativeTextField]);
+               }
+               if (isset($fieldConfiguration['captions'])) {
+                       $captionField = $fieldConfiguration['captions'];
+                       $captionContents = explode(LF, $row[$captionField]);
+               }
+               if (isset($fieldConfiguration['links'])) {
+                       $linkField = $fieldConfiguration['links'];
+                       $linkContents = explode(LF, $row[$linkField]);
+               }
+
+               $queries = array();
+               $i = 0;
+               foreach ($fieldItems as $item) {
+
+                       if(!PATH_site) throw new Exception('PATH_site was undefined.');
+
+                               // copy file
+                       $sourcePath = PATH_site . $fieldConfiguration['sourcePath'] . $item;
+                       $targetPath = PATH_site.'fileadmin/'.$fieldConfiguration['targetPath']. $item;
+                       if(!is_dir(dirname($targetPath))) {
+                               t3lib_div::mkdir_deep(dirname($targetPath));
+                       }
+
+                       rename($sourcePath, $targetPath);
+
+                               // get the File object
+                       $file = $this->storage->getFile($fieldConfiguration['targetPath'] . $item);
+
+                       if($file instanceof t3lib_file_File) {
+                               $fields = array(
+                                               // TODO add sorting/sorting_foreign
+                                       'fieldname' => $fieldname,
+                                       'table_local' => 'sys_file',
+                                       'uid_foreign' => $row['uid'],
+                                       'uid_local' => $file->getUid(),
+                                       'tablenames' => $table,
+                                       'crdate' => time(),
+                                       'tstamp' => time(),
+                               );
+                               if (isset($titleTextField)) {
+                                       $fields['title'] = trim($titleTextContents[$i]);
+                               }
+                               if (isset($alternativeTextField)) {
+                                       $fields['alternative'] = trim($alternativeTextContents[$i]);
+                               }
+                               if (isset($captionField)) {
+                                       $fields['description'] = trim($captionContents[$i]);
+                               }
+                               if (isset($linkField)) {
+                                       $fields['link'] = trim($linkContents[$i]);
+                               }
+
+                               $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_file_reference', $fields);
+                               $queries[] = str_replace(LF, ' ', $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery);
+
+                               ++$i;
+                       }
+               }
+
+               $GLOBALS['TYPO3_DB']->exec_UPDATEquery($table, 'uid=' . $row['uid'], array($fieldname => ''));
+               $queries[] = str_replace(LF, ' ', $GLOBALS['TYPO3_DB']->debug_lastBuiltQuery);
+
+               return $queries;
+               // TODO update original row
+       }
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/install/Classes/Updates/File/TtContentUploadsUpdateWizard.php b/typo3/sysext/install/Classes/Updates/File/TtContentUploadsUpdateWizard.php
new file mode 100644 (file)
index 0000000..e8632ec
--- /dev/null
@@ -0,0 +1,257 @@
+<?php
+/***************************************************************
+ *  Copyright notice
+ *
+ *  (c) 2011 Steffen Ritter <steffen.ritter@typo3.org>
+ *  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 3 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.
+ *
+ *  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!
+ ***************************************************************/
+
+/**
+ * Upgrade wizard which goes through all files referenced in the tt_content.media filed
+ * and creates sys_file records as well as sys_file_reference records for the individual usages.
+ *
+ * @package     TYPO3
+ * @author Steffen Ritter <steffen.ritter@typo3.org>
+ * @license     http://www.gnu.org/copyleft/gpl.html
+ */
+class Tx_Install_Updates_File_TtContentUploadsUpdateWizard extends Tx_Install_Updates_Base {
+       const FOLDER_ContentUploads = 'content_uploads';
+
+       /**
+        * @var string
+        */
+       protected $title = 'Migrate file relations of tt_content "uploads"';
+
+       /**
+        * @var string
+        */
+       protected $targetDirectory;
+
+       /**
+        * @var t3lib_file_Factory
+        */
+       protected $fileFactory;
+
+       /**
+        * @var t3lib_file_Repository_FileRepository
+        */
+       protected $fileRepository;
+
+       /**
+        * @var t3lib_file_Storage
+        */
+       protected $storage;
+
+       /**
+        * Initialize all required repository and factory objects.
+        *
+        * @throws RuntimeException
+        */
+       protected function init() {
+               $fileadminDirectory = rtrim($GLOBALS['TYPO3_CONF_VARS']['BE']['fileadminDir'], '/') . '/';
+
+               /** @var $storageRepository t3lib_file_Repository_StorageRepository */
+               $storageRepository = t3lib_div::makeInstance('t3lib_file_Repository_StorageRepository');
+               $storages = $storageRepository->findAll();
+
+               foreach ($storages as $storage) {
+                       $storageRecord = $storage->getStorageRecord();
+                       $configuration = $storage->getConfiguration();
+
+                       $isLocalDriver = $storageRecord['driver'] === 'Local';
+                       $isOnFileadmin = (!empty($configuration['basePath']) && t3lib_div::isFirstPartOfStr($configuration['basePath'], $fileadminDirectory));
+
+                       if ($isLocalDriver && $isOnFileadmin) {
+                               $this->storage = $storage;
+                               break;
+                       }
+               }
+
+               if (!isset($this->storage)) {
+                       throw new RuntimeException('Local default storage could not be initialized - migth be due to missing sys_file* tables.');
+               }
+
+               $this->fileFactory = t3lib_div::makeInstance("t3lib_file_Factory");
+               $this->fileRepository= t3lib_div::makeInstance('t3lib_file_Repository_FileRepository');
+               $this->targetDirectory = PATH_site . $fileadminDirectory . self::FOLDER_ContentUploads . '/';
+       }
+
+       /**
+        * Checks if an update is needed
+        *
+        * @param       string          &$description: The description for the update
+        * @return      boolean         TRUE if an update is needed, FALSE otherwise
+        */
+       public function checkForUpdate(&$description) {
+               $updateNeeded = FALSE;
+
+               // Fetch records where the field media does not contain a plain integer value
+               // * check whether media field is not empty
+               // * then check whether media field does not contain a reference count (= not integer)
+               $notMigratedRowsCount = $GLOBALS['TYPO3_DB']->exec_SELECTcountRows(
+                       'uid',
+                       'tt_content',
+                       "media <> '' AND CAST(CAST(media AS DECIMAL) AS CHAR) <> media OR (CType = 'uploads' AND select_key != '')"     // include also deleted, as they might be undeleted
+               );
+               if ($notMigratedRowsCount > 0) {
+                       $description = 'There are Content Elements of type "upload" which are referencing files,' .
+                          ' not using FAL. The Wizard will move the files to fileadmin/content_uploads/ and index them.';
+                       $updateNeeded = TRUE;
+               }
+
+               return $updateNeeded;
+       }
+
+       /**
+        * Performs the database update.
+        *
+        * @param       array           &$dbQueries: queries done in this update
+        * @param       mixed           &$customMessages: custom messages
+        * @return      boolean         TRUE on success, FALSE on error
+        */
+       public function performUpdate(&$dbQueries, &$customMessages) {
+               $this->init();
+               $records = $this->getRecordsFromTable('tt_content');
+               $this->checkPrerequisites();
+
+               foreach ($records as $singleRecord) {
+                       $this->migrateRecord($singleRecord);
+               }
+
+               return TRUE;
+       }
+
+       /**
+        * Ensures a new folder "fileadmin/content_upload/" is available.
+        *
+        * @return void
+        */
+       protected function checkPrerequisites() {
+               if (!$this->storage->hasFolder(self::FOLDER_ContentUploads)) {
+                       $this->storage->createFolder(
+                               self::FOLDER_ContentUploads,
+                               $this->storage->getRootLevelFolder()
+                       );
+               }
+       }
+
+       /**
+        * Processes the actual transformation from CSV to sys_file_references
+        *
+        * @param array $record
+        * @return void
+        */
+       protected function migrateRecord(array $record) {
+               $collections = array();
+               if (trim($record['select_key'])) {
+                       $GLOBALS['TYPO3_DB']->exec_INSERTquery(
+                               'sys_file_collection',
+                               array(
+                                       'pid' => $record['pid'],
+                                       'title' => $record['select_key'],
+                                       'storage' => $this->storage->getUid(),
+                                       'folder' => ltrim("fileadmin/", $record['select_key'])
+                               )
+                       );
+                       $collections[] = $GLOBALS['TYPO3_DB']->sql_insert_id();
+               }
+
+               $files = t3lib_div::trimExplode(',', $record['media'], TRUE);
+               $descriptions = t3lib_div::trimExplode("\n", $record['imagecaption']);
+               $titleText = t3lib_div::trimExplode("\n", $record['titleText']);
+
+               $i = 0;
+               foreach ($files as $file) {
+                       if (file_exists(PATH_site . 'uploads/media/' . $file)) {
+                               t3lib_div::upload_copy_move(
+                                       PATH_site . 'uploads/media/' . $file,
+                                       $this->targetDirectory . $file
+                               );
+
+                               $fileObject = $this->storage->getFile('content_uploads/' . $file);
+                               $this->fileRepository->addToIndex($fileObject);
+                               
+                               $dataArray = array(
+                                       'uid_local' => $fileObject->getUid(),
+                                       'tablenames' => 'tt_content',
+                                       'uid_foreign' => $record['uid'],
+                                       'fieldname' => 'media',
+                                       'sorting_foreign' => $i
+                               );
+
+                               if (isset($descriptions[$i])) {
+                                       $dataArray['description'] = $descriptions[$i];
+                               }
+
+                               if (isset($titleText[$i])) {
+                                       $dataArray['alternative'] = $titleText[$i];
+                               }
+
+                               $GLOBALS['TYPO3_DB']->exec_INSERTquery('sys_file_reference', $dataArray);
+                               unlink(PATH_site . 'uploads/media/' . $file);
+                       }
+
+                       $i++;
+               }
+
+               $this->cleanRecord($record, $i, $collections);
+       }
+
+       /**
+        * Removes the old fields from the database-record
+        *
+        * @param array $record
+        * @param integer $fileCount
+        * @param array $collectionUids
+        * @return void
+        */
+       protected function cleanRecord(array $record, $fileCount, array $collectionUids) {
+               $GLOBALS['TYPO3_DB']->exec_UPDATEquery(
+                       'tt_content',
+                       'uid = ' . $record['uid'],
+                       array(
+                               'media' => $fileCount,
+                               'imagecaption' => '',
+                               'titleText' => '',
+                               'altText' => '',
+                               'select_key' => '',
+                               'file_collections' => implode(',', $collectionUids)
+                       )
+               );
+       }
+
+       /**
+        * Retrieve every record which needs to be processed
+        *
+        * @return array
+        */
+       protected function getRecordsFromTable() {
+               $fields = implode(',', array('uid', 'pid', 'select_key', 'media', 'imagecaption', 'titleText'));
+
+               $records = $GLOBALS['TYPO3_DB']->exec_SELECTgetRows(
+                       $fields,
+                       'tt_content',
+                       "media <> '' AND CAST(CAST(media AS DECIMAL) AS CHAR) <> media OR (CType = 'uploads' AND select_key != '')"
+               );
+
+               return $records;
+       }
+}
+
+?>
\ No newline at end of file
index c76b6cc..a786e6b 100644 (file)
@@ -7,6 +7,8 @@ $extPath = t3lib_extMgm::extPath('install');
 return array(
        'tx_install_report_installstatus' => $extPath . 'report/class.tx_install_report_installstatus.php',
        'tx_install_service_basicservice' => $extPath . 'Classes/Service/BasicService.php',
+       'tx_install_updates_file_ttcontentupgradewizard' => $extPath . 'Classes/Updates/File/TtContentUpgradeWizard.php',
+       'tx_install_updates_file_ttcontentuploadsupgradewizard' => $extPath . 'Classes/Updates/File/TtContentUploadsUpgradeWizard.php',
        'tx_install_updates_base' => $extPath . 'Classes/Updates/Base.php',
        'tx_install_interfaces_checkthedatabasehook' => $extPath . 'Classes/Interfaces/CheckTheDatabaseHook.php'
 );
index 5e467bf..c665c95 100644 (file)
@@ -50,4 +50,12 @@ $TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['addFlexformsToAcl'] = '
 
        // Version 4.5: Split tt_content image_link to newline by comma
 $TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['imagelink'] = 'tx_coreupdates_imagelink';
+
+       // Version 6.0: Migrate files content elements to use File Abstraction Layer
+       // Migrations of tt_content.image DB fields and captions, alt texts, etc. into sys_file_reference records.
+$TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['sysext_file_init'] = 'Tx_Install_Updates_File_InitUpdateWizard';
+$TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['sysext_file_images'] = 'Tx_Install_Updates_File_TceformsUpdateWizard';
+$TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['sysext_file_uploads'] = 'Tx_Install_Updates_File_TtContentUploadsUpdateWizard';
+$TYPO3_CONF_VARS['SC_OPTIONS']['ext/install']['update']['sysext_file_filemounts'] = 'Tx_Install_Updates_File_FilemountUpdateWizard';
+
 ?>
\ No newline at end of file
index 70c49ed..f822f56 100644 (file)
@@ -69,6 +69,9 @@
                        <trans-unit id="files" xml:space="preserve">
                                <source>Files</source>
                        </trans-unit>
+                       <trans-unit id="folder" xml:space="preserve">
+                               <source>Folder</source>
+                       </trans-unit>
                        <trans-unit id="first" xml:space="preserve">
                                <source>First</source>
                        </trans-unit>
index 6293bef..bbe1b09 100644 (file)
                        <trans-unit id="LGL.disable" xml:space="preserve">
                                <source>Disable:</source>
                        </trans-unit>
+                       <trans-unit id="LGL.baseStorage" xml:space="preserve">
+                               <source>Storage:</source>
+                       </trans-unit>
+                       <trans-unit id="LGL.folder" xml:space="preserve">
+                               <source>Folder:</source>
+                       </trans-unit>
                        <trans-unit id="LGL.startingpoint" xml:space="preserve">
                                <source>Startingpoint:</source>
                        </trans-unit>
index 6e347e6..d7dc004 100644 (file)
                        <trans-unit id="overwriteExistingFiles" xml:space="preserve">
                                <source>Overwrite existing files</source>
                        </trans-unit>
+                       <trans-unit id="uploadMultipleFilesInfo" xml:space="preserve">
+                               <source>Upload multiple files by holding the Shift or CTRL-file pressed while selecting your files (works on modern browsers only).</source>
+                       </trans-unit>
                        <trans-unit id="selectPosition" xml:space="preserve">
                                <source>Select a position for the new page</source>
                        </trans-unit>
index 04c90e3..5347f16 100644 (file)
@@ -9,6 +9,9 @@
                        <trans-unit id="mlang_tabs_tab" xml:space="preserve">
                                <source>File</source>
                        </trans-unit>
+                       <trans-unit id="sys_file_storage.isOffline" xml:space="preserve">
+                               <source>offline</source>
+                       </trans-unit>
                </body>
        </file>
 </xliff>
index 5cc8eb0..02c2bf4 100644 (file)
                                <source>Path type:</source>
                        </trans-unit>
                        <trans-unit id="localDriverFlexform_pathType_relative" xml:space="preserve">
-                               <source>absolute</source>
+                               <source>relative</source>
                        </trans-unit>
                        <trans-unit id="localDriverFlexform_pathType_absolute" xml:space="preserve">
                                <source>absolute</source>
                        </trans-unit>
+                       <trans-unit id="storageNotBrowsableTitle" xml:space="preserve">
+                               <source>Access denied.</source>
+                       </trans-unit>
+                       <trans-unit id="storageNotBrowsableMessage" xml:space="preserve">
+                               <source>You are trying to access a folder in a storage that is not browsable.</source>
+                       </trans-unit>
+                       <trans-unit id="folderNotFoundTitle" xml:space="preserve">
+                               <source>Folder access denied.</source>
+                       </trans-unit>
+                       <trans-unit id="folderNotFoundMessage" xml:space="preserve">
+                               <source>The folder "%s" cannot be accessed.</source>
+                       </trans-unit>
                </body>
        </file>
 </xliff>
index 320bef3..ccb1e9b 100644 (file)
                        <trans-unit id="sys_collection.type.static" xml:space="preserve">
                                <source>static record composition</source>
                        </trans-unit>
-                       <trans-unit id="sys_collection.type.filter" xml:space="preserve">
-                               <source>dynamic record filter</source>
+                       <trans-unit id="sys_file_storage" xml:space="preserve">
+                               <source>File Storage</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_storage.type" xml:space="preserve">
+                               <source>Entry point</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_storage.name" xml:space="preserve">
+                               <source>Name</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_storage.description" xml:space="preserve">
+                               <source>Description</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_storage.hidden" xml:space="preserve">
+                               <source>Hide from listings</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_storage.is_online" xml:space="preserve">
+                               <source>Is online?</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_storage.is_browsable" xml:space="preserve">
+                               <source>Is browsable?</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_storage.is_public" xml:space="preserve">
+                               <source>Is publically available?</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_storage.is_writable" xml:space="preserve">
+                               <source>Is writable?</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_storage.capabilities" xml:space="preserve">
+                               <source>Capabilities</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_storage.processingfolder" xml:space="preserve">
+                               <source>Folder for manipulated and temporary images etc.</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_storage.driver" xml:space="preserve">
+                               <source>Driver</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_storage.driver.local" xml:space="preserve">
+                               <source>Local Filesystem</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_storage.configuration" xml:space="preserve">
+                               <source>Driver Configuration</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file" xml:space="preserve">
+                               <source>File</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.storage" xml:space="preserve">
+                               <source>Storage</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.identifier" xml:space="preserve">
+                               <source>Identifier</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.name" xml:space="preserve">
+                               <source>Title</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.type" xml:space="preserve">
+                               <source>File Type</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.type.unknown" xml:space="preserve">
+                               <source>Unknown</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.type.text" xml:space="preserve">
+                               <source>Text</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.type.image" xml:space="preserve">
+                               <source>Image</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.type.audio" xml:space="preserve">
+                               <source>Audio</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.type.video" xml:space="preserve">
+                               <source>Video</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.type.software" xml:space="preserve">
+                               <source>Software</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.mime_type" xml:space="preserve">
+                               <source>Mime Type</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.sha1" xml:space="preserve">
+                               <source>SHA1</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.size" xml:space="preserve">
+                               <source>Size</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.identifier" xml:space="preserve">
+                               <source>Identifier</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.usage_count" xml:space="preserve">
+                               <source>Usage Count</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.description" xml:space="preserve">
+                               <source>Description</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file.alternative" xml:space="preserve">
+                               <source>Alternative Text</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_reference" xml:space="preserve">
+                               <source>File Reference</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_reference.uid_local" xml:space="preserve">
+                               <source>File</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_reference.uid_foreign" xml:space="preserve">
+                               <source>Used by content elements</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_reference.tablenames" xml:space="preserve">
+                               <source>Table name</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_reference.fieldname" xml:space="preserve">
+                               <source>Foreign Field</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_reference.sorting_foreign" xml:space="preserve">
+                               <source>Sorting foreign</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_reference.basicoverlayPalette" xml:space="preserve">
+                               <source>File Metadata</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_reference.imageoverlayPalette" xml:space="preserve">
+                               <source>Image Metadata</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_reference.title" xml:space="preserve">
+                               <source>Title</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_reference.description" xml:space="preserve">
+                               <source>Description (Caption)</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_reference.downloadname" xml:space="preserve">
+                               <source>Download Name</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_reference.alternative" xml:space="preserve">
+                               <source>Alternative Text</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_reference.link" xml:space="preserve">
+                               <source>Link</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_collection" xml:space="preserve">
+                               <source>File collection</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_collection.files" xml:space="preserve">
+                               <source>Files</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_collection.title" xml:space="preserve">
+                               <source>Title</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_collection.type" xml:space="preserve">
+                               <source>Type</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_collection.storage" xml:space="preserve">
+                               <source>File Storage</source>
+                       </trans-unit>
+                       <trans-unit id="sys_file_collection.folder" xml:space="preserve">
+                               <source>Folder</source>
                        </trans-unit>
                        <trans-unit id="sys_language" xml:space="preserve">
                                <source>Website Language</source>