- Timestamp:
- May 16, 2007 5:36:18 AM (17 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/css/codebase.inc.css
r107 r257 9 9 */ 10 10 11 /*_____________________ SC Messaging____________________*/11 /*_____________________ App.inc.php ____________________*/ 12 12 .sc-msg { font-family: verdana,geneva,arial,sans-serif; } 13 13 … … 25 25 .sc-msg-notice { color: #C60; border-color: #C60; } 26 26 27 /*_____________________ PEdit Forms____________________*/27 /*_____________________ PEdit.inc.php ____________________*/ 28 28 29 29 .sc-pedit-form {} … … 49 49 white-space: nowrap; 50 50 } 51 52 /*_____________________ Utilities.inc.php ____________________*/ 53 54 .sc-highlightwords { 55 background-color: #EBFE00; 56 color: #000; 57 } -
trunk/lib/Utilities.inc.php
r255 r257 67 67 * Returns text with appropriate html translations. 68 68 * 69 * @param string $t xtText to clean.69 * @param string $text Text to clean. 70 70 * @param bool $preserve_html If set to true, oTxt will not translage <, >, ", or ' 71 71 * characters into HTML entities. This allows HTML to pass … … 73 73 * @return string Cleaned text. 74 74 */ 75 function oTxt($t xt, $preserve_html=false)75 function oTxt($text, $preserve_html=false) 76 76 { 77 77 $app =& App::getInstance(); … … 103 103 $replace['ampersand'] = '&'; 104 104 105 return preg_replace($search, $replace, htmlentities($t xt, ENT_QUOTES, $app->getParam('character_set')));105 return preg_replace($search, $replace, htmlentities($text, ENT_QUOTES, $app->getParam('character_set'))); 106 106 } 107 107 … … 110 110 * TODO: Allow a string such as this to be passted: <a href="javascript:openPopup('/foo/bar.php')">Click here</a> 111 111 * 112 * @param string $t xtText to clean.112 * @param string $text Text to clean. 113 113 * @return string Cleaned text. 114 114 */ 115 function fancyTxt($t xt)115 function fancyTxt($text) 116 116 { 117 117 $search = array(); … … 138 138 $replace['em_dash'] = '$1—$2'; 139 139 140 return preg_replace($search, $replace, $txt); 140 return preg_replace($search, $replace, $text); 141 } 142 143 /** 144 * Applies a class to search terms to highlight them ala-google results. 145 * 146 * @param string $text Input text to search. 147 * @param string $search String of word(s) that will be highlighted. 148 * @param string $class CSS class to apply. 149 * @return string Text with searched words wrapped in <span>. 150 */ 151 function highlightWords($text, $search, $class='sc-highlightwords') 152 { 153 $words = preg_split('/[^\w]/', $search, -1, PREG_SPLIT_NO_EMPTY); 154 155 $search = array(); 156 $replace = array(); 157 158 foreach ($words as $w) { 159 $search[] = '/\b(' . preg_quote($w) . ')\b/i'; 160 $replace[] = '<span class="' . $class . '">$1</span>'; 161 } 162 163 return preg_replace($search, $replace, $text); 141 164 } 142 165
Note: See TracChangeset
for help on using the changeset viewer.