Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.25 KB | None | 0 0
  1.  public function modify($id = 0){
  2.         if($id == 0){
  3.             $data['title'] = "Choisir monstre à modifier";
  4.             $data['monsters'] = $this->monster_model->getMonstersIdNameLvl();
  5.             $this->construct_page('modo/monster/list', $data);
  6.         }
  7.         else {
  8.             $this->load->helper('form');
  9.             $this->load->library('form_validation');
  10.  
  11.             $this->form_validation->set_rules('name', 'Nom du monstre', 'required|max_length[100]|is_unique[monster.name]');
  12.             $this->form_validation->set_rules('description', 'La description du monstre', 'required');
  13.             $this->form_validation->set_rules('life', 'La vie du monstre', 'required');
  14.             $this->form_validation->set_rules('lvl', 'Lvl du monstre', 'required');
  15.             $this->form_validation->set_rules('xp', 'Xp loot par le monstre', 'required');
  16.             $this->form_validation->set_rules('attack', 'Attaque du monstre', 'required');
  17.             $this->form_validation->set_rules('defense', 'Défense du monstre', 'required');
  18.             $this->form_validation->set_rules('speed', 'Vitesse du mpnstre', 'required');
  19.             $this->form_validation->set_rules('escape', 'Fuite du monstre', 'required');
  20.  
  21.             if($this->form_validation->run() == FALSE) {
  22.                 $this->load->model('modo/object_model');
  23.                 $this->load->model('modo/map_model');
  24.  
  25.                 $data['title'] = "Modification d'un monstre";
  26.                 $data['objects'] = $this->object_model->getObjects();
  27.                 $data['techs'] = $this->monster_model->getTechs();
  28.                 $data['mapsTypes'] = $this->map_model->getTypes();
  29.                 $this->construct_page('modo/monster/modify', $data);
  30.             }
  31.             else {
  32.                 $config['upload_path'] = './assets/img/monsters/';
  33.                 $config['allowed_types'] = 'png';
  34.                 $config['max_size'] = '2000';
  35.                 $config['max_width']  = '4000';
  36.                 $config['max_height']  = '2260';
  37.                 $config['file_name'] = $id.'.png';
  38.                 $config['overwrite'] = true;
  39.                 $this->load->library('upload', $config);
  40.                 $this->upload->do_upload();
  41.  
  42.                 $name = $this->input->post('name');
  43.                 $description = $this->input->post('description');
  44.                 $life = $this->input->post('life');
  45.                 $lvl = $this->input->post('lvl');
  46.                 $xp = $this->input->post('xp');
  47.                 $attack = $this->input->post('attack');
  48.                 $defense = $this->input->post('defense');
  49.                 $speed = $this->input->post('speed');
  50.                 $escape = $this->input->post('escape');
  51.                 $maps = $this->input->post('maps');
  52.                 $objects = $this->input->post('objects');
  53.                 $techs = $this->input->post('techs');
  54.  
  55.                 $this->monster_model->modifyMonster($id, $name, $description, $life, $lvl, $xp, $attack, $defense, $speed, $escape, $maps, $objects, $techs);
  56.  
  57.                 $data['title'] = "Enregistrement réussis du monstre $name";
  58.                 $data['sauv'] = " du monstre $name";
  59.                 $this->construct_page('modo/monster/reussis', $data);
  60.             }
  61.         }
  62.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement