Permalink
Browse files

beacon/html/beaconui.html: changed to remove - select one - option fr…

…om Create

new document and Edit remote document dialogs.

beacon/js/Beacon.js: added new function fetchDoc to fetch an XML document from
a URL and edit it.

beacon/plugins/docbook/php/docbook.php: changed to accept $source parameter in
newdoc() function.

beacon/plugins/guidexml/php/guidexml.php: changed to accept $source parameter
in newdoc() function.

php/lib/BeaconAPI.php: changed to pass $xmlsource parameter to
plugin_object->newdoc() functions.

php/lib/BeaconAuthenticator.php: changed dictionary key "id" to "uid".
  • Loading branch information...
1 parent 150ecae commit 20e3458fd91828864200f999324ad726594b9d08 @pjps pjps committed Jun 23, 2011
@@ -36,9 +36,7 @@
<p><input id="BeaconNewFileName" type="text" /></p>
<p>{Choose Document Type:}</p>
<p>
- <select id="BeaconNewDocType">
- <option value="-1">{Select one}</option>
- </select>
+ <select id="BeaconNewDocType"></select>
</p>
<p><a id="BeaconCreateNewButton" class="BeaconButton ui-corner-all">{Create New!}</a></p>
</div>
@@ -50,9 +48,7 @@
<p><input id="BeaconEditFileName" type="text" /></p>
<p>{Choose Document Type:}</p>
<p>
- <select id="BeaconEditDocType">
- <option value="-1">{Select one}</option>
- </select>
+ <select id="BeaconEditDocType"></select>
</p>
<div id="BeaconEditFetchFormContainer">
<p>{Enter a URL to fetch from:}</p>
View
@@ -186,7 +186,7 @@ Beacon.prototype.init = function() {
$("#BeaconCreateNewButton").bind("click", this.newDoc.attach(this));
- //$("#BeaconFetchButton").bind("click", this.fetchDoc.attach(this));
+ $("#BeaconFetchButton").bind("click", this.fetchDoc.attach(this));
$(".BeaconEditDocumentButton").bind("click", this.editDoc.attach(this));
$(".BeaconDeleteDocumentButton").bind("click", this.deleteDoc.attach(this));
@@ -316,7 +316,24 @@ Beacon.prototype.newDoc = function() {
// To add some randomness to the tab id temporarily
id = Math.floor(Math.random()*10001);
- this.initDoc(filename, id, "newdoc", this.settings.plugins[filetype]);
+ this.initDoc(filename, id, "newdoc",
+ this.settings.plugins[filetype], undefined);
+};
+
+
+Beacon.prototype.fetchDoc = function(e) {
+ var furl = $.trim($("#BeaconURLField").val()),
+ fname = $.trim($("#BeaconEditFileName").val()),
+ ftype = $.trim($("#BeaconEditDocType").val());
+
+ $.ajax({url: furl, type: 'GET',
+ success: function(data) {
+ var id = Math.floor(Math.random() * 10001);
+ data = (new XMLSerializer()).serializeToString(data);
+
+ beacon.initDoc(fname, id, "newdoc",
+ beacon.settings.plugins[ftype], data);
+ } });
};
@@ -390,18 +407,20 @@ Beacon.prototype.editDoc = function(e) {
return false;
};
-Beacon.prototype.initDoc = function(filename, id, action, plugin) {
+Beacon.prototype.initDoc = function(filename, id, action, plugin, source) {
container = '#' + filename + id;
$(this.container).tabs("add", container, filename);
$(container).addClass('BeaconDocumentTab');
$(this.container).tabs('select', container);
- this.showLoading(container, "Please wait while the document is being created...");
+ this.showLoading(container,
+ "Please wait while the document is being created...");
var o = {
plugin: plugin,
- filename: filename
+ filename: filename,
+ xmlsource: source
};
var data = {
@@ -7,8 +7,11 @@ class BeaconDocbook {
var $xml2html = "xml/docbook2html.xsl";
var $css_path = "css/docbook.css";
- function newdoc($beacon) {
- $text = file_get_contents($beacon->path . $this->new_template);
+ function newdoc($beacon, $source) {
+
+ $text = $source;
+ if (!$text)
+ $text = file_get_contents($beacon->path . $this->new_template);
$text = $beacon->parser->xslParse($text,
$beacon->path . $this->xml2html);
@@ -1,4 +1,4 @@
-<?
+<?php
class BeaconGuideXML {
@@ -7,8 +7,11 @@ class BeaconGuideXML {
var $xml2html = "xml/guide2html.xsl";
var $css_path = "css/guide.css";
- function newdoc($beacon) {
- $text = file_get_contents($beacon->path . $this->new_template);
+ function newdoc($beacon, $source) {
+
+ $text = $source;
+ if (!$text)
+ $text = file_get_contents($beacon->path . $this->new_template);
$text = $beacon->parser->xslParse($text,
$beacon->path . $this->xml2html);
@@ -38,3 +41,4 @@ function get_css_path() {
return new BeaconGuideXML();
+?>
@@ -56,6 +56,7 @@ function newdoc() {
// Check which plugin it is
$plugin = $this->request->payload->plugin;
$filename = $this->request->payload->filename;
+ $xmlsource = $this->request->payload->xmlsource;
// Get the plugin Object
$plugin_object = include($this->pluginpath . $plugin . "/php/" . $plugin . ".php");
@@ -66,7 +67,7 @@ function newdoc() {
$beacon->parser = new BeaconXSLTransformer();
// Get the HTML
- $html = $plugin_object->newdoc($beacon);
+ $html = $plugin_object->newdoc($beacon, $xmlsource);
// Get the Source
$beacon->html = $html;
@@ -35,7 +35,7 @@ function login($username, $password)
{
if($user['password'] == $password)
{
- $this->user_id = $user['id'];
+ $this->user_id = $user['uid'];
$this->username = $username;
$this->ok = true;
@@ -57,7 +57,7 @@ function check($username, $password)
{
if($user['password'] == $password)
{
- $this->user_id = $user['id'];
+ $this->user_id = $user['uid'];
$this->username = $username;
$this->ok = true;
return true;
@@ -77,4 +77,4 @@ function logout()
session_write_close();
}
-}
+}

0 comments on commit 20e3458

Please sign in to comment.