Changeset 334 for trunk/lib/Utilities.inc.php
- Timestamp:
- May 13, 2008 4:14:53 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/Utilities.inc.php
r331 r334 69 69 * 70 70 * @param string $text Text to clean. 71 * @param bool $preserve_html If set to true, oTxt will not translage <, >, ", or ' 72 * characters into HTML entities. This allows HTML to pass 73 * through unmunged. 71 * @param bool $preserve_html If set to true, oTxt will not translate <, >, ", or ' 72 * characters into HTML entities. This allows HTML to pass through unmunged. 74 73 * @return string Cleaned text. 75 74 */ … … 100 99 } 101 100 102 // & becomes &. Exclude any occur ance where the & is followed by a alphanum or unicode caracter.101 // & becomes &. Exclude any occurrence where the & is followed by a alphanum or unicode character. 103 102 $search['ampersand'] = '/&(?![\w\d#]{1,10};)/'; 104 103 $replace['ampersand'] = '&'; 105 104 106 return preg_replace($search, $replace, html entities($text, ENT_QUOTES, $app->getParam('character_set')));107 } 108 109 /** 110 * Returns text with stylistic modifications. Warning: this will break some HTML att ibutes!105 return preg_replace($search, $replace, htmlspecialchars($text, ENT_QUOTES, $app->getParam('character_set'))); 106 } 107 108 /** 109 * Returns text with stylistic modifications. Warning: this will break some HTML attributes! 111 110 * TODO: Allow a string such as this to be passed: <a href="javascript:openPopup('/foo/bar.php')">Click here</a> 112 111 * … … 143 142 144 143 /** 145 * Applies a class to search terms to highlight them ala -google results.144 * Applies a class to search terms to highlight them ala google results. 146 145 * 147 146 * @param string $text Input text to search. … … 169 168 170 169 /** 171 * Generates a hexadeci bal html color based on provided word.170 * Generates a hexadecimal html color based on provided word. 172 171 * 173 172 * @access public … … 190 189 case 1 : 191 190 default : 192 // Reduce all hex values sligh ly to avoid all white.191 // Reduce all hex values slightly to avoid all white. 193 192 array_walk($rgb, create_function('&$v', '$v = dechex(round(hexdec($v) * 0.87));')); 194 193 break; … … 353 352 354 353 /** 355 * Tests the exist ance of a file anywhere in the include path.354 * Tests the existence of a file anywhere in the include path. 356 355 * 357 356 * @param string $file File in include path. … … 440 439 /** 441 440 * If $var is net set or null, set it to $default. Otherwise leave it alone. 442 * Returns the final value of $var. Use to find a default value of one is not av ilable.441 * Returns the final value of $var. Use to find a default value of one is not available. 443 442 * 444 443 * @param mixed $var The variable that is being set. … … 460 459 * 461 460 * @param array $array input array 462 * @param array $delim optional character that will also be e xcaped.461 * @param array $delim optional character that will also be escaped. 463 462 * @return array an array with the same values as $array1 but shuffled 464 463 */ … … 480 479 * Converts a PHP Array into encoded URL arguments and return them as an array. 481 480 * 482 * @param mixed $data An array to transverse recursiv ly, or a string481 * @param mixed $data An array to transverse recursively, or a string 483 482 * to use directly to create url arguments. 484 483 * @param string $prefix The name of the first dimension of the array. … … 494 493 if (is_array($data)) { 495 494 foreach ($data as $key => $val) { 496 // If the prefix is empty, use the $key as the name of the first dimen tion of the "array".497 // ...otherwise, append the key as a new dimen tion of the "array".495 // If the prefix is empty, use the $key as the name of the first dimension of the "array". 496 // ...otherwise, append the key as a new dimension of the "array". 498 497 $new_prefix = ('' == $prefix) ? urlencode($key) : $prefix . '[' . urlencode($key) . ']'; 499 498 // Enter recursion. … … 501 500 } 502 501 } else { 503 // We've come to the last dimen tion of the array, save the "array" and its value.502 // We've come to the last dimension of the array, save the "array" and its value. 504 503 $args[$prefix] = urlencode($data); 505 504 } … … 517 516 * Converts a PHP Array into encoded URL arguments and return them in a string. 518 517 * 519 * @param mixed $data An array to transverse recursiv ly, or a string518 * @param mixed $data An array to transverse recursively, or a string 520 519 * to use directly to create url arguments. 521 * @param string $prefix The name of the first dimen tion of the array.520 * @param string $prefix The name of the first dimension of the array. 522 521 * If not specified, the first keys of the array will be used. 523 522 * @return string url A string ready to append to a url. … … 537 536 538 537 /** 539 * Fills an arrray with the result from a multiple ereg search. 540 * Curtesy of Bruno - rbronosky@mac.com - 10-May-2001 541 * Blame him for the funky do...while loop. 538 * Fills an array with the result from a multiple ereg search. 539 * Courtesy of Bruno - rbronosky@mac.com - 10-May-2001 542 540 * 543 541 * @param mixed $pattern regular expression needle … … 661 659 /** 662 660 * If magic_quotes_gpc is in use, run stripslashes() on $var. If $var is an 663 * array, stripslashes is run on each value, recursiv ly, and the stripped661 * array, stripslashes is run on each value, recursively, and the stripped 664 662 * array is returned. 665 663 * … … 991 989 * 992 990 * @param bool $exclude_query Remove the query string first before comparing. 993 * @return bool True if the current URL is the same as the refer ing URL, false otherwise.991 * @return bool True if the current URL is the same as the referring URL, false otherwise. 994 992 */ 995 993 function refererIsMe($exclude_query=false)
Note: See TracChangeset
for help on using the changeset viewer.