# HG changeset patch # User viric@mandarina # Date 1230497290 0 # Node ID cb13c07e7e5d146c52439ef8e7464c66c1c3e930 # Parent fcb273554da66d1ce36e57d10fd46f08b1ad8d4a Made multilanguage. Catalan and Russian. diff -r fcb273554da6 -r cb13c07e7e5d config/config.php --- a/config/config.php Sun Dec 28 17:20:55 2008 +0000 +++ b/config/config.php Sun Dec 28 20:48:10 2008 +0000 @@ -11,7 +11,7 @@ | http://example.com/ | */ -$config['base_url'] = "http://localhost/~viric/ci/"; +$config['base_url'] = "http://mandarina/~viric/ci/"; /* |-------------------------------------------------------------------------- diff -r fcb273554da6 -r cb13c07e7e5d controllers/opiniarbo.php --- a/controllers/opiniarbo.php Sun Dec 28 17:20:55 2008 +0000 +++ b/controllers/opiniarbo.php Sun Dec 28 20:48:10 2008 +0000 @@ -13,6 +13,8 @@ $this->load->library('aulib'); $this->load->library('parser'); $this->load->helper('form'); + $this->load->language('arbo','rusa'); + $this->load->helper('language'); $this->load->model('opiniarbo_model'); } @@ -38,16 +40,16 @@ else if ($this->mainassert == 0) { $this->_process_new_assertion(NULL); - $this->_show_assertions(NULL, "Bazaj asertoj"); - $this->_form_new_assertion(NULL, "Nova baza aserto"); + $this->_show_assertions(NULL, lang("headassertions_str")); + $this->_form_new_assertion(NULL, lang("newheadassertion_str")); } else { $this->_process_new_assertion($this->mainassert); $this->_show_preassertions($this->mainassert); $this->_show_assertion($this->mainassert); - $this->_show_assertions($this->mainassert, "Subasertoj"); - $this->_form_new_assertion($this->mainassert, "Nova subaserto"); + $this->_show_assertions($this->mainassert, lang("subassertions_str")); + $this->_form_new_assertion($this->mainassert, lang("newsubassertion_str")); } $this->load->view('page_bottom'); } @@ -79,7 +81,7 @@ $viewdata['assertionid'] = $this->mainassert; $viewdata['other_user'] = $this->userid2; $viewdata['other_user_name'] = $this->opiniarbo_model->get_user_name($this->userid2); - $viewdata['other_users'] = array_merge(array(array('id' => 0, 'name' => 'Neniu')), + $viewdata['other_users'] = array_merge(array(array('id' => 0, 'name' => lang('noone_str'))), $this->opiniarbo_model->get_other_users($this->userid)); $viewdata['loginlink'] = $this->aulib->getLoginLink(); $this->load->view('users', $viewdata); @@ -117,7 +119,7 @@ function _show_assertion($id) { - $viewdata['title'] = "Ĉefa asserto"; + $viewdata['title'] = lang("mainassertion_str"); $viewdata['assertionid'] = $this->mainassert; $viewdata['other_user'] = $this->userid2; $viewdata['user_name'] = $this->opiniarbo_model->get_user_name($this->userid); @@ -162,14 +164,10 @@ { if (isset($row['value1'])) $row['value1'] = ($row['value1'] - 0.5) * 20; - if (isset($row['influence1'])) - $row['influence1'] = $row['influence1']*10; if (isset($row['calc_value1'])) $row['calc_value1'] = ($row['calc_value1'] - 0.5)*20; if (isset($row['value2'])) $row['value2'] = ($row['value2'] - 0.5) * 20; - if (isset($row['influence2'])) - $row['influence2'] = $row['influence2']*10; if (isset($row['calc_value2'])) $row['calc_value2'] = ($row['calc_value2'] - 0.5)*20; } @@ -184,7 +182,7 @@ $this->form_validation->set_rules('text', 'Aserta teksto', 'required|min_length[1]'); $this->form_validation->set_rules('value', 'Valoro', 'callback__value_check'); if ($this->input->post('parent')) - $this->form_validation->set_rules('influence', 'Influo', 'required'); + $this->form_validation->set_rules('influence', 'Influo', 'callback__influence_check'); // Add the subassertion if possible if ($this->form_validation->run()) @@ -192,10 +190,11 @@ $dbdata['assert'] = $this->input->post('text'); $dbdata['value'] = $this->input->post('value')/20. + 0.5; if ($this->input->post('parent')) - $dbdata['influence'] = $this->input->post('influence')/10.; + $dbdata['influence'] = $this->input->post('influence'); if ($this->input->post('context')) $dbdata['context'] = $this->input->post('context'); - $dbdata['parent'] = $this->mainassert; + if ($this->mainassert != 0) + $dbdata['parent'] = $this->mainassert; $this->opiniarbo_model->insert_assertion($this->aulib->getSessionId(), $dbdata); $this->opiniarbo_model->recalculate($this->aulib->getSessionId()); @@ -207,7 +206,7 @@ $this->form_validation->set_rules('vid', 'Valoro ID', 'required'); $this->form_validation->set_rules('value', 'Valoro', 'callback__value_check'); if ($this->input->post('parent')) - $this->form_validation->set_rules('influence', 'Influo', 'required'); + $this->form_validation->set_rules('influence', 'Influo', 'callback__influence_check'); // Modify the values if possible if ($this->form_validation->run()) @@ -216,7 +215,7 @@ $dbdata['valueid'] = $this->input->post('vid'); $dbdata['value'] = $this->input->post('value')/20.+0.5; if ($this->input->post('parent')) - $dbdata['influence'] = $this->input->post('influence')/10; + $dbdata['influence'] = $this->input->post('influence'); $this->opiniarbo_model->modify_values($this->aulib->getSessionId(), $dbdata); $this->opiniarbo_model->recalculate($this->aulib->getSessionId()); @@ -241,7 +240,7 @@ $dbdata['assertid'] = $this->input->post('id'); $dbdata['value'] = $this->input->post('value')/20.+0.5; if ($this->input->post('parent')) - $dbdata['influence'] = $this->input->post('influence')/10; + $dbdata['influence'] = $this->input->post('influence'); $this->opiniarbo_model->add_value($this->aulib->getSessionId(), $dbdata); $this->opiniarbo_model->recalculate($this->aulib->getSessionId()); diff -r fcb273554da6 -r cb13c07e7e5d language/kataluna/arbo_lang.php --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/language/kataluna/arbo_lang.php Sun Dec 28 20:48:10 2008 +0000 @@ -0,0 +1,23 @@ +db->select('id,name'); $this->db->from('auser'); $this->db->where('id', $userid); @@ -253,31 +253,35 @@ $this->db->where('values.user', $user); $query = $this->db->get(); - if ($query->num_rows() > 0) - { - $qresult = $query->result_array(); - - // Calculate the calc_value - $val = 0; - foreach($qresult as $row) - { - if ($row['influence'] >= 0) - $val += $row['influence'] * $this->get_user_calc_value($user, - $row['id'], $row['value']); - else - $val += $row['influence'] * ($this->get_user_calc_value($user, - $row['id'], $row['value']) - 1); - } - } - else - { - $val = NULL; - } - - // Set the NULL calc_value to those without subassertions, - // and the proper value to those with subassertions. + $val = NULL; if ($parent != NULL) { + if ($query->num_rows() > 0) + { + $qresult = $query->result_array(); + + $sum_influence = 0; + + foreach($qresult as $row) + { + $sum_influence += abs($row['influence']); + } + + // Calculate the calc_value + $val = 0; + foreach($qresult as $row) + { + if ($row['influence'] >= 0) + $val += $row['influence'] * $this->get_user_calc_value($user, + $row['id'], $row['value']) / $sum_influence; + else + $val += $row['influence'] * ($this->get_user_calc_value($user, + $row['id'], $row['value']) - 1) / $sum_influence; + } + } + + // Set the NULL calc_value to those without subassertions, + // and the proper value to those with subassertions. $query2 = $this->db->where('assertion', $parent); $query2 = $this->db->where('user', $user); $query2->update('values', array('calc_value' => $val)); @@ -292,7 +296,7 @@ function recalculate($user) { // Get all heads calculated - $this->recalc_user_influences($user, NULL); + //$this->recalc_user_influences($user, NULL); $this->get_user_calc_value($user, NULL, 0); } @@ -322,7 +326,6 @@ function modify_values($user, $inputdata) { - print_r($inputdata); $valuesdata = array('value' => $inputdata['value']); if (isset($inputdata['influence'])) $valuesdata = array_merge($valuesdata,array('influence' => $inputdata['influence'])); diff -r fcb273554da6 -r cb13c07e7e5d views/assertions.php --- a/views/assertions.php Sun Dec 28 17:20:55 2008 +0000 +++ b/views/assertions.php Sun Dec 28 20:48:10 2008 +0000 @@ -13,19 +13,19 @@ -Id + -Influo + -Valoro -Kalkulita + + -Influo + -Valoro -Kalkulita -Teksto -Ŝanĝi + + + + @@ -36,7 +36,7 @@ echo "{$assertion['id']}"; if(isset($assertion['value1'])) { - $value1 = $assertion['value1']; + $value1 = sprintf("%2.2f", $assertion['value1']); // We suppose any value1 comes with vid echo ""; } @@ -47,18 +47,18 @@ if (isset($assertion['parent'])) { if(isset($assertion['influence1'])) - $influence1 = $assertion['influence1']; + $influence1 = sprintf("%2.2f", $assertion['influence1']); else $influence1 = ""; echo ""; + $influence1."\" maxlength=\"5\" size=\"3\" />"; } else echo ""; } echo ""; + $value1."\" maxlength=\"5\" size=\"3\" />"; if (isset($assertion['calc_value1'])) echo "".sprintf("%2.2f", $assertion['calc_value1']); @@ -70,10 +70,10 @@ if (isset($assertion['parent'])) { if(isset($assertion['influence2'])) - $influence2 = $assertion['influence2']; + $influence2 = sprintf("%2.2f", $assertion['influence2']); else $influence2 = ""; - echo "".sprintf("%2.2f", $influence2); + echo "".$influence2; } else echo ""; @@ -93,10 +93,10 @@ ?> - - + "/> + "/> - + "/> diff -r fcb273554da6 -r cb13c07e7e5d views/context.php --- a/views/context.php Sun Dec 28 17:20:55 2008 +0000 +++ b/views/context.php Sun Dec 28 20:48:10 2008 +0000 @@ -1,2 +1,2 @@ -

Kunteksto

+

diff -r fcb273554da6 -r cb13c07e7e5d views/new_assertion.php --- a/views/new_assertion.php Sun Dec 28 17:20:55 2008 +0000 +++ b/views/new_assertion.php Sun Dec 28 20:48:10 2008 +0000 @@ -7,15 +7,15 @@ -

Kunteksto

+

-

+

"/>

diff -r fcb273554da6 -r cb13c07e7e5d views/users.php --- a/views/users.php Sun Dec 28 17:20:55 2008 +0000 +++ b/views/users.php Sun Dec 28 20:48:10 2008 +0000 @@ -1,7 +1,7 @@ -

Uzantoj

+

-

Komparite kun

+

+ "> -