a_href() fixed to return the value (not to print it)
[www.energie.vellum.cz.git] / common.php
index 4acad91..048176a 100644 (file)
@@ -10,6 +10,9 @@
                unset($viewcvs);
        $cvs_id_split=split(" ",$cvs_id);
        if (count($cvs_id_split)==8) {
+               $cvs_id_split[2]=""
+                               ."<a href=\"".ereg_replace("/viewcvs/","\\0~checkout~/",$viewcvs)."?rev=".$cvs_id_split[2]."\">"
+                               .$cvs_id_split[2]."</a>";
                $cvs_id_split[1]="<a href=\"$viewcvs\">".$cvs_id_split[1]."</a>";
                $cvs_id_split[5]="<a href=\"mailto:".$cvs_id_split[5]."@$cvs_mailhost\">".$cvs_id_split[5]."</a>";
                }
@@ -628,10 +631,20 @@ function a_href($url,$contents)
 {
        global $have_ent;
 
-       print("<a href=\"");
-       if (ereg("^[a-z]+://",$url) && !$have_ent)
-               $url="redirect.php?location=".urlencode($url);
-       print(htmlspecialchars($url)."\">$contents</a>");
+       $r="<a href=\"";
+       $urlent=htmlspecialchars($url);
+            if ($url==$urlent)
+               $r.=$url;
+       else if (!ereg("^[a-z]+://",$url))      // $url is our resource
+               $r.=$urlent;
+       else if (isset($have_ent) && !$have_ent)        // non-ent client
+               $r.=$url;
+       else if ($have_ent) // ent client
+               $r.=$urlent;
+       else // unknown client, htmlspecialchars() should not be needed here
+               $r.=htmlspecialchars("redirect.php?location=".urlencode($url));
+       $r.="\">$contents</a>";
+       return($r);
 }
 
 function footer($delimit=true)