Mercurial > hg > extraction-interface
comparison develop/models/extractapp.php @ 29:fc7342914cdf
develop_v0
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Thu, 05 Mar 2015 15:08:09 +0100 |
parents | e6e9bdc4f256 |
children | 4b3da4802998 |
comparison
equal
deleted
inserted
replaced
28:e6e9bdc4f256 | 29:fc7342914cdf |
---|---|
15 $this->SetSectionId($_urlvalues); | 15 $this->SetSectionId($_urlvalues); |
16 | 16 |
17 } | 17 } |
18 | 18 |
19 public function GetTextFromFileId($_postdata) { | 19 public function GetTextFromFileId($_postdata) { |
20 | 20 /* |
21 if ($this->current_fileId != 0) { | 21 if ($this->current_fileId != 0) { |
22 $this->file_id = $this->current_fileId; | 22 $this->file_id = $this->current_fileId; |
23 } else { | 23 } else { |
24 $this->file_id = $_postdata['fileId']; | 24 $this->file_id = $_postdata['fileId']; |
25 } | 25 } |
26 | 26 */ |
27 $this->file_id = $_postdata['fileId']; | |
27 $branch_id = $_postdata['branchId']; | 28 $branch_id = $_postdata['branchId']; |
28 $section_id = $_postdata['sectionId']; | 29 $section_id = $_postdata['sectionId']; |
29 | 30 |
30 $this->branch_id = $branch_id; | 31 $this->branch_id = $branch_id; |
31 $this->user_id = $_postdata['userId']; | 32 $this->user_id = $_postdata['userId']; |
55 | 56 |
56 $section_id = $_postdata['sectionId']; | 57 $section_id = $_postdata['sectionId']; |
57 $this->section_id = $section_id; | 58 $this->section_id = $section_id; |
58 $this->user_id = $_postdata['userId']; | 59 $this->user_id = $_postdata['userId']; |
59 | 60 |
60 // TODO: get info from LGService | |
61 $this->section_name = $_postdata['sectionName']; | 61 $this->section_name = $_postdata['sectionName']; |
62 $this->book_id = $_postdata['bookId']; | 62 $this->book_id = $_postdata['bookId']; |
63 $this->book_name = $_postdata['bookName']; | 63 $this->book_name = $_postdata['bookName']; |
64 | |
65 | 64 |
66 | 65 |
67 // get from URL with file_id | 66 // get from URL with file_id |
68 $lg_text_url = $this->get_text_from_sectionId_url.$section_id; | 67 $lg_text_url = $this->get_text_from_sectionId_url.$section_id; |
69 $lg_text = file_get_contents($lg_text_url); | 68 $lg_text = file_get_contents($lg_text_url); |
104 } | 103 } |
105 if ($_postdata['topic_id']) { | 104 if ($_postdata['topic_id']) { |
106 $this->topic = $_postdata['topic_id']; | 105 $this->topic = $_postdata['topic_id']; |
107 } | 106 } |
108 | 107 |
109 // TODO: LGService | |
110 if ($_postdata['sectionName']) { | 108 if ($_postdata['sectionName']) { |
111 $this->section_name = $_postdata['sectionName']; | 109 $this->section_name = $_postdata['sectionName']; |
112 } | 110 } |
113 if ($_postdata['bookName']) { | 111 if ($_postdata['bookName']) { |
114 $this->book_name = $_postdata['bookName']; | 112 $this->book_name = $_postdata['bookName']; |
163 | 161 |
164 $this->lg_text = $lg_text; | 162 $this->lg_text = $lg_text; |
165 | 163 |
166 | 164 |
167 } | 165 } |
166 /* | |
167 public function Reload($_postdata) { | |
168 | |
169 // update text using $this->current_fileId | |
170 // getTextbyFileId | |
171 $current_fileId = $_postdata['currentFileId']; | |
172 //$this->file_id = $_postdata['currentFileId']; | |
173 //$this->GetTextFromFileId($_postdata); | |
174 //$latest_editing = $this->lg_text; | |
175 // get from URL with file_id | |
176 | |
177 $lg_text_url = $this->get_text_from_fileId_url.$current_fileId; | |
178 $lg_text = file_get_contents($lg_text_url); | |
179 | |
180 $stringInput = $lg_text; | |
181 $stringInput = preg_replace("/ /u", "○", $stringInput); | |
182 $stringInput = preg_replace("/\n/u", "<br>", $stringInput); | |
183 $stringInput = preg_replace("/【(.*?)】/u", "【<a href=\"review_index_xml_images.php?books_id=".$bookId."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $stringInput); | |
184 $lg_text = $stringInput; | |
185 | |
186 | |
187 //var_dump($lg_text); | |
188 | |
189 echo json_encode($lg_text); | |
190 //var_dump($this->file_id); | |
191 | |
192 } | |
193 */ | |
194 | |
195 | |
168 | 196 |
169 // === for tagging === | 197 // === for tagging === |
170 public function StartTagging() { | 198 public function StartTagging() { |
171 | 199 |
172 // $this->Initialize($urlvalues); | 200 // $this->Initialize($urlvalues); |
237 } | 265 } |
238 | 266 |
239 } | 267 } |
240 | 268 |
241 public function UpdateInfoByResponseFromLGService($response) { | 269 public function UpdateInfoByResponseFromLGService($response) { |
242 | 270 |
243 | 271 /* |
244 $status = $response["status"]; | 272 $response_file = $response["file"]; |
245 if ($response["status"] == "error") { | 273 $response_branch = $response["branch"]; |
274 | |
275 | |
276 $status = (string)$response["status"]; | |
277 | |
278 if ((string)$response["status"] == "error") { | |
246 $response_currentFile = $response["currentFile"]; | 279 $response_currentFile = $response["currentFile"]; |
247 | 280 |
248 $this->current_fileId = (string)$response_currentFile['id']; | 281 $this->current_fileId = (string)$response_currentFile['id']; |
249 $this->messages .= "saving does not success! ".(string)$response["message"]; | 282 $this->messages .= "saving does not success! ".(string)$response["message"]; |
250 | 283 |
251 | 284 |
252 } else { | 285 } else { |
253 | 286 |
254 $response_file = $response["file"]; | |
255 $response_branch = $response["branch"]; | |
256 | |
257 $this->messages .= "saving success."; | 287 $this->messages .= "saving success."; |
288 var_dump((string)$response_file["id"]); | |
289 | |
258 $this->file_id = (string)$response_file["id"]; | 290 $this->file_id = (string)$response_file["id"]; |
259 $this->branch_id = (string)$response_branch["id"]; | 291 $this->branch_id = (string)$response_branch["id"]; |
260 | 292 |
261 } | 293 } |
262 | 294 */ |
263 | 295 |
264 /* | 296 |
265 $response_file = $response["file"]; | 297 $response_file = $response["file"]; |
266 $response_branch = $response["branch"]; | 298 $response_branch = $response["branch"]; |
267 | 299 |
268 $status = (string)$response["status"]; | 300 $status = (string)$response["status"]; |
269 if ($status == "ok") { | 301 if ($status == "ok") { |
272 $this->branch_id = (string)$response_branch["id"]; | 304 $this->branch_id = (string)$response_branch["id"]; |
273 | 305 |
274 } else if ($status == "error") { | 306 } else if ($status == "error") { |
275 // saving not success | 307 // saving not success |
276 $this->messages .= "saving does not success! ".(string)$response["message"]; | 308 $this->messages .= "saving does not success! ".(string)$response["message"]; |
277 $this->current_fileId = $response["currentFileId"]; | 309 $response_currentFile = $response["currentFile"]; |
278 } | 310 //$this->current_fileId = $response["currentFileId"]; |
279 */ | 311 $this->current_fileId = (string)$response_currentFile["id"]; |
312 | |
313 } | |
280 | 314 |
281 | 315 |
282 } | 316 } |
283 public function SaveFullTextToLGService($_postdata) { | 317 public function SaveFullTextToLGService($_postdata) { |
284 // save tagged text (full text) by Jorge's API to lg service | 318 // save tagged text (full text) by Jorge's API to lg service |
349 curl_setopt($ch, CURLOPT_HTTPHEADER, array( | 383 curl_setopt($ch, CURLOPT_HTTPHEADER, array( |
350 'Content-type: multipart/form-data;charset=utf-8' | 384 'Content-type: multipart/form-data;charset=utf-8' |
351 )); | 385 )); |
352 | 386 |
353 // execute the request | 387 // execute the request |
354 | 388 $output = curl_exec($ch); |
355 //$output = curl_exec($ch); | |
356 | 389 |
357 | 390 |
358 // output the profile information - includes the header | 391 // output the profile information - includes the header |
359 echo($output) . PHP_EOL; | 392 //echo($output) . PHP_EOL; |
360 | 393 |
361 // close curl resource to free up system resources | 394 // close curl resource to free up system resources |
362 curl_close($ch); | 395 curl_close($ch); |
363 | 396 |
364 $response = json_decode($output, true); | 397 $response = json_decode($output, true); |