예제 #1
0
 /**
  * Get subfields definition for current object
  *
  * @param integer (can be null - for compatibility only) $objectID the object ID who requests these infos
  * @return array(integer "subFieldID" =>  array("type" => string [integer|string|text|date], "objectID" => integer, "fieldID" => integer, "subFieldID" => integer))
  * @access public
  */
 function getSubFieldsDefinition($objectID = "")
 {
     $subFieldsDefinition = array();
     foreach (array_keys($this->_objectValues) as $subFieldID) {
         if (!is_a($this->_objectValues[$subFieldID], 'CMS_multi_poly_object')) {
             $subFieldDefinition = $this->_objectValues[$subFieldID]->getSubFieldsDefinition($this->_ID);
         } else {
             $type = $this->_objectFieldsDefinition[$subFieldID]->getValue('type');
             $subFieldDefinition = CMS_multi_poly_object::getSubFieldsDefinition(io::substr($type, 6), $this->_ID, $this->_objectFieldsDefinition[$subFieldID]);
         }
         $subFieldsDefinition = array_merge($subFieldsDefinition, $subFieldDefinition);
     }
     return $subFieldsDefinition;
 }
예제 #2
0
 /**
  * Get object field as an array structure used for export
  *
  * @param array $params The export parameters. Not used here
  * @param array $files The reference to the found files used by object
  * @return array : the object array structure
  * @access public
  */
 public function asArray($params = array(), &$files)
 {
     $aField = array('id' => $this->_fieldID, 'uuid' => $this->_objectFieldValues['uuid'], 'labels' => CMS_object_i18nm::getValues($this->_objectFieldValues['labelID']), 'descriptions' => CMS_object_i18nm::getValues($this->_objectFieldValues['descriptionID']), 'objectID' => $this->_objectFieldValues['objectID'], 'type' => null, 'multi' => null, 'params' => array('order' => $this->_objectFieldValues['order'], 'required' => $this->_objectFieldValues['required'], 'indexable' => $this->_objectFieldValues['indexable'], 'searchlist' => $this->_objectFieldValues['searchlist'], 'searchable' => $this->_objectFieldValues['searchable']));
     $linkedObjectId = null;
     if (io::strpos($this->_objectFieldValues['type'], 'multi|') !== false) {
         $aField['multi'] = 1;
         $type = explode('|', $this->_objectFieldValues['type']);
         $aField['type'] = $type[1];
         $linkedObjectId = $type[1];
     } else {
         $aField['multi'] = 0;
         $aField['type'] = $this->_objectFieldValues['type'];
         if (io::isPositiveInteger($aField['type'])) {
             $linkedObjectId = $this->_objectFieldValues['type'];
         }
     }
     if ($linkedObjectId) {
         $objectDefition = new CMS_poly_object_definition($linkedObjectId);
         if ($objectDefition) {
             $aField['params']['linkedObjectUuid'] = $objectDefition->getValue('uuid');
         }
     }
     if (!io::isPositiveInteger($aField['type'])) {
         if (class_exists($aField['type'])) {
             $oType = new $aField['type'](array(), $this, false);
             $aField['params']['params'] = $oType->asArray();
         }
     } elseif ($aField['multi']) {
         $oType = new CMS_multi_poly_object($aField['type'], array(), $this, false);
         $aField['params']['params'] = $oType->asArray();
     }
     return $aField;
 }
