| Philippe VINCENT-ROYOL
                                                                                                                             
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | Monday 14 April 2008 6:39:15 am 
                                                                
                                                                 Hello,  I try to create an import file but ive some problem with image file. This is a partial code : $upload = "/var/www/tmp/my_image.jpg";
$attributes_agenda = array( 	'titre' 	=> $rows[$i]["TITRE"],
					'lieu' 	=> $rows[$i]["LIEU"],
					'texte'	=> $rows[$i]["TEXTE"],
					'date' 	=> $rows[$i]["DATE"],
					'date_fin' => $rows[$i]["DATE_FIN"],
					'image' 	=> $upload
				);
$params = array();
$params['creator_id'] = 14;
$params['parent_node_id'] = $nodeID;
$params['class_identifier'] = 'agenda_formation';
$params['attributes'] = $attributes_agenda;
$object = eZContentFunctions::createAndPublishObject( $params );
 
 My "agenda_formation" class have an image attribute but it doesn't work. All text variable work perfectly..
 I've someone have an idea..
 
Thanks :)Philippe
 Certified Developer (4.1): http://auth.ez.no/certification/verify/272607Certified Developer (4.4): http://auth.ez.no/certification/verify/377321
 
 G+ : http://plus.tl/dspe
 Twitter : http://twitter.com/dspe
 
 | 
                                                
                                                                                                                                                        
                                                        | Philippe VINCENT-ROYOL
                                                                                                                             | Tuesday 15 April 2008 8:32:51 am 
                                                                 Hi Kristof 
 I m using Exponential 3.9.2I've forget to add permission on storage directory ! I m using image and binary file.. my class looks like this :
 
titre : text linelieu : text line
 texte : text block
 date : datetime
 date_fin : datetime
 image : image (via upload)
 fichier : file (via upload)
 Now i find my binary file and can download it.. but its strange.. the debug outpout show, for example: 
SELECT id, contentobject_attribute_id, filepath
                    FROM   ezimagefile
WHERE  filepath='var/nfs/hopital/storage/images-versioned/28290/1-fre-FR/formation_des_administrateurs_des_etablissements_sanitaires_sociaux_et_medico_sociaux1.jpg'
But directorty "images-versioned" don't exists.. and storage have a good permission..  Certified Developer (4.1): http://auth.ez.no/certification/verify/272607Certified Developer (4.4): http://auth.ez.no/certification/verify/377321
 
 G+ : http://plus.tl/dspe
 Twitter : http://twitter.com/dspe
 
 | 
                                                                                                    
                                                        | Philippe VINCENT-ROYOL
                                                                                                                             | Thursday 17 April 2008 2:32:46 am 
                                                                 Now i continue ^^ The last step is to add more file. I've try to use eZContentFunctions::createAndPublishObject( $params ); to add more file but don't find a solution. so i've add this : 
$object = eZContentFunctions::createAndPublishObject( $params );
		
if($fichier2 != "")
{
	include_once("kernel/classes/datatypes/ezbinaryfile/ezbinaryfile.php");
	include_once("lib/ezutils/classes/ezmimetype.php");
	include_once("lib/ezutils/classes/ezdir.php");
				
	$contentObjectAttributes =& $object->contentObjectAttributes();
			
	$attributeValue = $rows[$i]["FIC2_NOM"];
	$contentObjectAttributes[1]->setAttribute('binary_file', $attributeValue);
	$contentObjectAttributes[1]->store();
				
	$contentObjectAttribute =& $contentObjectAttributes[1];
			
	$contentObjectAttributeID = $contentObjectAttribute->attribute("id");
	$version = $contentObjectAttribute->attribute("version");
				
	$file =& eZBinaryFile::create($contentObjectAttributeID, $version);
				
	$file->setAttribute("contentobject_attribute_id", $contentObjectAttributeID);
	$file->setAttribute("version", $version);
	$file->setAttribute("filename", $rows[$i]["FIC2_NOM"]);
	$file->setAttribute("original_filename", $rows[$i]["FIC2_NOM"]);
				
	$mimeObj = new eZMimeType();
	$mime = $mimeObj->mimeTypeFor( false, $rows[$i]["FIC2_NOM"]);
			
	$file->setAttribute("mime_type", $mime);
	$file->store();
				
	$sys =& eZSys::instance();
	$storage_dir = $sys->storageDirectory();
				
	list($subdir, $extension) = split("/",$mime);
	$file_dir = $storage_dir.'/'."original/".$subdir;
	if(!file_exists($file_dir))
	{
		eZDir::mkdir($file_dir,0777,true);
	}
	$source_file = $storage_dir."/temp/".$rows[$i]["FIC2_NOM"];
	$target_file = $storage_dir."/original/".$subdir."/".$rows[$i]["FIC2_NOM"];
	copy($source_file,$target_file);
				
}
So , Exponential have insert lines on ezbinaryfile table but when i want to see on back office the node.. it show only the first file :/ 
Thanks in advance,Philippe
 Certified Developer (4.1): http://auth.ez.no/certification/verify/272607Certified Developer (4.4): http://auth.ez.no/certification/verify/377321
 
 G+ : http://plus.tl/dspe
 Twitter : http://twitter.com/dspe
 
 | 
                                                                                                    
                                                        | Philippe VINCENT-ROYOL
                                                                                                                             | Friday 18 April 2008 5:41:06 am 
                                                                 ok i promise this is the latest question !! Source code was on a module. But i need to place it on a cronjob. 
