/ Published in: PHP
This class is used to convert any WYSIWYG text to flash friendly text.
Hope you people would like that.
Hope you people would like that.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<?php // Usage: // $flashString = $objFlahTags->makeFlashFriendlyStr($str); class flashTags { function rgb2hex($r, $g=-1, $b=-1) { return '#' . $color; } function getAttribute($attrib, $tag) { //get attribute from html tag $re = '/' . $attrib . '=["\']?([^"\' ]*)["\' ]/is'; if ($match) $return = $match[1]; else $return = false; return $return; } function getReplacesArray($match0, $match1) { $replaceFrom = $match0; $span_elem = $span_full[0][0]; } for ($j = 0; $j < $len; $j++) { $single_attr = $span_attrs_parts[$j]; $startTags[] = '<b>'; $endTags[] = '</b>'; $startTags[] = '<i>'; $endTags[] = '</i>'; $startTags[] = '<u>'; $endTags[] = '</u>'; $partR = $rgbParts[0]; $colorHex = $this->rgb2hex($partR, $partG, $partB); } $startTags[] = "<font color='$colorHex'>"; $endTags[] = "</font>"; } } } $replaceTo = $startTags . $match1 . $endTags; } function getArrReplacesArray($matches) { if ($totalMatches > 0) { for ($i = 0; $i < $totalMatches; $i++) { $match0 = $matches[$i][0]; $match1 = $matches[$i][1]; } else $arrReplaceFrom[] = $replaceFrom; $arrReplaceTo[] = $replaceTo; } } } function replaceAllAnchorStyles($str) { if ($totalMatches) { for ($i = 0; $i < $totalMatches; $i++) { $match0 = $matches[$i][0]; $href = $this->getAttribute('href', $match0); $target = $this->getAttribute('target', $match0); $title = $this->getAttribute('title', $match0); $match1 = $matches1[0][1]; if ($match1) { $startTag = "<u><a"; if ($href) $startTag .= " href='$href'"; if ($target) $startTag .= " target='$target'"; if ($title) $startTag .= " title='$title'"; $startTag .= ">"; for ($j = 0; $j < $len; $j++) { $single_attr = $attrs_parts[$j]; $startTags[] = '<b>'; $endTags[] = '</b>'; $startTags[] = '<i>'; $endTags[] = '</i>'; $startTags[] = '<u>'; $endTags[] = '</u>'; $partR = $rgbParts[0]; $colorHex = $this->rgb2hex($partR, $partG, $partB); } $startTags[] = "<font color='$colorHex'>"; $endTags[] = "</font>"; } } } $replaceTo = $startTags . $matches[$i][1] . $endTags; $arrReplaceFrom[] = $match0; $arrReplaceTo[] = $replaceTo; } } } } return $str; } function makeFlashFriendlyStr($str) { $dummyBrText = '~d~u~m~m~y~b~r~'; $str = $str_wo_br; do { } while ($matches); $str = $this->replaceAllAnchorStyles($str); $str = "<TEXTFORMAT LEADING='0'><font face='Verdana' size='13'>$str</font></TEXTFORMAT>"; return $str; } } ?>