[FEATURE] Allow custom record list in element browser 47/21347/5
authorAlexander Stehlik <alexander.stehlik@googlemail.com>
Tue, 11 Jun 2013 17:58:26 +0000 (19:58 +0200)
committerGeorg Ringer <georg.ringer@gmail.com>
Mon, 17 Jun 2013 05:53:46 +0000 (07:53 +0200)
Introduces a class variable and a setter for a custom record list
instance in the element browser that can be used to override the
default element browser recordlist.

Resolves: #49037
Releases: 6.2
Change-Id: I41fd3a33f70e72aedef9362ee6bf67de9dcde8ac
Reviewed-on: https://review.typo3.org/21347
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Philipp Gampe
Reviewed-by: Georg Ringer
Tested-by: Georg Ringer
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php

index 2399ed0..be2803e 100644 (file)
@@ -34,6 +34,14 @@ namespace TYPO3\CMS\Recordlist\Browser;
  */
 class ElementBrowser {
 
+       /**
+        * Optional instance of a record list that TBE_expandPage() should
+        * use to render the records in a page
+        *
+        * @var \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList
+        */
+       protected $recordList = NULL;
+
        // Internal, static:
        // Current site URL (Frontend)
        /**
@@ -1409,7 +1417,11 @@ class ElementBrowser {
                        $table = '';
                        // Generate the record list:
                        /** @var $dblist \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList */
-                       $dblist = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\RecordList\\ElementBrowserRecordList');
+                       if (isset($this->recordList)) {
+                               $dblist = $this->recordList;
+                       } else {
+                               $dblist = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Backend\\RecordList\\ElementBrowserRecordList');
+                       }
                        $dblist->thisScript = $this->thisScript;
                        $dblist->backPath = $GLOBALS['BACK_PATH'];
                        $dblist->thumbs = 0;
@@ -2053,6 +2065,21 @@ class ElementBrowser {
        }
 
        /**
+        * Setter for the class that should be used by TBE_expandPage()
+        * to generate the record list.
+        *
+        * @param \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList $recordList
+        * @throws \InvalidArgumentException
+        * @return void
+        */
+       public function setRecordList($recordList) {
+               if (!$recordList instanceof \TYPO3\CMS\Backend\RecordList\ElementBrowserRecordList) {
+                       throw new \InvalidArgumentException('$recordList needs to be an instance of \\TYPO3\\CMS\\Backend\\RecordList\\ElementBrowserRecordList', 1370878522);
+               }
+               $this->recordList = $recordList;
+       }
+
+       /**
         * For TBE: Makes an upload form for uploading files to the filemount the user is browsing.
         * The files are uploaded to the tce_file.php script in the core which will handle the upload.
         *