HTML file:
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Xinha Example Shoutbox</title>
<script type="text/javascript">
// You must set _editor_url to the URL (including trailing slash) where
// where xinha is installed, it's highly recommended to use an absolute URL
// eg: _editor_url = "/path/to/xinha/";
// You may try a relative URL if you wish]
// eg: _editor_url = "../";
_editor_url = "/latest/"
_editor_lang = "en"; // And the language we need to use in the editor.
</script>
<!-- Load up the actual editor core -->
<script type="text/javascript" src="../latest/XinhaCore.js"></script>
<script type="text/javascript" src="restricted_config.php"></script>
<style type="text/css">
body {font-family: sans-serif;}
pre {background-color:#ccc;border:dotted black thin;padding:10px; }
</style>
</head>
<body>
<h1>Xinha Example (stripped down editor)</h1>
<div style="float:left">
<form action="input.php" method="post" id="editors_here" onsubmit="this.myTextArea.name='myTextArea';return confirm('HTML output:\n'+this.myTextArea.value + '\nClick OK to save');">
<textarea id="myTextArea" style="width:400px;height:320px;">
<?php
print htmlspecialchars('
<h2>Xinha Example Shoutbox</h2>
<p>Write somethin\' nice</p>
');
?>
</textarea>
<input type="submit" />
</form>
</div>
<div>
<iframe id="output" src="output.php" style="width:400px;height:320px;margin-left:15px;border:1px dotted grey"></iframe>
<br style="clear:both"/>
HTML file:<br />
<pre>
<?php
print htmlspecialchars(file_get_contents('restricted.php'));
?>
</pre>
<br />
Config file:<br />
<pre>
<?php
print htmlspecialchars(file_get_contents('restricted_config.php'));
?>
</pre>
</div>
</body>
</html>
Config file:
<?php header("Content-type: text/javascript"); ?>
xinha_editors = null;
xinha_init = null;
xinha_config = null;
xinha_plugins = null;
xinha_init = xinha_init ? xinha_init : function()
{
xinha_plugins = xinha_plugins ? xinha_plugins :
[
'DoubleClick',
'ExtendedFileManager',
'Linker'
];
// THIS BIT OF JAVASCRIPT LOADS THE PLUGINS, NO TOUCHING :)
if(!Xinha.loadPlugins(xinha_plugins, xinha_init)) return;
xinha_editors = xinha_editors ? xinha_editors :
[
'myTextArea'
];
xinha_config = xinha_config ? xinha_config : new Xinha.Config();
xinha_config.toolbar =
[
["popupeditor","separator","formatblock","bold","italic","separator","createlink","insertimage"]
];
xinha_config.formatblock =
{
"— format —" : "",
"Heading 2": "h2",
"Normal" : "p"
};
xinha_config.showLoading = true;
xinha_config.statusBar = false;
xinha_config.stripBaseHref = true;
xinha_config.baseHref = "<?php print 'http://'. $_SERVER['SERVER_NAME'] ?>";
<?php require_once '../latest/contrib/php-xinha.php'; ?>
if (xinha_config.Linker)
{
with(xinha_config.Linker)
{
<?php
xinha_pass_to_php_backend
(
array(
'dir' => $_SERVER['DOCUMENT_ROOT'].'/latest/',
'include' => '/\.(php|shtml|html|htm|shtm|cgi|txt|doc|pdf|rtf|xls|csv)$/', // Regex or null
'exclude' => null, // Regex or null
'dirinclude' => null, // Regex or null
'direxclude' => null // Regex or null
)
);
?>
}
}
xinha_config.ExtendedFileManager.use_linker = true;
if (xinha_config.ExtendedFileManager) {
with (xinha_config.ExtendedFileManager)
{
<?php
// define backend configuration for the plugin
$IMConfig = array();
// the directories have to be writeable for php (that means 777 under linux)
$IMConfig['max_foldersize_mb'] = 10;
$IMConfig['files_dir'] = $_SERVER['DOCUMENT_ROOT'].'x_examples/images';
$IMConfig['images_dir'] = $_SERVER['DOCUMENT_ROOT'].'x_examples/images';
$IMConfig['files_url'] = '/x_examples/images/';
$IMConfig['images_url'] = '/x_examples/images/';
$IMConfig['images_enable_styling'] = false;
$IMConfig['max_filesize_kb_image'] = 200;
// we can use the value 'max' to allow the maximium upload size defined in php_ini
$IMConfig['max_filesize_kb_link'] = 'max';
$IMConfig['allowed_link_extensions'] = array("jpg","gif","js","pdf","zip","txt","psd","png","html","swf","xml","xls");
xinha_pass_to_php_backend($IMConfig);
?>
}
}
xinha_editors = Xinha.makeEditors(xinha_editors, xinha_config, xinha_plugins);
Xinha.startEditors(xinha_editors);
}
Xinha._addEvent(window,"load",xinha_init);