eZ Community » Forums » Developer » eZInformationCollection fetch...
expandshrink

eZInformationCollection fetch information collector data CLI

eZInformationCollection fetch information collector data CLI

Wednesday 25 March 2009 11:42:06 am - 1 reply

Hi,

I have been trying to figure out how to use php to get information collector data as I need to export it as xml for a external application to use.

I am able to get the collection ids, but not to get the collected info for each collection.

What I probably need is simply to have this:

{def $collection=fetch( 'content', 'collected_info_collection',
                        hash( 'collection_id',    123,
                              'contentobject_id', 456 ) )}

in the php format ?

below is my script I am trying:


#!/usr/bin/env php
<?php 
 
 require 'autoload.php';
 
include_once( 'lib/ezutils/classes/ezcli.php' );
include_once( 'kernel/classes/ezscript.php' );
 
$cli =& eZCLI::instance();
$script =& eZScript::instance();
 
$script->startup();
 
$options = $script->getOptions();
 
$script->initialize();
 
	//include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
	include_once( 'kernel/classes/ezcontentclass.php' );
	include_once( 'kernel/classes/ezcontentobject.php' );
	include_once( 'kernel/classes/ezinformationcollection.php' );
	
	 
	$objectID = 887;
                                                               
	$collections = eZInformationCollection::fetchCollectionsList(
											                 $objectID,
											                 false,
											                 false,
											                 array() ); 
                                                                  
	$numberOfCollections = eZInformationCollection::fetchCollectionCountForObject( $objectID ); 
	 
	 
	 /*{def $collection=fetch( 'content', 'collected_info_collection',
                        hash( 'collection_id',    123,
                              'contentobject_id', 456 ) )}*/

	
	
	/*$v0 = var_export($collections);	
	$cli->output($v0);*/

	$node = eZInformationCollection::fetch( 2 );
	
	$v0 = var_export($node);	
	$cli->output($v0);
	
	$cli->output("node2::");
	
	$node2 = eZInformationCollection::fetch( 534 );
	
	$v02 = var_export($node2);	
	$cli->output($v02);
		
	
	$cli->output("by identifier::");
	
	$node3 = eZInformationCollection::fetchByUserIdentifier( '64sbs9p4krcpe7ba0vp7ico4r2' , $objectID );
	
	$v03 = var_export($node3);	
	$cli->output($v03);
		
	/*foreach($collections as $collection) {
				
		$v2 = var_export($collection);

		$cli->output($v2);
		$cli->output("colitemID:" );
		$cli->output($collection->ID);
		
	}*/
		
	//write to file
	/*$myFile = "testWrite.php";
	$fh = fopen($myFile, 'w') or die("can't open file");
	$stringData = "Floppy Jalopy\n";
	fwrite($fh, $stringData);
	fclose($fh);*/
	 
	//$cli->output("NumberCollections:  ".$numberOfCollections );
	//$cli->output($v );
	
 
$script->shutdown();
 
?>

I have installed the extension http://projects.ez.no/cie which works well, however have tried running the cronjob and doenst work, I get errors.

Thursday 23 February 2012 2:03:22 pm

Fetching Information Collection in eZ 4.2 in php cli (only snippets);

 $collectionID = 4711;
    $collections = eZInformationCollection::fetchCollectionsList(
        $collectionID,
        false,
        false,
        array() );

$collection_count = eZInformationCollection::fetchCollectionCountForObject( $collectionID );

foreach ($collections as $collection) {
        $cli->output("Infocollection ID: " . $collection->ID);

        $collObj = eZContentObject::fetch( $collection->ID );
        $objectName = $object->attribute( 'name' );
        $cli->output("Infocollection Name: " . $objectName);

        $attributes=$object->contentObjectAttributes();
        foreach ($attributes as $my_attribute)
        {
            switch ( $my_attribute->attribute( 'data_type_string' ) )
            {
                  case "ezstring":
                  {
                    $cli->output("Infocollection Attr Content: " . $my_attribute->content());
                  }break;
                  default:
                  {
                      $cli->output("Unsupported attribute: " . $my_attribute->attribute( 'data_type_string' ));
                  }break;
            }

        }
}
expandshrink

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu