changeset 23:a879f6b9d166

modification for select-move-taglist: tags don't appear to be duplicated in other topics.
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Wed, 25 Feb 2015 10:59:45 +0100
parents a8ae5cbc3364
children b55f5d3564c4
files develop/index.php develop/models/extractapp.php develop/views/Extractapp/configtagsintopic.php develop/views/Extractapp/taggingtext.php develop/views/maintemplate_local.php
diffstat 5 files changed, 58 insertions(+), 62 deletions(-) [+]
line wrap: on
line diff
--- a/develop/index.php	Tue Feb 24 17:29:56 2015 +0100
+++ b/develop/index.php	Wed Feb 25 10:59:45 2015 +0100
@@ -19,17 +19,6 @@
 require("controllers/home.php");
 require("controllers/extractapp.php");
 
-/*
-$output = '{"file":{"id":5,"creationDate":"11/02/2015-15:52","text":"Jorge   青城續修縣志第五册   藝文志 上     山左文人遞興一盛於邊廷實再盛於李滄 HHHH","creatorId":12,"fileName":"66666_3_5_2015.02.11_03.52.42.747.txt","info":"id=5, creation date=Wed Feb 11 15:52:42 CET 2015, last change=Wed Feb 11 15:52:42 CET 2015"},"branch":{"id":3,"creationDate":"11/02/2015-15:42","currentLastFileId":5,"sectionId":66666,"creatorId":12,"label":"qwe","info":"id=3, creation date=Wed Feb 11 15:42:36 CET 2015, last change=Wed Feb 11 15:52:42 CET 2015"}}';
-echo $output;
-
-$json = json_decode($output, true);
-
-echo "id=";
-echo $json['file']['id'];
-echo "<br>";
-*/
-
 
 
 // create the controller and execute the action
--- a/develop/models/extractapp.php	Tue Feb 24 17:29:56 2015 +0100
+++ b/develop/models/extractapp.php	Wed Feb 25 10:59:45 2015 +0100
@@ -633,12 +633,32 @@
         $tag_tmp_others = array();
         while ($row = mysql_fetch_assoc($result)) {
             if ($row['topic_id'] == $topic) {
-                array_push($tag_intopic, array('id=>'=>$row['id'],'name'=>$row['name'], 'tag'=>$row['tag'], 'color'=>$row['color'], 'topic_id'=>$row['topic_id']));
+                array_push($tag_intopic, array('id'=>$row['id'],'name'=>$row['name'], 'tag'=>$row['tag'], 'color'=>$row['color'], 'topic_id'=>$row['topic_id']));
             } else {
-                array_push($tag_tmp_others, array('id=>'=>$row['id'],'name'=>$row['name'], 'tag'=>$row['tag'], 'color'=>$row['color'], 'topic_id'=>$row['topic_id']));
+                array_push($tag_tmp_others, array('id'=>$row['id'],'name'=>$row['name'], 'tag'=>$row['tag'], 'color'=>$row['color'], 'topic_id'=>$row['topic_id']));
             }
         }
 
+        // check if there's any duplicated tags in tag_tmp_others. remove the duplicated tags
+        $num_others = count($tag_tmp_others);
+        for ($i=0; $i < $num_others; $i++) { 
+            $cnt = 0;
+            for ($j=$i+1; $j < $num_others; $j++) { 
+                if ($tag_tmp_others[$i]['tag'] == $tag_tmp_others[$j]['tag']) {
+                    break;
+                } else {
+                    $cnt++;
+                }
+            }
+            if ($cnt == ($num_others-$i-1) ) {
+                $row = $tag_tmp_others[$i];
+                array_push($tag_others, array('id'=>$row['id'],'name'=>$row['name'], 'tag'=>$row['tag'], 'color'=>$row['color'], 'topic_id'=>$row['topic_id']) );
+            }
+        }
+
+        // remove duplicated tags in tag_others that is duplicated with tags in tag_intopic
+        $tag_tmp_others = $tag_others;
+        $tag_others = array();
         
         foreach ($tag_tmp_others as $tmp) {
             $cnt = 0;
@@ -650,6 +670,7 @@
                 }
             }
             if ($cnt == count($tag_intopic)) {
+                // not appear in $tag_intopic
                 array_push($tag_others, $tmp);
             }
         }
