Skip to content
This repository has been archived by the owner on Nov 25, 2020. It is now read-only.

Commit

Permalink
Simple implementation of WebODF viewer. Only as viewer for the moment…
Browse files Browse the repository at this point in the history
…, we have to get a way to send back the modif in a standard manner, probably by replacing the Runtime implementation.
  • Loading branch information
cdujeu committed Oct 31, 2013
1 parent db5de96 commit 66b64af
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 1 deletion.
99 changes: 99 additions & 0 deletions core/src/plugins/editor.webodf/class.WebodfEditor.js
@@ -0,0 +1,99 @@
/*
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pydio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://pyd.io/>.
*/
Class.create("WebodfEditor", AbstractEditor, {

padID:null,
sessionID: null,
node: null,

initialize: function($super, oFormObject, options)
{
$super(oFormObject, options);
if(!ajaxplorer.user || ajaxplorer.user.canWrite()){
this.canWrite = true;
this.actions.get("saveButton").observe('click', function(){
this.saveFile();
return false;
}.bind(this));
}else{
this.canWrite = false;
this.actions.get("saveButton").hide();
}
// HIDE SAVE FOR THE MOMENT
this.actions.get("saveButton").hide();

if(options.context.__className == "Modal"){
this.actions.get("downloadFileButton").observe('click', function(){
if(!this.currentFile) return;
ajaxplorer.triggerDownload(ajxpBootstrap.parameters.get('ajxpServerAccess')+'&action=download&file='+this.currentFile);
return false;
}.bind(this));
}else{
this.actions.get("downloadFileButton").hide();
}
},

open : function($super, nodeOrNodes){
$super(nodeOrNodes);
this.node = nodeOrNodes;
var fileName = nodeOrNodes.getPath();
var fileContent = ajxpBootstrap.parameters.get('ajxpServerAccess')+'&get_action=download&file='+fileName;

this.contentMainContainer = this.element.down('#webodf_container');
this.contentMainContainer.src = 'plugins/editor.webodf/frame.php?token='+Connexion.SECURE_TOKEN+'&file='+fileName;

this.resize();
this.element.observe('editor:close', function(){
this.contentMainContainer.src = '';
}.bind(this));
/*
var conn = new Connexion();
conn.addParameter("get_action", "get_content");
conn.addParameter("file", fileName);
conn.onComplete = function(transport){
var data = transport.responseJSON;
this.padID = data.padID;
this.sessionID = data.sessionID;
$("ether_box").down("#ether_box_frame").src = data.url;
fitHeightToBottom($("ether_box").down("#ether_box_frame"));
}.bind(this);
conn.sendAsync();
*/

if(window.ajxpMobile){
this.setFullScreen();
attachMobileScroll(this.textarea, "vertical");
}


},


saveFile : function(){
if(!this.padID || !this.node) return;
var conn = new Connexion();
conn.addParameter("get_action", "etherpad_save");
conn.addParameter("file", this.node.getPath());
conn.addParameter("pad_id", this.padID);
conn.sendAsync();
}

});
32 changes: 32 additions & 0 deletions core/src/plugins/editor.webodf/frame.php
@@ -0,0 +1,32 @@
<?php
$AJXP_SECURE_TOKEN = $_GET["token"];
$AJXP_FILE_URL = $_GET["file"];
?>
<html>
<head>
<script src="webodf/webodf.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
function init()
{
var odfelement = document.getElementById("odf");
window.odfcanvas = new odf.OdfCanvas(odfelement);
window.odfcanvas.load("http://localhost/index.php?secure_token=<?php echo $AJXP_SECURE_TOKEN; ?>&get_action=download&file=<?php echo $AJXP_FILE_URL; ?>");
//window.odfcanvas.setEditable(true);
/*
odfcanvas.odfContainer().save(function(err){
console.log(err);
});
*/
}
window.setTimeout(init, 0);
</script>
<style type="text/css">
.shadow_class{
box-shadow: 1px 1px 6px black;
}
</style>
</head>
<body style="background-color: rgb(85, 85, 85);">
<div id="odf" class="shadow_class"></div>
</body>
</html>
24 changes: 24 additions & 0 deletions core/src/plugins/editor.webodf/i18n/conf/en.php
@@ -0,0 +1,24 @@
<?php
/*
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pydio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://pyd.io/>.
*/
$mess=array(
"Open Documents Viewer" => "Open Documents Viewer",
"Open Document Formats viewer - based on WebODF.js library" => "Open Document Formats viewer - based on WebODF.js library",
);
24 changes: 24 additions & 0 deletions core/src/plugins/editor.webodf/i18n/conf/fr.php
@@ -0,0 +1,24 @@
<?php
/*
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pydio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://pyd.io/>.
*/
$mess=array(
"Open Documents Viewer" => "Open Documents Viewer",
"Open Document Formats viewer - based on WebODF.js library" => "Open Document Formats viewer - based on WebODF.js library",
);
25 changes: 25 additions & 0 deletions core/src/plugins/editor.webodf/i18n/en.php
@@ -0,0 +1,25 @@
<?php
/*
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pydio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://pyd.io/>.
*/

