Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Bb2html W Klasie...
czachor
post
Post #1





Grupa: Zarejestrowani
Postów: 897
Pomógł: 40
Dołączył: 16.12.2003
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Witam!
Używam w mojej klasie funkcji bb2html() podanej kiedyś na forum bodajże przez @scannera... Dla przypomnienia (nie znalazłem jej, więc nie podam linka):
  1. <?php
  2. //jest kilka moich zmian odnośnie zgodności z W3C
  3.  
  4. class content_manager
  5. {
  6.  
  7. // ciach... (konstruktor, inne funkcje)
  8.  
  9. function bb2html($str)
  10. {
  11. global $codesArr;
  12.  
  13. $codesArr = array(
  14. 'url' => Array('a','href=\"'),
  15. 'img' => Array('img', 'src=\"'),
  16. 'color' => Array('span','style=\"color:'),
  17. 'b' => 'font-weight: bold',
  18. 'u' => 'text-decoration: underline',
  19. 'i' => 'font-style: italic'
  20. );
  21.  
  22. reset($codesArr);
  23. foreach( $codesArr as $aKey => $aVal)
  24. {
  25. $str = preg_replace_callback(&#092;"#[($aKey)+[=]?(http|https|ftp+://)?(.*?)](http|https|ftp+://)?(.*?)[/$aKey]#si\", \"$this -> repl\", $str);
  26. };
  27.  
  28. return $str;
  29. }
  30.  
  31.  
  32. function repl($matches)
  33. {
  34. global $codesArr;
  35.  
  36. if (is_array($codesArr[$matches[1]]))
  37. {
  38. if (!empty($matches[2]))
  39. {
  40. $protocol = $matches[2];
  41. }
  42. elseif (!empty($matches[4]))
  43. {
  44. $protocol = $matches[4];
  45. }
  46. else
  47. {
  48. $protocol = 'http://';
  49. };
  50.  
  51. switch($matches[1])
  52. {
  53. case 'url':
  54. $address = empty( $matches[3] ) ? $matches[5] : $matches[3];
  55. $x = '<'.implode( ' ', $codesArr[$matches[1]] ).$protocol.$address.'\">'.$matches[4].$matches[5].'</'.$codesArr[$matches[1]][0].'>';
  56. break;
  57.  
  58. case 'img':
  59. $address = empty( $matches[3] ) ? $matches[4].$matches[5] : $matches[2].$matches[3];
  60. $x = '<'.implode( ' ', $codesArr[$matches[1]] ).$address.'\" alt=\"\" />';
  61. break;
  62.  
  63. default:
  64. $x = '<'.implode( ' ', $codesArr[$matches[1]] ).$matches[3].'\">'.$matches[4].$matches[5].'</'.$codesArr[$matches[1]][0].'>';
  65. break;
  66. }
  67. }
  68. else
  69. {
  70. $x = '<span style=\"'.$codesArr[$matches[1]].'\">'.$matches[5].'</span>';
  71. }
  72.  
  73. return $x;
  74.  
  75. }
  76.  
  77. };
  78. ?>

o co teraz chodzi... chcę to wstawić w klasę... problem jest w tym, że gdy się do niej odwołuję (chcę przepuścić przez bb2html()) otrzymuję komunikat
Cytat
Warning: preg_replace_callback() requires argument 2, 'repl', to be a valid callback in C:\Serwer\Apache2\htdocs\doc\lbn\classes\content_manager.class.php on line 125 {tutaj linia 25-27}

Nie wiem, jak zmienić ten drugi argument w funkcji preg_replace_callback... wszystkie zmiany nic nie dają, próbowałem m. in. ze wstawieniem "$this -> repl", ale ciągle ten sam komunikat...
mam nadzieję, że jasno wytłumaczyłem rolleyes.gif
za wszelką pomoc z góry thx !


--------------------
how many SEO experts does it take to change a light bulb,lightbulb,light,bulb,lamp,lighting,switch,sex,xxx
5-Reasons-why-you-should-NEVER-fix-a-computer-for-free
Go to the top of the page
+Quote Post
rogrog
post
Post #2





Grupa: Zarejestrowani
Postów: 602
Pomógł: 1
Dołączył: 3.04.2004
Skąd: Trójmiasto (Gdańsk)

Ostrzeżenie: (0%)
-----


zdaje się że zamiast nazwy funkcji powinno się podać dwuelementową tablicę:

  1. <?php
  2.  
  3. array('tu nazwa klasy', 'tu nazwa funkcji');
  4.  
  5. ?>


--------------------
Go to the top of the page
+Quote Post
czachor
post
Post #3





Grupa: Zarejestrowani
Postów: 897
Pomógł: 40
Dołączył: 16.12.2003
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Wielkie dzięki @rogrog! Działa tak jak trzeba.


--------------------
how many SEO experts does it take to change a light bulb,lightbulb,light,bulb,lamp,lighting,switch,sex,xxx
5-Reasons-why-you-should-NEVER-fix-a-computer-for-free
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 19.08.2025 - 13:45