Cze¶æ! Mam problem z edytorem WYSIWYG na stronê.... Mianowicie dotychczas korzysta³em z htmlarea, jednak¿e nie dzia³a na innych przegladarkach ni¿ IE dlatego postanowi³em go zmieniæ. Problem polega na tym i ile z zaincludowaniem do skryptu htmlarea nie mia³em problemu to ju¿ z tym edytorem jest. Moze kto¶ bêdzie wiedzia³ jak to zrobiæ. Prosze o pomoc!!!

Fragment kodu panelu administracyjnego:
  1. <script language="Javascript1.2"><!-- // load htmlarea
  2. _editor_url = "htmlarea/";  // URL to htmlarea files
  3. var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
  4. if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
  5. if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
  6. if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
  7. if (win_ie_ver >= 5.5) {
  8.  document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
  9.  document.write(' language="Javascript1.2"></scr' + 'ipt>');
  10. } else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
  11. // --></script>
  12. </head>
  13. <body>
  14.  
  15. <table border="1" cellspacing="0" cellpadding="0" align="center" bgcolor="#F2F7F2" style="border-color: #7F8A7F" width="750">
  16.  <tr>
  17.  <td>
  18. <table border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#DAE2DA" style="border-color: #7F8A7F" width="750">
  19.  <tr style="text-align: center; height: 20px;">
  20. <td><a href="admin.php?dzial=news">newsy</a></td>
  21.  
  22.  <td><a href="admin.php?logout"><b>wyloguj</b></a></td>
  23.  </tr>
  24. </table>
  25. </td>
  26.  </tr>
  27.  <tr>
  28. <td align="center"><?php
  29. $baza = "baza/";
  30. switch($_GET['dzial']){
  31.  
  32. case "news";
  33.  
  34. if ( isset($_GET['publikuj']) ){
  35.  $id = $_GET['id'];
  36.  if ( $_GET['publikuj'] == "tak" ){
  37. $query = "UPDATE news SET z='tak' WHERE news_id='$id'";
  38. $result = mysql_query($query);
  39. }else if ( $_GET['publikuj'] == "nie" ){
  40. $query = "UPDATE news SET z='nie' WHERE news_id='$id'";
  41. $result = mysql_query($query);
  42. }
  43. }
  44.  
  45. if (isset($_POST['zapisz'])) {
  46. $id = $_POST['id'];
  47. $temat = escape_data( $_POST['tytul'] );
  48. $tresc_k = escape_data( $_POST['area2'] );
  49. $tresc = escape_data( $_POST['area'] );
  50. if(empty($_POST['data'])){
  51. $data = date("Y-m-d H:i:s"); 
  52. }else{
  53. $data = $_POST['data'];
  54. }
  55. if ( $_POST['co'] == "update" ) {
  56. $query = "UPDATE news SET tytul='$tytul', tresc_krotka='$tresc_k', tresc='$tresc' ,data='$data'WHERE news_id='$id'";
  57. $result = mysql_query($query);
  58.  echo '<p><font color="red">dane uaktualniono</font></p>'; 
  59.  }else{ 
  60.  echo 'Ku** cos poszlo nie tak';
  61.  }
  62. }else if ( $_POST['co'] == "nowy" ){
  63. $query = "INSERT INTO news ( tytul, tresc_krotka, tresc, data ) VALUES ( '$tytul', '$tresc_k', '$tresc', '$data' )";
  64. $result = mysql_query($query);
  65.  echo '<p><font color="red">dane dodano</font></p>'; 
  66.  }else{ 
  67.  echo 'Ku** cos poszlo nie tak';
  68.  }
  69. }
  70. }
  71.  
  72. if ( isset($_GET['edytuj']) and is_numeric($_GET['edytuj'])  ) {
  73.  
  74.  $query = "SELECT * FROM news WHERE news_id={$_GET['edytuj']}";
  75.  $result = mysql_query($query);
  76.  $row = mysql_fetch_array($result);
  77.  
  78. echo '<form action="admin.php?dzial=news" method="post">
  79. <input type="hidden" name="co" value="update">
  80. <input type="hidden" name="id" value="'.$row['news_id'].'">
  81. Data: 0000-00-00 00:00:00 <input type="text" value="'.stripslashes($row['data']).'" name="data" size="30">
  82. <br>
  83. Tytu³: <input type="text" value="'.stripslashes($row['tytul']).'" name="tytul" size="100%"><br>
  84. Tresc krótka <textarea rows="20" cols="100%" name="area2">'.stripslashes($row['tresc_krotka']).'</textarea><br>
  85. Tresc <textarea rows="20" cols="100%" name="area">'.stripslashes($row['tresc']).'</textarea><br>
  86. <input type="submit" value="zapisz" name="zapisz">
  87. </form>';
  88.  ?>
  89. <script language="JavaScript1.2" defer>
  90. var config = new Object(); // create new config object
  91. var config2 = new Object(); // create new config object
  92.  
  93. config.width = "100%";
  94. config.height = "400px";
  95. config.bodyStyle = 'background-color: white; font-family: "Verdana"; font-size: x-small;';
  96. config.debug = 0;
  97.  
  98. config2.width = "100%";
  99. config2.height = "100px";
  100. config2.bodyStyle = 'background-color: white; font-family: "Verdana"; font-size: x-small;';
  101. config2.debug = 0;
  102.  
  103.  
  104. editor_generate('area',config);
  105. editor_generate('area2',config2);
  106. </script>
  107. ....


A to jest ca³y kod jaki jest podany w pliku example edytora który chcê zaincludowaæ zamiast istniejacego:
  1. <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <style>
  6. body{font:10px verdana,arial,sans-serif;}
  7. a{color:#cc0000;font-size:xx-small;}
  8. </style>
  9.  
  10. <?
  11. //Check user's Browser
  12. if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE"))
  13. echo "<script language=JavaScript src='../scripts/editor.js'></script>";
  14. else
  15. echo "<script language=JavaScript src='../scripts/moz/editor.js'></script>";
  16. ?>
  17.  
  18. <script>
  19. function submitForm()
  20. {
  21. document.forms.Form1.elements.inpContent.value = oEdit1.getHTMLBody();
  22. document.forms.Form1.submit()
  23. }
  24. </script>
  25.  
  26. </head>
  27. <body>
  28.  
  29. <h5>Complete Toolbar Buttons (php example) &nbsp;-&nbsp;<a href="../default.htm">Back</a></h5>
  30.  
  31. <pre id="idTemporary" name="idTemporary" style="display:none">
  32. <?
  33. if(isset($_POST["inpContent"])) 
  34. {
  35. $sContent=stripslashes($_POST['inpContent']);//remove slashes (/)
  36. echo htmlentities($sContent);
  37. }
  38. ?>
  39. </pre>
  40.  
  41. <form method="post" action="default1.php" id="Form1">
  42. <script>
  43. var oEdit1 = new InnovaEditor("oEdit1");
  44. oEdit1.arrStyle = [["BODY",false,"","font:10px verdana,arial,sans-serif;"]];
  45.  
  46. oEdit1.width=505;
  47. oEdit1.features=["Save","FullScreen","Preview","Print","Search","SpellCheck",
  48. "Cut","Copy","Paste","PasteWord","PasteText","|","Undo","Redo","|",
  49. "ForeColor","BackColor","|","Bookmark","Hyperlink",
  50. "CustomTag","HTMLFullSource","HTMLSource","XHTMLFullSource",
  51. "XHTMLSource","BRK","Numbering","Bullets","|","Indent","Outdent","LTR","RTL","|","Image","Flash","Media","|","InternalLink","CustomObject","|",
  52. "Table","Guidelines","Absolute","|","Characters","Line",
  53. "Form","Clean","ClearAll","BRK",
  54. "StyleAndFormatting","TextFormatting","ListFormatting","BoxFormatting",
  55. "ParagraphFormatting","CssText","Styles","|",
  56. "Paragraph","FontName","FontSize","|",
  57. "Bold","Italic",
  58. "Underline","Strikethrough","|","Superscript","Subscript","|",
  59. "JustifyLeft","JustifyCenter","JustifyRight","JustifyFull"];
  60.  
  61. oEdit1.cmdAssetManager="modalDialogShow('/Editor/assetmanager/assetmanager.php',640,465)";
  62.  
  63. oEdit1.onSave = new Function("submitForm()");
  64.  
  65. oEdit1.cmdInternalLink = "modelessDialogShow('links.htm',365,270)"
  66. oEdit1.cmdCustomObject = "modelessDialogShow('objects.htm',365,270)"
  67.  
  68. oEdit1.arrCustomTag=[["First Name","{%first_name%}"],
  69. ["Last Name","{%last_name%}"],
  70. ["Email","{%email%}"]];
  71.  
  72. oEdit1.RENDER(document.getElementById("idTemporary").innerHTML);
  73. </script>
  74. <input type="hidden" name="inpContent" id="inpContent">
  75. </form>
  76.  
  77.  
  78. <br><br>
  79.  
  80. <?
  81. if(isset($_POST["inpContent"])) 
  82. {
  83. $sContent=stripslashes($_POST['inpContent']);//remove slashes (/)
  84. echo $sContent;
  85. }
  86. ?>
  87.  
  88. </body>
  89. </html>


Dobra, zaincludowa³em ten edytor, tylko teraz mam inny problem. Edytor zczytuje z bazy danych zawartosæ komórki tresc, jednak gdy chcem ju¿ co¶ zapisaæ, zapisuje mi puste pole. A teraz zaprezentuje fragment jak rozwi±za³em swój problem z includowaniem...

  1. <?
  2. //Check user's Browser
  3. if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE"))
  4. // £aduj gdy IE
  5. echo "<script language=JavaScript src='Editor/scripts/editor.js'></script>";
  6. else
  7. // £aduj gdy inna przegladarka
  8. echo "<script language=JavaScript src='Editor/scripts/moz/editor.js'></script>";
  9. ?>
  10.  
  11. </head>
  12. <body>
  13.  
  14.  
  15. <table border="1" cellspacing="0" cellpadding="0" align="center" bgcolor="#F2F7F2" style="border-color: #7F8A7F" width="750">
  16.  
  17. tutaj jest menu
  18.  
  19. </table>
  20. </td>
  21.  
  22.  
  23. <td align="center" valign="top">
  24. <?php
  25. $baza = "baza/";
  26. switch($_GET['dzial']){
  27.  
  28. case "news";
  29.  
  30. if ( isset($_GET['publikuj']) ){
  31.  $id = $_GET['id'];
  32.  if ( $_GET['publikuj'] == "tak" ){
  33. $query = "UPDATE news SET z='tak' WHERE news_id='$id'";
  34. $result = mysql_query($query);
  35. }else if ( $_GET['publikuj'] == "nie" ){
  36. $query = "UPDATE news SET z='nie' WHERE news_id='$id'";
  37. $result = mysql_query($query);
  38. }
  39. }
  40.  
  41. if (isset($_POST['zapisz'])) {
  42. $id = $_POST['id'];
  43. $temat = escape_data( $_POST['tytul'] );
  44. $tresc = escape_data( $_POST['tresc'] );
  45. if(empty($_POST['data'])){
  46. $data = date("Y-m-d H:i:s"); 
  47. }else{
  48. $data = $_POST['data'];
  49. }
  50. if ( $_POST['co'] == "update" ) {
  51. $query = "UPDATE news SET tytul='$tytul', tresc='$tresc' ,data='$data'WHERE news_id='$id'";
  52. $result = mysql_query($query);
  53.  echo '<p><font color="red">dane uaktualniono</font></p>'; 
  54.  }else{ 
  55.  echo '<br>Operacja wykonana b³êdnie :( ==> Wykonaj ja poprawnie<br>';
  56.  }
  57. }else if ( $_POST['co'] == "nowy" ){
  58. $query = "INSERT INTO news ( tytul, tresc, data ) VALUES ( '$tytul', '$tresc', '$data' )";
  59. $result = mysql_query($query);
  60.  echo '<p><font color="red">dane dodano</font></p>'; 
  61.  }else{ 
  62.  echo '<br>Operacja wykonana b³êdnie :( ==> Wykonaj ja poprawnie<br>';
  63.  }
  64. }
  65. }
  66.  
  67. if ( isset($_GET['edytuj']) and is_numeric($_GET['edytuj'])  ) {
  68.  
  69.  $query = "SELECT * FROM news WHERE news_id={$_GET['edytuj']}";
  70.  $result = mysql_query($query);
  71.  $row = mysql_fetch_array($result);
  72.  $tresc = stripslashes($row['tresc']);
  73. echo '<table width="100%" style= "padding: 1px; border: 0px; background-color: #d3d3d3;" cellspacing="1" cellpadding="1">
  74. <tr style="background-color: #dddddd; text-align: center; height: 20px;">
  75. <td colspan="2">
  76. <b>Edytuj newsa</b>
  77. </td>
  78. </tr>
  79.  
  80. <form action="admin.php?dzial=news" method="post">
  81. <input type="hidden" name="co" value="update">
  82. <input type="hidden" name="id" value="'.$row['news_id'].'" >
  83.  
  84. <tr style="background-color: #f3f3f3;">
  85. <td width="75" style="padding: 5px; text-align: left;">
  86. Data:<br>(0000-00-00)
  87. </td>
  88. <td style="padding: 5px;">
  89. <input type="text" name="data" size="92%" value="'.stripslashes($row['data']).'">
  90. </td>
  91. </tr>
  92. <tr style="background-color: #f3f3f3;">
  93. <td width="50" style="padding: 5px; text-align: left;">
  94. Tytu³:
  95. </td>
  96. <td style="padding: 5px;">
  97. <input type="text" name="tytul" size="92%" value="'.stripslashes($row['tytul']).'">
  98. </td>
  99. </tr>
  100.  <tr style="background-color: #f3f3f3;">
  101.  
  102. <td style="padding: 5px;" colspan="2">
  103.  
  104. <script>
  105. var oEdit1 = new InnovaEditor("oEdit1");
  106. oEdit1.RENDER("'.$tresc.'");
  107. oEdit1.arrStyle = [["BODY",false,"","font:10px verdana,arial,sans-serif;"]];
  108.  
  109. oEdit1.width=490;
  110. oEdit1.features=["Save","FullScreen","Preview","Print","Search","SpellCheck",
  111. "Cut","Copy","Paste","PasteWord","PasteText","|","Undo","Redo","|",
  112. "ForeColor","BackColor","|","Bookmark","Hyperlink",
  113. "CustomTag","HTMLFullSource","HTMLSource","XHTMLFullSource",
  114. "XHTMLSource","BRK","Numbering","Bullets","|","Indent","Outdent","LTR","RTL","|","Image","Flash","Media","|","InternalLink","CustomObject","|",
  115. "Table","Guidelines","Absolute","|","Characters","Line",
  116. "Form","Clean","ClearAll","BRK",
  117. "StyleAndFormatting","TextFormatting","ListFormatting","BoxFormatting",
  118. "ParagraphFormatting","CssText","Styles","|",
  119. "Paragraph","FontName","FontSize","|",
  120. "Bold","Italic",
  121. "Underline","Strikethrough","|","Superscript","Subscript","|",
  122. "JustifyLeft","JustifyCenter","JustifyRight","JustifyFull"];
  123.  oEdit1.cmdAssetManager="modalDialogShow(`Editor/assetmanager/assetmanager.php`,640,465)";
  124.  
  125.  
  126. </script>
  127. </td>
  128. </tr>
  129.  <tr style="background-color: #dddddd;">
  130. <td colspan="2" style="padding: 5px; text-align: center;">
  131. <input type="submit" value="Zapisz zmiany" name="zapisz">
  132. </td>
  133. </tr>
  134. </form></table>';
  135.  ?>


Moze czego¶ zapomnia³em, ze mi nie zapisuje?? Tylko czego... A mo¿e co¶ trzeba dodac lub dopisaæ?questionmark.gif