Problem with an eZPedia article

Author Message

Sébastien Antoniotti

Friday 09 February 2007 12:36:38 pm

Hi,

I'm trying to run this script : http://ezpedia.org/wiki/en/ez/snippet_ez_cli_data_creation_script_unstable

But I get this error

Parse error: syntax error, unexpected '&' in /var/www/eztest/seb.php on line 26

Here is the line 26 :

24 if ( !$class = eZContentClass::fetch( $classID ) )
25 {
26     $cli->output('Error: Could not fetch class');
27 }

And I don't know the signification of this : $cli->

Thanks in advance for your help !

eZ Publish Freelance
web : http://www.webaxis.fr

Paul Borgermans

Friday 09 February 2007 1:22:01 pm

Ok, trouble with conversion of characters:

24 if ( !$class = eZContentClass::fetch( $classID ) )
25 {
26    $cli->output('Error: Could not fetch class');
27 }

hth
Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Sébastien Antoniotti

Friday 09 February 2007 2:09:46 pm

Sorry it was very basic !

eZ Publish Freelance
web : http://www.webaxis.fr

kracker (the)

Friday 09 February 2007 6:23:19 pm

An I knowingly admit respect for the contributor of this article,
yet simply because of the reasons above and ... principle,
could we change the primary storage location for this source
code to reside (with crosslinks) in PubSVN instead of eZpeadia.

Let us all read eZpedia but keep the runtime sources for completed tools like this in PubSVN no?

//kracker

<b>DMX - Ruff Ryders Anthem...</b>
It's just an idea, not a believe ... I swear.

Member since: 2001.07.13 || http://ezpedia.se7enx.com/

Sébastien Antoniotti

Friday 09 February 2007 11:52:08 pm

I'm sorry but I don't understand all the sense of your last reply (my english is poor...).

eZ Publish Freelance
web : http://www.webaxis.fr

Sébastien Antoniotti

Saturday 10 February 2007 12:07:51 am

It's me again =)

I get a new error trying to insert html data like "word<br />word2" into a xml bloc attribute.

I have found this page : http://ez.no/ezpublish/documentation/development/importing_attribute_data

and here is how I use it :

$classID = 17;
$nodeID = 79;
 
if ( !$class = eZContentClass::fetch( $classID ) )
{
    $cli->output('Error: Could not fetch class');
}
 
$node = eZContentObjectTreeNode::fetch($nodeID);
if (!$node)
{    
    $cli->output('Error: no mapped parent node');        
}
 
$object =& $class->instantiate();        
if (!$object)
{
    $cli->output('Error: could not create object');
}
 
$objectID = $object->attribute( 'id' );
$cli->output('Object ID: ' . $objectID);
$cli->output('Node ID: ' . $nodeID);
$cli->output();
$nodeAssignment = eZNodeAssignment::create( array( 'contentobject_id' => $objectID,
                                                   'contentobject_version' => 1,
                                                   'parent_node' => $nodeID,
                                                   'is_main' => 1 ) 
                                           );
$nodeAssignment->store();
 
$dataMap =& $object->dataMap();
foreach( array_keys( $dataMap ) as $key )
{
    $cli->output($key);
 
    $attribute =& $dataMap[$key];
    $classAttributeID = $attribute->attribute( 'contentclassattribute_id' );
    switch ($key){
    	case 'titre':
		    $attribute->setAttribute( 'data_text',$title );    
    		break;
    	case 'contenu':
    		$contentClassAttribute = $attribute->attribute( 'contentclass_attribute' ); 
			$dummy = "";            
			$converter = new text2xml( $dummy, 0, $contentClassAttribute );            
			$converter->validateText( $introtext, $contentClassAttribute );            
			$attribute->SetAttribute( 'data_int', EZ_XMLTEXT_VERSION_TIMESTAMP );  
    		break;    	
    		
    }

    $attribute->store();
}
 
if ( !eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $objectID, 'version' => 1 ) ) )
{
    // TODO:
    // add to the list of errors
    $cli->output('Error: Could not execute');
}

$introtext is my html text queried in a database, and the definition of the text2xml class is included at bottom of the script.(I have paste them into an external php file).

So I get this error :

Fatal error: Call to a member function on a non-object in /var/www/eztest/convert.php on line 97

And here is the line 97 :

           $objects =& $dom->elementsByName( 'object' );

If I don't try to set this xml bloc attribute my object is nicely created, so the rest of the code is ok (I get it on eZpedia ;-))

Sorry for all this questions !

eZ Publish Freelance
web : http://www.webaxis.fr

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.