So i've create my_import.php file .. this is the source code:
 
include_once( 'lib/ezutils/classes/ezcli.php' );
include_once( 'kernel/classes/ezscript.php' );
global $cli;
$cli =& eZCLI::instance();
$script =& eZScript::instance( array( 'description' => ( "Import  Database\n" .
                                                         "\n" .
                                                         "./bin/my_import.php" ),
                                      'debug-message' => '',
                                      'debug-output' => true,
                                      'use-session' => true,
                                      'use-module' => true,
                                      'use-extension' => true ) );
$script->startup();
$scriptOptions = $script->getOptions( "",
                                      "",
                                      array(),
                                      false,
                                      array( 'user' => true )
                                     );
                                     
$script->initialize();
include_once( 'lib/ezdb/classes/ezdb.php' );
include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
include_once( 'kernel/classes/ezcontentfunctions.php' );
$params = array(	'server' => 'localhost',
			'user' => 'root',
			'password' => '',
			'database' => 'FHF',
			'use_slave_server' => 'false',
			'use_persistent_connection' => false
);
$db = eZDB::instance('ezmysql', $params, true);
		
$user = eZuser::fetch( 14 );
eZuser::setCurrentLyLoggedInUser( $user, $user->attribute( 'contentobject_id' ) );
		
$nodeID = "3051";		
$node = eZcontentObjectTreeNode::fetch( $nodeID );
$attribute_node = array( 'name' => 'test');
$param_node['creator_id'] = 14;
$param_node['parent_node_id'] = $nodeID;
$param_node['class_identifier'] = 'folder';
$param_node['attributes'] = $attribute_node;			
			
$object_node = eZContentFunctions::createAndPublishObject( $param_node );
$script->shutdown(0);
and i obtain this debug: 
Fatal error: Exponential did not finish its request
The execution of Exponential was abruptly ended, the debug output is present below.
Notice: (eZMySQLDB::query(0.000 ms) query number per page:0)
SET NAMES 'utf8'
Error: (eZDebug::writeFile)
Cannot open log file 'var/log/notice.log' for writing
The web server must be allowed to modify the file.
File logging for 'var/log/notice.log' is disabled.
Error: (eZDebug::writeFile)
Cannot open log file 'var/log/error.log' for writing
The web server must be allowed to modify the file.
File logging for 'var/log/error.log' is disabled.
Notice: (eZMySQLDB::query(0.000 ms) query number per page:0)
SET NAMES 'utf8'
Warning: (PHP)
Invalid argument supplied for foreach() in /var/www/hopital.fr/hopital.hopital.fr/html/lib/ezutils/classes/ezmoduleoperationinfo.php on line 70
Error: (eZDebug::writeFile)
Cannot open log file 'var/log/warning.log' for writing
The web server must be allowed to modify the file.
File logging for 'var/log/warning.log' is disabled.
Warning: (PHP)
Undefined variable:  definitionFile in /var/www/hopital.fr/hopital.hopital.fr/html/lib/ezutils/classes/ezmoduleoperationinfo.php on line 77
Error: (eZModuleOperationInfo::loadDefinition)
Missing operation definition file for module: content
Error: (eZOperationHandler::execute)
Cannot execute operation 'publish' in module 'content', no valid data
No timing points defined
Group ini_load: 
Load cache: 0.0060 sec (2.5871%), 0.0010 avg sec (6)
FindInputFiles: 0.0022 sec (0.9720%), 0.0004 avg sec (6)
Group Mysql Total: 
Mysql_queries: 0.0135 sec (5.8531%), 0.0005 avg sec (30)
Looping result: 0.0007 sec (0.3210%), 0.0001 avg sec (13)
Group class_abstraction: 
Instantiating content class attribute: 0.0010 sec (0.4349%), 0.0001 avg sec (20)
Group General: 
String conversion: 0.0000 sec (0.0186%), 0.0000 avg sec (1)
Total script time: 0.2314 sec
 I've forget to initialise something? It works on module and not here :/ 
Thanks in advance,Philippe
 Certified Developer (4.1): http://auth.ez.no/certification/verify/272607Certified Developer (4.4): http://auth.ez.no/certification/verify/377321
 
 G+ : http://plus.tl/dspe
 Twitter : http://twitter.com/dspe
 
 |