public function action_edit($pid = null) { if (!$pid) { $pid = $this->request->param('id', null); } if ($pid) { $problem = Model_Problem::find_by_id($pid); if (!$problem) { throw new Exception_Page(__('common.problem_not_found')); } } else { $problem = new Model_Problem(); } if ($this->request->is_post()) { $post = $this->cleaned_post(); $problem->update($post); $problem->spj = Model_Problem::JUDGE_NORMAL; if (array_key_exists('spj', $post)) { $problem->spj = Model_Problem::JUDGE_SPECIAL; } $problem->save(); } $this->template_data['title'] = __('admin.problem.edit.edit_:id_:name', array(':id' => $problem['problem_id'], ':name' => $problem['title'])); $this->template_data['problem'] = $problem; }