Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [php],[js] - Jak napisać to w PHP ?
Setesh
post
Post #1





Grupa: Zarejestrowani
Postów: 102
Pomógł: 0
Dołączył: 2.10.2006
Skąd: Wrocław

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


Witam.

Znalazłem w pewnym forum kawałek kodu w JS który bardzo by mi się przydał dla mojej stronki.

kod wygląda tak :
  1. //----------------------------------------------------
  2. // Prosty tag ([tag]tekst[/tag])
  3. //----------------------------------------------------
  4.  
  5. function simpletag(thetag) {
  6. tag("[" + thetag + "]", "[/" + thetag + "]");
  7. }
  8.  
  9. //----------------------------------------------------
  10. // Taguje tekst
  11. //----------------------------------------------------
  12.  
  13. function tag(bbopen, bbclose) {
  14. var txtarea = document.form.text;
  15. if ((clientVer >= 4) && is_ie && is_win) {
  16. //Win IE
  17. theSelection = document.selection.createRange().text;
  18. if (!theSelection) {
  19. txtarea.value += bbopen + bbclose;
  20. txtarea.focus();
  21. return;
  22. }
  23. document.selection.createRange().text = bbopen + theSelection + bbclose;
  24. txtarea.focus();
  25. return;
  26. } else if (txtarea.selectionEnd && (txtarea.selectionEnd - txtarea.selectionStart > 0)) {
  27. //Mozilla/gecko
  28. mozTag(txtarea, bbopen, bbclose);
  29. return;
  30. } else {
  31. //inna
  32. txtarea.value += bbopen + bbclose;
  33. txtarea.focus();
  34. }
  35. storeCaret(txtarea);
  36. }
  37.  
  38. //----------------------------------------------------
  39. // Taguje tekst pod mozilla
  40. //----------------------------------------------------
  41.  
  42. function mozTag(txtarea, open, close) {
  43. var selLength = txtarea.textLength;
  44. var selStart = txtarea.selectionStart;
  45. var selEnd = txtarea.selectionEnd;
  46. if (selEnd == 1 || selEnd == 2) {
  47. selEnd = selLength;
  48. }
  49.  
  50. var s1 = (txtarea.value).substring(0,selStart);
  51. var s2 = (txtarea.value).substring(selStart, selEnd);
  52. var s3 = (txtarea.value).substring(selEnd, selLength);
  53. txtarea.value = s1 + open + s2 + close + s3;
  54. return;
  55. }


funkcja ta zamienia tekst typu [ quote ] Coś [ / quote ]
Cytat
Jakiś tekst
i odpowiednio coś z nim robi według tego jak ustalimy.

Chciałem to napisać w PHP aby mi automatycznie zmieniało wiele rzeczy (coś jak na forum dodawanie kodu PHP czyli w znacznikach). Problem w tym że nie mam pojęcia jak to zrobić sad.gif

Wie ktoś z was jak to napisać lub gdzie jest przykład jakiś tego ?

Ten post edytował Setesh 12.05.2007, 10:41:06


--------------------
Znudził Ci się wygląd twojej v39'ki ? Zmień to! :)

| Google | CodeGear | Swiss Delphi Center (ENG) | digitalmars.com | 4programmers.net | dsdt.info | BinBoy | delphi.cartall.com.pl | CPW.net.pl | cyfbar.republika.pl|
Go to the top of the page
+Quote Post

Posty w temacie


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: 20.08.2025 - 10:12