formular for webapp 1.0 finished (not working with 1.2 due to api changes...)

This commit is contained in:
Christoph Haas 2012-11-11 16:48:37 +00:00
commit ea1a60743d
7 changed files with 330 additions and 0 deletions

11
.project Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>calendarimporter</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

7
config.php Normal file
View File

@ -0,0 +1,7 @@
<?php
/** Disable the import plugin for all clients */
define('PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE', false);
/** The default calendar to import to*/
define('PLUGIN_CALENDARIMPORTER_DEFAULT', "Default");
?>

217
js/calendarimporter.js Normal file
View File

@ -0,0 +1,217 @@
/*############################################################################################################################
* IMPORT PANEL
*############################################################################################################################*/
Ext.namespace("Zarafa.plugins.calendarimporter"); // Assign the right namespace
Zarafa.plugins.calendarimporter.ImportPanel = Ext.extend(Ext.form.FormPanel, {
constructor: function (a) {
a = a || {};
var b = this;
Ext.apply(a, {
xtype: "calendarimporter.ImportPanel",
layout: {
type: "form",
align: "stretch"
},
anchor: "100%",
bodyStyle: "background-color: inherit;",
defaults: {
border: true,
bodyStyle: "background-color: inherit; padding: 3px 0px 3px 0px; border-style: none none solid none;"
},
items: [this.createSelectBox(), this.createUploadField(), this.createSubmitButton(), this.createCancelButton()]
});
Zarafa.plugins.calendarimporter.ImportPanel.superclass.constructor.call(this, a)
},
createSelectBox: function() {
ctx = container.getContextByName('calendar');
model = ctx.getModel();
defaultFolder = model.getDefaultFolder();
subFolders = defaultFolder.getChildren();
var myStore = new Ext.data.ArrayStore({
fields: ['calendar_id', 'calendar_displayname'],
idIndex: 0 // id for each record will be the first element
});
/* Calendar Record holds the name and real name of the calender */
var CalendarRecord = Ext.data.Record.create([
{name: 'realname', type: "string"},
{name: 'displayname', type: "string"}
]);
/* Store the default folder */
var myNewRecord = new CalendarRecord({
realname: defaultFolder.getDefaultFolderKey(),
displayname: defaultFolder.getDisplayName()
});
myStore.add(myNewRecord);
for(i=0;i<subFolders.length;i++) {
/* Store all subfolders */
myNewRecord = new CalendarRecord({
realname: subFolders[i].getDefaultFolderKey(),
displayname: subFolders[i].getDisplayName()
});
myStore.add(myNewRecord);
}
/* commit the changes to the store */
myStore.commitChanges();
return {
xtype: "selectbox",
editable: false,
name: "choosen_calendar",
width: 100,
fieldLabel: "Select a calender",
store: myStore,
valueField: 'realname',
displayField: 'displayname',
labelSeperator: ":",
border: false,
anchor: "100%",
scope: this,
allowBlank: false
}
},
createUploadField: function() {
return {
xtype: "fileuploadfield",
width: 100,
id: 'form-file',
name: 'icspath',
fieldLabel: "Upload .ics file",
emptyText: 'Select an .ics calendar',
labelSeperator: ":",
border: false,
anchor: "100%",
scope: this,
allowBlank: false
}
},
createSubmitButton: function() {
return {
xtype: "button",
width: 100,
border: false,
text: _("Import"),
anchor: "100%",
handler: this.importAllEvents,
scope: this,
allowBlank: false
}
},
createCancelButton: function() {
return {
xtype: "button",
width: 100,
border: false,
text: _("Cancel"),
anchor: "100%",
handler: this.close,
scope: this,
allowBlank: false
}
},
close: function () {
this.getForm().reset();
this.dialog.close()
},
importAllEvents: function () {
if(this.getForm().isValid()){
form_action=1;
this.getForm().submit({
url: 'plugins/calendarimporter/php/upload.php',
waitMsg: 'Uploading file...',
success: function(form,action){
msg('Success', 'Processed file on the server');
}
});
}
}
});
Zarafa.core.ui.Dialog.register(Zarafa.plugins.calendarimporter.ImportPanel, "calendarimporter.ImportPanel");
/*############################################################################################################################
* IMPORT DIALOG
*############################################################################################################################*/
Ext.namespace("Zarafa.plugins.calendarimporter"); // Assign the right namespace
Zarafa.plugins.calendarimporter.ImportDialog = Ext.extend(Zarafa.core.ui.Dialog, {
constructor: function (a) {
a = a || {};
Ext.applyIf(a, {
layout: "",
title: _("Calender Import"),
alwaysUseDefaultTitle: true,
useShadowStore: false,
closeOnSave: true,
width : 500,
height : 300,
items: [{
xtype: "calendarimporter.ImportPanel"
}]
});
Zarafa.plugins.calendarimporter.ImportDialog.superclass.constructor.call(this, a)
}
});
Zarafa.core.ui.Dialog.register(Zarafa.plugins.calendarimporter.ImportDialog, "calendarimporter.ImportDialog");
/*############################################################################################################################
* IMPORT BUTTON
*############################################################################################################################*/
Ext.namespace("Zarafa.plugins.calendarimporter"); // Assign the right namespace
Zarafa.plugins.calendarimporter.ImportPlugin = Ext.extend(Zarafa.core.Plugin, { // create new import plugin
/**
* @constructor
* @param {Object} config Configuration object
*
*/
constructor: function (config) {
config = config || {};
Zarafa.plugins.calendarimporter.ImportPlugin.superclass.constructor.call(this, config);
this.init();
},
/**
* Called after constructor.
* Registers insertion point for import button.
* @private
*/
init: function () {
this.registerInsertionPoint("navigation.south", this.createButton, this)
},
/**
* Creates the button
*
* @return {Object} Configuration object for a {@link Ext.Button button}
* @private
*/
createButton: function () { // eine Button definition
return {
xtype: "button",
text: _("Import Calendar"),
iconCls: "icon_calendarimporter_button",
navigationContext: container.getContextByName("calendar"),
handler: this.onImportButtonClick,
scope: this
}
},
/**
* Clickhandler for the button
*/
onImportButtonClick: function () {
Zarafa.plugins.calendarimporter.ImportDialog.create()
}
});
/*############################################################################################################################
* STARTUP
*############################################################################################################################*/
Zarafa.onReady(function() {
if(container.getSettingsModel().get("zarafa/v1/plugins/calendarimporter/enable") === true) {
container.registerPlugin(new Zarafa.plugins.calendarimporter.ImportPlugin)
}
});

