کد:$row->promotions=''; $query = "SELECT p.* FROM #__djcf_promotions p ORDER BY p.id "; $db->setQuery($query); $promotions=$db->loadObjectList(); foreach($promotions as $prom){ if(JRequest::getVar($prom->name,'0')){ $row->promotions .=$prom->name.','; } } if($row->promotions){ $row->promotions = substr($row->promotions, 0,-1); } if(strstr($row->promotions, 'p_first')){ $row->special = 1; }else{ $row->special = 0; } if(($row->region_id || $row->address) && (($row->latitude=='0.000000000000000' && $row->longitude=='0.000000000000000') || (!$row->latitude && !$row->longitude))){ $address= ''; if($row->region_id){ $reg_path = DJClassifiedsRegion::getParentPath($row->region_id); for($r=count($reg_path)-1;$r>=0;$r--){ if($reg_path[$r]->country){ $address = $reg_path[$r]->name; } if($reg_path[$r]->city){ if($address){ $address .= ', ';} $address .= $reg_path[$r]->name; } } } if($address){ $address .= ', ';} $address .= $row->address; if($row->post_code){ $address .= ', '.$row->post_code; } $loc_coord = DJClassifiedsGeocode::getLocation($address); if(is_array($loc_coord)){ $row->latitude = $loc_coord['lat']; $row->longitude = $loc_coord['lng']; } } //echo '<pre>';print_r($_POST);print_r($row);echo '</pre>';die(); if (!$row->store()) { echo $row->getError(); exit (); } if($is_new){ $query ="UPDATE #__djcf_items SET date_sort=date_start WHERE id=".$row->id." "; $db->setQuery($query); $db->query(); } $item_images = ''; if(!$is_new){ $query = "SELECT * FROM #__djcf_images WHERE item_id=".$row->id." AND type='item' "; $db->setQuery($query); $item_images =$db->loadObjectList('id'); } $img_ids = JRequest::getVar('img_id',array(),'post','array'); $img_captions = JRequest::getVar('img_caption',array(),'post','array'); $img_images = JRequest::getVar('img_image',array(),'post','array'); $img_id_to_del=''; foreach($item_images as $item_img){ $img_to_del = 1; foreach($img_ids as $img_id){ if($item_img->id==$img_id){ $img_to_del = 0; break; } } if($img_to_del){ $path_to_delete = JPATH_ROOT.$item_img->path.$item_img->name; if (JFile::exists($path_to_delete.'.'.$item_img->ext)){ JFile::delete($path_to_delete.'.'.$item_img->ext); } if (JFile::exists($path_to_delete.'_ths.'.$item_img->ext)){ JFile::delete($path_to_delete.'_ths.'.$item_img->ext); } if (JFile::exists($path_to_delete.'_thm.'.$item_img->ext)){ JFile::delete($path_to_delete.'_thm.'.$item_img->ext); } if (JFile::exists($path_to_delete.'_thb.'.$item_img->ext)){ JFile::delete($path_to_delete.'_thb.'.$item_img->ext); } $img_id_to_del .= $item_img->id.','; } } if($img_id_to_del){ $query = "DELETE FROM #__djcf_images WHERE item_id=".$row->id." AND type='item' AND ID IN (".substr($img_id_to_del, 0, -1).") "; $db->setQuery($query); $db->query(); }




پاسخ با نقل قول
علاقه مندی ها (Bookmarks)