Author Topic

Betsy Gamrat

Tuesday 23 January 2007 5:27:14 am

Comment47607

kracker and Kristof,

Thank you for your ideas.

I contacted eZ support, and Kristian Hole was a great help.

I liked the <b>insertRegularFile</b> function and used it. It first goes through ezdatatype, and ultimately, in this case, ends in ezbinaryfiletype.php.

I suspect this code will work with images, too.

There is a bugfix that was necessary. The link is at the end of this post.

:)

<b>Solution</b> <i>(based on the ubiquitous create.php script)</i>


/* eZBinaryFile includes */
include_once( "kernel/classes/ezdatatype.php" );

...
        // Loop through the attributes, processing each one
        foreach (array_keys($contentObjectAttributes) as $key)
        {
                $contentObjectAttribute =& $contentObjectAttributes[$key];
                $contentClassAttribute =& $contentObjectAttribute->contentClassAttribute();
                $attributeName = $contentClassAttribute->attribute('name');

                switch ($attributeName)
                {
                        case 'Filename to store':
                                store($contentClassAttribute->attribute('identifier'),$contentObject,$contentObjectVersion,false,$contentObjectAttribute,$uPDFfilename );
                                $contentObjectAttribute->store();
                                break;
...

// This function stores the file.
function store($id,&$contentObject,$contentObjectVersion,$objectLanguage,&$contentObjectAttribute,$sourceFile )
{
$dataMap =& $contentObject->dataMap();
$status = $dataMap[$id]->insertRegularFile( $contentObject, $contentObjectVersion, $objectLanguage,$sourceFile,$result );
}

http://issues.ez.no/IssueView.php?Id=10070