99, 'novy' => 2, 'detail' => 0, 'index' => 99, 'obrazok' => 2, 'obrazokzmazat' => 2, 'id' => 0, 'hlavny-obrazok' => 0, ); function __construct() { parent::__construct(); if ($this->session->userdata('logged_in') == true) { $this->data['me'] = true; } } function _remap($method) { $this->check_right($this->rights); /* echo $this->uri->uri_string()." "; echo $this->uri->ruri_string()." "; die(); */ if ($method == 'novy') { $this->new_item($this->uri->segment(3)); } else if ($method == 'obrazok') { $this->add_item_picture(); } else if ($method == 'obrazokzmazat') { $this->del_item_picture(); } else if ($method == 'novy-pridat') { $this->add_item(); } else if ($method == 'hlavny-obrazok') { $this->_ajax_main_image(); } else { if(method_exists(__CLASS__, $method) == true) { $this->$method($this->uri->segment(3)); } else { redirect(''); } } } function index() { echo "DSSD"; } function new_item($action='') { $this->data['item_images'] = ''; $this->data['tmp_imgname'] = md5($this->session->userdata('username').time()); $this->data['item_postal'] = $this->input->post('item_postal'); $this->data['item_postaleu'] = $this->input->post('item_postaleu'); if ($this->input->post('item_save')) { $this->load->library('form_validation'); $res = $this->form_validation->run('new_item'); //var_dump($_POST); //die(); //var_dump($this->form_validation); if ($res === FALSE) { $this->data['item_images'] = $this->input->post('item_imgcontentdiv'); $this->data['tmp_imgname'] = $this->input->post('tmp_imgmask'); $this->data['form_val_ko_warnig'] = $this->lang->line('valerror_new_item'); } else { $this->load->model('item_model'); $this->item_model->update_item(); $this->session->set_flashdata('info', sprintf($this->lang->line('item_updated'), $this->input->post('item_name'))); redirect($this->session->userdata('username')); } } else { $this->load->model('profile_model'); $res = $this->profile_model->get_profile($this->session->userdata('id')); if(count($res) > 0) { $this->data['item_postal'] = $res->carring_txt; $this->data['item_postaleu'] = $res->carring_txt_out; } } $this->data['item_name'] = $this->input->post('item_name'); $this->data['item_desc'] = $this->input->post('item_desc'); $this->data['item_keywords'] = $this->input->post('item_keywords'); $this->data['item_size'] = $this->input->post('item_size'); $this->data['item_price'] = $this->input->post('item_price'); $this->data['item_price'] = $this->input->post('item_price'); $this->data['item_provision'] = SITE_PROVISION; $this->data['item_count'] = $this->input->post('item_count'); $this->data['sel_kat'] = $this->input->post('item_cat'); $this->data['sel_color'] = $this->input->post('item_color'); $this->data['count_img'] = $this->input->post('count_img'); $this->load->model('category_model'); $sub_cat = $this->category_model->get_sub_categories(); $main_cat = $this->category_model->get_child_categories(); $all_cat = array(); foreach($main_cat->result() as $key => $val) { //$all_cat[$key] = $sub_cat[$key]; $all_cat[$val->id] = $val->name; //var_dump($key); $index = (int) $val->id; $m_cat[$index] = 1; foreach($sub_cat[$index] as $k1 => $v1) { $all_cat[$k1] = "    ".$v1; } } $this->data['ni_cat'] = $all_cat; $this->data['ni_cat_main'] = $m_cat; $this->data['main_content'] = 'item/new_item'; $this->load->view('includes/template', $this->data); } function add_item_picture() { $config['upload_path'] = './uploads/item/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '1024'; $config['file_name'] = $this->input->post('file_mask'); $this->load->library('upload', $config); $res = $config['file_name']; $res_upload = $this->upload->do_upload(); if ($res_upload === FALSE) { $res = "KO".$this->upload->display_errors(); } else { $img_info = $this->upload->data(); $data = array('imgupld_path' => base_url().$config['upload_path'].$img_info['raw_name'].$img_info['file_ext'], 'imgupld_index' => $this->input->post('img_index')); $res = $this->load->view('item/item_imgupld', $data); } echo $res; } function del_item_picture() { $upload_path = 'uploads/item/'; $file_name = basename($this->input->post('imgdel')); unlink($upload_path.$file_name); } function item_images_check() { $this->form_validation->set_message('item_images_check', $this->lang->line('valerror_must_have_one_image')); return strlen($this->input->post('item_imgupd1')) > 0; } function id() { $id_item = $this->uri->segment(3); $id_items = explode('-', $id_item); $id_item = $id_items[0]; $this->load->helper('image_helper'); $item_data = $this->_get_item_data($id_item); $item = $item_data['records']->row(); if (count($item) === 0) { $this->data['main_content'] = 'item/no_item'; } elseif ($item->disabled === '1') { $this->data['main_content'] = 'item/item_breaking'; } elseif (($item->valid !== '1') OR ($item->valid_admin !== '1')) { $this->data['main_content'] = 'item/item_deleted'; } else { $this->load->model('category_model'); $sub_cat_info = $this->category_model->get_category_info($item->id_category)->row(); $main_cat_info = $this->category_model->get_category_info($sub_cat_info->id_parent)->row(); $kw = $this->item_model->get_kw($id_item)->result(); $i = 0; $kw_out = array(); foreach($kw as $val) { if(strlen($val->kw) > 0) { $kw_out[$i]['href'] = base_url().'slovo/'.url_title(strtolower(remove_diacritics($val->kw))); $kw_out[$i]['kw'] = $val->kw; $i++; } } $this->data['is_my_item'] = $item->id == $this->session->userdata('id'); $this->data['kw'] = $kw_out; $this->data['do_open_graph'] = TRUE; $this->data['og_item_url'] = base_url().'vyrobok/id/'.$item->id_item."-".url_title(strtolower(remove_diacritics($item->name))); $this->data['main_cat_link'] = base_url().'kategoria/'.$main_cat_info->id."-".url_title(strtolower(remove_diacritics($main_cat_info->name))); $this->data['main_cat_name'] = $main_cat_info->name; $this->data['sub_cat_link'] = base_url().'kategoria/'.$sub_cat_info->id."-".url_title(strtolower(remove_diacritics($sub_cat_info->name))); $this->data['sub_cat_name'] = $sub_cat_info->name; $this->data['item'] = $item; $this->data['item_img'] = get_thumbs(md5($item->username)."_".$item->id_item, 'item', $size='m'); $this->data['item_img_orig'] = get_thumbs(md5($item->username)."_".$item->id_item, 'item', $size='o'); $this->data['item_price'] = price_format($item->price,$item->provision); $this->data['item_count_sold'] = $this->item_model->get_items_count($item->id, 'sold')->cnt; $this->data['item_count_selling'] = $this->item_model->get_items_count($item->id, 'selling')->cnt; $img_usr_arr = get_thumbs(md5($item->username), 'profile', 's'); $this->data['item_user_img'] = isset($img_usr_arr[0]) === TRUE? base_url().$img_usr_arr[0] : ''; $this->data['main_content'] = 'item/item_view'; $this->item_model->update_viewed($item->id_item); } $this->load->view('includes/template', $this->data); } function _get_item_data($id_item) { $this->load->model('item_model'); $where_data = array('item.count >= ' =>'0', "(rv_item.status = 'selling' or rv_item.status = 'sold')"=>null,); $item_data = $this->item_model->get_category_items(null, 0, 1, $where_data, $id_item); return $item_data; } function _ajax_main_image() { $item_id = $this->uri->segment(3); $img_index = $this->uri->segment(4); $item_data = $this->_get_item_data($item_id); $item = $item_data['records']->row(); $this->data['item'] = $item; $this->load->helper('image_helper'); $this->data['item_img'] = get_thumbs(md5($item->username)."_".$item->id_item."_".$img_index, 'item', $size='m'); $this->data['item_img_orig'] = get_thumbs(md5($item->username)."_".$item->id_item."_".$img_index, 'item', $size='o'); $res = $this->load->view('item/main_image.php', $this->data); } }