source: trunk/examples/mootools-file-manager.php @ 1361

Last change on this file since 1361 was 1325, checked in by gogo, 7 years ago

Update MootoolsFileManager? example to use new configuration names.

File size: 9.4 KB
Line 
1<?php require_once('require-password.php'); ?>
2<!DOCTYPE html
3     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
4    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
5<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
6<head>
7
8  <!--------------------------------------:noTabs=true:tabSize=2:indentSize=2:--
9    --  Xinha example usage.  This file shows how a developer might make use of
10    --  Xinha, it forms the primary example file for the entire Xinha project.
11    --  This file can be copied and used as a template for development by the
12    --  end developer who should simply removed the area indicated at the bottom
13    --  of the file to remove the auto-example-generating code and allow for the
14    --  use of the file as a boilerplate.
15    --
16    --  $HeadURL: http://svn.xinha.org/trunk/examples/testbed.html $
17    --  $LastChangedDate: 2009-11-08 17:36:46 +1300 (Sun, 08 Nov 2009) $
18    --  $LastChangedRevision: 1197 $
19    --  $LastChangedBy: gogo $
20    --------------------------------------------------------------------------->
21
22  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
23  <title>Example of Xinha</title>
24  <link rel="stylesheet" href="files/full_example.css" />
25
26  <script type="text/javascript">
27    // You must set _editor_url to the URL (including trailing slash) where
28    // where xinha is installed, it's highly recommended to use an absolute URL
29    //  eg: _editor_url = "/path/to/xinha/";
30    // You may try a relative URL htmlif you wish]
31    //  eg: _editor_url = "../";
32    // in this example we do a little regular expression to find the absolute path.
33    _editor_url  = document.location.href.replace(/examples\/.*/, '')
34    _editor_lang = "en";      // And the language we need to use in the editor.   
35    _editor_skin = 'blue-look';
36   
37    <?php
38      if(@$_REQUEST['NoFlash'])
39      {
40        ?>__MFM_USE_FLASH__ = false;<?php
41      }
42      else
43      {
44        ?>__MFM_USE_FLASH__ = true;<?php
45      }
46    ?>
47  </script>
48
49  <!-- Load up the actual editor core -->
50  <script type="text/javascript" src="../XinhaCore.js"></script>
51
52  <script type="text/javascript">
53    xinha_editors = null;
54    xinha_init    = null;
55    xinha_config  = null;
56    xinha_plugins = null;
57
58    // This contains the names of textareas we will make into Xinha editors
59    xinha_init = xinha_init ? xinha_init : function()
60    {
61      /** STEP 1 ***************************************************************
62       * First, what are the plugins you will be using in the editors on this
63       * page.  List all the plugins you will need, even if not all the editors
64       * will use all the plugins.
65       ************************************************************************/
66
67      xinha_plugins = xinha_plugins ? xinha_plugins :
68      [
69        'MootoolsFileManager','Linker'
70      ];
71             // THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING  :)
72             if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;
73
74      /** STEP 2 ***************************************************************
75       * Now, what are the names of the textareas you will be turning into
76       * editors?
77       ************************************************************************/
78
79      xinha_editors = xinha_editors ? xinha_editors :
80      [
81        'myTextArea'
82      ];
83
84      /** STEP 3 ***************************************************************
85       * We create a default configuration to be used by all the editors.
86       * If you wish to configure some of the editors differently this will be
87       * done in step 4.
88       *
89       * If you want to modify the default config you might do something like this.
90       *
91       *   xinha_config = new Xinha.Config();
92       *   xinha_config.width  = 640;
93       *   xinha_config.height = 420;
94       *
95       *************************************************************************/
96
97       xinha_config = xinha_config ? xinha_config : new Xinha.Config();
98       xinha_config.fullPage = true;
99       with (xinha_config.MootoolsFileManager)
100        {
101          <?php
102            require_once('../contrib/php-xinha.php');
103            xinha_pass_to_php_backend
104            (       
105              array
106              (
107                'images_dir' => getcwd() . '/images',
108                'images_url' => preg_replace('/\/examples.*/', '', $_SERVER['REQUEST_URI']) . '/examples/images',
109                'images_allow_upload' => true,
110                'images_allow_delete' => true,
111                'images_allow_download' => true,
112               
113                'files_dir' => getcwd() . '/images',
114                'files_url' => preg_replace('/\/examples.*/', '', $_SERVER['REQUEST_URI']) . '/examples/images',
115                'files_allow_upload' => true,
116                'max_files_upload_size' => '4M',
117              )
118            )
119          ?>
120        }
121       
122       with (xinha_config.Linker)
123        {
124          <?php
125            require_once('../contrib/php-xinha.php');
126            xinha_pass_to_php_backend
127            (       
128              array
129              (
130                'dir' => getcwd(),
131                'url' => '/examples',               
132              )
133            )
134          ?>
135        }
136      /** STEP 3 ***************************************************************
137       * We first create editors for the textareas.
138       *
139       * You can do this in two ways, either
140       *
141       *   xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
142       *
143       * if you want all the editor objects to use the same set of plugins, OR;
144       *
145       *   xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config);
146       *   xinha_editors['myTextArea'].registerPlugins(['Stylist']);
147       *   xinha_editors['anotherOne'].registerPlugins(['CSS','SuperClean']);
148       *
149       * if you want to use a different set of plugins for one or more of the
150       * editors.
151       ************************************************************************/
152
153      xinha_editors   = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
154
155      /** STEP 4 ***************************************************************
156       * If you want to change the configuration variables of any of the
157       * editors,  this is the place to do that, for example you might want to
158       * change the width and height of one of the editors, like this...
159       *
160       *   xinha_editors.myTextArea.config.width  = 640;
161       *   xinha_editors.myTextArea.config.height = 480;
162       *
163       ************************************************************************/
164
165
166      /** STEP 5 ***************************************************************
167       * Finally we "start" the editors, this turns the textareas into
168       * Xinha editors.
169       ************************************************************************/
170
171      Xinha.startEditors(xinha_editors);
172      window.onload = null;
173    }
174
175    window.onload   = xinha_init;
176  </script>
177</head>
178
179<body>
180  <h1> Demonstration of MootoolsFileManager with Xinha integration </h1>
181  <p>  Click into the WYSIWYG area and then click the insert image button in the tool bar. </p>
182  <p>  Highlight some text and click the insert file link button (folder with a link on it).</p>
183  <p>  This demo also includes the Linker plugin (for creating normal links). </p>
184  <?php
185    if(!isset($_REQUEST['NoFlash']))
186    {
187      ?>
188      <p>You are using the Flash version of MFM, <a href="mootools-file-manager.php?NoFlash=1">switch to NoFlash.</a></p>
189      <?php
190    }
191    else
192    {
193      ?>
194      <p>You are using the NoFlash version of MFM, <a href="mootools-file-manager.php">switch to Flash.</a></p>
195      <?php
196    }
197  ?>
198  <form action="javascript:void(0);" id="editors_here" onsubmit="alert(this.myTextArea.value);">
199     <div>
200     <textarea id="myTextArea" name="myTextArea" style="width:100%;height:320px;">
201      &lt;html&gt;
202      &lt;head&gt;
203        &lt;title&gt;Hello&lt;/title&gt;
204        &lt;style type="text/css"&gt;
205          li { color:red; }
206        &lt;/style&gt;
207      &lt;/head&gt;
208      &lt;body&gt;&lt;span style="color:purple"&gt;
209
210      &lt;p&gt;
211        Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
212        Aliquam et tellus vitae justo varius placerat. Suspendisse iaculis
213        velit semper dolor. Donec gravida tincidunt mi. Curabitur tristique
214        ante elementum turpis.  &lt;span style="color:green"&gt;Aliquam &lt;/span&gt; nisl. Nulla posuere neque non
215        tellus. Morbi vel nibh. &lt;font face="Arial"&gt;&lt;font color="#009933"&gt;Cum  sociis natoque&lt;/font&gt;&lt;/font&gt; penatibus et magnis dis
216        parturient montes, nascetur ridiculus mus. Nam nec wisi. In wisi.
217        Curabitur pharetra bibendum lectus.
218      &lt;/p&gt;
219
220      &lt;ul&gt;
221        &lt;li style="color:green"&gt; Phasellus et massa sed diam viverra semper.  &lt;/li&gt;
222        &lt;li&gt; Mauris tincidunt felis in odio.              &lt;/li&gt;
223        &lt;li&gt; Nulla placerat nunc ut pede.                 &lt;/li&gt;
224        &lt;li&gt; Vivamus ultrices mi sit amet urna.           &lt;/li&gt;
225        &lt;li&gt; Quisque sed augue quis nunc laoreet volutpat.&lt;/li&gt;
226        &lt;li&gt; Nunc sit amet metus in tortor semper mattis. &lt;/li&gt;
227      &lt;/ul&gt;
228      &lt;/span&gt;&lt;/body&gt;
229      &lt;/html&gt;
230    </textarea>
231
232    <input type="submit" /> <input type="reset" />
233    </div>
234  </form>
235
236  <p>
237    <script type="text/javascript">
238      document.write('Browser Compatability Mode: ' + document.compatMode);
239    </script>
240  </p>
241</body>
242</html>
Note: See TracBrowser for help on using the repository browser.