Example #1
0
 private function _createSchema(array $parameters)
 {
     $res = array();
     $i = 1;
     $parent = isset($parameters['parent']) ? $parameters['parent'] : false;
     while (isset($parameters['level' . $i . 'Field'])) {
         $field = $parameters['level' . $i . 'Field'];
         if (!empty($parent)) {
             $property = SJB_ListingManager::getPropertyByParentID($parent, $field);
             $field = $parent . '_' . $field;
         } else {
             $property = SJB_ListingManager::getPropertyByPropertyName($field);
         }
         if (empty($property)) {
             return $res;
         }
         $type = $property->getType();
         $treeLevel = $this->_getTreeLevel($type, $field);
         $res[] = array('field' => $field, 'treeLevel' => $treeLevel, 'homepage' => isset($parameters['homepage']) ? $parameters['homepage'] : 0, 'type' => $type, 'sid' => $property->getSID(), 'parent' => $parent);
         $i++;
     }
     return $res;
 }
Example #2
0
 public static function propertyIsCommon($property_name)
 {
     $common_property = SJB_ListingManager::getPropertyByPropertyName($property_name);
     return !empty($common_property);
 }
Example #3
0
 public static function extractCriteriaFromRequestData($request_data, $object = null)
 {
     $criteria = array('system' => array(), 'common' => array());
     foreach ($request_data as $property_name => $criteria_data) {
         if (is_array($criteria_data)) {
             foreach ($criteria_data as $criterion_type => $criterion_value) {
                 $criterion = SJB_SearchCriterion::getCriterionByType($criterion_type);
                 if (!is_null($criterion)) {
                     if (!empty($object)) {
                         $object_details = $object->getDetails();
                         $object_properties = $object_details->getProperties();
                     }
                     $property = isset($object_properties[$property_name]) ? $object_properties[$property_name] : null;
                     if (empty($property) && !empty($object)) {
                         foreach ($object_properties as $objectProperty) {
                             if ($objectProperty->isComplex()) {
                                 $object_properties = $objectProperty->type->complex->getProperties();
                                 $propertyNameWithoutParent = str_replace($objectProperty->getID() . ':', '', $property_name);
                                 if (isset($object_properties[$propertyNameWithoutParent])) {
                                     $property = $objectProperty;
                                     break;
                                 }
                             }
                         }
                     }
                     $property_is_system = SJB_ListingManager::propertyIsSystem($property_name) || !empty($property) && $property->isSystem();
                     //*** integer, float, date  i18n transformation
                     if (empty($property)) {
                         $property = SJB_ListingManager::getPropertyByPropertyName($property_name);
                     }
                     if (!empty($property) && preg_match("/integer|float|date/i", $property->getType())) {
                         $property->setValue($criterion_value);
                         if ($property->isValid()) {
                             $criterion_value = $property->getValue();
                         }
                     }
                     //*** ----------------------------------------
                     $criterion->setProperty($property);
                     $criterion->setPropertyName($property_name);
                     $criterion->setValue($criterion_value);
                     if ($property_is_system) {
                         $criteria['system'][$property_name][] = $criterion;
                     } else {
                         $criteria['common'][$property_name][] = $criterion;
                     }
                 }
             }
         }
     }
     return $criteria;
 }
 public function getFieldSID($field)
 {
     $property = SJB_ListingManager::getPropertyByPropertyName($field);
     return $property->getSID();
 }