$mess = array(
"1" => "Open Documents Viewer",
"2" => "Open Documents Viewer",
);
25 changes: 25 additions & 0 deletions core/src/plugins/editor.webodf/i18n/fr.php
@@ -0,0 +1,25 @@
<?php
/*
* Copyright 2007-2013 Charles du Jeu - Abstrium SAS <team (at) pyd.io>
* This file is part of Pydio.
*
* Pydio is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Pydio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Pydio. If not, see <http://www.gnu.org/licenses/>.
*
* The latest code can be found at <http://pyd.io/>.
*/

$mess = array(
"1" => "Visualiseur Open Documents",
"2" => "Visualiser les formats Open Documents Format",
);
25 changes: 25 additions & 0 deletions core/src/plugins/editor.webodf/manifest.xml
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<editor enabled="false" id="editor.webodf" openable="true" iconClass="icon-font" order="1"
text="webodf.2" title="webodf.3" icon="edit.png" className="WebodfEditor"
mimes="odt,ods,odp" formId="webodf_box" label="CONF_MESSAGE[Open Documents Viewer]" description="CONF_MESSAGE[Open Document Formats viewer - based on WebODF.js library]"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<client_settings>
<resources>
<js file="plugins/editor.webodf/class.WebodfEditor.js" className="WebodfEditor" autoload="true"/>
<i18n path="plugins/editor.webodf/i18n" namespace="webodf"/>
</resources>
</client_settings>
<clientForm id="webodf_box"><![CDATA[
<div id="webodf_box" box_width="80%" box_height="90%" box_padding="0">
<div class="action_bar">
<a href="#" onclick="return false;" class="icon-save" id="saveButton" onclick="saveForm();return false;"><img src="AJXP_THEME_FOLDER/images/actions/22/filesave.png" width="22" height="22" alt="AJXP_MESSAGE[53]" border="0"><br><span message_id="53">AJXP_MESSAGE[53]</span></a>
<a href="#" onclick="return false;" class="icon-download" id="downloadFileButton"><img width="22" height="22" src="AJXP_THEME_FOLDER/images/actions/22/download_manager.png" alt="AJXP_MESSAGE[88]" border="0"><br><span message_id="88">AJXP_MESSAGE[88]</span></a>
</div>
<iframe id="webodf_container" style="border:0; width:100%;"></iframe>
</div>
]]></clientForm>
<dependencies>
<!-- Stream Wrapper Access -->
<activePlugin pluginName="access.AJXP_STREAM_PROVIDER"/>
</dependencies>
</editor>
3 changes: 3 additions & 0 deletions core/src/plugins/editor.webodf/plugin_doc.html
@@ -0,0 +1,3 @@
<p>Preview Open Document Formats files (ODT, ODS, ODP) as generated by LibreOffice or OpenOffice.</p>
<p>You first have to download and install the Webodf.js library inside the plugin folder, under /webodf/webodf.js.</p>
<p>Download the compiled version of the library from KOGmbh here <a href="http://webodf.org/demo/demobrowser/webodf.js">http://webodf.org/demo/demobrowser/webodf.js</a> </p>
2 changes: 1 addition & 1 deletion core/src/plugins/editor.zoho/manifest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<editor id="editor.zoho" enabled="false" openable="true" text="zoho_editor.1" iconClass="icon-edit" title="zoho_editor.2" description="Zoho editor" icon="zoho_img/zoho.png" label="Office Docs" className="ZohoEditor" mimes="xls,xlsx,ods,sxc,csv,tsv,ppt,pps,odp,sxi,doc,docx,rtf,odt,sxw" formId="zoho_box" write="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<editor id="editor.zoho" order="3" enabled="false" openable="true" text="zoho_editor.1" iconClass="icon-edit" title="zoho_editor.2" description="Zoho editor" icon="zoho_img/zoho.png" label="Office Docs" className="ZohoEditor" mimes="xls,xlsx,ods,sxc,csv,tsv,ppt,pps,odp,sxi,doc,docx,rtf,odt,sxw" formId="zoho_box" write="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:../core.ajaxplorer/ajxp_registry.xsd">
<class_definition filename="plugins/editor.zoho/class.ZohoEditor.php" classname="ZohoEditor"/>
<server_settings>
<global_param name="ZOHO_API_KEY" type="string" description="CONF_MESSAGE[Zoho API Key, you must have registered to api.zoho.com]" label="CONF_MESSAGE[API Key]" mandatory="true"/>
Expand Down

0 comments on commit 66b64af

Please sign in to comment.