]> andersk Git - sql-web.git/blobdiff - lib/display.lib.php
git-svn-id: svn://presbrey.mit.edu/sql/web@112 a142d4bd-2cfb-0310-9673-cb33a7e74f58
[sql-web.git] / lib / display.lib.php
index b1d6d2d4d9de8af442aa110139920156e0d0a509..e33721d1339935312ae802351ee0fb086a865b0c 100644 (file)
@@ -1,4 +1,7 @@
 <?php
+/*
+       (c) 2005 Joe Presbrey
+*/
 
 ## FORMATTING FUNCTIONS
 
@@ -20,4 +23,54 @@ function sprintTS($timestamp) {
                ':'.substr($timestamp,12,2);
 }
 
+function printBar($percent, $txt1 = '', $txt2 = '') {
+       $color1 = 'black';
+       $color2 = 'white';
+       $color3 = 'white';
+       $color4 = 'black';
+       /* if ($percent>1) {
+               $percent = $percent/100;
+       }
+       } elseif (!is_integer($percent) && $percent<2) {
+               $percent = $percent*100;
+       } elseif ($percent == 1) {
+               $percent = 100;
+       } */
+       $per1 = $per2 = floor($percent*100);
+       if ($per1>100) {
+               $per1 = 100;
+               $per2 = 0;
+       } else {
+               $per2 = 100 - $per2;
+       }
+       $per1 .= "%";
+       $per2 .= "%";
+/*     return '<table cellpadding=0 cellspacing=0 width="100%" class="bargraph">
+                               <tr>
+                               <td class="bar" align="left" width="'.$per1.'"><div style="position: relative;"><div style="left: 0; display: inline; position: absolute;">&nbsp;'.$txt1.'&nbsp;</div>&nbsp;</div></td>
+                               <td class="fill" align="left" width="'.$per2.'"><div style="position: relative;">&nbsp;<div style="right: 0; display: inline; position: absolute;">'.$txt2.'&nbsp;<em>'.$per1.'</em></div></div></td>
+                               </tr></table>';*/
+       return '<table cellpadding=0 cellspacing=0 width="100%" class="bargraph">
+                               <tr>
+                               <td class="bar" align="left" width="'.$per1.'"><div style="position: relative;"></div></td>
+                               <td class="fill" align="right" width="'.$per2.'"><div style="position: relative;"></div></td>
+                               </tr>
+                       </table><table cellpadding=0 cellspacing=0 width="100%">
+                               <tr style="height: 1px;">
+                               <td class="bar" align="left" width="50%"><div style="position: relative;"><div style="bottom: 3px; left: 5px; position: absolute;">'.$txt1.'</div></div></td>
+                               <td class="fill" align="right" width="50%"><div style="position: relative;"><div style="bottom: 3px; right: 3px; position: absolute;">'.$txt2.'&nbsp;&nbsp;<em>'.$per1.'</em></div></div></td>
+                               </tr>
+                               </table>';
+}
+
+function chars_encode($string) {
+   $chars = array();
+   $ent = null;
+   $chars = preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY);
+   for ($i = 0; $i < count($chars); $i++)
+               $ent[$i] = '&#' . ord($chars[$i]) . ';';
+   if (sizeof($ent) < 1) return '';
+   return implode('',$ent);
+}
+
 ?>
This page took 0.035811 seconds and 4 git commands to generate.