function saveItem($multiple = false)
 {
     if (!$multiple) {
         $list_item = new SJB_ListItem();
         $list_item->setFieldSID($this->field_sid);
         $list_item_value = $this->input_data['list_item_value'];
         $list_item->setValue(trim($list_item_value));
         return $this->ListItemManager->SaveListItem($list_item);
     } else {
         $list_item_value = str_replace("\r", '', $this->input_data['list_multiItem_value']);
         $list_item_value = explode("\n", $list_item_value);
         $result = true;
         foreach ($list_item_value as $list_it) {
             $list_it = trim($list_it);
             if ($list_it != "") {
                 $list_item = new SJB_ListItem();
                 $list_item->setFieldSID($this->field_sid);
                 $list_item->setValue(trim($list_it));
                 if (!$this->ListItemManager->SaveListItem($list_item) && $result) {
                     $result = false;
                 }
             }
         }
         return $result;
     }
 }
 function saveItem($multiple = false)
 {
     if (!$multiple) {
         $list_item = new SJB_ListItem();
         $list_item->setFieldSID($this->field_sid);
         $list_item_value = $this->input_data['list_item_value'];
         $list_item->setValue(trim($list_item_value));
         return $this->ListItemManager->SaveListItem($list_item);
     } else {
         $list_item_value = $this->input_data['list_multiItem_value'];
         $result = true;
         foreach ($list_item_value as $key => $list_it) {
             $list_it = trim($list_it);
             if ($list_it != "") {
                 $list_item = new SJB_ListItem();
                 $list_item->setFieldSID($this->field_sid);
                 $list_item->setValue($list_it);
                 $list_item->score = $this->input_data['score'][$key];
                 if (!$this->ListItemManager->SaveListItem($list_item) && $result) {
                     $result = false;
                 }
             }
         }
         return $result;
     }
 }
Exemple #3
0
 private function UpdateListValues($listing)
 {
     $list_properties = array();
     $details = $listing->getDetails();
     $properties = $details->getProperties();
     foreach ($properties as $property) {
         if ($property->getType() == 'list') {
             $list_properties[$property->getID()] = $property;
         }
     }
     $listingFieldListItemManager = new SJB_ListingFieldListItemManager();
     foreach ($list_properties as $property) {
         $property_sid = $property->getSID();
         $property_value = $property->getValue();
         if (!empty($property_value)) {
             $list_item = $listingFieldListItemManager->getListItemByValue($property->getSID(), $property->getValue());
             if (empty($list_item)) {
                 $list_item = new SJB_ListItem();
                 $list_item->setFieldSID($property_sid);
                 $list_item->setValue($property_value);
                 $listingFieldListItemManager->saveListItem($list_item);
             }
         }
     }
 }
Exemple #4
0
 public function getListItemByValue($field_sid, $value)
 {
     $item_info = SJB_DB::query("SELECT * FROM `{$this->table_prefix}_field_list` WHERE `field_sid`=?n AND `value`=?s", $field_sid, $value);
     if (!empty($item_info)) {
         $item_info = array_pop($item_info);
         $list_item = new SJB_ListItem();
         $list_item->setValue($item_info['value']);
         $list_item->setFieldSID($item_info['field_sid']);
         $list_item->setSID($item_info['sid']);
         return $list_item;
     }
     return null;
 }