[FEATURE] Make DatabaseRecordList configurable to be editable 73/41573/3
authorGeorg Ringer <georg.ringer@gmail.com>
Fri, 17 Jul 2015 14:35:32 +0000 (16:35 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sat, 18 Jul 2015 09:03:10 +0000 (11:03 +0200)
A new property makes it possible to render the record list as readonly.
Furthermore the localization view is enabled for the Element Browser

Resolves: #68282
Releases: master
Change-Id: I56e64f2681d83b414066650688adc64f8528be49
Reviewed-on: http://review.typo3.org/41573
Reviewed-by: Susanne Moog <typo3@susannemoog.de>
Tested-by: Susanne Moog <typo3@susannemoog.de>
Reviewed-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
Tested-by: Stefan Neufeind <typo3.neufeind@speedpartner.de>
typo3/sysext/core/Documentation/Changelog/master/Feature-68282-MakeDatabaseRecordListConfigurableToBeEditable.rst [new file with mode: 0644]
typo3/sysext/recordlist/Classes/Browser/ElementBrowser.php
typo3/sysext/recordlist/Classes/RecordList/DatabaseRecordList.php

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-68282-MakeDatabaseRecordListConfigurableToBeEditable.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-68282-MakeDatabaseRecordListConfigurableToBeEditable.rst
new file mode 100644 (file)
index 0000000..fb6ec96
--- /dev/null
@@ -0,0 +1,14 @@
+=====================================================================
+Feature: #68282 - Make DatabaseRecordList configurable to be editable
+=====================================================================
+
+Description
+===========
+
+A new property ``editable`` is added to ``\TYPO3\CMS\Recordlist\RecordList\DatabaseRecordList`` which is set to TRUE by default. If set to FALSE, the records can't be edited.
+
+
+Impact
+======
+
+The record list in the Element Browser benefits from the new setting as the localization view is now enabled. This will show editors translated records properly intended below the record with the default language.
\ No newline at end of file
index 34f0c5d..11f6848 100755 (executable)
@@ -1690,6 +1690,8 @@ class ElementBrowser {
                $dbList->thisScript = $this->thisScript;
                $dbList->backPath = $GLOBALS['BACK_PATH'];
                $dbList->thumbs = 0;
+               $dbList->localizationView = 1;
+               $dbList->setIsEditable(FALSE);
                $dbList->calcPerms = $backendUser->calcPerms($pageInfo);
                $dbList->noControlPanels = 1;
                $dbList->clickMenuEnabled = 0;
index 015aa53..f283c0d 100644 (file)
@@ -185,6 +185,13 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
        public $MOD_MENU;
 
        /**
+        * If defined the records are editable
+        *
+        * @var bool
+        */
+       protected $editable = TRUE;
+
+       /**
         * Create the panel of buttons for submitting the form or otherwise perform
         * operations.
         *
@@ -939,7 +946,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                        break;
                                case '_CONTROL_':
                                        // Control panel:
-                                       if (!$GLOBALS['TCA'][$table]['ctrl']['readOnly']) {
+                                       if ($this->isEditable($table)) {
                                                // If new records can be created on this page, add links:
                                                $permsAdditional = ($table === 'pages' ? 8 : 16);
                                                if ($this->calcPerms & $permsAdditional && $this->showNewRecLink($table)) {
@@ -1012,7 +1019,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                                                }
                                                // If the table can be edited, add link for editing THIS field for all
                                                // listed records:
-                                               if (!$GLOBALS['TCA'][$table]['ctrl']['readOnly'] && $permsEdit && $GLOBALS['TCA'][$table]['columns'][$fCol]) {
+                                               if ($this->isEditable($table) && $permsEdit && $GLOBALS['TCA'][$table]['columns'][$fCol]) {
                                                        $editIdList = implode(',', $currentIdList);
                                                        if ($this->clipNumPane()) {
                                                                $editIdList = '\'+editList(\'' . $table . '\',\'' . $editIdList . '\')+\'';
@@ -1209,7 +1216,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                // "Edit" link: ( Only if permissions to edit the page-record of the content of the parent page ($this->id)
                if ($permsEdit) {
                        $params = '&edit[' . $table . '][' . $row['uid'] . ']=edit';
-                       $spriteIcon = ($GLOBALS['TCA'][$table]['ctrl']['readOnly'] ? 'actions-document-open-read-only' : 'actions-document-open');
+                       $spriteIcon = (!$this->isEditable($table) ? 'actions-document-open-read-only' : 'actions-document-open');
                        $editAction = '<a class="btn btn-default" href="#" onclick="' . htmlspecialchars(BackendUtility::editOnClick($params, '', -1))
                                . '" title="' . $this->getLanguageService()->getLL('edit', TRUE) . '">' . IconUtility::getSpriteIcon($spriteIcon) . '</a>';
                        $this->addActionToCellGroup($cells, $editAction, 'edit');
@@ -1228,7 +1235,7 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                        $this->addActionToCellGroup($cells, $moveAction, 'move');
                }
                // If the table is NOT a read-only table, then show these links:
-               if (!$GLOBALS['TCA'][$table]['ctrl']['readOnly']) {
+               if ($this->isEditable($table)) {
                        // "Revert" link (history/undo)
                        $moduleUrl = BackendUtility::getModuleUrl('record_history', array('element' => $table . ':' . $row['uid']));
                        $onClick = 'return jumpExt(' . GeneralUtility::quoteJSvalue($this->backPath . $moduleUrl) . ',\'#latest\');';
@@ -1583,15 +1590,17 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
                );
                // Reset translations
                $this->translations = array();
-               $translations = $this->translateTools->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList);
+
                // Language title and icon:
                $out[0] = $this->languageFlag($row[$GLOBALS['TCA'][$table]['ctrl']['languageField']]);
+
+               $translations = $this->translateTools->translationInfo($table, $row['uid'], 0, $row, $this->selFieldList);
                if (is_array($translations)) {
                        $this->translations = $translations['translations'];
                        // Traverse page translations and add icon for each language that does NOT yet exist:
                        $lNew = '';
                        foreach ($this->pageOverlays as $lUid_OnPage => $lsysRec) {
-                               if (!isset($translations['translations'][$lUid_OnPage]) && $this->getBackendUserAuthentication()->checkLanguageAccess($lUid_OnPage)) {
+                               if ($this->isEditable && !isset($translations['translations'][$lUid_OnPage]) && $this->getBackendUserAuthentication()->checkLanguageAccess($lUid_OnPage)) {
                                        $url = substr($this->listURL(), strlen($this->backPath));
                                        $href = $this->getModule()->doc->issueCommand(
                                                '&cmd[' . $table . '][' . $row['uid'] . '][localize]=' . $lUid_OnPage,
@@ -1900,6 +1909,22 @@ class DatabaseRecordList extends AbstractDatabaseRecordList {
        }
 
        /**
+        * @param bool $isEditable
+        */
+       public function setIsEditable($isEditable) {
+               $this->editable = $isEditable;
+       }
+
+       /**
+        * Check if the table is readonly or editable
+        * @param string $table
+        * @return bool
+        */
+       public function isEditable($table) {
+               return $GLOBALS['TCA'][$table]['ctrl']['readOnly'] || $this->editable;
+       }
+
+       /**
         * @return DatabaseConnection
         */
        protected function getDatabaseConnection() {