replace.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <!--
  3. Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
  4. For licensing, see LICENSE.html or http://ckeditor.com/license
  5. -->
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <title>Replace Selected Textarea Elements &mdash; CKEditor Sample</title>
  9. <meta content="text/html; charset=utf-8" http-equiv="content-type"/>
  10. <link href="../sample.css" rel="stylesheet" type="text/css"/>
  11. </head>
  12. <body>
  13. <h1 class="samples">
  14. CKEditor Sample &mdash; Replace Selected Textarea Elements Using PHP Code
  15. </h1>
  16. <div class="description">
  17. <p>
  18. This sample shows how to replace a selected <code>&lt;textarea&gt;</code> element
  19. with a CKEditor instance by using PHP code.
  20. </p>
  21. <p>
  22. To replace a <code>&lt;textarea&gt;</code> element, place the following call at any point
  23. after the <code>&lt;textarea&gt;</code> element:
  24. </p>
  25. <pre class="samples">
  26. &lt;?php
  27. // Include the CKEditor class.
  28. include_once "ckeditor/ckeditor.php";
  29. // Create a class instance.
  30. $CKEditor = new CKEditor();
  31. // Path to the CKEditor directory.
  32. $CKEditor->basePath = '/ckeditor/';
  33. // Replace a textarea element with an id (or name) of "textarea_id".
  34. $CKEditor->replace("textarea_id");
  35. ?&gt;</pre>
  36. <p>
  37. Note that <code><em>textarea_id</em></code> in the code above is the <code>id</code> attribute of
  38. the <code>&lt;textarea&gt;</code> element to be replaced.
  39. </p>
  40. </div>
  41. <!-- This <div> holds alert messages to be display in the sample page. -->
  42. <div id="alerts">
  43. <noscript>
  44. <p>
  45. <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
  46. support, like yours, you should still see the contents (HTML data) and you should
  47. be able to edit it normally, without a rich editor interface.
  48. </p>
  49. </noscript>
  50. </div>
  51. <form action="../sample_posteddata.php" method="post">
  52. <p>
  53. <label for="editor1">
  54. Editor 1:</label>
  55. <textarea cols="80" id="editor1" name="editor1" rows="10">&lt;p&gt;This is some &lt;strong&gt;sample text&lt;/strong&gt;. You are using &lt;a href="http://ckeditor.com/"&gt;CKEditor&lt;/a&gt;.&lt;/p&gt;</textarea>
  56. </p>
  57. <p>
  58. <input type="submit" value="Submit"/>
  59. </p>
  60. </form>
  61. <div id="footer">
  62. <hr />
  63. <p>
  64. CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
  65. </p>
  66. <p id="copy">
  67. Copyright &copy; 2003-2011, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
  68. Knabben. All rights reserved.
  69. </p>
  70. </div>
  71. <?php
  72. // Include the CKEditor class.
  73. include_once "../../ckeditor.php";
  74. // Create a class instance.
  75. $CKEditor = new CKEditor();
  76. // Path to the CKEditor directory, ideally use an absolute path instead of a relative dir.
  77. // $CKEditor->basePath = '/ckeditor/'
  78. // If not set, CKEditor will try to detect the correct path.
  79. $CKEditor->basePath = '../../';
  80. // Replace a textarea element with an id (or name) of "editor1".
  81. $CKEditor->replace("editor1");
  82. ?>
  83. </body>
  84. </html>