@@ -723,7 +744,7 @@
     
 
         /*
-§        $query = "SELECT * FROM topic_tag_relation";
+        $query = "SELECT * FROM topic_tag_relation";
         $result = mysql_query($query);
         if (!$result) {
             echo json_encode("error when select from topic_tag_relation");
--- a/develop/views/Extractapp/configtagsintopic.php	Tue Feb 24 17:29:56 2015 +0100
+++ b/develop/views/Extractapp/configtagsintopic.php	Wed Feb 25 10:59:45 2015 +0100
@@ -85,10 +85,8 @@
 
 </script>
 
-<div class="container-fluid">
-    <div class="row">	
-    	<div class="col-xs-12 col-sm-12 col-md-8 col-md-offset-2 col-lg-6 col-lg-offset-3">
-
+<div class="container-fluid" style="margin-left:30%;">
+   
 		<form name="config" autocomplete='off' action="Javascript:checkTopic(document.config.InTopic)">
 			<h3>Topic: <?php echo $topic_name;?> </h3>
 			
@@ -105,7 +103,7 @@
 					<td>
 						<select name="InTopic" size="<?php echo count($taglistArray)*0.8; ?>" class="form-control" multiple>
 							<?php 
-								foreach ($taglistArray as $taglistValue) {
+								foreach ($tag_intopic as $taglistValue) {
 									if ($taglistValue['topic_id'] == $topic) {
 										echo "<option value='".$taglistValue['id']."'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>";
 									}
@@ -121,7 +119,7 @@
 					<td >
 						<select name="Others" size="<?php echo count($taglistArray)*0.8; ?>" class="form-control" multiple>
 							<?php 
-								foreach ($taglistArray as $taglistValue) {
+								foreach ($tag_others as $taglistValue) {
 									if ($taglistValue['topic_id'] != $topic) {
 										echo "<option value='".$taglistValue['id']."'>".$taglistValue['name']." (".$taglistValue['tag'].") "."</option>";
 									}
@@ -137,49 +135,9 @@
 				</tr>
 				</tbody>
 			</table>
-
 			
 		</form>
-		</div>
-	</div>
 </div>
 
-	<!--
-	<form name="config" autocomplete='off' action="Javascript:checkTopic(this)">
-		<h3>Topic: <?php echo $topic_name;?> </h3>
-		<div> Select/Unselect the following tags for the topic. </div> 
-		<input type="submit" value="Submit">
-
-		<table style="" border="1">
-			<thead>
-			<tr>
-				<td>Name</td>
-				<td>Tag</td>
-				<td>Select/Unselect</td>
-			</tr>	
-			</thead>
-			<tbody>
-			<?php
-				// list the tags with topic
-				foreach ($taglistArray as $taglistValue) {
-					echo "<tr>";
-					echo "<td>".$taglistValue['name']."</td>";
-					echo "<td>".$taglistValue['tag']."</td>";
-					// checkbox for topic
-					if ($taglistValue['topic_id'] == $topic) {
-						echo "<td> <input type='checkbox' name='".$taglistValue['id']."' checked='true'/> </td>";
-					} else {
-						echo "<td> <input type='checkbox' name='".$taglistValue['id']."'/> </td>";
-					}
-					echo "</tr>";
-				}
-			?>       
-			</tbody>
-		</table>
-		
-	</form>
-	-->
-
-
 </body>
 </html>
--- a/develop/views/Extractapp/taggingtext.php	Tue Feb 24 17:29:56 2015 +0100
+++ b/develop/views/Extractapp/taggingtext.php	Wed Feb 25 10:59:45 2015 +0100
@@ -666,14 +666,14 @@
                 </div>
             </div>
 
-            <div id="follow-scroll" style="position:absolute; height:680px; overflow:scroll;margin:0 5 5 5; max-width:270px">
+            <div id="follow-scroll" style="position:absolute; height:680px; overflow:scroll; margin:0 5 5 5; max-width:270px">
                 <form action="javascript:void(0);">   
                     <fieldset>
                         <legend><h5 class="text-success"> Config Topic: </h5></legend>
                         <div> current topic is <?php echo $topic_name; ?> 
                             <button onclick="chooseTopic(<?php echo $default_topic_id; ?>)" class="btn btn-xs btn-default">Change</button>
                         </div>
-                        <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-sm btn-default" style="">Config Tags</button></br>
+                        <button onclick="configTagsInTopic(<?php echo $default_topic_id;?>)" class="btn btn-sm btn-default" style="">Manage Tags in topic</button></br>
                     </fieldset>
 
                     <fieldset>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/develop/views/maintemplate_local.php	Wed Feb 25 10:59:45 2015 +0100
@@ -0,0 +1,28 @@
+<html>
+<head>
+<title></title>
+
+<!-- 
+<script src="../../js/jquery-1.10.2.min.js"></script> 
+<script src="../../js/taggingtext.js"></script>
+-->
+
+<script src="../../js/jquery-1.10.2.min.js"></script>
+<script src="../../js/taggingtext.js"></script>
+
+
+<!-- Bootstrap -->
+<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
+<!--
+<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
+<link href="../../css/bootstrap.min.css" rel="stylesheet">
+<script src="../../js/bootstrap.min.js"></script>
+<script src="../../js/bootstrap.js"></script>
+-->
+
+</head>
+<body>
+
+</body>
+
+</html>
\ No newline at end of file