Grazie in anticipo a tutti, mi dareste una mano a far funzioanre ckeditor, in modo da renderlo un vero editor html online, visto che ckeditor, a tutte le funzioni tranne quella per il salvataggio del testo scritto,
io sto cercando di realizare una cosa simile ma non ci riesco mi chiedevo, se gentilmente mi dareste una mano con il creare una funzione di salvataggio su server hosting linux con ckeditor, mi spiego il mio problema nel caso vogliate darmi una mano, nel voler dare un aggiustatina al mio script per ckeditor.
Stò cercando di creare una funzione con ckeditor che consente di salvare e carricare i file html da cartella hosting,dirreatamente nel contenuto della textareadel editor, ho scritto questo script ma non sono molto esperto di php, ci sarebbe qualche bravo programmatore che vuole rimproverarmi, degli errori che ci sono in questo script pls.
file.html
codice:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>API Usage — CKEditor Sample</title>
<meta content="text/html; charset=utf-8" http-equiv="content-type" />
<script type="text/javascript" src="ckeditor/ckeditor.js"></script>
<script src="sample.js" type="text/javascript"></script>
<link href="sample.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
//<![CDATA[
CKEDITOR.on( 'instanceReady', function( ev )
{
document.getElementById( 'eMessage' ).innerHTML = '
Instance <code>' + ev.editor.name + '<\/code> loaded.<\/p>';
document.getElementById( 'eButtons' ).style.display = 'block';
});
function InsertHTML()
{
var oEditor = CKEDITOR.instances.editor1;
var value = document.getElementById( 'htmlArea' ).value;
if ( oEditor.mode == 'wysiwyg' )
{
oEditor.insertHtml( value );
}
else
alert( 'You must be in WYSIWYG mode!' );
}
function InsertText()
{
var oEditor = CKEDITOR.instances.editor1;
var value = document.getElementById( 'txtArea' ).value;
if ( oEditor.mode == 'wysiwyg' )
{
oEditor.insertText( value );
}
else
alert( 'You must be in WYSIWYG mode!' );
}
function SetContents()
{
var oEditor = CKEDITOR.instances.editor1;
var value = document.getElementById( 'htmlArea' ).value;
oEditor.setData( value );
}
function GetContents()
{
var oEditor = CKEDITOR.instances.editor1;
alert( oEditor.getData() );
}
function ExecuteCommand( commandName )
{
var oEditor = CKEDITOR.instances.editor1;
if ( oEditor.mode == 'wysiwyg' )
{
oEditor.execCommand( commandName );
}
else
alert( 'You must be in WYSIWYG mode!' );
}
function CheckDirty()
{
var oEditor = CKEDITOR.instances.editor1;
alert( oEditor.checkDirty() );
}
function ResetDirty()
{
var oEditor = CKEDITOR.instances.editor1;
oEditor.resetDirty();
alert( 'The "IsDirty" status has been reset' );
}
//]]>
</script>
</head>
<body>
</noscript>
</div>
<input name="Titolo" style="width: 100px" type="text" / size="1" maxlength="15">
<textarea cols="100" id="editor1" name="editor1" rows="10"><?php echo htmlentities($_POST['editor1'], ENT_QUOTES, 'UTF-8'); ?></textarea>
<script type="text/javascript">
//<![CDATA[
// Replace the <textarea id="editor1"> with an CKEditor instance.
var editor = CKEDITOR.replace( 'editor1' );
//]]>
</script>
<div id="eMessage">
</div>
<div id="eButtons" style="display: none">
<input onclick="InsertHTML();" type="button" value="INVIA SCRIPT HTML" />
<textarea cols="100" id="htmlArea" rows="3"><h2>Test</h2><p>This is some <a href="/Test1.html">sample</a> HTML code.</p></textarea>
</div>
<form method="post" action="pagina.php">
DIGITARE IL NOME DEL FILE DA SALVARE HO DA CARICARE
<input name="Titolo" style="width: 100px" type="text" / size="1" maxlength="15">
<input type="submit" name="save" value="salva" />
<input type="reset" name="reset" value="carica" />
</form>
</body>
</html>
pagina.php
Codice PHP:
<?php
if (isset($_POST['editor1']) == false)
{
$_POST['editor1'] = '';
}
else
{
$_POST['editor1'] = stripslashes($_POST['editor1']);
}
if (isset($_POST['submit']))
{
$fp = fopen(stripslashes($_POST['/public/nomesito/*.html']), 'wb');
fwrite($fp, $_POST['editor1']);
fclose($fp);
}
else if (isset($_POST['reset']))
{
$_POST['editor1'] = file_get_content(stripslashes($_POST['/public/nomesito/*.html']));
}
?>