Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [PHP] Problem z integracją Tiny MCE
Forum PHP.pl > Forum > Przedszkole
walus16
Witam. Mam problem z integracją wtyczki Tiny MCE do edytora tekstu.
Nie wiem czy w pliku podstrona.php, w którym ma działać ten edytor jest jakiś błąd bo się w ogóle nie włącza.
  1. <?php
  2.  
  3. require_once "../silnik.php";
  4. require_once "../ustawienia/szablon/naglowek.php";
  5.  
  6. if (isset($_GET['status']) && !isset($message)) {
  7. if ($_GET['status'] == "sn") {
  8. $message = "Dodano dodatkową stronę.<br />Adres URL do tej strony to: \n";
  9. $message .= "<a href='".BASEDIR."viewpage.php?page_id=".intval($_GET['pid'])."'>viewpage.php?page_id=".intval($_GET['pid'])."</a>\n";
  10. } elseif ($_GET['status'] == "su") {
  11. $message = "Zaktualizowano dodatkową stronę.<br />Adres URL do tej strony to: \n";
  12. $message .= "<a href='".BASEDIR."viewpage.php?page_id=".intval($_GET['pid'])."'>viewpage.php?page_id=".intval($_GET['pid'])."</a>\n";
  13. } elseif ($_GET['status'] == "del") {
  14. $message = "Usunięto dodatkową stronę.";
  15. }
  16. if ($message) {
  17. $message = "<div class='admin-message'>".$message."</div>";
  18. if ($_GET['status'] == "sn" || $_GET['status'] == "su") {
  19. echo $message;
  20. } else {
  21. echo "<div id='close-message'>".$message."</div>\n";
  22. }
  23. }
  24. }
  25.  
  26. function stripinput($text) {
  27. if (!is_array($text)) {
  28. $text = stripslash(trim($text));
  29. $search = array("&", "\"", "'", "\\", '\"', "\'", "<", ">", "&nbsp;");
  30. $replace = array("&amp;", "&quot;", "'", "\", "&quot;", "'", "&lt;", "&gt;", " ");
  31. $text = preg_replace("/(&amp;)+(?=\#([0-9]{2,3});)/i", "&", str_replace($search, $replace, $text));
  32. } else {
  33. foreach ($text as $key => $value) {
  34. $text[$key] = stripinput($value);
  35. }
  36. }
  37. return $text;
  38. }
  39. function addslash($text) {
  40. if (!QUOTES_GPC) {
  41. $text = addslashes(addslashes($text));
  42. } else {
  43. $text = addslashes($text);
  44. }
  45. return $text;
  46. }
  47. function phpentities($text) {
  48. $search = array("&", "\"", "'", "\\", "<", ">");
  49. $replace = array("&amp;", "&quot;", "'", "\", "&lt;", "&gt;");
  50. $text = str_replace($search, $replace, $text);
  51. return $text;
  52. }
  53.  
  54. if (isset($_POST['save'])) {
  55. $page_title = stripinput($_POST['page_title']);
  56. $page_content = addslash($_POST['page_content']);
  57. if (isset($_POST['page_id']) && isnum($_POST['page_id'])) {
  58. $result = mysql_query("UPDATE ".DB_PREFIX."podstrona SET page_title='".$page_title."', page_content='".$page_content."' WHERE page_id='".$_POST['page_id']."'");
  59. } else {
  60. $result = mysql_query("INSERT INTO ".DB_PREFIX."podstrona (page_title, page_content) VALUES ('".$page_title."', '".$page_content."')");
  61. $page_id = mysql_insert_id();
  62. if (isset($_POST['add_link'])) {
  63. $data = @mysql_fetch_assoc(mysql_query("SELECT link_order FROM ".DB_SITE_LINKS." ORDER BY link_order DESC LIMIT 1"));
  64. $link_order = $data['link_order'] + 1;
  65. $result = mysql_query("INSERT INTO ".DB_SITE_LINKS." (link_name, link_url, link_visibility, link_position, link_window, link_order) VALUES ('".$page_title."', 'viewpage.php?page_id=".$page_id."', '".$page_access."', '1', '0', '".$link_order."')");
  66. }
  67. }
  68. if (isset($_POST['page_id']) && isnum($_POST['page_id'])) {
  69. header("Location: ".FUSION_SELF."?status=su&pid=".$_POST['page_id']);
  70. } else {
  71. header("Location: ".FUSION_SELF."?status=sn&pid=".$page_id);
  72. }
  73. } else if (isset($_POST['delete']) && (isset($_POST['page_id']) && isnum($_POST['page_id']))) {
  74. $result = mysql_query("DELETE FROM ".DB_PREFIX."podstrona WHERE page_id='".$_POST['page_id']."'");
  75. $result = mysql_query("DELETE FROM ".DB_SITE_LINKS." WHERE link_url='viewpage.php?page_id=".$_POST['page_id']."'");
  76. header("Location: ".FUSION_SELF."?status=del");
  77. } else {
  78. if (isset($_POST['preview'])) {
  79. $addlink = isset($_POST['add_link']) ? " checked='checked'" : "";
  80. $page_title = stripinput($_POST['page_title']);
  81. $page_content = stripslash($_POST['page_content']);
  82. $page_content = phpentities($page_content);
  83. }
  84. $result = mysql_query("SELECT page_id, page_title FROM ".DB_PREFIX."podstrona ORDER BY page_title");
  85. if (@mysql_num_rows($result) != 0) {
  86. $editlist = ""; $sel = "";
  87. while ($data = @mysql_fetch_assoc($result)) {
  88. if (isset($_POST['page_id'])) { $sel = ($_POST['page_id'] == $data['page_id'] ? " selected='selected'" : ""); }
  89. $editlist .= "<option value='".$data['page_id']."'$sel>[".$data['page_id']."] ".$data['page_title']."</option>\n";
  90. }
  91. opentable("Istniejące dodatkowe strony");
  92. echo "<div style='text-align:center'>\n<form name='selectform' method='post' action='".FUSION_SELF."'>\n";
  93. echo "<select name='page_id' class='textbox' style='width:200px;'>\n".$editlist."</select>\n";
  94. echo "<input type='submit' name='edit' value='Edytuj' />\n";
  95. echo "<input type='submit' name='delete' value='Usuń' onclick='return DeletePage();' />\n";
  96. echo "</form>\n</div>\n";
  97. closetable();
  98. }
  99.  
  100. if (isset($_POST['edit']) && (isset($_POST['page_id']) && isnum($_POST['page_id']))) {
  101. $result = mysql_query("SELECT page_id, page_title, page_content FROM ".DB_PREFIX."podstrona WHERE page_id='".$_POST['page_id']."' LIMIT 1");
  102. if (@mysql_num_rows($result)) {
  103. $data = @mysql_fetch_assoc($result);
  104. $page_title = $data['page_title'];
  105. $page_content = phpentities(stripslashes($data['page_content']));
  106. $addlink = "";
  107. } else {
  108. header("Location: podstrona.php");
  109. }
  110. }
  111. if (isset($_POST['page_id']) && isnum($_POST['page_id'])) {
  112. opentable("Edytuj dodatkową stronę : [".$_POST['page_id']."] ".$page_title);
  113. } else {
  114. if (!isset($_POST['preview'])) {
  115. $page_title = "";
  116. $page_content = "";
  117. $addlink = "";
  118. }
  119. opentable("Dodaj dodatkową stronę");
  120. }
  121. echo "<form name='inputform' method='post' action='".FUSION_SELF."' onsubmit='return ValidateForm(this);'>\n";
  122. echo "<table cellpadding='0' cellspacing='0' class='center'>\n<tr>\n";
  123. echo "<td width='100' class='tbl'>Tytuł strony:</td>\n";
  124. echo "<td width='80%' class='tbl'><input type='text' name='page_title' value='".$page_title."' class='textbox' style='width:250px;' />\n";
  125. echo "</tr>\n<tr>\n";
  126. echo "<td valign='top' width='100' class='tbl'>Zawartość strony:</td>\n";
  127. echo "<td width='80%' class='tbl'><textarea name='page_content' cols='95' rows='15' style='width:98%'>".$page_content."</textarea></td>\n";
  128. echo "</tr>\n<tr>\n";
  129. echo "<td align='center' colspan='2' class='tbl'><br />\n";
  130. if (isset($_POST['page_id']) && isnum($_POST['page_id'])) {
  131. echo "<input type='hidden' name='page_id' value='".$_POST['page_id']."' />\n";
  132. }
  133. echo "<input type='submit' name='save' value='Zachowaj' /></td>\n";
  134. echo "</tr>\n</table>\n</form>\n";
  135. closetable();
  136. echo "<script type='text/javascript'>\n"."function DeletePage() {\n";
  137. echo "return confirm('Usunąć dodatkową stronę?');\n}"."\n";
  138. echo "function ValidateForm(frm) {\n"."if(frm.page_title.value=='') {\n";
  139. echo "alert('Wpisz tytuł strony');\n"."return false;\n}\n";
  140. /*if ($ustawienia['tinymce']) {
  141. echo "function SetTinyMCE(val) {\n";
  142. echo "now=new Date();\n"."now.setTime(now.getTime()+1000*60*60*24*365);\n";
  143. echo "expire=(now.toGMTString());\n"."document.cookie=\"custom_pages_tinymce=\"+escape(val)+\";expires=\"+expire;\n";
  144. echo "location.href='".FUSION_SELF."';\n"."}\n";
  145. }*/
  146. echo "</script>\n";
  147. }
  148.  
  149. require_once "../ustawienia/szablon/stopka.php";
  150. ?>
IceManSpy
Linijka 30 masz:
  1. $replace = array("&", """, "'", "\", """, "'", "<", ">", " ");

A ma być:
  1. $replace = array("&", """, "'", "\\", """, "'", "<", ">", " ");


EDIT
Poprawka smile.gif
Chodzi o to, że przez slashem, ma być jeszcze jeden slash.
walus16
Cytat(IceManSpy @ 10.11.2011, 23:14:57 ) *
Linijka 30 masz:
  1. $replace = array("&amp;", "&quot;", "'", "\", "&quot;", "'", "&lt;", "&gt;", " ");

A ma być:
  1. $replace = array("&amp;", "&quot;", "'", "\", "&quot;", "'", "&lt;", "&gt;", " ");


Podane przez Ciebie linijki niczym się nie różnią
minolone
zamien linie 30 na
  1. $replace = array("&amp;", "&quot;", "'", "\\", "&quot;", "'", "&lt;", "&gt;", " ");

linie 49 na
  1. $replace = array("&amp;", "&quot;", "'", "\\", "&lt;", "&gt;");
IceManSpy
Cytat(walus16 @ 10.11.2011, 23:18:52 ) *
Podane przez Ciebie linijki niczym się nie różnią

Faktycznie, poprawiłem swojego posta.
walus16
No dobra a co dalej? Dlaczego Tiny MCE mi nie działa? W części head strony mam dodany kod
  1. <!-- TinyMCE -->
  2. <script type="text/javascript" src="../jscripts/tiny_mce/tiny_mce.js"></script>
  3. <script type="text/javascript">
  4. tinyMCE.init({
  5. // General options
  6. mode : "textareas",
  7. theme : "advanced",
  8. plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emot
    ions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contex
    tmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxt
    ras,template,wordcount,advlist,autosave",
  9.  
  10. // Theme options
  11. theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justif
    ycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizesele
    ct",
  12. theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,out
    dent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|
    ,insertdate,inserttime,preview,|,forecolor,backcolor",
  13. theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iesp
    ell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
  14. theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acro
    nym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft",
  15. theme_advanced_toolbar_location : "top",
  16. theme_advanced_toolbar_align : "left",
  17. theme_advanced_statusbar_location : "bottom",
  18. theme_advanced_resizing : true,
  19.  
  20. // Example content CSS (should be your site CSS)
  21. content_css : "css/content.css",
  22.  
  23. // Drop lists for link/image/media/template dialogs
  24. template_external_list_url : "lists/template_list.js",
  25. external_link_list_url : "lists/link_list.js",
  26. external_image_list_url : "lists/image_list.js",
  27. media_external_list_url : "lists/media_list.js",
  28.  
  29. // Style formats
  30. style_formats : [
  31. {title : 'Bold text', inline : 'b'},
  32. {title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
  33. {title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
  34. {title : 'Example 1', inline : 'span', classes : 'example1'},
  35. {title : 'Example 2', inline : 'span', classes : 'example2'},
  36. {title : 'Table styles'},
  37. {title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
  38. ],
  39.  
  40. // Replace values for the template plugin
  41. template_replace_values : {
  42. username : "Some User",
  43. staffid : "991234"
  44. }
  45. });
  46. <!-- /TinyMCE -->
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.