Mercurial > hg > extraction-interface
comparison develop/models/extractapp.php @ 13:cc36a20a68ab
automatically decide which rows (what data) should be shown in the exporting table based on the topic.
author | Zoe Hong <zhong@mpiwg-berlin.mpg.de> |
---|---|
date | Tue, 17 Feb 2015 15:25:11 +0100 |
parents | e82ca7375e93 |
children | ac77748bb813 |
comparison
equal
deleted
inserted
replaced
12:e82ca7375e93 | 13:cc36a20a68ab |
---|---|
6 | 6 |
7 public function Index() { | 7 public function Index() { |
8 return array("Index Value 1", "Value 2", "Value 3"); | 8 return array("Index Value 1", "Value 2", "Value 3"); |
9 } | 9 } |
10 | 10 |
11 protected $section_id, $data_path, $file_id, $branch_id, $user_id, $lg_tex; | 11 protected $section_id=0, $data_path, $file_id=0, $branch_id=0, $user_id=0, $lg_text=""; |
12 | 12 |
13 private function Initialize($_urlvalues) { | 13 private function Initialize($_urlvalues) { |
14 $this->SetSectionId($_urlvalues); | 14 $this->SetSectionId($_urlvalues); |
15 | 15 |
16 } | 16 } |
184 file_put_contents("data/parsing_files/".$postdata['filename'].".txt", $require); | 184 file_put_contents("data/parsing_files/".$postdata['filename'].".txt", $require); |
185 } | 185 } |
186 | 186 |
187 } | 187 } |
188 | 188 |
189 public function UpdateInfoByResonseFromLGService($response) { | 189 public function UpdateInfoByResponseFromLGService($response) { |
190 | 190 |
191 $response_file = $response["file"]; | 191 $response_file = $response["file"]; |
192 $response_branch = $response["branch"]; | 192 $response_branch = $response["branch"]; |
193 | 193 |
194 $this->file_id = (string)$response_file["id"]; // should updated | 194 $this->file_id = (string)$response_file["id"]; // should updated |
286 return $response; | 286 return $response; |
287 | 287 |
288 } | 288 } |
289 | 289 |
290 // === for export table === | 290 // === for export table === |
291 public function ExportTable($urlvalues, $postdata) { | 291 public function ExportTable($postdata) { |
292 // $this->Initialize($urlvalues); | 292 // $this->Initialize($urlvalues); |
293 | |
293 $content = $postdata['content']; | 294 $content = $postdata['content']; |
294 $topic = $postdata['topic']; | 295 $topic = $postdata['topic']; |
295 | |
296 // outputTableArray: | |
297 // $section_id = $this->GetSectionId(); | |
298 $section_id = $this->section_id; | 296 $section_id = $this->section_id; |
299 if (!$section_id) { | 297 |
300 //$this->Initialize($urlvalues); | 298 |
301 $section_id = $this->GetSectionId(); | 299 // TODO: this should be get from LGServic: sectionName, bookId, bookName |
302 } | |
303 | |
304 $section_info = $this->GetSectionInfo(); | 300 $section_info = $this->GetSectionInfo(); |
305 | 301 |
306 $sectionName = $section_info['sectionName']; | 302 $sectionName = $section_info['sectionName']; |
307 $bookId = $section_info['bookId']; | 303 $bookId = $section_info['bookId']; |
308 | 304 |
309 $books_info = $this->GetBooksInfo($bookId); | 305 $books_info = $this->GetBooksInfo($bookId); |
310 $bookName = $books_info['bookName']; | 306 $bookName = $books_info['bookName']; |
307 // ===== | |
308 | |
311 | 309 |
312 $outputTableArray = array(); | 310 $outputTableArray = array(); |
313 | 311 |
314 //$taglistArray = $this->GetTaglistArray(); | 312 //$taglistArray = $this->GetTaglistArray(); |
315 | |
316 $taglistArray = $this->GetTaglistByTopicID($topic); | 313 $taglistArray = $this->GetTaglistByTopicID($topic); |
317 | 314 |
318 $outputTableArray[0]=array(); | 315 $outputTableArray[0]=array(); |
319 $outputTableArray[0][0]=array(); | 316 $outputTableArray[0][0]=array(); |
320 $outputTableArray[0][1]=array(); | 317 $outputTableArray[0][1]=array(); |
375 } | 372 } |
376 /* | 373 /* |
377 echo "<br>"."DEBUG: outputTableArray:"."<br>"; | 374 echo "<br>"."DEBUG: outputTableArray:"."<br>"; |
378 var_dump($outputTableArray); | 375 var_dump($outputTableArray); |
379 */ | 376 */ |
377 | |
378 $topic_tag = $this->GetTopicTag($topic); | |
380 | 379 |
381 foreach ( $outputTableArray as $arrayIndex => $arrayValue ) { | 380 foreach ( $outputTableArray as $arrayIndex => $arrayValue ) { |
382 // output each row which the topic tag | 381 // output each row which the topic tag |
383 // e.g. the original version is for 'person' | 382 // e.g. the original version is for 'person' |
384 | 383 if ( !isset($arrayValue[0][$topic_tag]) ) { |
385 // TODO: choose topic tag based on the topic | 384 unset($outputTableArray[$arrayIndex]); |
386 // for person topic | 385 } |
386 | |
387 /* | |
387 if ($topic == 1) { | 388 if ($topic == 1) { |
388 if ( !isset($arrayValue[0]["person"]) ) { | 389 if ( !isset($arrayValue[0]["person"]) ) { |
389 unset($outputTableArray[$arrayIndex]); | 390 unset($outputTableArray[$arrayIndex]); |
390 } | 391 } |
391 } else if ($topic == 2) { | 392 } else if ($topic == 2) { |
393 // for object topic | 394 // for object topic |
394 if ( !isset($arrayValue[0]["object"]) ) { // only the record with the tag of 'object' will become a row | 395 if ( !isset($arrayValue[0]["object"]) ) { // only the record with the tag of 'object' will become a row |
395 unset($outputTableArray[$arrayIndex]); | 396 unset($outputTableArray[$arrayIndex]); |
396 } | 397 } |
397 } | 398 } |
399 */ | |
398 | 400 |
399 } | 401 } |
400 | |
401 | 402 |
402 $data = array(); | 403 $data = array(); |
403 | 404 |
404 $data['outputTableArray'] = $outputTableArray; | 405 $data['outputTableArray'] = $outputTableArray; |
405 $data['bookId'] = $bookId; | 406 $data['bookId'] = $bookId; |
563 | 564 |
564 // =========================== | 565 // =========================== |
565 | 566 |
566 // === for manage wordlist === | 567 // === for manage wordlist === |
567 public function EditWordlist($urlvalues) { | 568 public function EditWordlist($urlvalues) { |
568 //$this->Initialize($urlvalues); | |
569 $result = $this->GetWordlist(); | 569 $result = $this->GetWordlist(); |
570 $wordlistArray = array(); | 570 $wordlistArray = array(); |
571 while ($row = mysql_fetch_assoc($result)) { | 571 while ($row = mysql_fetch_assoc($result)) { |
572 $wordlistArray[$row['id']] = $row['name']; | 572 $wordlistArray[$row['id']] = $row['name']; |
573 } | 573 } |