کد:$last_id= $row->id; $nw = (int)$par->get('th_width',-1); $nh = (int)$par->get('th_height',-1); $nws = (int)$par->get('smallth_width',-1); $nhs = (int)$par->get('smallth_height',-1); $nwm = (int)$par->get('middleth_width',-1); $nhm = (int)$par->get('middleth_height',-1); $nwb = (int)$par->get('bigth_width',-1); $nhb = (int)$par->get('bigth_height',-1); $img_ord = 1; $img_to_insert = 0; $query_img = "INSERT INTO #__djcf_images(`item_id`,`type`,`name`,`ext`,`path`,`caption`,`ordering`) VALUES "; $new_img_path = JPATH_SITE."/components/com_djclassifieds/images/item/"; for($im = 0;$im<count($img_ids);$im++){ if($img_ids[$im]){ if($item_images[$img_ids[$im]]->ordering!=$img_ord || $item_images[$img_ids[$im]]->caption!=$img_captions[$im]){ $query = "UPDATE #__djcf_images SET ordering='".$img_ord."', caption='".$db->escape($img_captions[$im])."' WHERE item_id=".$row->id." AND type='item' AND id=".$img_ids[$im]." "; $db->setQuery($query); $db->query(); } }else{ $new_img_name = explode(';',$img_images[$im]); if(is_array($new_img_name)){ $new_img_name_u =JPATH_ROOT.'/tmp/djupload/'.$new_img_name[0]; if (JFile::exists($new_img_name_u)){ if(getimagesize($new_img_name_u)){ $new_img_n = $last_id.'_'.str_ireplace(' ', '_',$new_img_name[1]); $new_img_n = $lang->transliterate($new_img_n); $new_img_n = strtolower($new_img_n); $new_img_n = JFile::makeSafe($new_img_n); $new_path_check = $new_img_path.$new_img_n; $nimg= 0; while(JFile::exists($new_path_check)){ $nimg++; $new_img_n = $last_id.'_'.$nimg.'_'.str_ireplace(' ', '_',$new_img_name[1]); $new_img_n = $lang->transliterate($new_img_n); $new_img_n = strtolower($new_img_n); $new_img_n = JFile::makeSafe($new_img_n); $new_path_check = $new_img_path.$new_img_n; } rename($new_img_name_u, $new_img_path.$new_img_n); $name_parts = pathinfo($new_img_n); $img_name = $name_parts['filename']; $img_ext = $name_parts['extension']; DJClassifiedsImage::makeThumb($new_img_path.$new_img_n,$new_img_path.$img_name.'_ths.'.$img_ext, $nws, $nhs); DJClassifiedsImage::makeThumb($new_img_path.$new_img_n,$new_img_path.$img_name.'_thm.'.$img_ext, $nwm, $nhm); DJClassifiedsImage::makeThumb($new_img_path.$new_img_n,$new_img_path.$img_name.'_thb.'.$img_ext, $nwb, $nhb); $query_img .= "('".$row->id."','item','".$img_name."','".$img_ext."','/components/com_djclassifieds/images/item/','".$db->escape($img_captions[$im])."','".$img_ord."'), "; $img_to_insert++; if($par->get('store_org_img','1')==0){ JFile::delete($new_img_path.$new_img_n); } } } } } $img_ord++; } if($img_to_insert){ $query_img = substr($query_img, 0, -2).';'; $db->setQuery($query_img); $db->query(); } //if($row->cat_id){ if($row->cat_id==''){$row->cat_id=0;} $query ="SELECT f.* FROM #__djcf_fields f " ."LEFT JOIN #__djcf_fields_xref fx ON f.id=fx.field_id " ."WHERE (fx.cat_id = ".$row->cat_id." OR f.source=1) "; $db->setQuery($query); $fields_list =$db->loadObjectList(); //echo '<pre>'; print_r($db);print_r($fields_list);die(); $ins=0; if(count($fields_list)>0){ $query = "INSERT INTO #__djcf_fields_values(`field_id`,`item_id`,`value`,`value_date`) VALUES "; foreach($fields_list as $fl){ if($fl->type=='checkbox'){ if(isset($_POST[$fl->name])){ $field_v = $_POST[$fl->name]; $f_value=';'; for($fv=0;$fv<count($field_v);$fv++){ $f_value .=$field_v[$fv].';'; } $query .= "('".$fl->id."','".$row->id."','".$db->escape($f_value)."',''), "; $ins++; } }else if($fl->type=='date'){ if(isset($_POST[$fl->name])){ $f_var = JRequest::getVar( $fl->name,'','','string' ); $query .= "('".$fl->id."','".$row->id."','','".$db->escape($f_var)."'), "; $ins++; } }else{ if(isset($_POST[$fl->name])){ $f_var = JRequest::getVar( $fl->name,'','','string',JREQUEST_ALLOWRAW ); $query .= "('".$fl->id."','".$row->id."','".$db->escape($f_var)."',''), "; $ins++; } } } } //print_r($query);die(); if($ins){ $query = substr($query, 0, -2).';'; $db->setQuery($query); $db->query(); } //} JPluginHelper::importPlugin('djclassifieds'); $dispatcher->trigger('onAfterDJClassifiedsSaveAdvert', array($row,$is_new)); switch(JRequest::getVar('task')) { case 'apply': $link = 'index.php?option=com_djclassifieds&task=item.edit&id='.$row->id; $msg = JText::_('COM_DJCLASSIFIEDS_ITEM_SAVED'); break; case 'save2new': $link = 'index.php?option=com_djclassifieds&task=item.add'; $msg = JText::_('COM_DJCLASSIFIEDS_ITEM_SAVED'); break; case 'saveItem': default: $link = 'index.php?option=com_djclassifieds&view=items'; $msg = JText::_('COM_DJCLASSIFIEDS_ITEM_SAVED'); break; } $app->redirect($link, $msg); } function deletebid(){ $app = JFactory::getApplication(); $par = JComponentHelper::getParams( 'com_djclassifieds' ); $db = JFactory::getDBO(); $id = JRequest::getInt('id',0); $bid = JRequest::getInt('bid',0); if($id && $bid){ $query = "DELETE FROM #__djcf_auctions WHERE id= ".$bid." AND item_id=".$id; $db->setQuery($query); $db->query(); $query = "SELECT i.* FROM #__djcf_items i " ."WHERE i.id = ".$id." "; $db->setQuery($query); $item = $db->loadObject(); $price_start = $item->price_start; $query = "SELECT a.* FROM #__djcf_auctions a " ." WHERE a.item_id=".$item->id." ORDER BY a.date DESC LIMIT 1"; $db->setQuery($query); $last_bid=$db->loadObject(); if($last_bid){ $price_start = $last_bid->price; } $query="UPDATE #__djcf_items SET price='".$price_start."' " ." WHERE id=".$item->id; $db->setQuery($query); $db->query(); $msg = JText::_('COM_DJCLASSIFIEDS_BID_DELETED'); }else{ $msg = JText::_('COM_DJCLASSIFIEDS_WRONG_BID_ID'); } $link = 'index.php?option=com_djclassifieds&task=item.edit&id='.$id; $app->redirect($link, $msg); } } ?>




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