ez projects / data_import / forum / general / the method update_ez_node / re: the method update_ez_node
You need to be logged in to post messages in the forums. New users may register here.
Member since: Posts: 15 |
Thursday 28 August 2008 1:33:37 pm Hi Philipp,
It's a good extension, and I'm using it. I want to know when the method update_eZ_node will be done ? And I make a LaAbstractClass for my project, maybe you can add it in the project. Can I join in your team ? <?php /* * LaAbstractClass * LIU Bin * bin.liu@lagardere-active.com * */ class LaAbstractClass extends XmlHandlerPHP5 { public $handlerTitle ; protected $current_loc_info = array(); protected $logfile ; protected $parent_node_id; protected $section_id = 1; protected $ini; protected $file; protected $remote_identify; protected $xml_root; protected $class_idendify; protected $mappingTable; public function setFile($file) { $this->file = $file; } // mapping for xml field name and attribute name in ez publish public function geteZAttributeIdentifierFromField() { $field_name = $this->current_field->tagName; $mappingData = $this->ini->variable("mappingAttributeName", $this->mappingTable); return isset($mappingData[$field_name]) ? $mappingData[$field_name] : false; } // handles xml fields before storing them in ez publish public function getValueFromField() { return $this->current_field->nodeValue; } // logic where to place the current content node into the content tree public function getParentNodeId() { return $this->parent_node_id; } public function getSectionId() { return $this->section_id; } public function setParentNodeId($parent_node_id) { return $this->parent_node_id = $parent_node_id; } public function getDataRowId() { $remote_id = $this->current_row->firstChild->nextSibling->nextSibling->nextSibling->nodeValue; return $this->remote_identify.$remote_id; } public function readData() { return $this->parse_xml_document( $this->file , $this->xml_root ); } public function post_publish_handling( $eZ_object, $force_exit ) { $force_exit = false; return true; } public function getTargetContentClass() { return $this->class_idendify; } } ?> and for each class, like image, disporama, etc. <?php class Diaporama extends LaAbstractClass { public $xml_root = "diaporamas"; protected $class_idendify = "diaporama"; public function __construct() { $this->handlerTitle = __CLASS__." Handler"; $this->logfile = __CLASS__."_import.log"; $this->remote_identify = __CLASS__."_xml_"; $this->ini = new eZINI("import.ini.append.php"); $this->parent_node_id = $this->ini->variable("ParentNodeId",__CLASS__); $this->mappingTable = "mapping".__CLASS__; } // handles xml fields before storing them in ez publish public function getValueFromField() { switch( $this->current_field->tagName ) { case 'diaporama_id': $id = preg_replace("/[_a-z]/","",$this->current_field->nodeValue); return $id; break; default: { return $this->current_field->nodeValue; } } } } ?> My import.ini <?php /* #?ini charset="utf-8"? [UserSettings] UserCreatorID=4769 [ParentNodeId] Diaporama=5929 Personnalite=5931 [mappingAttributeName] #mappingClassName[xmlAttributeName]=ezAttributeName mappingDiaporama[diaporama_id]=id_source mappingDiaporama[diaporama_titre]=titre mappingPersonnalite[personne_id]=id_source mappingPersonnalite[personne_plurimediaid]=plurimedia_id mappingPersonnalite[personne_prenom]=prenom mappingPersonnalite[personne_nom]=nom [Path] PathIn=extension/data_import/dataSource/importIn/ PathOut=extension/data_import/dataSource/importOut/ FilePrefix=premiere- */ ?> === Lagardère Active === |
|
Member since: Posts: 15 |
Thursday 28 August 2008 1:38:53 pm Add create user, because now the create user is anonymous.
In importOperator.php public $user_id = 14; //by default admin public function setUserId($id) { $this->user_id = $id; } function setNodesPriority() { ***** $eZ_object = $eZClass->instantiate( $this->user_id, $this->source_handler->getSectionId()); ***** } $ini = new eZINI("import.ini.append.php"); $userCreatorID = $ini->variable("UserSettings","UserCreatorID"); $handler = new Diaporama(); $operator = new ImportOperator( $handler ); $operator->setUserId($userCreatorID); $operator->run(); === Lagardère Active === |
|
Member since: Posts: 15 |
Thursday 28 August 2008 1:39:07 pm And a little bug
add static for the function HandleXmlError static function HandleXmlError($errno, $errstr, $errfile, $errline) === Lagardère Active === |
|
Member since: Posts: 11 |
Friday 29 August 2008 8:20:18 pm LIU Bin,
I really like the idea to be able to set the owner of imported objects. I will add a method to the SourceHandler to get the owner info -- per default it will read the config file to get it. But you would be able to override the method in your custom import scripts to determine the owner for each imported object. I just had a quick look to your abstract handler - I'm not sure why you want me to include the handler in the extension. It looks pretty specific to your project and I'm not sure why it is interesting for other people. But maybe I'm just missing an important point here. Let me know. Regards, Philipp http://www.mugo.ca |
|
Member since: Posts: 11 |
Friday 29 August 2008 8:24:00 pm I tried to add you as a member - but I don't know how to do it :(
http://www.mugo.ca |
|
Member since: Posts: 15 |
Monday 01 September 2008 10:56:24 am Hi Philipp,
Thanks for you reply. You use contentObjectAttribute->fromString( $value ); is a really good idea. forget the LaAbstractClass, I thought maybe it's a good example use the ini config. but just forget it. And could you please tell me if the update_eZ_node is in your roadmap ? and when ? Thanks a lot. Best, Bin === Lagardère Active === |
|
Member since: Posts: 15 |
Monday 01 September 2008 10:59:33 am I tried to add you as a member - but I don't know how to do it :(
And for this, I click the 'Register membership', and I think you have a buttun "approve" somewhere. === Lagardère Active === |
You need to be logged in to post messages in the forums. New users may register here.