# HG changeset patch # User Zoe Hong # Date 1423654439 -3600 # Node ID 3d6fba07bfbd5054c8a76a952c2be45c341a55d3 # Parent 54a235d436947be1696cfe3dab6905ea3381c458 implemented for topic tag. tagging with topic tag (main tag) indicating each row when export to html. diff -r 54a235d43694 -r 3d6fba07bfbd develop/classes/basemodel.php --- a/develop/classes/basemodel.php Tue Feb 10 16:20:29 2015 +0100 +++ b/develop/classes/basemodel.php Wed Feb 11 12:33:59 2015 +0100 @@ -98,6 +98,14 @@ return $result; } + protected function GetTopicByID($topic_id) { + $query = sprintf("SELECT * FROM `topics` WHERE id=\"%s\"", $topic_id); + $result = mysql_query($query); + if (!$result) { + return json_encode("Failed during selecting topics table."); + } + return $result; + } } diff -r 54a235d43694 -r 3d6fba07bfbd develop/controllers/extractapp.php --- a/develop/controllers/extractapp.php Tue Feb 10 16:20:29 2015 +0100 +++ b/develop/controllers/extractapp.php Wed Feb 11 12:33:59 2015 +0100 @@ -18,6 +18,7 @@ if ($this->postdata['topic']) { $viewmodel->SetTopic($this->postdata['topic']); } + // TODO: get the _post data from Jorge's service $this->ReturnView($viewmodel->StartTagging($this->urlvalues), false); break; } @@ -66,7 +67,17 @@ } - + protected function ConfigTagsInTopic() { + $viewmodel = new ExtractappModel(); + switch ($this->postdata['func']) { + case '': + + break; + default: + $this->ReturnView($viewmodel->ConfigTagsInTopic($this->urlvalues,$this->postdata), false); + break; + } + } protected function TestAction() { $viewmodel = new ExtractappModel(); diff -r 54a235d43694 -r 3d6fba07bfbd develop/data/parsing_files/10078.txt --- a/develop/data/parsing_files/10078.txt Tue Feb 10 16:20:29 2015 +0100 +++ b/develop/data/parsing_files/10078.txt Wed Feb 11 12:33:59 2015 +0100 @@ -1,4 +1,7 @@ -【829】南陵縣志卷十七 職官志 秦改封建為郡縣縣置令或長 漢縣置令或長一 縣萬户為令秩工石至六百石減 萬户為長秩五百石至三百石掌 治民顯善勸義禁姦罰惡理訟平賊恤 □時務秋冬集課上計於所屬郡國 丞一 貳 漢制 丞尉縣多以本部為之秩四百 石至二百石丞署文書典知倉獄 主簿一 佐 令 長自調 用 尉大縣二餘一 圭捕盜賊 察姦宄 諸曹椽史有秩三 老 掌教 化 +【829】南陵縣志卷十七 職官志 秦改封建為郡縣縣置令或長 漢縣置令或長一 縣萬户為令秩工石至六百石減 +〈萬户為長秩五百石至三百石掌〉 治民 +顯善勸義禁姦罰惡理訟平賊恤 □時務秋冬集課上計於所屬郡國 丞一 貳 漢制 丞尉縣多以本部為之 +四百 石至二百石丞署文書典知倉獄 主簿一人 佐 令 長自調尉大縣二餘一 圭捕盜賊 察姦宄 諸曹椽史有秩三 老 掌教 化 游徼 循禁 姦盜 嗇夫 主知民情 平其差品 鄕佐 主收 賦稅 亭長 主 捕 盜 賊 里魁 掌察一里善 惡 並幕屬 吳官制書闕無考縣令佐貳大率多沿漢制 【830】晉縣大者置令小者置長縣佐有主簿 省 丞 錄事史記室 史門下書佐幹游徼議生循行功曹史廷椽户曹法 曹金倉賊曹椽兵曹賊捕椽等員又縣五百户以上 置一鄕 三千以上二鄕五千 以上三鄕萬置四鄕 鄕置嗇夫一縣率百 户置里吏一户千置校官一 南北朝宋縣大者為令小為長有簿有尉 尉大縣 鄕有 鄕佐 五家為伍有伍長二伍為什有什長十什 為里有里魁十里為亭有亭長十亭為鄕 三老 有秩嗇夫游徼各一齊梁陳略同 隋縣為令或長其下為丞簿尉 煬帝時嘗改 尉為縣正 廢鄕官 開 皇 初經部授 十五罷 【831】唐上縣令一丞一人主簿一縣尉二餘縣一 自令以下並以縣上中下分品 武德初改尉曰正尋復稱尉 司户佐司法佐各一 人 貞觀初縣置 錄事後省 經學博士助教各一縣置知縣事一 初用京朝官以重民社之寄其後 參用幕職及試銜官而令選猥下 天聖中詔為舉法以重令選慶歷紹興屢嚴其制乾 道御筆非兩任縣令不除察御史而其職始 重 丞一人主簿一尉大邑二餘一 宋初無丞 天聖中始 於赤縣置丞小 邑以簿兼之 鎭砦官無定員 元縣達魯花赤一尹一人丞一簿一尉典史各 一人教諭一 書院有 山長 訓導一 按元史百官志 無訓導官未詳 巡 檢稅務使無定員又有直學一 見學 宮碑 diff -r 54a235d43694 -r 3d6fba07bfbd develop/js/taggingtext.js --- a/develop/js/taggingtext.js Tue Feb 10 16:20:29 2015 +0100 +++ b/develop/js/taggingtext.js Wed Feb 11 12:33:59 2015 +0100 @@ -361,6 +361,13 @@ range.insertNode(newdiv); var newdiv = document.createElement("br"); range.insertNode(newdiv); + } else if (tag=="object2") { + var newdiv = document.createElement("object"); + newdiv.innerHTML = stringSelection; + range.insertNode(newdiv); + var newdiv = document.createElement("br"); + range.insertNode(newdiv); + } else { var newdiv = document.createElement(tag); newdiv.innerHTML = stringSelection; @@ -707,7 +714,7 @@ } } -function exportAll(section_id) { +function exportAll(section_id, topic_id) { var el = document.getElementById("editable-area"); var str="" + el.innerHTML; var form = document.createElement("form"); @@ -721,11 +728,18 @@ hiddenField.setAttribute("value", str); form.appendChild(hiddenField); + var hiddenField2 = document.createElement("input"); + hiddenField2.setAttribute("name", "topic"); + hiddenField2.setAttribute("value", topic_id); + form.appendChild(hiddenField2); + console.log(topic_id); + + /* var hiddenField = document.createElement("input"); hiddenField.setAttribute("name", "sectionid"); hiddenField.setAttribute("value", section_id); form.appendChild(hiddenField); - + */ if(navigator.userAgent.toLowerCase().indexOf('firefox') > -1) { document.body.appendChild(form); diff -r 54a235d43694 -r 3d6fba07bfbd develop/models/extractapp.php --- a/develop/models/extractapp.php Tue Feb 10 16:20:29 2015 +0100 +++ b/develop/models/extractapp.php Wed Feb 11 12:33:59 2015 +0100 @@ -13,6 +13,7 @@ private function Initialize($_urlvalues) { $this->SetSectionId($_urlvalues); + } // === for tagging === @@ -42,6 +43,7 @@ $data['section_id'] = $section_id; $data['topiclistArray'] = $topiclistArray; $data['default_topic_id'] = $this->GetTopic(); + $data['topic_tag'] = $this->GetTopicTag($this->GetTopic()); return $data; @@ -76,8 +78,8 @@ public function ExportTable($urlvalues, $postdata) { $this->Initialize($urlvalues); $content = $postdata['content']; + $topic = $postdata['topic']; - // outputTableArray: $section_id = $this->GetSectionId(); @@ -91,8 +93,10 @@ $outputTableArray = array(); - $taglistArray = $this->GetTaglistArray(); + //$taglistArray = $this->GetTaglistArray(); + $taglistArray = $this->GetTaglistByTopicID($topic); + $outputTableArray[0]=array(); $outputTableArray[0][0]=array(); $outputTableArray[0][1]=array(); @@ -151,11 +155,29 @@ $value = preg_replace("/"."DEBUG: outputTableArray:"."
"; + var_dump($outputTableArray); + */ foreach ( $outputTableArray as $arrayIndex => $arrayValue ) { - if ( !isset($arrayValue[0]["person"]) ) { - unset($outputTableArray[$arrayIndex]); + // output each row which the topic tag + // e.g. the original version is for 'person' + + // TODO: choose topic tag based on the topic + // for person topic + if ($topic == 1) { + if ( !isset($arrayValue[0]["person"]) ) { + unset($outputTableArray[$arrayIndex]); + } + } else if ($topic == 2) { + + // for object topic + if ( !isset($arrayValue[0]["object"]) ) { // only the record with the tag of 'object' will become a row + unset($outputTableArray[$arrayIndex]); + } } + } @@ -240,7 +262,9 @@ } // === for config topic === - + public function ConfigTagsInTopic($urlvalues, $postdata) { + + } private function GetTaglistByTopicID($topic_id) { $taglistArray = array(); @@ -284,11 +308,20 @@ $topiclistArray = array(); $result = $this->GetTopiclist(); while ($row = mysql_fetch_assoc($result)) { - array_push($topiclistArray, array('id'=>$row['id'],'name'=>$row['name'])); + array_push($topiclistArray, array('id'=>$row['id'],'name'=>$row['name'],'tag'=>$row['tag'])); } return $topiclistArray; } + + private function GetTopicTag($topic_id) { + $result = $this->GetTopicByID($topic_id); + $row = mysql_fetch_assoc($result); + $tag = $row['tag']; + return $tag; + + } + // =========================== // === for manage wordlist === @@ -469,7 +502,6 @@ } return $taglistArray; - } private function GetWordlistArray() { diff -r 54a235d43694 -r 3d6fba07bfbd develop/views/Extractapp/taggingtext.php --- a/develop/views/Extractapp/taggingtext.php Tue Feb 10 16:20:29 2015 +0100 +++ b/develop/views/Extractapp/taggingtext.php Wed Feb 11 12:33:59 2015 +0100 @@ -6,6 +6,7 @@ $section_id = $viewmodel['section_id']; $topiclistArray = $viewmodel['topiclistArray']; $default_topic_id = $viewmodel['default_topic_id']; +$topic_tag = $viewmodel['topic_tag']; ?> @@ -141,15 +142,31 @@ // for pop up window on edit-area for tag list newdiv.innerHTML = "Tag: "+String(selection)+"
"; + [TopicTag]Tag as:".$taglistValue[1]."(necessary for this topic!)\";\n"; + echo "newdiv.innerHTML += \"\";\n"; + echo "newdiv.innerHTML += \"
\";\n"; + break; + } + } + ?> + newdiv.innerHTML += "
"; Tag as:".$taglistValue[1]."(No BR)\";\n"; echo "newdiv.innerHTML += \"\";\n"; echo "newdiv.innerHTML += \"
\";\n"; - } else if ($taglistValue[2] == "post_time") { + } else */ + if ($taglistValue[2] == $topic_tag) { + // pass + } else if ($taglistValue[2] == "post_time") { echo "newdiv.innerHTML += \"\";\n"; echo "newdiv.innerHTML += \"
\";\n"; } else if ($taglistValue[2] == "office") { @@ -158,7 +175,8 @@ } else { echo "newdiv.innerHTML += \"\";\n"; echo "newdiv.innerHTML += \"
\";\n"; - } + } + } ?> } @@ -348,7 +366,7 @@
- +
Replace By Smart Regex©:

@@ -384,7 +402,7 @@ Export: Page: to

-
+