/**
  * Import module 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
  */
 static 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;
     }
     $return = true;
     foreach ($data as $categoryDatas) {
         $importType = '';
         if (isset($categoryDatas['uuid']) && ($id = CMS_moduleCategories_catalog::categoryExists($params['module'], $categoryDatas['uuid']))) {
             //category already exist : load it if we can update it
             if (!isset($params['update']) || $params['update'] == true) {
                 $category = CMS_moduleCategories_catalog::getByID($id);
                 $importType = ' (Update)';
             }
         } else {
             //create new category if we can
             if (!isset($params['create']) || $params['create'] == true) {
                 //if category to create has parent, try to get it
                 if (isset($categoryDatas['parent']) && $categoryDatas['parent']) {
                     //check for uuid translation
                     if (isset($idsRelation['categories-uuid'][$categoryDatas['parent']])) {
                         $categoryDatas['parent'] = $idsRelation['categories-uuid'][$categoryDatas['parent']];
                     }
                     //parent already exist : load it
                     $parentId = CMS_moduleCategories_catalog::categoryExists($params['module'], $categoryDatas['parent']);
                 }
                 if (isset($categoryDatas['root']) && $categoryDatas['root']) {
                     //check for uuid translation
                     if (isset($idsRelation['categories-uuid'][$categoryDatas['root']])) {
                         $categoryDatas['root'] = $idsRelation['categories-uuid'][$categoryDatas['root']];
                     }
                     //root already exist : load it
                     $rootId = CMS_moduleCategories_catalog::categoryExists($params['module'], $categoryDatas['root']);
                 }
                 //create category
                 $category = new CMS_moduleCategory(0, $cms_language);
                 $importType = ' (Creation)';
                 //set module
                 $category->setAttribute('moduleCodename', $params['module']);
                 if (isset($rootId)) {
                     $category->setAttribute('rootID', $rootId);
                 }
                 if (isset($parentId)) {
                     $category->setAttribute('parentID', $parentId);
                 }
             }
         }
         if (isset($category)) {
             if ($category->fromArray($categoryDatas, $params, $cms_language, $idsRelation, $infos)) {
                 $return &= true;
                 $infos .= 'Category "' . $category->getLabel($cms_language) . '" successfully imported' . $importType . "\n";
             } else {
                 $return = false;
                 $infos .= 'Error during import of category ' . $categoryDatas['id'] . $importType . "\n";
             }
         }
     }
     return $return;
 }