Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for UUID for files. #5

Open
stefanheimes opened this issue Feb 13, 2020 · 2 comments
Open

Add support for UUID for files. #5

stefanheimes opened this issue Feb 13, 2020 · 2 comments
Assignees
Labels
bug Something isn't working enhancement New feature or request
Milestone

Comments

@stefanheimes
Copy link
Member

stefanheimes commented Feb 13, 2020

I found a little problem with fileTree Widgets in the MCW and this attribute. The sql use for the value field a simple text type so all binary data would not be readable. So we have to checnge the binary data back to a string.

    /**
     * {@inheritdoc}
     */
    public function valueToWidget($varValue)
    {
        if (!is_array($varValue)) {
            return array();
        }

        $widgetValue = array();
        foreach ($varValue as $row) {
            foreach ($row as $col) {
                // We can't handle binary data so we have to replace it.
                if (Validator::isStringUuid($col['value'])) {
                    $col['value'] = StringUtil::uuidToBin($col['value']);
                }
                $widgetValue[$col['row']]['col_' . $col['col']] = $col['value'];
            }
        }

        return $widgetValue;
    }

    /**
     * {@inheritdoc}
     */
    public function widgetToValue($varValue, $itemId)
    {

        if (!is_array($varValue)) {
            return array();
        }

        $newValue = array();
        // Start row numerator at 0.
        $intRow = 0;
        foreach ($varValue as $k => $row) {
            foreach ($row as $kk => $col) {
                $kk = substr($kk, 4);

                // We cant handle binary data so we have to replace it back to string.
                if(Validator::isBinaryUuid($col)){
                    $col = StringUtil::binToUuid($col);
                }

                $newValue[$k][$kk]['value'] = $col;
                $newValue[$k][$kk]['col']   = $kk;
                $newValue[$k][$kk]['row']   = $intRow;
            }
            $intRow++;
        }

        return $newValue;
    }
@stefanheimes
Copy link
Member Author

We have to check multiple files as well.

@stefanheimes stefanheimes added bug Something isn't working enhancement New feature or request labels Feb 13, 2020
@stefanheimes stefanheimes self-assigned this Feb 13, 2020
@zonky2 zonky2 added this to the 2.1.3 milestone Feb 13, 2020
@discordier
Copy link
Member

IMO ir would be better to check if the sub field type is file picker as your implementation now prevents using uuids entirely as it converts them to binary in all cases.

@zonky2 zonky2 modified the milestones: 2.1.3, 2.2.2 Jan 5, 2023
@zonky2 zonky2 modified the milestones: 2.2.2, 2.3.0 Mar 29, 2023
@zonky2 zonky2 modified the milestones: 2.3.0, Future Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants