Skip to content

Add support for UUID for files. #5

@stefanheimes

Description

@stefanheimes

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;
    }

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingenhancementNew feature or request

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions