BXE 2.0 ServerClipboard

ServerClipboard

The Server Clipboard is a BXE [Plugin], which allows to put elements on a server and later get it again. For example if you want to copy a node from one document to another.

Config.xml

You have to put the following into your config.xml, to include the plugin:

<plugins>
<plugin name="ServerClipboard">
<option name="urlfunction">bxe_serverClipboardURL</option>
</plugin>
</plugins>

The option urlfunction defines, which user defined function has to be called to get the URL, where the element should be stored. This makes it very flexible and you can customize it to your needs (if you want for example include a user-id into the request).

User defined function

If you want to use userdefined functions in BXE, the best thing is to put them into a seperate JavaScript file and include that also via the config.xml file

<scripts>
<file>myfunctions.js</file>
</script>

The path is resolved relative to the bxeLoader.js file (except, when it starts with http:// or /, then it's absolute).

BXE now calls your defined function for getting the URL, it provides one parameter, which can either be POST or GET. One for storing the element and one for getting it. A very simple function looks like this.

function bxe_serverClipboardURL(action) {
if (action == 'POST')

Unknown macro: { return "clipboard.php?action=POST"; }

else

Unknown macro: { return "clipboard.php?action=GET"; }

}

Server side

The server has to store the send elememt somehow (it's a serialized XML document) and later send it back. A very simple implementation in PHP:

<?php
if ($_GET['action'] == 'POST') {
if (get_magic_quotes_gpc() )

Unknown macro: { $_POST['content'] = stripslashes($_POST['content']); }

file_put_contents("clipboard.xml",$_POST['content']);
} else

Unknown macro: { header("Content-type}

?>

Make sure, you send the content-type as text/xml and be aware, that the input is always utf-8 encoded.

Caveats

It doesn't work, if you load BXE from the filesystem (via file://) in the browser

Labels:

Enter labels to add to this page:
Wait Image 
Looking for a label? Just start typing.