Changeset 235 for trunk/lib/Utilities.inc.php
- Timestamp:
- Mar 7, 2007 11:32:07 AM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Utilities.inc.php
r224 r235 150 150 function getTextColor($text, $method=1) 151 151 { 152 $r = substr(md5($text), 0, 1); 153 $g = substr(md5($text), 1, 1); 154 $b = substr(md5($text), 2, 1); 152 $hash = md5($text); 153 $rgb = array( 154 substr($hash, 0, 1), 155 substr($hash, 1, 1), 156 substr($hash, 2, 1), 157 substr($hash, 3, 1), 158 substr($hash, 4, 1), 159 substr($hash, 5, 1), 160 ); 155 161 156 162 switch ($method) { 157 case 2 :158 if (hexdec($r) > hexdec('c')) {159 $r = dechex(hexdec('f') - hexdec($r));160 }161 if (hexdec($g) > hexdec('c')) {162 $g = dechex(hexdec('f') - hexdec($g));163 }164 if (hexdec($b) > hexdec('c')) {165 $b = dechex(hexdec('f') - hexdec($b));166 }167 break;168 169 163 case 1 : 170 164 default : 171 $r = dechex(round(hexdec($r) * .8)); 172 $g = dechex(round(hexdec($g) * .8)); 173 $b = dechex(round(hexdec($b) * .6)); 165 // Reduce all hex values slighly to avoid all white. 166 array_walk($rgb, create_function('&$v', '$v = dechex(round(hexdec($v) * 0.87));')); 174 167 break; 175 } 176 177 return $r . $r . $g . $g . $b . $b; 168 case 2 : 169 foreach ($rgb as $i => $v) { 170 if (hexdec($v) > hexdec('c')) { 171 $rgb[$i] = dechex(hexdec('f') - hexdec($v)); 172 } 173 } 174 break; 175 } 176 177 return join('', $rgb); 178 178 } 179 179 … … 392 392 * @return array URL with array elements as URL key=value arguments. 393 393 */ 394 function urlEncodeArray($data, $prefix='', $_return=true) { 394 function urlEncodeArray($data, $prefix='', $_return=true) 395 { 395 396 396 397 // Data is stored in static variable. … … 428 429 * @return string url A string ready to append to a url. 429 430 */ 430 function urlEncodeArrayToString($data, $prefix='') { 431 function urlEncodeArrayToString($data, $prefix='') 432 { 431 433 432 434 $array_args = urlEncodeArray($data, $prefix); … … 708 710 * will see data before the page is finished processing. 709 711 */ 710 function flushBuffer() { 712 function flushBuffer() 713 { 711 714 echo str_repeat(' ', 205); 712 715 flush();
Note: See TracChangeset
for help on using the changeset viewer.