11 parent::Controller(); |
11 parent::Controller(); |
12 $this->load->library('form_validation'); |
12 $this->load->library('form_validation'); |
13 $this->load->library('aulib'); |
13 $this->load->library('aulib'); |
14 $this->load->library('parser'); |
14 $this->load->library('parser'); |
15 $this->load->helper('form'); |
15 $this->load->helper('form'); |
|
16 $this->load->language('arbo','rusa'); |
|
17 $this->load->helper('language'); |
16 $this->load->model('opiniarbo_model'); |
18 $this->load->model('opiniarbo_model'); |
17 } |
19 } |
18 |
20 |
19 function index() |
21 function index() |
20 { |
22 { |
36 // No user logged in |
38 // No user logged in |
37 } |
39 } |
38 else if ($this->mainassert == 0) |
40 else if ($this->mainassert == 0) |
39 { |
41 { |
40 $this->_process_new_assertion(NULL); |
42 $this->_process_new_assertion(NULL); |
41 $this->_show_assertions(NULL, "Bazaj asertoj"); |
43 $this->_show_assertions(NULL, lang("headassertions_str")); |
42 $this->_form_new_assertion(NULL, "Nova baza aserto"); |
44 $this->_form_new_assertion(NULL, lang("newheadassertion_str")); |
43 } |
45 } |
44 else |
46 else |
45 { |
47 { |
46 $this->_process_new_assertion($this->mainassert); |
48 $this->_process_new_assertion($this->mainassert); |
47 $this->_show_preassertions($this->mainassert); |
49 $this->_show_preassertions($this->mainassert); |
48 $this->_show_assertion($this->mainassert); |
50 $this->_show_assertion($this->mainassert); |
49 $this->_show_assertions($this->mainassert, "Subasertoj"); |
51 $this->_show_assertions($this->mainassert, lang("subassertions_str")); |
50 $this->_form_new_assertion($this->mainassert, "Nova subaserto"); |
52 $this->_form_new_assertion($this->mainassert, lang("newsubassertion_str")); |
51 } |
53 } |
52 $this->load->view('page_bottom'); |
54 $this->load->view('page_bottom'); |
53 } |
55 } |
54 |
56 |
55 function recalculate() |
57 function recalculate() |
77 function _show_users() |
79 function _show_users() |
78 { |
80 { |
79 $viewdata['assertionid'] = $this->mainassert; |
81 $viewdata['assertionid'] = $this->mainassert; |
80 $viewdata['other_user'] = $this->userid2; |
82 $viewdata['other_user'] = $this->userid2; |
81 $viewdata['other_user_name'] = $this->opiniarbo_model->get_user_name($this->userid2); |
83 $viewdata['other_user_name'] = $this->opiniarbo_model->get_user_name($this->userid2); |
82 $viewdata['other_users'] = array_merge(array(array('id' => 0, 'name' => 'Neniu')), |
84 $viewdata['other_users'] = array_merge(array(array('id' => 0, 'name' => lang('noone_str'))), |
83 $this->opiniarbo_model->get_other_users($this->userid)); |
85 $this->opiniarbo_model->get_other_users($this->userid)); |
84 $viewdata['loginlink'] = $this->aulib->getLoginLink(); |
86 $viewdata['loginlink'] = $this->aulib->getLoginLink(); |
85 $this->load->view('users', $viewdata); |
87 $this->load->view('users', $viewdata); |
86 } |
88 } |
87 |
89 |
115 } |
117 } |
116 } |
118 } |
117 |
119 |
118 function _show_assertion($id) |
120 function _show_assertion($id) |
119 { |
121 { |
120 $viewdata['title'] = "Ĉefa asserto"; |
122 $viewdata['title'] = lang("mainassertion_str"); |
121 $viewdata['assertionid'] = $this->mainassert; |
123 $viewdata['assertionid'] = $this->mainassert; |
122 $viewdata['other_user'] = $this->userid2; |
124 $viewdata['other_user'] = $this->userid2; |
123 $viewdata['user_name'] = $this->opiniarbo_model->get_user_name($this->userid); |
125 $viewdata['user_name'] = $this->opiniarbo_model->get_user_name($this->userid); |
124 $viewdata['other_user_name'] = $this->opiniarbo_model->get_user_name($this->userid2); |
126 $viewdata['other_user_name'] = $this->opiniarbo_model->get_user_name($this->userid2); |
125 $viewdata['assertions'] = array($this->opiniarbo_model->get_assertion($this->userid, $this->userid2, $id)); |
127 $viewdata['assertions'] = array($this->opiniarbo_model->get_assertion($this->userid, $this->userid2, $id)); |
160 { |
162 { |
161 foreach($viewdata['assertions'] as &$row) |
163 foreach($viewdata['assertions'] as &$row) |
162 { |
164 { |
163 if (isset($row['value1'])) |
165 if (isset($row['value1'])) |
164 $row['value1'] = ($row['value1'] - 0.5) * 20; |
166 $row['value1'] = ($row['value1'] - 0.5) * 20; |
165 if (isset($row['influence1'])) |
|
166 $row['influence1'] = $row['influence1']*10; |
|
167 if (isset($row['calc_value1'])) |
167 if (isset($row['calc_value1'])) |
168 $row['calc_value1'] = ($row['calc_value1'] - 0.5)*20; |
168 $row['calc_value1'] = ($row['calc_value1'] - 0.5)*20; |
169 if (isset($row['value2'])) |
169 if (isset($row['value2'])) |
170 $row['value2'] = ($row['value2'] - 0.5) * 20; |
170 $row['value2'] = ($row['value2'] - 0.5) * 20; |
171 if (isset($row['influence2'])) |
|
172 $row['influence2'] = $row['influence2']*10; |
|
173 if (isset($row['calc_value2'])) |
171 if (isset($row['calc_value2'])) |
174 $row['calc_value2'] = ($row['calc_value2'] - 0.5)*20; |
172 $row['calc_value2'] = ($row['calc_value2'] - 0.5)*20; |
175 } |
173 } |
176 $this->load->view('assertions', $viewdata); |
174 $this->load->view('assertions', $viewdata); |
177 } |
175 } |
182 if ($this->input->post('add')) |
180 if ($this->input->post('add')) |
183 { |
181 { |
184 $this->form_validation->set_rules('text', 'Aserta teksto', 'required|min_length[1]'); |
182 $this->form_validation->set_rules('text', 'Aserta teksto', 'required|min_length[1]'); |
185 $this->form_validation->set_rules('value', 'Valoro', 'callback__value_check'); |
183 $this->form_validation->set_rules('value', 'Valoro', 'callback__value_check'); |
186 if ($this->input->post('parent')) |
184 if ($this->input->post('parent')) |
187 $this->form_validation->set_rules('influence', 'Influo', 'required'); |
185 $this->form_validation->set_rules('influence', 'Influo', 'callback__influence_check'); |
188 |
186 |
189 // Add the subassertion if possible |
187 // Add the subassertion if possible |
190 if ($this->form_validation->run()) |
188 if ($this->form_validation->run()) |
191 { |
189 { |
192 $dbdata['assert'] = $this->input->post('text'); |
190 $dbdata['assert'] = $this->input->post('text'); |
193 $dbdata['value'] = $this->input->post('value')/20. + 0.5; |
191 $dbdata['value'] = $this->input->post('value')/20. + 0.5; |
194 if ($this->input->post('parent')) |
192 if ($this->input->post('parent')) |
195 $dbdata['influence'] = $this->input->post('influence')/10.; |
193 $dbdata['influence'] = $this->input->post('influence'); |
196 if ($this->input->post('context')) |
194 if ($this->input->post('context')) |
197 $dbdata['context'] = $this->input->post('context'); |
195 $dbdata['context'] = $this->input->post('context'); |
198 $dbdata['parent'] = $this->mainassert; |
196 if ($this->mainassert != 0) |
|
197 $dbdata['parent'] = $this->mainassert; |
199 $this->opiniarbo_model->insert_assertion($this->aulib->getSessionId(), |
198 $this->opiniarbo_model->insert_assertion($this->aulib->getSessionId(), |
200 $dbdata); |
199 $dbdata); |
201 $this->opiniarbo_model->recalculate($this->aulib->getSessionId()); |
200 $this->opiniarbo_model->recalculate($this->aulib->getSessionId()); |
202 } |
201 } |
203 } |
202 } |
205 { |
204 { |
206 $this->form_validation->set_rules('id', 'Aserto ID', 'required'); |
205 $this->form_validation->set_rules('id', 'Aserto ID', 'required'); |
207 $this->form_validation->set_rules('vid', 'Valoro ID', 'required'); |
206 $this->form_validation->set_rules('vid', 'Valoro ID', 'required'); |
208 $this->form_validation->set_rules('value', 'Valoro', 'callback__value_check'); |
207 $this->form_validation->set_rules('value', 'Valoro', 'callback__value_check'); |
209 if ($this->input->post('parent')) |
208 if ($this->input->post('parent')) |
210 $this->form_validation->set_rules('influence', 'Influo', 'required'); |
209 $this->form_validation->set_rules('influence', 'Influo', 'callback__influence_check'); |
211 |
210 |
212 // Modify the values if possible |
211 // Modify the values if possible |
213 if ($this->form_validation->run()) |
212 if ($this->form_validation->run()) |
214 { |
213 { |
215 $dbdata['assertid'] = $this->input->post('id'); |
214 $dbdata['assertid'] = $this->input->post('id'); |
216 $dbdata['valueid'] = $this->input->post('vid'); |
215 $dbdata['valueid'] = $this->input->post('vid'); |
217 $dbdata['value'] = $this->input->post('value')/20.+0.5; |
216 $dbdata['value'] = $this->input->post('value')/20.+0.5; |
218 if ($this->input->post('parent')) |
217 if ($this->input->post('parent')) |
219 $dbdata['influence'] = $this->input->post('influence')/10; |
218 $dbdata['influence'] = $this->input->post('influence'); |
220 $this->opiniarbo_model->modify_values($this->aulib->getSessionId(), |
219 $this->opiniarbo_model->modify_values($this->aulib->getSessionId(), |
221 $dbdata); |
220 $dbdata); |
222 $this->opiniarbo_model->recalculate($this->aulib->getSessionId()); |
221 $this->opiniarbo_model->recalculate($this->aulib->getSessionId()); |
223 } |
222 } |
224 } |
223 } |
239 if ($this->form_validation->run()) |
238 if ($this->form_validation->run()) |
240 { |
239 { |
241 $dbdata['assertid'] = $this->input->post('id'); |
240 $dbdata['assertid'] = $this->input->post('id'); |
242 $dbdata['value'] = $this->input->post('value')/20.+0.5; |
241 $dbdata['value'] = $this->input->post('value')/20.+0.5; |
243 if ($this->input->post('parent')) |
242 if ($this->input->post('parent')) |
244 $dbdata['influence'] = $this->input->post('influence')/10; |
243 $dbdata['influence'] = $this->input->post('influence'); |
245 $this->opiniarbo_model->add_value($this->aulib->getSessionId(), |
244 $this->opiniarbo_model->add_value($this->aulib->getSessionId(), |
246 $dbdata); |
245 $dbdata); |
247 $this->opiniarbo_model->recalculate($this->aulib->getSessionId()); |
246 $this->opiniarbo_model->recalculate($this->aulib->getSessionId()); |
248 } |
247 } |
249 } |
248 } |