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.

eZ debug

Timing: Jan 21 2025 21:07:31
Script start
Timing: Jan 21 2025 21:07:31
Module start 'layout'
Timing: Jan 21 2025 21:07:31
Module start 'content'
Timing: Jan 21 2025 21:07:32
Module end 'content'
Timing: Jan 21 2025 21:07:32
Script end

Main resources:

Total runtime1.3343 sec
Peak memory usage4,096.0000 KB
Database Queries68

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0135 587.9141151.2109
Module start 'layout' 0.01350.0039 739.125036.6484
Module start 'content' 0.01751.3159 775.7734664.5156
Module end 'content' 1.33340.0009 1,440.289119.8516
Script end 1.3343  1,460.1406 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00470.3514160.0003
Check MTime0.00160.1235160.0001
Mysql Total
Database connection0.00140.108510.0014
Mysqli_queries1.245793.3579680.0183
Looping result0.00090.0644660.0000
Template Total1.269795.220.6348
Template load0.00370.275920.0018
Template processing1.266094.880520.6330
Template load and register function0.00020.016610.0002
states
state_id_array0.00180.136910.0018
state_identifier_array0.00170.124520.0008
Override
Cache load0.00330.2510480.0001
Sytem overhead
Fetch class attribute can translate value0.00130.098030.0004
Fetch class attribute name0.00170.126690.0002
XML
Image XML parsing0.00520.388530.0017
class_abstraction
Instantiating content class attribute0.00000.0020120.0000
General
dbfile0.00730.5446310.0002
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
6content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
6content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
6content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
3content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 36
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs