public function writeToPersistence()
 {
     if (empty($this->uuid)) {
         $this->uuid = io::uuid();
     }
     $fields = array('objectdefinition', 'codename', 'html', 'label', 'parameter', 'uuid');
     $sql_fields = '';
     foreach ($fields as $field) {
         $sql_fields .= empty($sql_fields) ? '' : ', ';
         $sql_fields .= $field . '_mood="' . CMS_query::echap($this->{$field}) . '"';
     }
     if ($this->id) {
         $sql = 'UPDATE mod_object_oembed_definition SET ' . $sql_fields . ' WHERE id_mood = ' . $this->id;
     } else {
         $sql = 'INSERT INTO mod_object_oembed_definition SET ' . $sql_fields;
     }
     $q = new CMS_query($sql);
     if ($q->hasError()) {
         $this->raiseError("Can't save object");
         return false;
     } elseif (!$this->id) {
         $this->id = $q->getLastInsertedID();
     }
 }
Esempio n. 2
0
 /**
  * Import field from given array datas
  *
  * @param array $data The module datas to import
  * @param array $params The import parameters.
  *		array(
  *				create	=> false|true : create missing objects (default : true)
  *				update	=> false|true : update existing objects (default : true)
  *				files	=> false|true : use files from PATH_TMP_FS (default : true)
  *			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (isset($data['labels'])) {
         $label = new CMS_object_i18nm($this->getValue("labelID"));
         $label->setValues($data['labels']);
         $label->writeToPersistence();
         $this->setValue("labelID", $label->getID());
     }
     if (isset($data['descriptions'])) {
         $description = new CMS_object_i18nm($this->getValue("descriptionID"));
         $description->setValues($data['descriptions']);
         $description->writeToPersistence();
         $this->setValue("descriptionID", $description->getID());
     }
     if (isset($data['type']) && $data['type']) {
         $type = !io::isPositiveInteger($data['type']) ? $data['type'] : (isset($data['multi']) && $data['multi'] ? 'multi|' . $data['type'] : $data['type']);
         if (!io::isPositiveInteger($data['type'])) {
             $type = $data['type'];
         } else {
             if (isset($idsRelation['objects'][$data['type']])) {
                 $objectId = $idsRelation['objects'][$data['type']];
                 $type = isset($data['multi']) && $data['multi'] ? 'multi|' . $objectId : $objectId;
             } else {
                 // Use UUID to look for the linked object
                 if (isset($data['params']['linkedObjectUuid'])) {
                     //$this->setValue("order", $data['params']['order']);
                     $linkedObjectDef = CMS_poly_object_catalog::getDefinitionFromUuid($data['params']['linkedObjectUuid']);
                     if ($linkedObjectDef) {
                         $objectId = $linkedObjectDef->getID();
                         $type = isset($data['multi']) && $data['multi'] ? 'multi|' . $objectId : $objectId;
                     } else {
                         $type = 'Unknown imported type ' . $data['type'];
                     }
                 } else {
                     $type = 'Unknown imported type ' . $data['type'];
                 }
             }
         }
         $this->setValue("type", $type);
     } else {
         $infos .= 'Error : missing or invalid type for field importation ...' . "\n";
         return false;
     }
     if (!$this->getID() && CMS_poly_object_catalog::fieldUuidExists($data['uuid'])) {
         //check imported uuid. If objects does not have an Id, the uuid must be unique or must be regenerated
         $uuid = io::uuid();
         //store old uuid relation
         $idsRelation['fields-uuid'][$data['uuid']] = $uuid;
         $data['uuid'] = $uuid;
     }
     //set object uuid if not exists
     if (!$this->_objectFieldValues["uuid"]) {
         $this->_objectFieldValues["uuid"] = $data['uuid'];
     }
     //if current object id has changed from imported id, set relation
     if (isset($idsRelation['objects'][$data['objectID']]) && $idsRelation['objects'][$data['objectID']]) {
         $this->setValue("objectID", $idsRelation['objects'][$data['objectID']]);
     } else {
         $this->setValue("objectID", $data['objectID']);
     }
     if (isset($data['params']['order'])) {
         $this->setValue("order", $data['params']['order']);
     }
     if (isset($data['params']['required'])) {
         $this->setValue("required", $data['params']['required']);
     }
     if (isset($data['params']['indexable'])) {
         $this->setValue("indexable", $data['params']['indexable']);
     }
     if (isset($data['params']['searchlist'])) {
         $this->setValue("searchlist", $data['params']['searchlist']);
     }
     if (isset($data['params']['searchable'])) {
         $this->setValue("searchable", $data['params']['searchable']);
     }
     //parameters
     if (!io::isPositiveInteger($data['type']) || isset($data['multi']) && $data['multi']) {
         $fieldObject = $this->getTypeObject();
         $GLOBALS['moduleCodename'] = $params['module'];
         if ($fieldObject && isset($data['params']['params']) && $data['params']['params']) {
             if (method_exists($fieldObject, 'treatParams')) {
                 $params = $fieldObject->treatParams($data['params']['params'], '');
                 if ($params) {
                     $this->setValue("params", $params);
                     //set this object into definition to convert array so it can be converted again at end of import process
                     $idsRelation['definitionToConvert'][] = $this;
                     //store field to convert params at end of import
                     if (method_exists($fieldObject, 'importParams')) {
                         $idsRelation['paramsFieldsToConvert'][] = $this;
                     }
                 } else {
                     $infos .= 'Error : missing or invalid parameters for field importation ...' . "\n";
                     return false;
                 }
             }
         }
     }
     //write field
     if (!$this->writeToPersistence()) {
         $infos .= 'Error : can not write object field ...' . "\n";
         return false;
     }
     //if current field id has changed from imported id, set relation
     if (isset($data['id']) && $data['id'] && $this->getID() != $data['id']) {
         $idsRelation['fields'][$data['id']] = $this->getID();
         if (isset($data['uuid']) && $data['uuid']) {
             $idsRelation['fields'][$data['uuid']] = $this->getID();
         }
     }
     return true;
 }
Esempio n. 3
0
 /**
  * Import row from given array datas
  *
  * @param array $data The module datas to import
  * @param array $params The import parameters.
  *		array(
  *				create	=> false|true : create missing objects (default : true)
  *				update	=> false|true : update existing objects (default : true)
  *				files	=> false|true : use files from PATH_TMP_FS (default : true)
  *			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (!$this->getID() && CMS_rowsCatalog::uuidExists($data['uuid'])) {
         //check imported uuid. If rows does not have an Id, the uuid must be unique or must be regenerated
         $uuid = io::uuid();
         //store old uuid relation
         $idsRelation['rows-uuid'][$data['uuid']] = $uuid;
         $data['uuid'] = $uuid;
     }
     //set uuid if not exists
     if (!$this->_uuid) {
         $this->_uuid = $data['uuid'];
     }
     //icon
     if (!isset($params['files']) || $params['files'] == true) {
         if (isset($data['image'])) {
             $icon = $data['image'];
             //create icon (do not update existing icon)
             if ($icon && file_exists(PATH_TMP_FS . $icon) && !file_exists(PATH_REALROOT_FS . $icon)) {
                 //move and rename icon file
                 $filename = PATH_TMP_FS . $icon;
                 $basename = pathinfo($filename, PATHINFO_BASENAME);
                 if ($basename != 'nopicto.gif') {
                     if (CMS_file::copyTo($filename, PATH_REALROOT_FS . $icon)) {
                         //set it
                         $this->setImage($basename);
                     }
                 }
             }
         }
     }
     //label
     if (isset($data['label'])) {
         $this->setLabel($data['label']);
     }
     //description
     if (isset($data['description'])) {
         $this->setDescription($data['description']);
     }
     //groups
     if (isset($data['groups'])) {
         $this->delAllGroups();
         $groups = explode(';', $data['groups']);
         foreach ($groups as $group) {
             if ($group) {
                 $this->addGroup($group);
             }
         }
     }
     //usability
     if (isset($data['useable'])) {
         $this->setUsability($data['useable']);
     }
     //definition & module
     if (!isset($params['files']) || $params['files'] == true) {
         if (isset($data['definition']) && $data['definition']) {
             if (!isset($params['updateRows']) || $params['updateRows'] == true) {
                 //set definition (and unescape cdata)
                 $return = $this->setDefinition(str_replace(']]\\>', ']]>', $data['definition']), false);
                 if ($return !== true) {
                     $infos .= 'Error : cannot set row definition ... : ' . $return . "\n";
                     return false;
                 }
             }
         }
     }
     //write object
     if (!$this->writeToPersistence()) {
         $infos .= 'Error : cannot write row ...' . "\n";
         return false;
     }
     //if current row id has changed from imported id, set relation
     if (isset($data['id']) && $data['id'] && $this->getID() != $data['id']) {
         $idsRelation['rows'][$data['id']] = $this->getID();
     }
     //set this object into definition to convert array so it can be converted again at end of import process
     $idsRelation['definitionToConvert'][] = $this;
     return true;
 }
Esempio n. 4
0
 /**
  * Import row from given array datas
  *
  * @param array $data The module datas to import
  * @param array $params The import parameters.
  *		array(
  *				module	=> false|true : the module to create categories (required)
  *				create	=> false|true : create missing objects (default : true)
  *				update	=> false|true : update existing objects (default : true)
  *				files	=> false|true : use files from PATH_TMP_FS (default : true)
  *			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (!isset($params['module'])) {
         $infos .= 'Error : missing module codename for categories importation ...' . "\n";
         return false;
     }
     $module = CMS_modulesCatalog::getByCodename($params['module']);
     if ($module->hasError()) {
         $infos .= 'Error : invalid module for categories importation : ' . $params['module'] . "\n";
         return false;
     }
     if (!$this->getID() && CMS_moduleCategories_catalog::uuidExists($data['uuid'])) {
         //check imported uuid. If categories does not have an Id, the uuid must be unique or must be regenerated
         $uuid = io::uuid();
         //store old uuid relation
         $idsRelation['categories-uuid'][$data['uuid']] = $uuid;
         $data['uuid'] = $uuid;
     }
     //set category uuid if not exists
     if (!$this->_uuid) {
         $this->_uuid = $data['uuid'];
     }
     if (!isset($params['files']) || $params['files'] == true) {
         if (isset($data['icon'])) {
             $icon = $data['icon'];
             if ($icon && file_exists(PATH_TMP_FS . $icon)) {
                 //destroy old file if any
                 if ($this->getIconPath(false, PATH_RELATIVETO_WEBROOT, true)) {
                     @unlink($this->getIconPath(true, PATH_RELATIVETO_FILESYSTEM, true));
                     $this->setAttribute('icon', '');
                 }
                 //move and rename uploaded file
                 $filename = PATH_TMP_FS . $icon;
                 $basename = pathinfo($filename, PATHINFO_BASENAME);
                 if (!$this->getID()) {
                     //need item ID
                     $this->writeToPersistence();
                 }
                 //create file path
                 $path = $this->getIconPath(true, PATH_RELATIVETO_FILESYSTEM, false) . '/';
                 $extension = pathinfo($icon, PATHINFO_EXTENSION);
                 $newBasename = "cat-" . $this->getID() . "-icon." . $extension;
                 $newFilename = $path . '/' . $newBasename;
                 if (CMS_file::moveTo($filename, $newFilename)) {
                     CMS_file::chmodFile(FILES_CHMOD, $newFilename);
                     //set it
                     $this->setAttribute('icon', $newBasename);
                 }
             } elseif (!$icon) {
                 //destroy old file if any
                 if ($this->getIconPath(false, PATH_RELATIVETO_WEBROOT, true)) {
                     @unlink($this->getIconPath(true, PATH_RELATIVETO_FILESYSTEM, true));
                     $this->setAttribute('icon', '');
                 }
             }
         }
     }
     if (isset($data['labels'])) {
         foreach ($data['labels'] as $language => $label) {
             $this->setLabel($label, $language);
         }
     }
     if (isset($data['descriptions'])) {
         foreach ($data['descriptions'] as $language => $desc) {
             $this->setDescription($desc, $language);
         }
     }
     if (!isset($params['files']) || $params['files'] == true) {
         if (isset($data['files']) && is_array($data['files'])) {
             foreach ($data['files'] as $language => $file) {
                 if ($file && file_exists(PATH_TMP_FS . $file)) {
                     //destroy old file if any
                     if ($this->getFilePath($language, false, PATH_RELATIVETO_WEBROOT, true)) {
                         @unlink($this->getFilePath($language, true, PATH_RELATIVETO_FILESYSTEM, true));
                         $this->setFile('', $language);
                     }
                     //move and rename uploaded file
                     $filename = PATH_TMP_FS . $file;
                     $basename = pathinfo($filename, PATHINFO_BASENAME);
                     if (!$this->getID()) {
                         //need item ID
                         $this->writeToPersistence();
                     }
                     //create file path
                     $path = $this->getFilePath($language, true, PATH_RELATIVETO_FILESYSTEM, false) . '/';
                     $extension = pathinfo($file, PATHINFO_EXTENSION);
                     $newBasename = "cat-" . $this->getID() . "-file-" . $language . "." . $extension;
                     $newFilename = $path . '/' . $newBasename;
                     if (CMS_file::moveTo($filename, $newFilename)) {
                         CMS_file::chmodFile(FILES_CHMOD, $newFilename);
                         //set it
                         $this->setFile($newBasename, $language);
                     }
                 } elseif (!$file) {
                     //destroy old file if any
                     if ($this->getFilePath($language, false, PATH_RELATIVETO_WEBROOT, true)) {
                         @unlink($this->getFilePath($language, true, PATH_RELATIVETO_FILESYSTEM, true));
                         $this->setFile('', $language);
                     }
                 }
             }
         }
     }
     //write object
     if (!$this->writeToPersistence()) {
         $infos .= 'Error : can not write category ...' . "\n";
         return false;
     }
     //if current category id has changed from imported id, set relation
     if (isset($data['id']) && $data['id'] && $this->getID() != $data['id']) {
         $idsRelation['categories'][$data['id']] = $this->getID();
         if (isset($data['uuid']) && $data['uuid']) {
             $idsRelation['categories'][$data['uuid']] = $this->getID();
         }
     }
     //set category order
     if (isset($data['order']) && $data['order']) {
         CMS_moduleCategories_catalog::moveCategoryIndex($this, $data['order']);
     }
     //set categories childs
     if (isset($data['childs']) && $data['childs']) {
         return CMS_moduleCategories_catalog::fromArray($data['childs'], $params, $cms_language, $idsRelation, $infos);
     }
     return true;
 }
 /**
  * Import object from given array datas
  *
  * @param array $data The object datas to import
  * @param array $params The import parameters.
  *		array(
  *				module	=> false|true : the module to create object (required)
  *				create	=> false|true : create missing objects (default : true)
  *				update	=> false|true : update existing objects (default : true)
  *				files	=> false|true : use files from PATH_TMP_FS (default : true)
  *			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (!isset($params['module'])) {
         $infos .= 'Error : missing module codename for object importation ...' . "\n";
         return false;
     }
     $module = CMS_modulesCatalog::getByCodename($params['module']);
     if ($module->hasError()) {
         $infos .= 'Error : invalid module for object importation : ' . $params['module'] . "\n";
         return false;
     }
     if (!$this->getID() && CMS_poly_object_catalog::objectUuidExists($data['uuid'])) {
         //check imported uuid. If objects does not have an Id, the uuid must be unique or must be regenerated
         $uuid = io::uuid();
         //store old uuid relation
         $idsRelation['objects-uuid'][$data['uuid']] = $uuid;
         $data['uuid'] = $uuid;
     }
     //set object uuid if not exists
     if (!$this->_objectValues["uuid"]) {
         $this->_objectValues["uuid"] = $data['uuid'];
     }
     if (isset($data['labels'])) {
         $label = new CMS_object_i18nm($this->getValue("labelID"));
         $label->setValues($data['labels']);
         $label->writeToPersistence();
         $this->setValue("labelID", $label->getID());
     }
     if (isset($data['descriptions'])) {
         $description = new CMS_object_i18nm($this->getValue("descriptionID"));
         $description->setValues($data['descriptions']);
         $description->writeToPersistence();
         $this->setValue("descriptionID", $description->getID());
     }
     if (isset($data['params']['resourceUsage'])) {
         $this->setValue("resourceUsage", $data['params']['resourceUsage']);
     }
     if (isset($data['params']['admineditable'])) {
         $this->setValue("admineditable", $data['params']['admineditable']);
     }
     if (isset($data['params']['indexable'])) {
         $this->setValue("indexable", $data['params']['indexable']);
     }
     if (isset($data['params']['multilanguage'])) {
         $this->setValue("multilanguage", $data['params']['multilanguage']);
     }
     if (isset($data['params']['composedLabel'])) {
         $this->setValue("composedLabel", $module->convertDefinitionString($data['params']['composedLabel'], false));
     }
     if (isset($data['params']['previewURL'])) {
         $this->setValue("previewURL", $module->convertDefinitionString($data['params']['previewURL'], false));
     }
     if (isset($data['params']['indexURL'])) {
         $this->setValue("indexURL", $module->convertDefinitionString($data['params']['indexURL'], false));
     }
     if (isset($data['params']['resultsDefinition'])) {
         $this->setValue("resultsDefinition", $module->convertDefinitionString($data['params']['resultsDefinition'], false));
     }
     //write object
     if (!$this->writeToPersistence()) {
         $infos .= 'Error : can not write object ...' . "\n";
         return false;
     }
     //if current object id has changed from imported id, set relation
     if (isset($data['id']) && $data['id'] && $this->getID() != $data['id']) {
         $idsRelation['objects'][$data['id']] = $this->getID();
     }
     //set this object into definition to convert array so it can be converted again at end of import process
     $idsRelation['definitionToConvert'][] = $this;
     $return = true;
     //object fields
     if (isset($data['fields'])) {
         foreach ($data['fields'] as $fieldDatas) {
             $importType = '';
             if (isset($fieldDatas['type'])) {
                 if (isset($fieldDatas['uuid']) && ($id = CMS_poly_object_catalog::fieldExists($params['module'], $fieldDatas['uuid']))) {
                     //field already exist : load it if we can update it
                     if (!isset($params['update']) || $params['update'] == true) {
                         $field = new CMS_poly_object_field($id);
                         $importType = ' (Update)';
                     }
                 } else {
                     //create new field if we can
                     if (!isset($params['create']) || $params['create'] == true) {
                         $field = new CMS_poly_object_field();
                         $importType = ' (Creation)';
                     }
                 }
                 if (isset($field)) {
                     if ($field->fromArray($fieldDatas, $params, $cms_language, $idsRelation, $infos)) {
                         $return &= true;
                         $infos .= 'Field "' . $field->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
                     } else {
                         $return = false;
                         $infos .= 'Error during import of field ...' . $importType . "\n";
                     }
                 }
             } else {
                 $return = false;
                 $infos .= 'Error during import of field : missing type' . "\n";
             }
         }
     }
     //object rss feeds
     if (isset($data['rss'])) {
         foreach ($data['rss'] as $rssDatas) {
             $importType = '';
             if (isset($rssDatas['uuid']) && ($id = CMS_poly_object_catalog::rssExists($params['module'], $rssDatas['uuid']))) {
                 //rss already exist : load it if we can update it
                 if (!isset($params['update']) || $params['update'] == true) {
                     $rss = new CMS_poly_rss_definitions($id);
                     $importType = ' (Update)';
                 }
             } else {
                 //create new rss if we can
                 if (!isset($params['create']) || $params['create'] == true) {
                     $rss = new CMS_poly_rss_definitions();
                     $importType = ' (Creation)';
                 }
             }
             if (isset($rss)) {
                 if ($rss->fromArray($rssDatas, $params, $cms_language, $idsRelation, $infos)) {
                     $return &= true;
                     $infos .= 'RSS feed "' . $rss->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
                 } else {
                     $return = false;
                     $infos .= 'Error during import of rss feed ...' . $importType . "\n";
                 }
             }
         }
     }
     //plugins wysiwyg
     if (isset($data['plugins'])) {
         foreach ($data['plugins'] as $pluginDatas) {
             $importType = '';
             if (isset($pluginDatas['uuid']) && ($id = CMS_poly_object_catalog::pluginExists($params['module'], $pluginDatas['uuid']))) {
                 //plugin already exist : load it if we can update it
                 if (!isset($params['update']) || $params['update'] == true) {
                     $plugin = new CMS_poly_plugin_definitions($id);
                     $importType = ' (Update)';
                 }
             } else {
                 //create new plugin if we can
                 if (!isset($params['create']) || $params['create'] == true) {
                     $plugin = new CMS_poly_plugin_definitions();
                     $importType = ' (Creation)';
                 }
             }
             if (isset($plugin)) {
                 if ($plugin->fromArray($pluginDatas, $params, $cms_language, $idsRelation, $infos)) {
                     $return &= true;
                     $infos .= 'Plugin Wysiwyg "' . $plugin->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
                 } else {
                     $return = false;
                     $infos .= 'Error during import of plugin wysiwyg ...' . $importType . "\n";
                 }
             }
         }
     }
     return $return;
 }
 /**
  * Import plugin from given array datas
  *
  * @param array $data The plugin datas to import
  * @param array $params The import parameters.
  *		array(
  *				module	=> false|true : the module to create plugin (required)
  *				create	=> false|true : create missing objects (default : true)
  *				update	=> false|true : update existing objects (default : true)
  *				files	=> false|true : use files from PATH_TMP_FS (default : true)
  *			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (!isset($params['module'])) {
         $infos .= 'Error : missing module codename for rss feed importation ...' . "\n";
         return false;
     }
     $module = CMS_modulesCatalog::getByCodename($params['module']);
     if ($module->hasError()) {
         $infos .= 'Error : invalid module for rss feed importation : ' . $params['module'] . "\n";
         return false;
     }
     if (!$this->getID() && CMS_poly_object_catalog::pluginUuidExists($data['uuid'])) {
         //check imported uuid. If plugin does not have an Id, the uuid must be unique or must be regenerated
         $uuid = io::uuid();
         //store old uuid relation
         $idsRelation['plugins-uuid'][$data['uuid']] = $uuid;
         $data['uuid'] = $uuid;
     }
     //set plugin uuid if not exists
     if (!$this->_objectValues["uuid"]) {
         $this->_objectValues["uuid"] = $data['uuid'];
     }
     if (isset($data['labels'])) {
         $label = new CMS_object_i18nm($this->getValue("labelID"));
         $label->setValues($data['labels']);
         $label->writeToPersistence();
         $this->setValue("labelID", $label->getID());
     }
     if (isset($data['descriptions'])) {
         $description = new CMS_object_i18nm($this->getValue("descriptionID"));
         $description->setValues($data['descriptions']);
         $description->writeToPersistence();
         $this->setValue("descriptionID", $description->getID());
     }
     //if current object id has changed from imported id, set relation
     if (isset($idsRelation['objects'][$data['objectID']]) && $idsRelation['objects'][$data['objectID']]) {
         $this->setValue("objectID", $idsRelation['objects'][$data['objectID']]);
     } else {
         $this->setValue("objectID", $data['objectID']);
     }
     //values
     if (isset($data['params']['query'])) {
         //translate ids if needed
         $query = array();
         foreach ($data['params']['query'] as $objectId => $value) {
             if (isset($idsRelation['objects'][$objectId])) {
                 //object exists with a translated id
                 $query[$idsRelation['objects'][$objectId]] = $value;
             } else {
                 $query[$objectId] = $value;
             }
         }
         $this->setValue("query", $query);
     }
     if (isset($data['params']['definition'])) {
         $this->setValue("definition", $module->convertDefinitionString($data['params']['definition'], false));
     }
     //write object
     if (!$this->writeToPersistence()) {
         $infos .= 'Error : can not write object ...' . "\n";
         return false;
     }
     //if current object id has changed from imported id, set relation
     if (isset($data['id']) && $data['id'] && $this->getID() != $data['id']) {
         $idsRelation['plugins'][$data['id']] = $this->getID();
     }
     //set this object into definition to convert array so it can be converted again at end of import process
     $idsRelation['definitionToConvert'][] = $this;
     return true;
 }
 /**
  * Import rss feed from given array datas
  *
  * @param array $data The rss feed datas to import
  * @param array $params The import parameters.
  *		array(
  *				module	=> false|true : the module to create rss feed (required)
  *				create	=> false|true : create missing objects (default : true)
  *				update	=> false|true : update existing objects (default : true)
  *				files	=> false|true : use files from PATH_TMP_FS (default : true)
  *			)
  * @param CMS_language $cms_language The CMS_langage to use
  * @param array $idsRelation : Reference : The relations between import datas ids and real imported ids
  * @param string $infos : Reference : The import infos returned
  * @return boolean : true on success, false on failure
  * @access public
  */
 function fromArray($data, $params, $cms_language, &$idsRelation, &$infos)
 {
     if (!isset($params['module'])) {
         $infos .= 'Error : missing module codename for rss feed importation ...' . "\n";
         return false;
     }
     $module = CMS_modulesCatalog::getByCodename($params['module']);
     if ($module->hasError()) {
         $infos .= 'Error : invalid module for rss feed importation : ' . $params['module'] . "\n";
         return false;
     }
     if (!$this->getID() && CMS_poly_object_catalog::rssUuidExists($data['uuid'])) {
         //check imported uuid. If rss does not have an Id, the uuid must be unique or must be regenerated
         $uuid = io::uuid();
         //store old uuid relation
         $idsRelation['rss-uuid'][$data['uuid']] = $uuid;
         $data['uuid'] = $uuid;
     }
     //set object uuid if not exists
     if (!$this->_objectValues["uuid"]) {
         $this->_objectValues["uuid"] = $data['uuid'];
     }
     if (isset($data['labels'])) {
         $label = new CMS_object_i18nm($this->getValue("labelID"));
         $label->setValues($data['labels']);
         $label->writeToPersistence();
         $this->setValue("labelID", $label->getID());
     }
     if (isset($data['descriptions'])) {
         $description = new CMS_object_i18nm($this->getValue("descriptionID"));
         $description->setValues($data['descriptions']);
         $description->writeToPersistence();
         $this->setValue("descriptionID", $description->getID());
     }
     //if current object id has changed from imported id, set relation
     if (isset($idsRelation['objects'][$data['objectID']]) && $idsRelation['objects'][$data['objectID']]) {
         $this->setValue("objectID", $idsRelation['objects'][$data['objectID']]);
     } else {
         $this->setValue("objectID", $data['objectID']);
     }
     //values
     if (isset($data['params']['link'])) {
         $this->setValue("link", $data['params']['link']);
     }
     if (isset($data['params']['author'])) {
         $this->setValue("author", $data['params']['author']);
     }
     if (isset($data['params']['copyright'])) {
         $this->setValue("copyright", $data['params']['copyright']);
     }
     if (isset($data['params']['namespaces'])) {
         $this->setValue("namespaces", $data['params']['namespaces']);
     }
     if (isset($data['params']['categories'])) {
         $this->setValue("categories", $data['params']['categories']);
     }
     if (isset($data['params']['ttl'])) {
         $this->setValue("ttl", $data['params']['ttl']);
     }
     if (isset($data['params']['email'])) {
         $this->setValue("email", $data['params']['email']);
     }
     if (isset($data['params']['definition'])) {
         //do not use set value for this because it try to compile definition and fail
         //$this->setValue("definition", $module->convertDefinitionString($data['params']['definition'], false));
         $this->_objectValues['definition'] = $module->convertDefinitionString($data['params']['definition'], false);
     }
     //write object
     if (!$this->writeToPersistence()) {
         $infos .= 'Error : can not write object ...' . "\n";
         return false;
     }
     //if current object id has changed from imported id, set relation
     if (isset($data['id']) && $data['id'] && $this->getID() != $data['id']) {
         $idsRelation['rss'][$data['id']] = $this->getID();
     }
     //set this object into definition to convert array so it can be converted again at end of import process
     $idsRelation['definitionToConvert'][] = $this;
     return true;
 }