source: trunk/examples/files/ext_example-body.php @ 1406

Last change on this file since 1406 was 1406, checked in by gogo, 21 months ago

A little quick tidy up of examples.

File size: 10.9 KB
Line 
1<?php
2  switch(@$_REQUEST['DocType'])
3  {
4   
5    case 'quirks':
6      break;
7     
8   case 'almost':
9      echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
10      break;
11   
12    case 'standards':
13    default:
14      echo '<!DOCTYPE html>';
15      break;
16     
17  }
18?>
19<html>
20<head>
21
22  <!-- ---------------------------------------------------------------------
23    --  $HeadURL: http://svn.xinha.org/branches/MootoolsFileManager-Update/examples/files/ext_example-body.html $
24    --  $LastChangedDate: 2008-10-13 06:42:42 +1300 (Mon, 13 Oct 2008) $
25    --  $LastChangedRevision: 1084 $
26    --  $LastChangedBy: ray $
27    ------------------------------------------------------------------------ -->
28
29  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
30  <title>Example of Xinha</title>
31  <link rel="stylesheet" type="text/css" href="full_example.css" />
32
33  <script type="text/javascript">
34    function showError( sMsg, sUrl, sLine){
35      document.getElementById('errors').value += 'Error: ' + sMsg + '\n' +
36                                                 'Source File: ' + sUrl + '\n' +
37                                                 'Line: ' + sLine + '\n';
38      return false;
39    }
40    // You must set _editor_url to the URL (including trailing slash) where
41    // where xinha is installed, it's highly recommended to use an absolute URL
42    //  eg: _editor_url = "/path/to/xinha/";
43    // You may try a relative URL if you wish]
44    //  eg: _editor_url = "../";
45    // in this example we do a little regular expression to find the absolute path.
46    _editor_url  = document.location.href.replace(/examples\/files\/ext_example-body\.php.*/, '')
47    //moved _editor_lang & _editor_skin to init function because of error thrown when frame document not ready
48  </script>
49
50  <!-- Load up the actual editor core -->
51  <script type="text/javascript" src="../../XinhaCore.js"></script>
52
53  <script type="text/javascript">
54    xinha_editors = null;
55    xinha_init    = null;
56    xinha_config  = null;
57    xinha_plugins = null;
58
59    xinha_init = xinha_init ? xinha_init : function() {
60      window.onerror = showError;
61      document.onerror = showError;
62
63      var f = top.frames["menu"].document.forms["fsettings"];
64      _editor_lang = f.lang[f.lang.selectedIndex].value; // the language we need to use in the editor.
65      _editor_skin = f.skin[f.skin.selectedIndex].value; // the skin we use in the editor
66      _editor_icons = f.icons[f.icons.selectedIndex].value;
67     
68// What are the plugins you will be using in the editors on this page.
69// List all the plugins you will need, even if not all the editors will use all the plugins.
70      xinha_plugins = [ ];
71      for(var x = 0; x < f.plugins.length; x++) {
72        if(f.plugins[x].checked) xinha_plugins.push(f.plugins[x].value);
73      }
74
75      // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :)
76      if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;
77
78// What are the names of the textareas you will be turning into editors?
79      var num = 1;
80      num = parseInt(f.num.value);
81      if(isNaN(num)) {
82        num = 1;
83        f.num.value = 1;
84      }
85      var dest = document.getElementById("editors_here");
86      var lipsum = window.parent.menu.document.getElementById('myTextarea0').value;
87
88      xinha_editors = [ ]
89      for(var x = 0; x < num; x++) {
90        var ta = 'myTextarea' + x;
91        xinha_editors.push(ta);
92
93        var div = document.createElement('div');
94        div.className = 'area_holder';
95
96        var txta = document.createElement('textarea');
97        txta.id   = ta;
98        txta.name = ta;
99        txta.value = lipsum;
100        txta.style.width="100%";
101        txta.style.height="420px";
102
103        div.appendChild(txta);
104        dest.appendChild(div);
105      }
106
107// Create a default configuration to be used by all the editors.
108      settings = top.frames["menu"].settings;
109      xinha_config = new Xinha.Config();
110      xinha_config.width = settings.width;
111      xinha_config.height = settings.height;
112      xinha_config.sizeIncludesBars = settings.sizeIncludesBars;
113      xinha_config.sizeIncludesPanels = settings.sizeIncludesPanels;
114      xinha_config.statusBar = settings.statusBar;
115      xinha_config.htmlareaPaste = settings.htmlareaPaste;
116      xinha_config.mozParaHandler = settings.mozParaHandler;
117      xinha_config.getHtmlMethod = settings.getHtmlMethod;
118      xinha_config.undoSteps = settings.undoSteps;
119      xinha_config.undoTimeout = settings.undoTimeout;
120      xinha_config.changeJustifyWithDirection = settings.changeJustifyWithDirection;
121      xinha_config.fullPage = settings.fullPage;
122      xinha_config.pageStyle = settings.pageStyle;
123      xinha_config.baseHref = settings.baseHref;
124      xinha_config.expandRelativeUrl = settings.expandRelativeUrl;
125      xinha_config.stripBaseHref = settings.stripBaseHref;
126      xinha_config.stripSelfNamedAnchors = settings.stripSelfNamedAnchors;
127      xinha_config.only7BitPrintablesInURLs = settings.only7BitPrintablesInURLs;
128      xinha_config.sevenBitClean = settings.sevenBitClean;
129      xinha_config.killWordOnPaste = settings.killWordOnPaste;
130      xinha_config.makeLinkShowsTarget = settings.makeLinkShowsTarget;
131      xinha_config.flowToolbars = settings.flowToolbars;
132      xinha_config.stripScripts = settings.stripScripts;
133      xinha_config.flowToolbars = settings.flowToolbars;
134      xinha_config.showLoading = settings.showLoading;
135      xinha_config.pageStyleSheets = ["full_example.css"];
136
137// Create a default configuration for the plugins
138      if (typeof CharCounter != 'undefined') {
139        xinha_config.CharCounter.showChar = settings.showChar;
140        xinha_config.CharCounter.showWord = settings.showWord;
141        xinha_config.CharCounter.showHtml = settings.showHtml;
142      }
143
144      if(typeof CharacterMap != 'undefined') xinha_config.CharacterMap.mode = settings.CharacterMapMode;
145      if(typeof ListType != 'undefined') xinha_config.ListType.mode = settings.ListTypeMode;
146      if(typeof CSSDropDowns != 'undefined') xinha_config.pageStyle = xinha_config.pageStyle + "\n" + "@import url(custom.css);";
147      if(typeof DynamicCSS != 'undefined') xinha_config.pageStyle = "@import url(dynamic.css);";
148      if(typeof Filter != 'undefined') xinha_config.Filters = ["Word", "Paragraph"];
149
150      if(typeof Stylist != 'undefined') {
151        // We can load an external stylesheet like this - NOTE : YOU MUST GIVE AN ABSOLUTE URL
152        //  otherwise it won't work!
153        xinha_config.stylistLoadStylesheet(document.location.href.replace(/[^\/]*\.html/, 'stylist.css'));
154
155        // Or we can load styles directly
156        xinha_config.stylistLoadStyles('p.red_text { color:red }');
157
158        // If you want to provide "friendly" names you can do so like
159        // (you can do this for stylistLoadStylesheet as well)
160        xinha_config.stylistLoadStyles('p.pink_text { color:pink }', {'p.pink_text' : 'Pretty Pink'});
161      }
162
163      if(typeof InsertWords != 'undefined') {
164        // Register the keyword/replacement list
165        var keywrds1 = new Object();
166        var keywrds2 = new Object();
167
168        keywrds1['-- Dropdown Label --'] = '';
169        keywrds1['onekey'] = 'onevalue';
170        keywrds1['twokey'] = 'twovalue';
171        keywrds1['threekey'] = 'threevalue';
172
173        keywrds2['-- Insert Keyword --'] = '';
174        keywrds2['Username'] = '%user%';
175        keywrds2['Last login date'] = '%last_login%';
176        xinha_config.InsertWords = {
177          combos : [ { options: keywrds1, context: "body" },
178                     { options: keywrds2, context: "li" } ]
179        }
180      }
181
182
183      if(typeof MootoolsFileManager != 'undefined')
184      {
185        with (xinha_config.MootoolsFileManager)
186        {
187          <?php
188            require_once('../../contrib/php-xinha.php');
189            xinha_pass_to_php_backend
190            (       
191              array
192              (
193                'images_dir' => getcwd() . '/../images',
194                'images_url' => preg_replace('/\/examples.*/', '', $_SERVER['REQUEST_URI']) . '/examples/images',
195                'images_allow_upload' => false,
196                'images_allow_delete' => false,
197                'images_allow_download' => true,
198                'images_use_hspace_vspace' => false,
199               
200                'files_dir' => getcwd() . '/../images',
201                'files_url' => preg_replace('/\/examples.*/', '', $_SERVER['REQUEST_URI']) . '/examples/images',
202                'files_allow_upload' => false,
203                'max_files_upload_size' => '4M',
204              )
205            )
206          ?>
207        }
208       
209      }
210// First create editors for the textareas.
211// You can do this in two ways, either
212//   xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
213// if you want all the editor objects to use the same set of plugins, OR;
214//   xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config);
215//   xinha_editors['myTextarea0'].registerPlugins(['Stylist']);
216//   xinha_editors['myTextarea1'].registerPlugins(['CSS','SuperClean']);
217// if you want to use a different set of plugins for one or more of the editors.
218      xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
219
220// If you want to change the configuration variables of any of the editors,
221// this is the place to do that, for example you might want to
222// change the width and height of one of the editors, like this...
223//   xinha_editors['myTextarea0'].config.width  = '640px';
224//   xinha_editors['myTextarea0'].config.height = '480px';
225
226// Finally we "start" the editors, this turns the textareas into Xinha editors.
227      Xinha.startEditors(xinha_editors);
228    }
229
230// javascript submit handler
231// this shows how to create a javascript submit button that works with the htmleditor.
232    submitHandler = function(formname) {
233      var form = document.getElementById(formname);
234      // in order for the submit to work both of these methods have to be called.
235      form.onsubmit();
236      window.parent.menu.document.getElementById('myTextarea0').value = document.getElementById('myTextarea0').value;
237      form.submit();
238      return true;
239    }
240
241    window.onload = xinha_init;
242//    window.onunload = Xinha.collectGarbageForIE;
243  </script>
244</head>
245
246<body>
247  <form id="to_submit" name="to_submit" method="post" action="ext_example-dest.php">
248  <div id="editors_here"></div>
249  <button type="button" onclick="submitHandler('to_submit');">Submit</button>
250  <textarea id="errors" name="errors" style="width:100%; height:100px; background:silver;"></textarea><!-- style="display:none;" -->
251  </form>
252 
253  <!-- This script is used to show the rendering mode (Quirks, Standards, Almost Standards) -->
254  <script type="text/javascript" src="../render-mode-developer-help.js"></script>
255</body>
256</html>
Note: See TracBrowser for help on using the repository browser.