src/hg/lib/hui.c 1.245

1.245 2009/11/04 01:12:18 tdreszer
Added support in controlled vocabulary link to support suffix that is not pare of the link
Index: src/hg/lib/hui.c
===================================================================
RCS file: /projects/compbio/cvsroot/kent/src/hg/lib/hui.c,v
retrieving revision 1.244
retrieving revision 1.245
diff -b -B -U 4 -r1.244 -r1.245
--- src/hg/lib/hui.c	26 Oct 2009 23:06:11 -0000	1.244
+++ src/hg/lib/hui.c	4 Nov 2009 01:12:18 -0000	1.245
@@ -4814,16 +4814,30 @@
 int count,ix;
 boolean found=FALSE;
 if((count = chopByWhite(cloneString(vocab), words,15)) <= 1)
     return cloneString(label);
+
+char labelRoot[128];
+safecpy(labelRoot,sizeof(labelRoot),label);
+char *extra=strstrNoCase(labelRoot,"&nbsp;"); // &nbsp; mean don't include the reset as part of the link
+if ((long)extra==-1)
+    extra=NULL;
+if (extra!=NULL)
+    {
+    *extra='\0';
+    extra+=6;
+    }
+
 for(ix=1;ix<count && !found;ix++)
     {
 #define VOCAB_LINK "<A HREF='hgEncodeVocab?ra=/usr/local/apache/cgi-bin/%s&term=\"%s\"' title='%s details' TARGET=ucscVocab>%s</A>"
     if(sameString(vocabType,words[ix])) // controlledVocabulary setting matches tag so all labels are linked
         {
         int sz=strlen(VOCAB_LINK)+strlen(words[0])+strlen(words[ix])+2*strlen(label) + 2;
         char *link=needMem(sz);
-        safef(link,sz,VOCAB_LINK,words[0],words[ix],label,label);
+        safef(link,sz,VOCAB_LINK,words[0],words[ix],labelRoot,labelRoot);
+        if(extra)
+            safecat(link,sz,extra);
         freeMem(words[0]);
         return link;
         }
     else if(countChars(words[ix],'=') == 1 && childTdb != NULL) // The name of a trackDb setting follows and will be the controlled vocab term
@@ -4837,9 +4851,11 @@
                 {
 		char *encodedTerm = cgiEncode(cvTerm);
                 int sz=strlen(VOCAB_LINK)+strlen(words[0])+strlen(encodedTerm)+2*strlen(label) + 2;
                 char *link=needMem(sz);
-                safef(link,sz,VOCAB_LINK,words[0],encodedTerm,label,label);
+                safef(link,sz,VOCAB_LINK,words[0],encodedTerm,cvTerm,labelRoot);
+                if(extra)
+                    safecat(link,sz,extra);
                 freeMem(words[0]);
                 freeMem(cvTerm);
                 freeMem(encodedTerm);
                 return link;