Пример #1
0
 /**
  * Import module 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)
 {
     $this->setPolymod(true);
     $return = true;
     $return &= parent::fromArray($data, $params, $cms_language, $idsRelation, $infos);
     //append codename to parameters
     $params['module'] = $this->_codename;
     //add objects
     if (isset($data['objects']) && $data['objects']) {
         if (!CMS_poly_object_catalog::fromArray($data['objects'], $params, $cms_language, $idsRelation, $infos)) {
             $infos .= 'Error during objects import ...' . "\n";
             $return = false;
         }
     }
     //import of module is complete so compile all definitions
     if (isset($idsRelation['definitionToConvert']) && $idsRelation['definitionToConvert']) {
         foreach ($idsRelation['definitionToConvert'] as $objectToCompile) {
             if (method_exists($objectToCompile, 'convertDefinitions')) {
                 $objectToCompile->convertDefinitions($this);
             }
         }
     }
     //convert params of imported fields
     if (isset($idsRelation['paramsFieldsToConvert']) && $idsRelation['paramsFieldsToConvert']) {
         foreach ($idsRelation['paramsFieldsToConvert'] as $field) {
             $fieldObject = $field->getTypeObject();
             if (method_exists($fieldObject, 'importParams')) {
                 $params = $fieldObject->getParamsValues();
                 $params = $fieldObject->importParams($params, $cms_language, $idsRelation, $infos);
                 if ($params) {
                     $field->setValue("params", $params);
                     $field->writeToPersistence();
                 }
             }
         }
     }
     return $return;
 }