/** * 實際上進行建立檔案的過程 * @param Object $json * @return Object */ private function _create_process($json) { // 是否啟用偵錯 $debug = FALSE; if ($debug) { $this->output->enable_profiler(TRUE); } $data = json_to_object($json); //檢視資料 //test_msg('annotation_setter._create_process', $json); //{ // "feature_location":[0,2,4], // "note":"%3Cp%3E%0A%09test%3C%2Fp%3E%0A", // "policy_type":1, // "is_like":false, // "like_count":0, // "feature_recommend_scope":[[6391,6434]], // "scope":[ // [6391,6433,"3.%20This%20distraction%20effect%20of%20the%20visual%20cue%20map%20has%20not%20been%20proven.%20In%20the%20future%2C%20a%20systematic%20experimental%20design%20should%20be%20conducted%20to%20examine%20whether%20the%20visual%20cue%20map%20distracts%20learners\'%20reading%2C%20thus%20affecting%20their%20reading%20comprehension"] // ], // "type":1 // } //先將權限設成管理者 set_ignore_authorize(true); //取得參考網址資料跟位於session的user $url = $this->url; $user = $this->user; //取得來自$json的範圍資料 $scope_coll_data = $data->scope; $scope_coll = $this->annotation_scope_collection->import_webpage_data($url, $scope_coll_data); //建立標註 $annotation = $this->annotation->create_annotation($user, $scope_coll); $data = $this->_setup_annotation($annotation, $data); set_ignore_authorize(true); $annotation = new Annotation($annotation->get_id()); // 建立推薦標註 //test_msg("_create_process", 'before create recommend'); if ($annotation->is_respond() === FALSE) { //test_msg("_create_process", 'before _setup_scores_recommend($annotation)'); $annotation = $this->_setup_scores_recommend($annotation); //test_msg("_create_process", 'before get_recommen()'); $recommend = $annotation->get_recommend(); //test_msg("_create_process", 'after get_recommen()'); if (isset($recommend)) { $recommend_data = $recommend->export_webpage_data($this->url); if (isset($recommend_data)) { $data['recommend'] = $recommend_data; } } } //test_msg("_create_process", 'after create recommend'); // 標註共識的分數都重新計算 $annotation = new Annotation($annotation->get_id()); $consensus_coll = $annotation->get_consensus_coll(); foreach ($consensus_coll as $consensus) { $this->_setup_scores($consensus); $consensus->update(); } // -------------------------------------------- //log區 $array_data = $annotation->export_webpage_data($this->url); $action = 13; if (isset($data['recommend'])) { $action = 14; } if ($annotation->is_respond()) { $action = 20; //如果是回自己,那就改成27 $topic = $annotation->get_respond_to_topic(); if ($topic->get_user()->equals($annotation->get_user())) { $action = 27; } } $user_id = NULL; if (isset($user)) { $user_id = $user->get_id(); } kals_log($this->db, $action, array('memo' => $array_data, 'user_id' => $user_id)); //test_msg("_create_process", 'before context_complete()'); //context_complete(); set_ignore_authorize(false); return $data; }
public function load_annotation_param($annotation_id, $callback) { //$this->output->enable_profiler(TRUE); $annotation = new Annotation($annotation_id); if ($annotation->is_deleted() == FALSE) { $output_data = $annotation->export_webpage_data($this->url); } else { $output_data = FALSE; } return $this->_display_jsonp($output_data, $callback); }