예제 #1
0
 function scenario($studyId, $scenarioId, $action = "")
 {
     $scenario = ScenarioModel::loadById($scenarioId);
     if ($action !== 'edit' && $scenario->getCompiled() === NULL) {
         $this->location('/scenario/' . $studyId . '/' . $scenarioId . '/edit');
     }
     $this->load->library('Parsedown');
     $parser = new Parsedown();
     $this->assign('parser', $parser);
     $this->assign('scenario', $scenario);
     $this->assign('title', $scenario->getNamespace() . ": " . $scenario->getTitle());
     $this->assign('study', StudyModel::loadById($studyId));
     $this->assign('models', ModelModel::loadByStudy($studyId));
     $this->assign('scenarios', ScenarioModel::loadByStudy($studyId));
     $this->assign('queries', QueryModel::loadByStudy($studyId));
     if ($action === "edit" || $scenario->getCompiled() === NULL) {
         $this->load->view('header');
         $this->load->view('scenario_edit');
         $this->load->view('footer');
     } else {
         $this->load->view('header');
         $this->load->view('scenario');
         $this->load->view('footer');
     }
 }
 /**
  * @AjaxCallable
  * @AjaxMethod=POST
  * @AjaxAsync=TRUE
  */
 function update_scenario_title()
 {
     $id = filter_input(INPUT_POST, 'id');
     $title = filter_input(INPUT_POST, 'title');
     $namespace = filter_input(INPUT_POST, 'namespace');
     $this->load->model('ScenarioModel');
     $scenario = ScenarioModel::loadById($id);
     $scenario->setTitle($title);
     $scenario->setNamespace($namespace);
     $scenario->update();
     return ['id' => $id, 'title' => $title, 'namespace' => $namespace];
 }