Project

General

Profile

Actions

Bug #47322

closed

Import Selection with TYPO3 Element Browser

Added by Gregor Hyneck about 11 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Must have
Assignee:
-
Category:
Backend User Interface
Target version:
Start date:
2013-04-17
Due date:
% Done:

100%

Estimated time:
TYPO3 Version:
6.2
PHP Version:
5.3
Tags:
Complexity:
Is Regression:
No
Sprint Focus:
Stabilization Sprint

Description

When I use the "Import Selection" Feature of the TYPO3 Element Browser, I can't add more than one image at a time to a dataset. This occurs in all extensions I tested: tt_news, cal and own extensions. The TCA config of the "Browse For Files" Button is set to

'type' => 'group',
'internal_type' => 'file',
'uploadfolder' => 'uploads/tx_t1test',
'show_thumbs' => 1,
'size' => 15,
'maxitems' => '200',
'allowed' => $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext'],
'disallowed' => '',
I tested with a clean TYPO3 6.04, 6.0.5-dev and 6.1-dev (Blank Package).

Files

browse_links.js (3.22 KB) browse_links.js Patched Nico Schieder, 2014-01-14 15:23
Actions #1

Updated by Henrik Ziegenhain almost 11 years ago

I think this is related to #45194

I noticed this so far only in EXT:imagecycle, because of this I posted it there.

Actions #2

Updated by Martin Borer almost 11 years ago

can confirm this for all Typo3 6.* Versions! This is not a should have, it's a must have!

Actions #3

Updated by Marc Willmann almost 11 years ago

  • Target version changed from 6.0.5 to next-patchlevel

I also confirm this for all browsers and TYPO3 6.1.1 and 6.1.2. I suggest to raise the priority, this is not "should have"!

Actions #4

Updated by Nico Schieder over 10 years ago

Bump for next patch.
This is quite a big issue for all Users who need to select more than 10 files for a gallery or imageslider.

So it is sure a must-have.

Actions #5

Updated by Ernesto Baschny over 10 years ago

  • Category set to File Abstraction Layer (FAL)
  • Target version deleted (next-patchlevel)
  • Is Regression set to No
Actions #6

Updated by Nico Schieder over 10 years ago

Greetings!

I found the problem.

Error

The file typo3/js/browse_links.js has been altered in Typo3 6.* Version to use the new functions "BrowseLinks.File.insertElement()" and "BrowseLinks.File.insertElementMultiple()". The "insertElement()" function works, but the function "insertElementMultiple()" relays on another function "insertMultiple()" which you can find in one of the inline <script>-Tags.

The "insertMultiple()" however just returns false, so nothing is done.

Handle Function (browse_links.js)

    handle: function(element) {
        var items = this.getItems(element);
        var selectedItems = [];
        if (items.length) {
            items.each(function(item) {
                if (item.checked && item.name) {
                    selectedItems.push(item.name);
                }
            });
            if (selectedItems.length == 1) {
                BrowseLinks.File.insertElement(selectedItems[0]);
            } else {
                BrowseLinks.File.insertElementMultiple(selectedItems);
            }
            BrowseLinks.focusOpenerAndClose(true);
        }
    },

insertElementMultiple Function (browse_links.js)

    insertElementMultiple: function(list) {
        var uidList = [];
        list.each(function(index) {
            if (typeof BrowseLinks.elements[index] !== undefined) {
                var element = BrowseLinks.elements[index];
                uidList.push(element.uid);
            }
        });
        insertMultiple('sys_file', uidList);
        return true;
    }

insertMultiple() (script-Tag)

function insertMultiple(table, uid) {
    var type = "";

    return false;
            }

Solution

My Solution is to alter the script so it only uses the working "insertElement()" function.
Now the Element Browser is importing the whole selection.
Just replace the old file with the new one and it should work!

    handle: function(element) {
        var items = this.getItems(element);
        var selectedItems = [];
        if (items.length) {
            items.each(function(item) {
                if (item.checked && item.name) {
                    BrowseLinks.File.insertElement(item.name);
                }
            });
            BrowseLinks.focusOpenerAndClose(true);
        }
    },
Actions #7

