comparison develop/models/extractapp.php @ 11:3d6fba07bfbd

implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html.
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Wed, 11 Feb 2015 12:33:59 +0100
parents 54a235d43694
children e82ca7375e93
comparison
equal deleted inserted replaced
10:54a235d43694 11:3d6fba07bfbd
11 protected $section_id, $data_path; 11 protected $section_id, $data_path;
12 12
13 13
14 private function Initialize($_urlvalues) { 14 private function Initialize($_urlvalues) {
15 $this->SetSectionId($_urlvalues); 15 $this->SetSectionId($_urlvalues);
16
16 } 17 }
17 18
18 // === for tagging === 19 // === for tagging ===
19 public function StartTagging($urlvalues) { 20 public function StartTagging($urlvalues) {
20 21
40 $data['taglistArray'] = $taglistArray; 41 $data['taglistArray'] = $taglistArray;
41 $data['wordlistArray'] = $wordlistArray; 42 $data['wordlistArray'] = $wordlistArray;
42 $data['section_id'] = $section_id; 43 $data['section_id'] = $section_id;
43 $data['topiclistArray'] = $topiclistArray; 44 $data['topiclistArray'] = $topiclistArray;
44 $data['default_topic_id'] = $this->GetTopic(); 45 $data['default_topic_id'] = $this->GetTopic();
46 $data['topic_tag'] = $this->GetTopicTag($this->GetTopic());
45 47
46 return $data; 48 return $data;
47 49
48 } 50 }
49 51
74 76
75 // === for export table === 77 // === for export table ===
76 public function ExportTable($urlvalues, $postdata) { 78 public function ExportTable($urlvalues, $postdata) {
77 $this->Initialize($urlvalues); 79 $this->Initialize($urlvalues);
78 $content = $postdata['content']; 80 $content = $postdata['content'];
79 81 $topic = $postdata['topic'];
80 82
81 // outputTableArray: 83 // outputTableArray:
82 $section_id = $this->GetSectionId(); 84 $section_id = $this->GetSectionId();
83 85
84 $section_info = $this->GetSectionInfo(); 86 $section_info = $this->GetSectionInfo();
85 87
89 $books_info = $this->GetBooksInfo($bookId); 91 $books_info = $this->GetBooksInfo($bookId);
90 $bookName = $books_info['bookName']; 92 $bookName = $books_info['bookName'];
91 93
92 $outputTableArray = array(); 94 $outputTableArray = array();
93 95
94 $taglistArray = $this->GetTaglistArray(); 96 //$taglistArray = $this->GetTaglistArray();
95 97
98 $taglistArray = $this->GetTaglistByTopicID($topic);
99
96 $outputTableArray[0]=array(); 100 $outputTableArray[0]=array();
97 $outputTableArray[0][0]=array(); 101 $outputTableArray[0][0]=array();
98 $outputTableArray[0][1]=array(); 102 $outputTableArray[0][1]=array();
99 foreach ( $taglistArray as $value ) { 103 foreach ( $taglistArray as $value ) {
100 $outputTableArray[0][0][$value[2]] = $value[1]; 104 $outputTableArray[0][0][$value[2]] = $value[1];
149 $outputTableArray[$count]["page"] = $pageNow; 153 $outputTableArray[$count]["page"] = $pageNow;
150 $value = preg_replace("/>/u", "&gt;", $value); 154 $value = preg_replace("/>/u", "&gt;", $value);
151 $value = preg_replace("/</u", "&lt;", $value); 155 $value = preg_replace("/</u", "&lt;", $value);
152 $outputTableArray[$count]["full"] = $value; 156 $outputTableArray[$count]["full"] = $value;
153 } 157 }
158 /*
159 echo "<br>"."DEBUG: outputTableArray:"."<br>";
160 var_dump($outputTableArray);
161 */
154 162
155 foreach ( $outputTableArray as $arrayIndex => $arrayValue ) { 163 foreach ( $outputTableArray as $arrayIndex => $arrayValue ) {
156 if ( !isset($arrayValue[0]["person"]) ) { 164 // output each row which the topic tag
157 unset($outputTableArray[$arrayIndex]); 165 // e.g. the original version is for 'person'
158 } 166
167 // TODO: choose topic tag based on the topic
168 // for person topic
169 if ($topic == 1) {
170 if ( !isset($arrayValue[0]["person"]) ) {
171 unset($outputTableArray[$arrayIndex]);
172 }
173 } else if ($topic == 2) {
174
175 // for object topic
176 if ( !isset($arrayValue[0]["object"]) ) { // only the record with the tag of 'object' will become a row
177 unset($outputTableArray[$arrayIndex]);
178 }
179 }
180
159 } 181 }
160 182
161 183
162 $data = array(); 184 $data = array();
163 185
238 } 260 }
239 261
240 } 262 }
241 263
242 // === for config topic === 264 // === for config topic ===
243 265 public function ConfigTagsInTopic($urlvalues, $postdata) {
266
267 }
244 268
245 private function GetTaglistByTopicID($topic_id) { 269 private function GetTaglistByTopicID($topic_id) {
246 $taglistArray = array(); 270 $taglistArray = array();
247 // select taglist ids from topic_tag_relation table 271 // select taglist ids from topic_tag_relation table
248 $query = sprintf("SELECT * FROM `topic_tag_relation` WHERE `topic_id`='%s'", $topic_id); 272 $query = sprintf("SELECT * FROM `topic_tag_relation` WHERE `topic_id`='%s'", $topic_id);
282 306
283 private function GetTopiclistArray() { 307 private function GetTopiclistArray() {
284 $topiclistArray = array(); 308 $topiclistArray = array();
285 $result = $this->GetTopiclist(); 309 $result = $this->GetTopiclist();
286 while ($row = mysql_fetch_assoc($result)) { 310 while ($row = mysql_fetch_assoc($result)) {
287 array_push($topiclistArray, array('id'=>$row['id'],'name'=>$row['name'])); 311 array_push($topiclistArray, array('id'=>$row['id'],'name'=>$row['name'],'tag'=>$row['tag']));
288 } 312 }
289 return $topiclistArray; 313 return $topiclistArray;
314 }
315
316
317 private function GetTopicTag($topic_id) {
318 $result = $this->GetTopicByID($topic_id);
319 $row = mysql_fetch_assoc($result);
320 $tag = $row['tag'];
321 return $tag;
322
290 } 323 }
291 324
292 // =========================== 325 // ===========================
293 326
294 // === for manage wordlist === 327 // === for manage wordlist ===
467 while ($row = mysql_fetch_assoc($result)) { 500 while ($row = mysql_fetch_assoc($result)) {
468 array_push($taglistArray, array( $row['id'], $row['name'], $row['tag'], $row['color'] )); 501 array_push($taglistArray, array( $row['id'], $row['name'], $row['tag'], $row['color'] ));
469 } 502 }
470 503
471 return $taglistArray; 504 return $taglistArray;
472
473 } 505 }
474 506
475 private function GetWordlistArray() { 507 private function GetWordlistArray() {
476 $wordlistArray=""; 508 $wordlistArray="";
477 $result = $this->GetWordlist(); 509 $result = $this->GetWordlist();