예제 #3
0
 protected function _createRecursiveDetailledStructure($objectsStructure, &$objectInfos, &$language, &$translationtable, $path, $translatedpath)
 {
     $structure = array();
     foreach ($objectsStructure as $fieldID => $field) {
         if (!is_array($field)) {
             //Field
             if (class_exists($field)) {
                 $object = new $field(array(), $objectInfos[$fieldID]);
                 //get object structure infos
                 $structure[io::substr($fieldID, 5)] = $object->getStructure();
                 //create path and translated path
                 $structure[io::substr($fieldID, 5)]['path'] = $path . '[' . io::substr($fieldID, 5) . ']';
                 $structure[io::substr($fieldID, 5)]['fieldID'] = io::substr($fieldID, 5);
                 if ($language && is_a($language, 'CMS_language')) {
                     $structure[io::substr($fieldID, 5)]['translatedpath'] = $translatedpath . ':' . sensitiveIO::sanitizeAsciiString($objectInfos[$fieldID]->getLabel($language));
                     $count = 1;
                     while (isset($translationtable[$structure[io::substr($fieldID, 5)]['translatedpath']])) {
                         $count++;
                         $structure[io::substr($fieldID, 5)]['translatedpath'] = $translatedpath . ':' . sensitiveIO::sanitizeAsciiString($objectInfos[$fieldID]->getLabel($language)) . $count;
                     }
                     CMS_poly_module_structure::_updateTranslationTable($translationtable, $structure[io::substr($fieldID, 5)]);
                 }
             }
         } else {
             $object = array_shift(array_keys($field));
             if (io::strpos($object, 'object') === 0) {
                 //poly_object
                 //get object structure infos
                 $structure[io::substr($fieldID, 5)] = $objectInfos[$object]->getStructure();
                 //create path and translated path
                 $structure[io::substr($fieldID, 5)]['path'] = $path . '[' . io::substr($fieldID, 5) . ']';
                 $structure[io::substr($fieldID, 5)]['fieldID'] = io::substr($fieldID, 5);
                 if ($language && is_a($language, 'CMS_language')) {
                     $structure[io::substr($fieldID, 5)]['translatedpath'] = $translatedpath . ':' . sensitiveIO::sanitizeAsciiString($objectInfos[$object]->getLabel($language));
                     $count = 1;
                     while (isset($translationtable[$structure[io::substr($fieldID, 5)]['translatedpath']])) {
                         $count++;
                         $structure[io::substr($fieldID, 5)]['translatedpath'] = $translatedpath . ':' . sensitiveIO::sanitizeAsciiString($objectInfos[$object]->getLabel($language)) . $count;
                     }
                     CMS_poly_module_structure::_updateTranslationTable($translationtable, $structure[io::substr($fieldID, 5)]);
                 }
                 //recurse on fields
                 $structure[io::substr($fieldID, 5)]['fields'] = CMS_poly_module_structure::_createRecursiveDetailledStructure($field[$object], $objectInfos, $language, $translationtable, $structure[io::substr($fieldID, 5)]['path'] . "['fields']", $structure[io::substr($fieldID, 5)]['translatedpath']);
             } elseif (io::strpos($object, 'multiobject') === 0) {
                 //multi poly_object
                 $objectDef = new CMS_multi_poly_object(io::substr($object, 11), $datas = array(), $objectInfos[$fieldID]);
                 //get object structure infos
                 $structure[io::substr($fieldID, 5)] = $objectDef->getStructure();
                 //create path and translated path
                 $structure[io::substr($fieldID, 5)]['path'] = $path . '[' . io::substr($fieldID, 5) . ']';
                 $structure[io::substr($fieldID, 5)]['fieldID'] = io::substr($fieldID, 5);
                 if ($language && is_a($language, 'CMS_language')) {
                     $structure[io::substr($fieldID, 5)]['translatedpath'] = $translatedpath . ':' . sensitiveIO::sanitizeAsciiString($objectDef->getFieldLabel($language));
                     $count = 1;
                     while (isset($translationtable[$structure[io::substr($fieldID, 5)]['translatedpath']])) {
                         $count++;
                         $structure[io::substr($fieldID, 5)]['translatedpath'] = $translatedpath . ':' . sensitiveIO::sanitizeAsciiString($objectDef->getFieldLabel($language)) . $count;
                     }
                     CMS_poly_module_structure::_updateTranslationTable($translationtable, $structure[io::substr($fieldID, 5)]);
                 }
                 //recurse on fields
                 $subobjectsDef = array('fieldn' => array('object' . io::substr($object, 11) => $field[$object]));
                 $structure[io::substr($fieldID, 5)]['fields'] = CMS_poly_module_structure::_createRecursiveDetailledStructure($subobjectsDef, $objectInfos, $language, $translationtable, $structure[io::substr($fieldID, 5)]['path'] . "['fields']", $structure[io::substr($fieldID, 5)]['translatedpath']);
             }
         }
     }
     return $structure;
 }