Updated by Sebastian Fischer almost 10 years ago

edited: Got the problem ignore my previous comment

Actions #8

Updated by Malte Riechmann almost 10 years ago

Perfect. Thanks @Nico this worked for me.

Actions #9

Updated by Maik Hagenbruch over 9 years ago

In my 6.2.9 installation this problem is almost there.
I did the solution from the last comment and it works. But is this problem not fixed in core until now?

Actions #10

Updated by Wouter Wolters about 9 years ago

  • Status changed from New to Accepted
  • TYPO3 Version changed from 6.0 to 6.2

This problem still applies in 6.2

Actions #11

Updated by J. Peter M. Schuler about 9 years ago

Problem still exists in 6.2.12; fix from @Nico still works in 6.2.12

Actions #12

Updated by Oskar Hasinski about 9 years ago

Hook Solution

ext_localconf.php

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['typo3/class.browse_links.php']['browseLinksHook'][] = 'Vendor\RegionalObject\Hook\BrowseLinksHook';

BrowseLinksHook.php

namespace Vendor\RegionalObject\Hook;

use TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface;

class BrowseLinksHook implements \TYPO3\CMS\Core\ElementBrowser\ElementBrowserHookInterface
{
    /**
     * Initializes the hook object
     *
     * @param \TYPO3\CMS\Recordlist\Browser\ElementBrowser Parent browse_links object
     * @param array Additional parameters
     * @return void
     */
    public function init($parentObject, $additionalParameters){
        $resourcePathJavaScript = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extRelPath('...') . 'Resources/...';
        $parentObject->doc->loadJavascriptLib("{$resourcePathJavaScript}/browse_links.js");
    }

    /**
     * Adds new items to the currently allowed ones and returns them
     *
     * @param array Currently allowed items
     * @return array Currently allowed items plus added items
     */
    public function addAllowedItems($currentlyAllowedItems){

    }

    /**
     * Modifies the menu definition and returns it
     *
     * @param array    Menu definition
     * @return array Modified menu definition
     */
    public function modifyMenuDefinition($menuDefinition){

    }

    /**
     * Returns a new tab for the browse links wizard
     *
     * @param string Current link selector action
     * @return string A tab for the selected link action
     */
    public function getTab($linkSelectorAction){

    }

    /**
     * Checks the current URL and determines what to do
     *
     * @param string $href
     * @param string $siteUrl
     * @param array $info
     * @return array
     */
    public function parseCurrentUrl($href, $siteUrl, $info){

    }
}

Then extend your insertMultiple with your custom JS.

Or just use the solution from @Nico.

Actions #13

Updated by Alex Borodinov about 9 years ago

Tell me pls, where this file should be allocated? (BrowseLinksHook.php)
Did it with my own extension, allowing to choose in backend, which js to use in import selection

Actions #14

Updated by Gernot Ploiner almost 9 years ago

The bug still exists in TYPO3 6.2.12. Tested with Firefox and Chrome.

Actions #15

Updated by Markus Klein almost 9 years ago

  • Category changed from File Abstraction Layer (FAL) to Backend User Interface
  • Priority changed from Should have to Must have
  • Target version set to 6.2.13
  • Sprint Focus set to Stabilization Sprint

Also present on current master branch.
Can be tested with ext:styleguide -> TCA -> GROUP -> GROUP: 5 internal_type=file, lots of file types allowed, show thumbs

Actions #16

Updated by Frank Nägler almost 9 years ago

The ElementBrowser and specially the JS-Stuff need a complete refactoring.

Actions #17

Updated by Gerrit Code Review almost 9 years ago

  • Status changed from Accepted to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39744

Actions #18

Updated by Gerrit Code Review almost 9 years ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39744

Actions #19

Updated by Gerrit Code Review almost 9 years ago

Patch set 3 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39744

Actions #20

Updated by Frank Nägler almost 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100
Actions #21

Updated by Gerrit Code Review almost 9 years ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch TYPO3_6-2 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at http://review.typo3.org/39906

Actions #22

Updated by Frank Nägler almost 9 years ago

  • Status changed from Under Review to Resolved
Actions #23

Updated by Riccardo De Contardi over 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF