Bonjour,

Je dois changer un fckeditor par un ckeditor. Cen n'est pas moi qui est installé fckeditor auparavant. Ils se servent de cette éditeur pour modifier toute une page html dans un CMS "fait maison". Un bouton "save" est mis a coté de l'éditeur pour sauvegarder. J'ai réussi à remplacer l'éditeur mais je n'arrive pas à sauvegarder. Voici la fonction qui utilise des évènements fckeditor on dirait :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
 
		function saveHTML() {
			for (var i=0; i<window.frames.length; i++) {
				if (window.frames[i].FCK) {
					window.frames[i].FCK.UpdateLinkedField();
				}
			}
			top.clickSaveHTML("<?PHP echo $_GET['file'] ; ?>", document.getElementById("textcontent").value) ;
		}
Le formulaire fckeditor initial avec le bouton save :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
 
<body style="margin:0; padding:0;">
<form action="save-text.php" method="post" style="margin:0; padding:0;" onSubmit="return false;">
	<input type="hidden" id="sourcefile" name="sourcefile" value="<?PHP echo pathFromID($_GET['file']); ?>" />
<?PHP
	include("../fckeditor/fckeditor.php") ;
	$ofckeditor = new fckeditor('textcontent') ;
	$ofckeditor->BasePath = '../fckeditor/' ;
	$ofckeditor->Value = $writeContent ;
	$ofckeditor->Height = '100%' ;
	$ofckeditor->Create() ;
?>
</form>
<button onclick="saveHTML();" id="saveHTMLButton">Save</button>
Le formulaire que j'ai fais avec ckeditor avec le bouton save :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
 
<body style="margin:0; padding:0;">
    <form method="post" action="save-text.php">
	<input type="hidden" id="sourcefile" name="sourcefile" value="<?PHP echo pathFromID($_GET['file']); ?>" />
        <p>
            <textarea name="textcontent"></textarea>
            <script>
                CKEDITOR.replace( 'textcontent' );
            </script>
 
        </p>
    </form>
<button onclick="saveHTML();" id="saveHTMLButton">Save</button>
la page save-text.php :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
 
<?PHP
	/* 
		Expects:
			$_POST['textcontent']
			$_POST['sourcefile']
			and possibly
			$_POST['dontrefresh'] (for Save & Continue with .text only)
 
		Takes the filename (LIVE for FREE INCLUDES, but PREVIEW for LCIs!) and new file content for TEXT or HTML files
		tries to save the preview copy of a file
		If it succeeds, tests whether the live and preview files match, returning
			<xml>
				<filesaved>
					<id>ID</id>
					<smatch>MATCH_CODE</smatch>
				</filesaved>
			</xml>
	*/
	require 'check-login.php' ;
	require '../cmsfns.php' ;
 
	/* echo "debug: " . $_POST['textcontent'] ; exit ;*/
 
	/* 
	echo "debug: " ;
	var_dump($_POST) ;
	exit ;
	*/
 
	// Check we have the bits
	if (!isset($_POST['textcontent'])) {
		print('error:No content supplied.') ;
		exit ;
	}
	else if (!isset($_POST['sourcefile'])) {
		print('error:No source text file name supplied.') ;
		exit ;
	}
	else {
		$sourceFile = pathFromID($_POST['sourcefile']) ;
		$fileContent = $_POST['textcontent'] ;
	}
 
	$mode = (isset($_POST['mode'])) ? $_POST['mode'] : false ;
	if (isPageTemplate($sourceFile)) $mode = 'pagetemplate' ;
	elseif (getFileExtension($sourceFile) == "php") $mode = 'page' ;
 
	/* 
		If a child include, save file to pv location, and save live copy if live not present or empty
		If a page, just save to pv location, and save live copy if not present or empty, PLUS correct the general-include call (for the LIVE version!)
		If a free include, save to pv location, and save live copy if not present or empty
		If a Page Template, simply save to PTs folder 
	*/
	switch ($mode) {
		case "ptchildinclude" :
			// ????????????????
			$previewFile = pathFromID($_POST['sourcefile']) ;
			$liveFile = False ;
		break ;
		case "pagetemplate" :
			// ????????????????
			$previewFile = pathFromID($_POST['sourcefile']) ;
			$liveFile = False ;
		break ;
		default :
			if (isLCI(pathFromID($_POST['sourcefile']))) {
				// We have an LCI
				$previewFile = pathFromID($_POST['sourcefile']) ;
				$liveFile = getLiveLCIFromPreview(pathFromID($previewFile)) ;
			}
			else {
				$liveFile = pathFromID($_POST['sourcefile']) ;
				$previewFile = getPreviewFileFromLive($liveFile) ;
			}
		break ;
	}
 
	/*
	print 'error: ' . $previewFile, "\n\n", $liveFile ;
	exit ; 
	DEBUGGING
	*/
 
	// Correct path to include for general, for Pages only
	if ($mode == "page") {
		$fileContent = correctGeneralInclude(stripslashes($fileContent), $liveFile) ;
		$fileContent = unSimplifyContents($fileContent, $previewFile) ;
	}
	else {
		$fileContent = stripslashes($fileContent) ;
 
		//$currentPath = dirname($_SERVER['SCRIPT_NAME']) ;
		//$relativePath = substr($currentPath, 0, stringrpos($currentPath, '/' . CMSDIRNAME)) ;
		//$fileContent = str_replace('href="' . $relativePath, 'href="^^SITEROOT^^', $fileContent) ;
	}
 
	// Open handle to Preview file
    if (False === ($fileHandle = @fopen($previewFile, 'w'))) {
		print('error:Could not open preview file:' . $previewFile . '.') ;
        exit;
    }
	chmod($previewFile, 0644) ;
	// Try to save Preview copy
	if (False === @fwrite($fileHandle, $fileContent)) {
		fclose($fileHandle) ;
		print('error:Could not save preview file - ' . $previewFile) ;
		exit ;
    }
	fclose($fileHandle);
 
 
	// If the live file is zero-length, save to Live also.
	if (
		$liveFile &&
		(!is_file($liveFile) || @filesize($liveFile) === 0)
	) {
		$saveLive = fopen($liveFile, 'w') ;
		if (False === @fwrite($saveLive, $fileContent)) {
			print('error:Could not save preview file') ;
			fclose($saveLive) ;
			exit ;
		}
		fclose($saveLive) ;
		chmod($liveFile, 0644) ;
	}
 
	header("Content-type: text/xml") ;
	$xmlr = '<xml>' ;
		if (isSet($_POST['dontrefresh'])) $xmlr .= '<dontrefresh>True</dontrefresh>' ;
		$xmlr .= '<id>' ;
			$xmlr .= $_POST['sourcefile'] ;
		$xmlr .= '</id>' ;
		if (file_exists($previewFile) && file_exists($liveFile)) {
			$xmlr .= '<match>' ;
				$xmlr .= (md5_file($previewFile) == md5_file($liveFile)) ? '1' : '0' ;
			$xmlr .= '</match>' ;
		}
	$xmlr .= '</xml>' ;
	print($xmlr) ;
	exit ;
?>
Si quelqu'un à déjà fait ce genre de chose...

Merci