31
manifest.xml Normal file
View File

@ -0,0 +1,31 @@
<?xml version="1.0"?>
<!DOCTYPE plugin SYSTEM "manifest.dtd">
<plugin version="2">
<info>
<version>0.1</version>
<name>calendarimporter</name>
<title>ICS Calendar Importer</title>
<author>Christoph Haas</author>
<authorURL>http://www.sprinternet.at</authorURL>
<description>Import a ICS file to the zarafa calendar</description>
</info>
<config>
<configfile>config.php</configfile>
</config>
<components>
<component>
<files>
<server>
<serverfile>php/plugin.calendarimporter.php</serverfile>
</server>
<client>
<clientfile load="release">js/calendarimporter.js</clientfile>
<clientfile load="debug">js/calendarimporter.js</clientfile>
</client>
<resources>
<resourcefile load="release">resources/css/calendarimporter.css</resourcefile>
</resources>
</files>
</component>
</components>
</plugin>

View File

@ -0,0 +1,58 @@
<?php
/**
* calendarimporter Plugin
*
* With this plugin you can import a ics file to your zarafa calendar
*
*/
class Plugincalendarimporter extends Plugin {
/**
* Constructor
*/
function Plugincalendarimporter() {}
/**
* Function initializes the Plugin and registers all hooks
*
* @return void
*/
function init() {
$this->registerHook('server.core.settings.init.before');
}
/**
* Function is executed when a hook is triggered by the PluginManager
*
* @param string $eventID the id of the triggered hook
* @param mixed $data object(s) related to the hook
* @return void
*/
function execute($eventID, &$data) {
switch($eventID) {
case 'server.core.settings.init.before' :
$this->injectPluginSettings($data);
break;
}
}
/**
* Called when the core Settings class is initialized and ready to accept sysadmin default
* settings.
* @param Array $data Reference to the data of the triggered hook
*/
function injectPluginSettings(&$data) {
$data['settingsObj']->addSysAdminDefaults(Array(
'zarafa' => Array(
'v1' => Array(
'plugins' => Array(
'calendarimporter' => Array(
'enable' => PLUGIN_CALENDARIMPORTER_USER_DEFAULT_ENABLE,
'default_calendar' => PLUGIN_CALENDARIMPORTER_DEFAULT
)
)
)
)
));
}
}
?>

View File

@ -0,0 +1,6 @@
.icon_calendarimporter_button {
background: url(../images/import_icon.png) no-repeat !important;
background-repeat: no-repeat;
background-position: center;
background-size: 18px!important;
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB