- Timestamp:
- 09/13/08 21:57:48 (2 years ago)
- Files:
-
- fActiveRecord.php (modified) (1 diff)
- fHTML.php (modified) (5 diffs)
- fPrintableException.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
fActiveRecord.php
r214 r218 Hide Line Numbers 1046 1046 // Turn like-breaks into breaks for text fields and add links 1047 1047 if ($formatting === TRUE && in_array($column_type, array('varchar', 'char', 'text'))) { 1048 return fHTML:: createLinks(fHTML::convertNewlines(fHTML::prepare($value)));1048 return fHTML::makeLinks(fHTML::convertNewlines(fHTML::prepare($value))); 1049 1049 } 1050 1050 fHTML.php
r214 r218 Hide Line Numbers 24 24 * @return boolean If the content contains a block level tag 25 25 */ 26 static public function c heckForBlockLevelHTML($content)26 static public function containsBlockLevelHTML($content) 27 27 { 28 28 static $inline_tags = '<a><abbr><acronym><b><big><br><button><cite><code><del><dfn><em><font><i><img><input><ins><kbd><label><q><s><samp><select><small><span><strike><strong><sub><sup><textarea><tt><u><var>'; … … 41 41 static $inline_tags_minus_br = '<a><abbr><acronym><b><big><button><cite><code><del><dfn><em><font><i><img><input><ins><kbd><label><q><s><samp><select><small><span><strike><strong><sub><sup><textarea><tt><u><var>'; 42 42 return (strip_tags($content, $inline_tags_minus_br) != $content) ? $content : nl2br($content); 43 } 44 45 46 /** 47 * Converts all html entities to normal characters, using UTF-8 48 * 49 * @param string $content The content to decode 50 * @return string The decoded content 51 */ 52 static public function decode($content) 53 { 54 return html_entity_decode($content, ENT_COMPAT, 'UTF-8'); 55 } 56 57 58 /** 59 * Converts all special characters to entites, using UTF-8. 60 * 61 * @param string $content The content to encode 62 * @return string The encoded content 63 */ 64 static public function encode($content) 65 { 66 return htmlentities($content, ENT_COMPAT, 'UTF-8'); 43 67 } 44 68 … … 51 75 * @return string The content with all URLs converted to HTML link 52 76 */ 53 static public function createLinks($content, $link_text_length=0)77 static public function makeLinks($content, $link_text_length=0) 54 78 { 55 79 // Determine what replacement to perform … … 110 134 111 135 /** 112 * Converts all html entities to normal characters, using UTF-8113 *114 * @param string $content The content to decode115 * @return string The decoded content116 */117 static public function decode($content)118 {119 return html_entity_decode($content, ENT_COMPAT, 'UTF-8');120 }121 122 123 /**124 * Converts all special characters to entites, using UTF-8.125 *126 * @param string $content The content to encode127 * @return string The encoded content128 */129 static public function encode($content)130 {131 return htmlentities($content, ENT_COMPAT, 'UTF-8');132 }133 134 135 /**136 136 * Prepares content for display in UTF-8 encoded HTML - allows HTML tags 137 137 * … … 187 187 188 188 $class = ($css_class) ? ' class="' . $css_class . '"' : ''; 189 if (self::c heckForBlockLevelHTML($content)) {189 if (self::containsBlockLevelHTML($content)) { 190 190 echo '<div' . $class . '>' . self::prepare($content) . '</div>'; 191 191 } else { fPrintableException.php
r214 r218 Hide Line Numbers 42 42 protected function getCSSClass() 43 43 { 44 // underscorize the current exception class name, extracted from fGrammar::underscorize() to reduce dependencies 45 return strtolower(preg_replace('/(?:([a-z0-9A-Z])([A-Z])|([a-zA-Z])([0-9]))/', '\1\3_\2\4', preg_replace('#^f#', '', get_class($this)))); 44 return fGrammar::underscorize(preg_replace('#^f#', '', get_class($this))); 46 45 } 47 46 … … 54 53 protected function prepare($content) 55 54 { 56 // See if the message has newline characters but not br tags, extracted from fHTML ::convertNewlines()to reduce dependencies55 // See if the message has newline characters but not br tags, extracted from fHTML to reduce dependencies 57 56 static $inline_tags_minus_br = '<a><abbr><acronym><b><big><button><cite><code><del><dfn><em><font><i><img><input><ins><kbd><label><q><s><samp><select><small><span><strike><strong><sub><sup><textarea><tt><u><var>'; 58 57 $content_with_newlines = (strip_tags($content, $inline_tags_minus_br)) ? $content : nl2br($content); 59 58 60 // Check to see if we have any block-level html, extracted from fHTML ::checkForBlockLevelHtml()to reduce dependencies59 // Check to see if we have any block-level html, extracted from fHTML to reduce dependencies 61 60 $inline_tags = $inline_tags_minus_br . '<br>'; 62 61 $no_block_html = strip_tags($content, $inline_tags) == $content; … … 64 63 $content = html_entity_decode($content, ENT_COMPAT, 'UTF-8'); 65 64 66 // This code ensures the output is properly encoded for display in (X)HTML, extracted from fHTML ::prepare()to reduce dependencies65 // This code ensures the output is properly encoded for display in (X)HTML, extracted from fHTML to reduce dependencies 67 66 $reg_exp = "/<\s*\/?\s*[\w:]+(?:\s+[\w:]+(?:\s*=\s*(?:\"[^\"]*?\"|'[^']*?'|[^'\">\s]+))?)*\s*\/?\s*>|&(?:#\d+|\w+);|<\!--.*?-->/"; 68 67 preg_match_all($reg_exp, $content, $html_matches, PREG_SET_ORDER);
