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:
<script language="Javascript1.2"><!-- // load htmlarea
_editor_url = "htmlarea/"; // URL to htmlarea files
var win_ie_ver = parseFloat(navigator.appVersion.split("MSIE")[1]);
if (navigator.userAgent.indexOf('Mac') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Windows CE') >= 0) { win_ie_ver = 0; }
if (navigator.userAgent.indexOf('Opera') >= 0) { win_ie_ver = 0; }
if (win_ie_ver >= 5.5) {
document.write('<scr' + 'ipt src="' +_editor_url+ 'editor.js"');
document.write(' language="Javascript1.2"></scr' + 'ipt>');
} else { document.write('<scr'+'ipt>function editor_generate() { return false; }</scr'+'ipt>'); }
// --></script>
</head>
<body>
<table border="1" cellspacing="0" cellpadding="0" align="center" bgcolor="#F2F7F2" style="border-color: #7F8A7F" width="750">
<tr>
<td>
<table border="0" cellspacing="0" cellpadding="0" align="center" bgcolor="#DAE2DA" style="border-color: #7F8A7F" width="750">
<tr style="text-align: center; height: 20px;">
<td><a href="admin.php?dzial=news">newsy</a></td>
<td><a href="admin.php?logout"><b>wyloguj</b></a></td>
</tr>
</table>
</td>
</tr>
<tr>
<td align="center"><?php
$baza = "baza/";
switch($_GET['dzial']){
case "news";
if ( isset($_GET['publikuj']) ){ $id = $_GET['id'];
if ( $_GET['publikuj'] == "tak" ){
$query = "UPDATE news SET z='tak' WHERE news_id='$id'";
}else if ( $_GET['publikuj'] == "nie" ){
$query = "UPDATE news SET z='nie' WHERE news_id='$id'";
}
}
if (isset($_POST['zapisz'])) { $id = $_POST['id'];
$temat = escape_data( $_POST['tytul'] );
$tresc_k = escape_data( $_POST['area2'] );
$tresc = escape_data( $_POST['area'] );
if(empty($_POST['data'])){ $data = date("Y-m-d H:i:s"); }else{
$data = $_POST['data'];
}
if ( $_POST['co'] == "update" ) {
$query = "UPDATE news SET tytul='$tytul', tresc_krotka='$tresc_k', tresc='$tresc' ,data='$data'WHERE news_id='$id'";
echo '<p><font color="red">dane uaktualniono</font></p>'; }else{
echo 'Ku** cos poszlo nie tak'; }
}else if ( $_POST['co'] == "nowy" ){
$query = "INSERT INTO news ( tytul, tresc_krotka, tresc, data ) VALUES ( '$tytul', '$tresc_k', '$tresc', '$data' )";
echo '<p><font color="red">dane dodano</font></p>'; }else{
echo 'Ku** cos poszlo nie tak'; }
}
}
$query = "SELECT * FROM news WHERE news_id={$_GET['edytuj']}";
echo '<form action="admin.php?dzial=news" method="post"> <input type="hidden" name="co" value="update">
<input type="hidden" name="id" value="'.$row['news_id'].'">
Data: 0000-00-00 00:00:00 <input type="text" value="'.stripslashes($row['data']).'" name="data" size="30"> <br>
Tytuł: <input type="text" value="'.stripslashes($row['tytul']).'" name="tytul" size="100%"><br> Tresc krótka <textarea rows="20" cols="100%" name="area2">'.stripslashes($row['tresc_krotka']).'</textarea><br> Tresc <textarea rows="20" cols="100%" name="area">'.stripslashes($row['tresc']).'</textarea><br> <input type="submit" value="zapisz" name="zapisz">
</form>';
?>
<script language="JavaScript1.2" defer>
var config = new Object(); // create new config object
var config2 = new Object(); // create new config object
config.width = "100%";
config.height = "400px";
config.bodyStyle = 'background-color: white; font-family: "Verdana"; font-size: x-small;';
config.debug = 0;
config2.width = "100%";
config2.height = "100px";
config2.bodyStyle = 'background-color: white; font-family: "Verdana"; font-size: x-small;';
config2.debug = 0;
editor_generate('area',config);
editor_generate('area2',config2);
</script>
....
A to jest cały kod jaki jest podany w pliku example edytora który chcę zaincludować zamiast istniejacego:<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style>
body{font:10px verdana,arial,sans-serif;}
a{color:#cc0000;font-size:xx-small;}
</style>
<?
//Check user's Browser
if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE")) echo "<script language=JavaScript src='../scripts/editor.js'></script>"; else
echo "<script language=JavaScript src='../scripts/moz/editor.js'></script>"; ?>
<script>
function submitForm()
{
document.forms.Form1.elements.inpContent.value = oEdit1.getHTMLBody();
document.forms.Form1.submit()
}
</script>
</head>
<body>
<h5>Complete Toolbar Buttons (php example) - <a href="../default.htm">Back</a></h5>
<pre id="idTemporary" name="idTemporary" style="display:none">
<?
if(isset($_POST["inpContent"])) {
$sContent=stripslashes($_POST['inpContent']);//remove slashes (/) }
?>
</pre>
<form method="post" action="default1.php" id="Form1">
<script>
var oEdit1 = new InnovaEditor("oEdit1");
oEdit1.arrStyle = [["BODY",false,"","font:10px verdana,arial,sans-serif;"]];
oEdit1.width=505;
oEdit1.features=["Save","FullScreen","Preview","Print","Search","SpellCheck",
"Cut","Copy","Paste","PasteWord","PasteText","|","Undo","Redo","|",
"ForeColor","BackColor","|","Bookmark","Hyperlink",
"CustomTag","HTMLFullSource","HTMLSource","XHTMLFullSource",
"XHTMLSource","BRK","Numbering","Bullets","|","Indent","Outdent","LTR","RTL","|","Image","Flash","Media","|","InternalLink","CustomObject","|",
"Table","Guidelines","Absolute","|","Characters","Line",
"Form","Clean","ClearAll","BRK",
"StyleAndFormatting","TextFormatting","ListFormatting","BoxFormatting",
"ParagraphFormatting","CssText","Styles","|",
"Paragraph","FontName","FontSize","|",
"Bold","Italic",
"Underline","Strikethrough","|","Superscript","Subscript","|",
"JustifyLeft","JustifyCenter","JustifyRight","JustifyFull"];
oEdit1.cmdAssetManager="modalDialogShow('/Editor/assetmanager/assetmanager.php',640,465)";
oEdit1.onSave = new Function("submitForm()");
oEdit1.cmdInternalLink = "modelessDialogShow('links.htm',365,270)"
oEdit1.cmdCustomObject = "modelessDialogShow('objects.htm',365,270)"
oEdit1.arrCustomTag=[["First Name","{%first_name%}"],
["Last Name","{%last_name%}"],
["Email","{%email%}"]];
oEdit1.RENDER(document.getElementById("idTemporary").innerHTML);
</script>
<input type="hidden" name="inpContent" id="inpContent">
</form>
<br><br>
<?
if(isset($_POST["inpContent"])) {
$sContent=stripslashes($_POST['inpContent']);//remove slashes (/) }
?>
</body>
</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...
<?
//Check user's Browser
if(strpos($_SERVER["HTTP_USER_AGENT"],"MSIE")) // Ładuj gdy IE
echo "<script language=JavaScript src='Editor/scripts/editor.js'></script>"; else
// Ładuj gdy inna przegladarka
echo "<script language=JavaScript src='Editor/scripts/moz/editor.js'></script>"; ?>
</head>
<body>
<table border="1" cellspacing="0" cellpadding="0" align="center" bgcolor="#F2F7F2" style="border-color: #7F8A7F" width="750">
tutaj jest menu
</table>
</td>
<td align="center" valign="top">
<?php
$baza = "baza/";
switch($_GET['dzial']){
case "news";
if ( isset($_GET['publikuj']) ){ $id = $_GET['id'];
if ( $_GET['publikuj'] == "tak" ){
$query = "UPDATE news SET z='tak' WHERE news_id='$id'";
}else if ( $_GET['publikuj'] == "nie" ){
$query = "UPDATE news SET z='nie' WHERE news_id='$id'";
}
}
if (isset($_POST['zapisz'])) { $id = $_POST['id'];
$temat = escape_data( $_POST['tytul'] );
$tresc = escape_data( $_POST['tresc'] );
if(empty($_POST['data'])){ $data = date("Y-m-d H:i:s"); }else{
$data = $_POST['data'];
}
if ( $_POST['co'] == "update" ) {
$query = "UPDATE news SET tytul='$tytul', tresc='$tresc' ,data='$data'WHERE news_id='$id'";
echo '<p><font color="red">dane uaktualniono</font></p>'; }else{
echo '<br>Operacja wykonana błędnie :( ==> Wykonaj ja poprawnie<br>'; }
}else if ( $_POST['co'] == "nowy" ){
$query = "INSERT INTO news ( tytul, tresc, data ) VALUES ( '$tytul', '$tresc', '$data' )";
echo '<p><font color="red">dane dodano</font></p>'; }else{
echo '<br>Operacja wykonana błędnie :( ==> Wykonaj ja poprawnie<br>'; }
}
}
$query = "SELECT * FROM news WHERE news_id={$_GET['edytuj']}";
echo '<table width="100%" style= "padding: 1px; border: 0px; background-color: #d3d3d3;" cellspacing="1" cellpadding="1"> <tr style="background-color: #dddddd; text-align: center; height: 20px;">
<td colspan="2">
<b>Edytuj newsa</b>
</td>
</tr>
<form action="admin.php?dzial=news" method="post">
<input type="hidden" name="co" value="update">
<input type="hidden" name="id" value="'.$row['news_id'].'" >
<tr style="background-color: #f3f3f3;">
<td width="75" style="padding: 5px; text-align: left;">
Data:<br>(0000-00-00)
</td>
<td style="padding: 5px;">
<input type="text" name="data" size="92%" value="'.stripslashes($row['data']).'"> </td>
</tr>
<tr style="background-color: #f3f3f3;">
<td width="50" style="padding: 5px; text-align: left;">
Tytuł:
</td>
<td style="padding: 5px;">
<input type="text" name="tytul" size="92%" value="'.stripslashes($row['tytul']).'"> </td>
</tr>
<tr style="background-color: #f3f3f3;">
<td style="padding: 5px;" colspan="2">
<script>
var oEdit1 = new InnovaEditor("oEdit1");
oEdit1.RENDER("'.$tresc.'");
oEdit1.arrStyle = [["BODY",false,"","font:10px verdana,arial,sans-serif;"]];
oEdit1.width=490;
oEdit1.features=["Save","FullScreen","Preview","Print","Search","SpellCheck",
"Cut","Copy","Paste","PasteWord","PasteText","|","Undo","Redo","|",
"ForeColor","BackColor","|","Bookmark","Hyperlink",
"CustomTag","HTMLFullSource","HTMLSource","XHTMLFullSource",
"XHTMLSource","BRK","Numbering","Bullets","|","Indent","Outdent","LTR","RTL","|","Image","Flash","Media","|","InternalLink","CustomObject","|",
"Table","Guidelines","Absolute","|","Characters","Line",
"Form","Clean","ClearAll","BRK",
"StyleAndFormatting","TextFormatting","ListFormatting","BoxFormatting",
"ParagraphFormatting","CssText","Styles","|",
"Paragraph","FontName","FontSize","|",
"Bold","Italic",
"Underline","Strikethrough","|","Superscript","Subscript","|",
"JustifyLeft","JustifyCenter","JustifyRight","JustifyFull"];
oEdit1.cmdAssetManager="modalDialogShow(`Editor/assetmanager/assetmanager.php`,640,465)";
</script>
</td>
</tr>
<tr style="background-color: #dddddd;">
<td colspan="2" style="padding: 5px; text-align: center;">
<input type="submit" value="Zapisz zmiany" name="zapisz">
</td>
</tr>
</form></table>';
?>
Moze czegoś zapomniałem, ze mi nie zapisuje?? Tylko czego... A może coś trzeba dodac lub dopisać?
Ten post edytował Domin 12.03.2006, 00:07:13
Głupi wie wszystko, mądry uczy się całe życie.