From: jsvoyager <jsv...@us...> - 2005-02-05 02:15:41
|
Update of /cvsroot/webschool/webschool/lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24467/lib Modified Files: mainfile.php Log Message: New Smart Feature Index: mainfile.php =================================================================== RCS file: /cvsroot/webschool/webschool/lib/mainfile.php,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** mainfile.php 30 Jan 2005 01:56:13 -0000 1.16 --- mainfile.php 5 Feb 2005 02:15:14 -0000 1.17 *************** *** 106,109 **** --- 106,145 ---- } + function brackets2table ($data, &$smarty){ + + if (preg_match_all('/\[(\[.*?\])\]/s', $data, $matches)) { + $count = count($matches[0]); + for ($i = 0; $i < $count; $i++) { + + $workstr = $matches[1][$i]; + $tmp = ''; + while ($tmp != $workstr) { + $tmp = $workstr; + $workstr = preg_replace('/\[(([^\|]*)\|)?([^\]]*)\]/s', '<td \2>\3</td>', $workstr, 1); + }/* + if ($i == 0){ + $replacement = "\n<table width=\"100%\" border=\"0\" noatr=\"find\">\n<tr>$workstr</tr>\n"; + }elseif ($i == $count){ + $replacement = "<tr>$workstr</tr>\n</table>"; + }else{ + $replacement = "<tr>$workstr</tr>\n"; + }*/ + //If the code above is ever re-emplemented, be sure to change the second arg below + // to $replacement + $data = preg_replace('/\[\[.*?\]\]/s', "<tr>$workstr</tr>\n", $data, 1); + + } + + $data = str_replace('[+', "\n<table width=\"100%\" border=\"0\" noatr=\"find\">\n", + $data); + $data = str_replace('+]', "\n</table>\n", + $data); + + + } + + return $data; + } + $smarty->register_outputfilter("brackets2table"); ?> \ No newline at end of file |