| 2 | | function graphical_text($text, $selector='default') |
|---|
| 3 | | { |
|---|
| 4 | | return image_tag(url_for('@sfTextReplacementImageSelector?text=' . urlencode($text) . '&selector=' . $selector), array('alt'=>$text)); |
|---|
| 5 | | } |
|---|
| 6 | | |
|---|
| 7 | | function js_replace_text($selector) |
|---|
| 8 | | { |
|---|
| 9 | | use_javascript('/sfTextReplacementPlugin/js/replacement.js'); |
|---|
| 10 | | if(!is_array($selector)) |
|---|
| 11 | | return 'sfTextReplacement_single("' . $selector . '" ,"' . url_for('@sfTextReplacementBase') . '",' . sfConfig::get('sftextreplacementplugin_selectors_default_wordwrap', 'false') .');'; |
|---|
| 12 | | } |
|---|
| 13 | | |
|---|
| 14 | | function seo_graphical_text($text, $selector='default', $width=NULL, $height=NULL) |
|---|
| 15 | | { |
|---|
| 16 | | use_stylesheet('/sfTextReplacementPlugin/css/replacement.css'); |
|---|
| 17 | | $url=url_for('@sfTextReplacementImageSelector?text=' . urlencode($text) . '&selector=' . $selector, TRUE); |
|---|
| 18 | | |
|---|
| 19 | | // FIXME: omg, this is really, I mean really really - UGLY AND SLOW! Fix that if in production use! |
|---|
| 20 | | if(!$width) |
|---|
| 21 | | { |
|---|
| 22 | | |
|---|
| 23 | | $dimensions = sfTextReplacement::getImageDimensions($text, $selector); //needs apache to allow outgoing http requests! |
|---|
| 24 | | $width = $dimensions['width']; |
|---|
| 25 | | $height = $dimensions['height']; |
|---|
| 26 | | } |
|---|
| 27 | | return '<span class="sfTextReplacement" style="height: ' . $height . 'px; width: ' . $width. 'px; background-image: url(\'' . $url. '\')"><span>' . $text . '</span></span>'; |
|---|
| 28 | | } |
|---|
| 29 | | |
|---|
| | 2 | use_helper('Javascript'); |
|---|
| | 3 | function graphical_text($text, $selector='default') |
|---|
| | 4 | { |
|---|
| | 5 | return image_tag(url_for('@sfTextReplacementImageSelector?text=' . urlencode($text) . '&selector=' . $selector), array('alt'=>$text)); |
|---|
| | 6 | } |
|---|
| | 7 | |
|---|
| | 8 | function js_replace_text($selector) |
|---|
| | 9 | { |
|---|
| | 10 | use_javascript('/sfTextReplacementPlugin/js/replacement.js'); |
|---|
| | 11 | |
|---|
| | 12 | $all_selectors = ""; |
|---|
| | 13 | |
|---|
| | 14 | if(is_array($selector)) |
|---|
| | 15 | { |
|---|
| | 16 | for($i = 0; $i < count($selector); $i++) |
|---|
| | 17 | { |
|---|
| | 18 | $all_selectors .= 'sfTextReplacement_single("' . $selector[$i] . '" ,"' . url_for('@sfTextReplacementBase') . '",' . sfConfig::get('sftextreplacementplugin_selectors_default_wordwrap', 'false') .');'; |
|---|
| | 19 | } |
|---|
| | 20 | } |
|---|
| | 21 | else |
|---|
| | 22 | { |
|---|
| | 23 | $all_selectors = 'sfTextReplacement_single("' . $selector . '" ,"' . url_for('@sfTextReplacementBase') . '",' . sfConfig::get('sftextreplacementplugin_selectors_default_wordwrap', 'false') .');'; |
|---|
| | 24 | } |
|---|
| | 25 | |
|---|
| | 26 | return javascript_tag($all_selectors); |
|---|
| | 27 | } |
|---|
| | 28 | |
|---|
| | 29 | function seo_graphical_text($text, $selector='default', $width=NULL, $height=NULL) |
|---|
| | 30 | { |
|---|
| | 31 | use_stylesheet('/sfTextReplacementPlugin/css/replacement.css'); |
|---|
| | 32 | $url=url_for('@sfTextReplacementImageSelector?text=' . urlencode($text) . '&selector=' . $selector, TRUE); |
|---|
| | 33 | |
|---|
| | 34 | // FIXME: omg, this is really, I mean really really - UGLY AND SLOW! Fix that if in production use! |
|---|
| | 35 | if(!$width) |
|---|
| | 36 | { |
|---|
| | 37 | |
|---|
| | 38 | $dimensions = sfTextReplacement::getImageDimensions($text, $selector); //needs apache to allow outgoing http requests! |
|---|
| | 39 | $width = $dimensions['width']; |
|---|
| | 40 | $height = $dimensions['height']; |
|---|
| | 41 | } |
|---|
| | 42 | return '<span class="sfTextReplacement" style="height: ' . $height . 'px; width: ' . $width. 'px; background-image: url(\'' . $url. '\')"><span>' . $text . '</span></span>'; |
|---|
| | 43 | } |
|---|
| | 44 | |
|---|