advanced.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  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>Setting Configuration Options &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; Setting Configuration Options
  15. </h1>
  16. <p>
  17. This sample shows how to insert a CKEditor instance with custom configuration options.
  18. </p>
  19. <p>
  20. To set configuration options, use the <a class="samples" href="http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html"><code>config</code></a> property. To set the attributes of a <code>&lt;textarea&gt;</code> element (which is displayed instead of CKEditor in unsupported browsers), use the <code>textareaAttributes</code> property.
  21. </p>
  22. <pre class="samples">
  23. &lt;?php
  24. // Include the CKEditor class.
  25. include_once "ckeditor/ckeditor.php";
  26. // Create a class instance.
  27. $CKEditor = new CKEditor();
  28. // Path to the CKEditor directory.
  29. $CKEditor->basePath = '/ckeditor/';
  30. // Set global configuration (used by every instance of CKEditor).
  31. $CKEditor-><strong>config['width']</strong> = 600;
  32. // Change default textarea attributes.
  33. $CKEditor-><strong>textareaAttributes</strong> = array("cols" => 80, "rows" => 10);
  34. // The initial value to be displayed in the editor.
  35. $initialValue = 'This is some sample text.';
  36. // Create the first instance.
  37. $CKEditor->editor("textarea_id", $initialValue);
  38. ?&gt;</pre>
  39. <p>
  40. Note that <code><em>textarea_id</em></code> in the code above is the <code>name</code> attribute of
  41. the <code>&lt;textarea&gt;</code> element to be created.
  42. </p>
  43. <!-- This <div> holds alert messages to be display in the sample page. -->
  44. <div id="alerts">
  45. <noscript>
  46. <p>
  47. <strong>CKEditor requires JavaScript to run</strong>. In a browser with no JavaScript
  48. support, like yours, you should still see the contents (HTML data) and you should
  49. be able to edit it normally, without a rich editor interface.
  50. </p>
  51. </noscript>
  52. </div>
  53. <form action="../sample_posteddata.php" method="post">
  54. <label>Editor 1:</label>
  55. <?php
  56. // Include the CKEditor class.
  57. include("../../ckeditor.php");
  58. // Create a class instance.
  59. $CKEditor = new CKEditor();
  60. // Do not print the code directly to the browser, return it instead.
  61. $CKEditor->returnOutput = true;
  62. // Path to the CKEditor directory, ideally use an absolute path instead of a relative dir.
  63. // $CKEditor->basePath = '/ckeditor/'
  64. // If not set, CKEditor will try to detect the correct path.
  65. $CKEditor->basePath = '../../';
  66. // Set global configuration (will be used by all instances of CKEditor).
  67. $CKEditor->config['width'] = 600;
  68. // Change default textarea attributes.
  69. $CKEditor->textareaAttributes = array("cols" => 80, "rows" => 10);
  70. // The initial value to be displayed in the editor.
  71. $initialValue = '<p>This is some <strong>sample text</strong>. You are using <a href="http://ckeditor.com/">CKEditor</a>.</p>';
  72. // Create the first instance.
  73. $code = $CKEditor->editor("editor1", $initialValue);
  74. echo $code;
  75. ?>
  76. <br />
  77. <label>Editor 2:</label>
  78. <?php
  79. // Configuration that will only be used by the second editor.
  80. $config['toolbar'] = array(
  81. array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ),
  82. array( 'Image', 'Link', 'Unlink', 'Anchor' )
  83. );
  84. $config['skin'] = 'v2';
  85. // Create the second instance.
  86. echo $CKEditor->editor("editor2", $initialValue, $config);
  87. ?>
  88. <p>
  89. <input type="submit" value="Submit"/>
  90. </p>
  91. </form>
  92. <div id="footer">
  93. <hr />
  94. <p>
  95. CKEditor - The text editor for the Internet - <a class="samples" href="http://ckeditor.com/">http://ckeditor.com</a>
  96. </p>
  97. <p id="copy">
  98. Copyright &copy; 2003-2011, <a class="samples" href="http://cksource.com/">CKSource</a> - Frederico
  99. Knabben. All rights reserved.
  100. </p>
  101. </div>
  102. </body>
  103. </html>