[Vtigercrm-commits] [vtiger-commits] r7227 - in /vtigercrm/trunk: Smarty/templates/DetailView.tpl include/Ajax/TagCloud.php include/freetag/freetag.class.php modules/Home/index.php

vtigercrm-commits at vtiger.fosslabs.com vtigercrm-commits at vtiger.fosslabs.com
Sat Jun 17 08:00:57 EDT 2006


Author: don
Date: Sat Jun 17 06:00:49 2006
New Revision: 7227

Log:
Tag delete integrated

Modified:
    vtigercrm/trunk/Smarty/templates/DetailView.tpl
    vtigercrm/trunk/include/Ajax/TagCloud.php
    vtigercrm/trunk/include/freetag/freetag.class.php
    vtigercrm/trunk/modules/Home/index.php

Modified: vtigercrm/trunk/Smarty/templates/DetailView.tpl
==============================================================================
--- vtigercrm/trunk/Smarty/templates/DetailView.tpl (original)
+++ vtigercrm/trunk/Smarty/templates/DetailView.tpl Sat Jun 17 06:00:49 2006
@@ -12,8 +12,8 @@
 
 -->*}
 <script type="text/javascript" src="modules/{$MODULE}/{$SINGLE_MOD}.js"></script>
-
-
+<script src="include/scriptaculous/prototype.js" type="text/javascript"></script>
+<script src="include/scriptaculous/scriptaculous.js" type="text/javascript"></script>
 <script language="JavaScript" type="text/javascript" src="include/js/dtlviewajax.js"></script>
 <span id="crmspanid" style="display:none;position:absolute;"  onmouseover="show('crmspanid');">
    <a class="link"  align="right" href="javascript:;">{$APP.LBL_EDIT_BUTTON}</a>
@@ -51,6 +51,22 @@
 		alert("Please enter a tag");
 		return false;
 	{rdelim}
+{rdelim}
+function DeleteTag(id)
+{ldelim}
+	$("vtbusy_info").style.display="inline";
+	Effect.Fade('tag_'+id);
+	new Ajax.Request(
+		'index.php',
+                {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
+                        method: 'post',
+                        postBody: "file=TagCloud&module={$MODULE}&action={$MODULE}Ajax&ajxaction=DELETETAG&tagid=" +id,
+                        onComplete: function(response) {ldelim}
+						getTagCloud();
+						$("vtbusy_info").style.display="none";
+                        {rdelim}
+                {rdelim}
+        );
 {rdelim}
 </script>
 
@@ -323,17 +339,21 @@
 {/if}
 
 <script>
+function getTagCloud()
+{ldelim}
 new Ajax.Request(
         'index.php',
         {ldelim}queue: {ldelim}position: 'end', scope: 'command'{rdelim},
         method: 'post',
-        postBody: 'module={$MODULE}&action={$MODULE}Ajax&file=TagCloud&ajxaction=GETTAGCLOUD',
+        postBody: 'module={$MODULE}&action={$MODULE}Ajax&file=TagCloud&ajxaction=GETTAGCLOUD&recordid={$ID}',
         onComplete: function(response) {ldelim}
                                 $("tagfields").innerHTML=response.responseText;
                                 $("txtbox_tagfields").value ='';
                         {rdelim}
         {rdelim}
 );
+{rdelim}
+getTagCloud();
 </script>
 <!-- added for validation -->
 <script language="javascript">

Modified: vtigercrm/trunk/include/Ajax/TagCloud.php
==============================================================================
--- vtigercrm/trunk/include/Ajax/TagCloud.php (original)
+++ vtigercrm/trunk/include/Ajax/TagCloud.php Sat Jun 17 06:00:49 2006
@@ -9,49 +9,45 @@
   *
   ********************************************************************************/
 $ajaxaction = $_REQUEST['ajxaction'];
+global $current_user;
+$crmid = $_REQUEST["recordid"];
+$module = $_REQUEST["module"];
+$userid = $current_user->id;
 if($ajaxaction == "SAVETAG")
 {
 	
 	require_once('include/freetag/freetag.class.php');
-	global $current_user;
-	$crmid = $_REQUEST["recordid"];
-	$module = $_REQUEST["module"];
 	$tagfields = $_REQUEST["tagfields"];
-	$userid = $current_user->id;
-    $freetag = new freetag();
+    	$freetag = new freetag();
 	if (isset($_REQUEST["tagfields"]) && trim($_REQUEST["tagfields"]) != "")
 	{
-	      $freetag->tag_object($userid,$crmid,$tagfields,$module);
-	 	  $tagcloud = $freetag->get_tag_cloud_html($module);
-		  echo $tagcloud;
+	      	$freetag->tag_object($userid,$crmid,$tagfields,$module);
+	  	$tagcloud = $freetag->get_tag_cloud_html($module,$userid,$crmid);
+	  	echo $tagcloud;
 	}
-	
+
 }
 elseif($ajaxaction == 'GETTAGCLOUD')
 {
 	require_once('include/freetag/freetag.class.php');
 	$freetag = new freetag();
-	$module = $_REQUEST["module"];
-	$useid = $current_user->id;
+	if(trim($module) != "")
+	{
+		$tagcloud = $freetag->get_tag_cloud_html($module,$userid,$crmid);
+		echo $tagcloud;
+	}else
+	{
+		$tagcloud = $freetag->get_tag_cloud_html("",$userid);
+		echo $tagcloud;
+	}
+}elseif($ajaxaction == 'DELETETAG')
+{
+	$tagid = $_REQUEST['tagid']; 
 	global $adb;
-	$query="select * from vtiger_freetagged_objects where module = '".$module ."'";
+	$query="delete from vtiger_freetagged_objects where tag_id=".$tagid;
 	$result=$adb->query($query);
-	if($adb->num_rows($result) > 0)
-	{
-		if(trim($module) != "")
-		{
-			$tagcloud = $freetag->get_tag_cloud_html($module);
-			echo $tagcloud;
-		}else
-		{
-			$tagcloud = $freetag->get_tag_cloud_html();
-			echo $tagcloud;
-		}
-	}
-	else
-	{
-		echo '';
-	}
+	$query="delete from vtiger_freetags where id=".$tagid;
+	$result=$adb->query($query);
+	echo 'SUCESS';
 }
-
 ?>

Modified: vtigercrm/trunk/include/freetag/freetag.class.php
==============================================================================
--- vtigercrm/trunk/include/freetag/freetag.class.php (original)
+++ vtigercrm/trunk/include/freetag/freetag.class.php Sat Jun 17 06:00:49 2006
@@ -894,13 +894,16 @@
 	 * @return string Returns an HTML snippet that can be used directly as a tag cloud.
 	 */
 
-	function get_tag_cloud_html($module="",$num_tags = 100, $min_font_size = 10, $max_font_size = 20, $font_units = 'px', $span_class = '', $tag_page_url = '/tag/', $tagger_id = NULL) {
-		$tag_list = $this->get_tag_cloud_tags($num_tags, $tagger_id,$module);
-		if(!$tag_list) return;
+	function get_tag_cloud_html($module="",$tagger_id = NULL,$obj_id= NULL,$num_tags = 100, $min_font_size = 10, $max_font_size = 20, $font_units = 'px', $span_class = '', $tag_page_url = '/tag/') {
+		global $theme;
+		$theme_path="themes/".$theme."/";
+		$image_path=$theme_path."images/";	
+		$tag_list = $this->get_tag_cloud_tags($num_tags, $tagger_id,$module,$obj_id);
+		if(!$tag_list[0]) return;
 		// Get the maximum qty of tagged objects in the set
-		$max_qty = max(array_values($tag_list));
+		$max_qty = max(array_values($tag_list[0]));
 		// Get the min qty of tagged objects in the set
-		$min_qty = min(array_values($tag_list));
+		$min_qty = min(array_values($tag_list[0]));
 
 		// For ever additional tagged object from min to max, we add
 		// $step to the font size.
@@ -920,11 +923,22 @@
 		include("config.php");
 		if($module =='')
 			$module = 'All';	
-		foreach ($tag_list as $tag => $qty) {
-          		$size = $min_font_size + ($qty - $min_qty) * 3;
-			$cloud_span[] = '<span class="' . $span_class . '"><a class="tagit" href="'.$site_URL.'/index.php?module=Home&action=UnifiedSearch&search_module='.$module.'&query_string='. $tag . '" style="font-size: '. $size . $font_units . '">' . htmlspecialchars(stripslashes($tag)) . '</a></span>';
-
-		}
+		if($module != 'All')	
+		{	
+			foreach($tag_list[0] as $tag => $qty) {
+				$size = $min_font_size + ($qty - $min_qty) * 3;
+				$cloud_span[] = '<span id="tag_'.$tag_list[1][$tag].'" class="' . $span_class . '" onMouseOver=$("tagspan_'.$tag_list[1][$tag].'").style.display="inline"; onMouseOut=$("tagspan_'.$tag_list[1][$tag].'").style.display="none";><a class="tagit" href="'.$site_URL.'/index.php?module=Home&action=UnifiedSearch&search_module='.$module.'&query_string='. $tag . '" style="font-size: '. $size . $font_units . '">' . htmlspecialchars(stripslashes($tag)) . '</a><span class="'. $span_class .'" id="tagspan_'.$tag_list[1][$tag].'" style="display:none;cursor:pointer;" onClick="DeleteTag('.$tag_list[1][$tag].');"><img src="'.$image_path.'del_tag.gif"></span></span>';
+
+			}
+		}else
+		{
+			foreach($tag_list[0] as $tag => $qty) {
+				$size = $min_font_size + ($qty - $min_qty) * 3;
+				$cloud_span[] = '<span class="' . $span_class . '"><a class="tagit" href="'.$site_URL.'/index.php?module=Home&action=UnifiedSearch&search_module='.$module.'&query_string='. $tag . '" style="font-size: '. $size . $font_units . '">' . htmlspecialchars(stripslashes($tag)) . '</a></span>';
+
+			}
+
+		}	
 		$cloud_html = join("\n ", $cloud_span);
 
 		return $cloud_html;
@@ -948,22 +962,28 @@
 	 * values are numeric quantity of objects tagged with that tag.
 	 */
 
-	function get_tag_cloud_tags($max = 100, $tagger_id = NULL,$module = "") {
+	function get_tag_cloud_tags($max = 100, $tagger_id = NULL,$module = "",$obj_id = NULL) {
 		global $adb;
 		if(isset($tagger_id) && ($tagger_id > 0)) {
-			$tagger_sql = "AND tagger_id = $tagger_id";
+			$tagger_sql = " AND tagger_id = $tagger_id";
 		} else {
 			$tagger_sql = "";
 		}
 
 		if($module != "") {
-			$tagger_sql .= "AND module = '$module'";
+			$tagger_sql .= " AND module = '$module'";
 		} else {
 			$tagger_sql .= "";
 		}
 
-		$prefix = $this->_table_prefix;
-		$sql = "SELECT tag, COUNT(object_id) AS quantity
+		if(isset($obj_id) && $obj_id > 0) {
+                        $tagger_sql .= " AND object_id = $obj_id";
+                } else {
+                        $tagger_sql .= "";
+                }
+
+		$prefix = $this->_table_prefix;
+		$sql = "SELECT tag,tag_id,COUNT(object_id) AS quantity
 			FROM ${prefix}freetags INNER JOIN ${prefix}freetagged_objects
 			ON (${prefix}freetags.id = tag_id)
 			WHERE 1=1
@@ -975,39 +995,15 @@
 		$retarr = array();
 		while(!$rs->EOF) {
 			$retarr[$rs->fields['tag']] = $rs->fields['quantity'];
+			$retarr1[$rs->fields['tag']] = $rs->fields['tag_id'];
 			$rs->MoveNext();
 		}
-
 		if($retarr) ksort($retarr);
-
-		return $retarr;
-
-	}
-
-
-	/**
-	 * silly_list
-	 *
-	 * silly_list is now deprecated in favor of using get_tag_cloud_tags. It's still
-	 * available for compatibility. If you're just looking to get a tag cloud going,
-	 * try get_tag_cloud_html().
-	 * 
-	 * This is a function built explicitly to set up a page with most popular tags
-	 * that contains an alphabetically sorted list of tags, which can then be sized
-	 * or colored by popularity.
-	 *
-	 * Also known more popularly as Tag Clouds!
-	 *
-	 * Here's the example case: http://upcoming.org/tag/
-	 *
-	 * @param int The maximum number of tags to return.
-	 *
-	 * @return array Returns an array where the keys are normalized tags, and the
-	 * values are numeric quantity of objects tagged with that tag.
-	 */
-
-	function silly_list($max = 100, $tagger_id = NULL) {
-		return $this->get_tag_cloud_tags($max, $tagger_id);
+		if($retarr1) ksort($retarr1);
+		$return_value[]=$retarr;
+		$return_value[]=$retarr1;
+		return $return_value;
+
 	}
 
 	/**

Modified: vtigercrm/trunk/modules/Home/index.php
==============================================================================
--- vtigercrm/trunk/modules/Home/index.php (original)
+++ vtigercrm/trunk/modules/Home/index.php Sat Jun 17 06:00:49 2006
@@ -166,7 +166,7 @@
 $smarty->assign("HOMEDEFAULTVIEW",DefHomeView());
 $smarty->assign("ACTIVITIES",$activities);
 $freetag = new freetag();
-$smarty->assign("ALL_TAG",$freetag->get_tag_cloud_html());
+$smarty->assign("ALL_TAG",$freetag->get_tag_cloud_html("",$current_user->id));
 $smarty->display("HomePage.tpl");
 
 function getLoginHistory()





More information about the vtigercrm-commits mailing list