コード例 #1
0
ファイル: FacebookFields.php プロジェクト: Maxlander/shixi
 /**
  * @param SJB_Listing $object
  * @param array $aFieldAssoc
  * @return void
  */
 public function fillOutListingData_Object(SJB_Listing &$object, $aFieldAssoc)
 {
     foreach ($aFieldAssoc as $propertyID => $value) {
         // checking if such property exists in listing
         if (!$object->getProperty($propertyID) instanceof SJB_ObjectProperty) {
             continue;
         }
         if ('tree' == $object->getProperty($propertyID)->getType()) {
             if (!empty($value['tree'])) {
                 $object->setPropertyValue($propertyID, $value['tree']);
             }
         } elseif (is_string($value) && strcmp($object->getPropertyValue($propertyID), $value) !== 0) {
             $object->setPropertyValue($propertyID, $value);
         } elseif (is_array($value)) {
             foreach ($value as $fieldID => $fieldValue) {
                 if ('complex' == $object->getProperty($propertyID)->getType()) {
                     if ('date' == $object->getProperty($propertyID)->type->complex->getProperty($fieldID)->getType()) {
                         foreach ($fieldValue as &$date) {
                             $date = !empty($date) ? SJB_I18N::getInstance()->getDate($date) : '';
                         }
                     }
                     $object->getProperty($propertyID)->type->complex->setPropertyValue($fieldID, $fieldValue);
                 } else {
                     $value = $value[0];
                     $object->setPropertyValue($propertyID, $value);
                 }
             }
         }
     }
 }