| [ PHPXref.com ] | [ Generated: Sun Jul 20 16:35:25 2008 ] | [ bBlog 0.7.6 ] |
| [ Index ] [ Variables ] [ Functions ] [ Classes ] [ Constants ] [ Statistics ] | ||
[Summary view] [Print] [Text view]
1 <?php 2 // by photomatt : http://photomatt.net/tools/texturize 3 function identify_modifier_texturize () { 4 return array ( 5 'name' =>'texturize', 6 'type' =>'modifier', 7 'nicename' =>'Texturize', 8 'description' =>'Makes quotes curly', 9 'authors' =>'photomatt', 10 'licence' =>'GPL', 11 'help' => '<p>See <A href="http://photomatt.net/tools/texturize">http://photomatt.net/tools/texturize</a>' 12 ); 13 } 14 15 function smarty_modifier_texturize($text) { 16 $textarr = preg_split("/(<.*>)/U", $text, -1, PREG_SPLIT_DELIM_CAPTURE); // capture the tags as well as in between 17 $stop = count($textarr); $next = true; // loop stuff 18 for ($i = 0; $i < $stop; $i++) { 19 $curl = $textarr[$i]; 20 if (!strstr($_SERVER['HTTP_USER_AGENT'], 'Gecko')) { 21 $curl = str_replace('<q>', '“', $curl); 22 $curl = str_replace('</q>', '”', $curl); 23 } 24 if ('<' != $curl{0} && $next) { // If it's not a tag 25 $curl = str_replace('---', '—', $curl); 26 $curl = str_replace('--', '–', $curl); 27 $curl = str_replace("...", '…', $curl); 28 $curl = str_replace('``', '“', $curl); 29 30 // This is a hack, look at this more later. It works pretty well though. 31 $cockney = array("'tain't","'twere","'twas","'tis","'twill","'til","'bout","'nuff","'round", "'em"); 32 $cockneyreplace = array("’tain’t","’twere","’twas","’tis","’twill","’til","’bout","’nuff","’round","’em"); 33 $curl = str_replace($cockney, $cockneyreplace, $curl); 34 35 36 $curl = preg_replace("/'s/", "’s", $curl); 37 $curl = preg_replace("/'(\d\d(?:’|')?s)/", "’$1", $curl); 38 $curl = preg_replace('/(\s|\A|")\'/', '$1‘', $curl); 39 $curl = preg_replace("/(\d+)\"/", "$1″", $curl); 40 $curl = preg_replace("/(\d+)'/", "$1′", $curl); 41 $curl = preg_replace("/(\S)'([^'\s])/", "$1’$2", $curl); 42 $curl = preg_replace('/"([\s.]|\Z)/', '”$1', $curl); 43 $curl = preg_replace('/(\s|\A)"/', '$1“', $curl); 44 $curl = preg_replace("/'([\s.]|\Z)/", '’$1', $curl); 45 $curl = preg_replace("/\(tm\)/i", '™', $curl); 46 $curl = preg_replace("/\(c\)/i", '©', $curl); 47 $curl = preg_replace("/\(r\)/i", '®', $curl); 48 49 $curl = str_replace("''", '”', $curl); 50 $curl = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&$1', $curl); 51 52 $curl = preg_replace('/(d+)x(\d+)/', "$1×$2", $curl); 53 54 } elseif (strstr($curl, '<code') || strstr($curl, '<pre') || strstr($curl, '<kbd' || strstr($curl, '<style') || strstr($curl, '<script'))) { 55 // strstr is fast 56 $next = false; 57 } else { 58 $next = true; 59 } 60 $output .= $curl; 61 } 62 63 return $output; 64 65 } 66 67 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| [ Powered by PHPXref - Served by Debian GNU/Linux ] |