X-Git-Url: https://jasonwoof.com/gitweb/?p=ckeditor.git;a=blobdiff_plain;f=_samples%2Fphp%2Fevents.php;h=a62519211240c209a00d2df8a015be6fef0a006c;hp=36f2be27644d3e39bfcd768f3e94c2a98b2b7cc4;hb=48b1db88210b4160dce439c6e3e32e14af8c106b;hpb=9afde8772159bd3436f1f5b7862960307710ae5a diff --git a/_samples/php/events.php b/_samples/php/events.php index 36f2be2..a625192 100644 --- a/_samples/php/events.php +++ b/_samples/php/events.php @@ -1,18 +1,48 @@ - Sample - CKEditor + Adding Event Handlers — CKEditor Sample -

- CKEditor Sample +

+ CKEditor Sample — Adding Event Handlers

+
+

+ This sample shows how to add event handlers to CKEditor with PHP. +

+

+ A snippet of the configuration code can be seen below; check the source code of this page for + the full definition: +

+
<?php
+// Include the CKEditor class.
+include("ckeditor/ckeditor.php");
+
+// Create a class instance.
+$CKEditor = new CKEditor();
+
+// Path to the CKEditor directory.
+$CKEditor->basePath = '/ckeditor/';
+
+// The initial value to be displayed in the editor.
+$initialValue = 'This is some sample text.';
+
+// Add event handler, instanceReady is fired when editor is loaded.
+$CKEditor->addEventHandler('instanceReady', 'function (evt) {
+	alert("Loaded editor: " + evt.editor.name);
+}');
+
+// Create an editor instance.
+$CKEditor->editor("editor1", $initialValue);
+
+
- -
- Output -
-

-
-

+ + addGlobalEventHandler('dialogDefinition', $function); } -// Include CKEditor class. +// Include the CKEditor class. include("../../ckeditor.php"); -// Create class instance. +// Create a class instance. $CKEditor = new CKEditor(); -// Set configuration option for all editors. +// Set a configuration option for all editors. $CKEditor->config['width'] = 750; -// Path to CKEditor directory, ideally instead of relative dir, use an absolute path: +// Path to the CKEditor directory, ideally use an absolute path instead of a relative dir. // $CKEditor->basePath = '/ckeditor/' // If not set, CKEditor will try to detect the correct path. $CKEditor->basePath = '../../'; @@ -83,18 +108,17 @@ $CKEditor->addEventHandler('instanceReady', 'function (evt) { alert("Loaded editor: " + evt.editor.name); }'); -// Create first instance. +// Create the first instance. $CKEditor->editor("editor1", $initialValue); -// Clear event handlers, instances that will be created later will not have +// Clear event handlers. Instances that will be created later will not have // the 'instanceReady' listener defined a couple of lines above. $CKEditor->clearEventHandlers(); ?> -

-
-

+
+ editor("editor2", $initialValue, $config, $events); ?> -

- -

-
-
+

+ +

+